documentation.d.ts 3.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /** Defines the cross module used constants to avoid circular dependncies */
  583. export class Constants {
  584. /** Defines that alpha blending is disabled */
  585. static readonly ALPHA_DISABLE: number;
  586. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  587. static readonly ALPHA_ADD: number;
  588. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  589. static readonly ALPHA_COMBINE: number;
  590. /** Defines that alpha blending is DEST - SRC * DEST */
  591. static readonly ALPHA_SUBTRACT: number;
  592. /** Defines that alpha blending is SRC * DEST */
  593. static readonly ALPHA_MULTIPLY: number;
  594. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  595. static readonly ALPHA_MAXIMIZED: number;
  596. /** Defines that alpha blending is SRC + DEST */
  597. static readonly ALPHA_ONEONE: number;
  598. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  599. static readonly ALPHA_PREMULTIPLIED: number;
  600. /**
  601. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  602. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  603. */
  604. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  605. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  606. static readonly ALPHA_INTERPOLATE: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  609. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_SCREENMODE: number;
  612. /**
  613. * Defines that alpha blending is SRC + DST
  614. * Alpha will be set to SRC ALPHA + DST ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEONE: number;
  617. /**
  618. * Defines that alpha blending is SRC * DST ALPHA + DST
  619. * Alpha will be set to 0
  620. */
  621. static readonly ALPHA_ALPHATOCOLOR: number;
  622. /**
  623. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  624. */
  625. static readonly ALPHA_REVERSEONEMINUS: number;
  626. /**
  627. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  628. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  629. */
  630. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  631. /**
  632. * Defines that alpha blending is SRC + DST
  633. * Alpha will be set to SRC ALPHA
  634. */
  635. static readonly ALPHA_ONEONE_ONEZERO: number;
  636. /**
  637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  638. * Alpha will be set to DST ALPHA
  639. */
  640. static readonly ALPHA_EXCLUSION: number;
  641. /** Defines that alpha blending equation a SUM */
  642. static readonly ALPHA_EQUATION_ADD: number;
  643. /** Defines that alpha blending equation a SUBSTRACTION */
  644. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  645. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  646. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  647. /** Defines that alpha blending equation a MAX operation */
  648. static readonly ALPHA_EQUATION_MAX: number;
  649. /** Defines that alpha blending equation a MIN operation */
  650. static readonly ALPHA_EQUATION_MIN: number;
  651. /**
  652. * Defines that alpha blending equation a DARKEN operation:
  653. * It takes the min of the src and sums the alpha channels.
  654. */
  655. static readonly ALPHA_EQUATION_DARKEN: number;
  656. /** Defines that the ressource is not delayed*/
  657. static readonly DELAYLOADSTATE_NONE: number;
  658. /** Defines that the ressource was successfully delay loaded */
  659. static readonly DELAYLOADSTATE_LOADED: number;
  660. /** Defines that the ressource is currently delay loading */
  661. static readonly DELAYLOADSTATE_LOADING: number;
  662. /** Defines that the ressource is delayed and has not started loading */
  663. static readonly DELAYLOADSTATE_NOTLOADED: number;
  664. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  665. static readonly NEVER: number;
  666. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  667. static readonly ALWAYS: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  669. static readonly LESS: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  671. static readonly EQUAL: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  673. static readonly LEQUAL: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  675. static readonly GREATER: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  677. static readonly GEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  679. static readonly NOTEQUAL: number;
  680. /** Passed to stencilOperation to specify that stencil value must be kept */
  681. static readonly KEEP: number;
  682. /** Passed to stencilOperation to specify that stencil value must be replaced */
  683. static readonly REPLACE: number;
  684. /** Passed to stencilOperation to specify that stencil value must be incremented */
  685. static readonly INCR: number;
  686. /** Passed to stencilOperation to specify that stencil value must be decremented */
  687. static readonly DECR: number;
  688. /** Passed to stencilOperation to specify that stencil value must be inverted */
  689. static readonly INVERT: number;
  690. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  691. static readonly INCR_WRAP: number;
  692. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  693. static readonly DECR_WRAP: number;
  694. /** Texture is not repeating outside of 0..1 UVs */
  695. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  696. /** Texture is repeating outside of 0..1 UVs */
  697. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  698. /** Texture is repeating and mirrored */
  699. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  700. /** ALPHA */
  701. static readonly TEXTUREFORMAT_ALPHA: number;
  702. /** LUMINANCE */
  703. static readonly TEXTUREFORMAT_LUMINANCE: number;
  704. /** LUMINANCE_ALPHA */
  705. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  706. /** RGB */
  707. static readonly TEXTUREFORMAT_RGB: number;
  708. /** RGBA */
  709. static readonly TEXTUREFORMAT_RGBA: number;
  710. /** RED */
  711. static readonly TEXTUREFORMAT_RED: number;
  712. /** RED (2nd reference) */
  713. static readonly TEXTUREFORMAT_R: number;
  714. /** RG */
  715. static readonly TEXTUREFORMAT_RG: number;
  716. /** RED_INTEGER */
  717. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  718. /** RED_INTEGER (2nd reference) */
  719. static readonly TEXTUREFORMAT_R_INTEGER: number;
  720. /** RG_INTEGER */
  721. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  722. /** RGB_INTEGER */
  723. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  724. /** RGBA_INTEGER */
  725. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  726. /** UNSIGNED_BYTE */
  727. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  728. /** UNSIGNED_BYTE (2nd reference) */
  729. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  730. /** FLOAT */
  731. static readonly TEXTURETYPE_FLOAT: number;
  732. /** HALF_FLOAT */
  733. static readonly TEXTURETYPE_HALF_FLOAT: number;
  734. /** BYTE */
  735. static readonly TEXTURETYPE_BYTE: number;
  736. /** SHORT */
  737. static readonly TEXTURETYPE_SHORT: number;
  738. /** UNSIGNED_SHORT */
  739. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  740. /** INT */
  741. static readonly TEXTURETYPE_INT: number;
  742. /** UNSIGNED_INT */
  743. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  744. /** UNSIGNED_SHORT_4_4_4_4 */
  745. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  746. /** UNSIGNED_SHORT_5_5_5_1 */
  747. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  748. /** UNSIGNED_SHORT_5_6_5 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  750. /** UNSIGNED_INT_2_10_10_10_REV */
  751. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  752. /** UNSIGNED_INT_24_8 */
  753. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  754. /** UNSIGNED_INT_10F_11F_11F_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  756. /** UNSIGNED_INT_5_9_9_9_REV */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  758. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  759. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  760. /** nearest is mag = nearest and min = nearest and no mip */
  761. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  762. /** mag = nearest and min = nearest and mip = none */
  763. static readonly TEXTURE_NEAREST_NEAREST: number;
  764. /** Bilinear is mag = linear and min = linear and no mip */
  765. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  766. /** mag = linear and min = linear and mip = none */
  767. static readonly TEXTURE_LINEAR_LINEAR: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** Trilinear is mag = linear and min = linear and mip = linear */
  771. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  772. /** mag = nearest and min = nearest and mip = nearest */
  773. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  774. /** mag = nearest and min = linear and mip = nearest */
  775. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  776. /** mag = nearest and min = linear and mip = linear */
  777. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  778. /** mag = nearest and min = linear and mip = none */
  779. static readonly TEXTURE_NEAREST_LINEAR: number;
  780. /** nearest is mag = nearest and min = nearest and mip = linear */
  781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  782. /** mag = linear and min = nearest and mip = nearest */
  783. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  784. /** mag = linear and min = nearest and mip = linear */
  785. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = none */
  789. static readonly TEXTURE_LINEAR_NEAREST: number;
  790. /** Explicit coordinates mode */
  791. static readonly TEXTURE_EXPLICIT_MODE: number;
  792. /** Spherical coordinates mode */
  793. static readonly TEXTURE_SPHERICAL_MODE: number;
  794. /** Planar coordinates mode */
  795. static readonly TEXTURE_PLANAR_MODE: number;
  796. /** Cubic coordinates mode */
  797. static readonly TEXTURE_CUBIC_MODE: number;
  798. /** Projection coordinates mode */
  799. static readonly TEXTURE_PROJECTION_MODE: number;
  800. /** Skybox coordinates mode */
  801. static readonly TEXTURE_SKYBOX_MODE: number;
  802. /** Inverse Cubic coordinates mode */
  803. static readonly TEXTURE_INVCUBIC_MODE: number;
  804. /** Equirectangular coordinates mode */
  805. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  806. /** Equirectangular Fixed coordinates mode */
  807. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  808. /** Equirectangular Fixed Mirrored coordinates mode */
  809. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  810. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  811. static readonly SCALEMODE_FLOOR: number;
  812. /** Defines that texture rescaling will look for the nearest power of 2 size */
  813. static readonly SCALEMODE_NEAREST: number;
  814. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  815. static readonly SCALEMODE_CEILING: number;
  816. /**
  817. * The dirty texture flag value
  818. */
  819. static readonly MATERIAL_TextureDirtyFlag: number;
  820. /**
  821. * The dirty light flag value
  822. */
  823. static readonly MATERIAL_LightDirtyFlag: number;
  824. /**
  825. * The dirty fresnel flag value
  826. */
  827. static readonly MATERIAL_FresnelDirtyFlag: number;
  828. /**
  829. * The dirty attribute flag value
  830. */
  831. static readonly MATERIAL_AttributesDirtyFlag: number;
  832. /**
  833. * The dirty misc flag value
  834. */
  835. static readonly MATERIAL_MiscDirtyFlag: number;
  836. /**
  837. * The all dirty flag value
  838. */
  839. static readonly MATERIAL_AllDirtyFlag: number;
  840. /**
  841. * Returns the triangle fill mode
  842. */
  843. static readonly MATERIAL_TriangleFillMode: number;
  844. /**
  845. * Returns the wireframe mode
  846. */
  847. static readonly MATERIAL_WireFrameFillMode: number;
  848. /**
  849. * Returns the point fill mode
  850. */
  851. static readonly MATERIAL_PointFillMode: number;
  852. /**
  853. * Returns the point list draw mode
  854. */
  855. static readonly MATERIAL_PointListDrawMode: number;
  856. /**
  857. * Returns the line list draw mode
  858. */
  859. static readonly MATERIAL_LineListDrawMode: number;
  860. /**
  861. * Returns the line loop draw mode
  862. */
  863. static readonly MATERIAL_LineLoopDrawMode: number;
  864. /**
  865. * Returns the line strip draw mode
  866. */
  867. static readonly MATERIAL_LineStripDrawMode: number;
  868. /**
  869. * Returns the triangle strip draw mode
  870. */
  871. static readonly MATERIAL_TriangleStripDrawMode: number;
  872. /**
  873. * Returns the triangle fan draw mode
  874. */
  875. static readonly MATERIAL_TriangleFanDrawMode: number;
  876. /**
  877. * Stores the clock-wise side orientation
  878. */
  879. static readonly MATERIAL_ClockWiseSideOrientation: number;
  880. /**
  881. * Stores the counter clock-wise side orientation
  882. */
  883. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  884. /**
  885. * Nothing
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_NothingTrigger: number;
  889. /**
  890. * On pick
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnPickTrigger: number;
  894. /**
  895. * On left pick
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnLeftPickTrigger: number;
  899. /**
  900. * On right pick
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnRightPickTrigger: number;
  904. /**
  905. * On center pick
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnCenterPickTrigger: number;
  909. /**
  910. * On pick down
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickDownTrigger: number;
  914. /**
  915. * On double pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnDoublePickTrigger: number;
  919. /**
  920. * On pick up
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickUpTrigger: number;
  924. /**
  925. * On pick out.
  926. * This trigger will only be raised if you also declared a OnPickDown
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickOutTrigger: number;
  930. /**
  931. * On long press
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnLongPressTrigger: number;
  935. /**
  936. * On pointer over
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPointerOverTrigger: number;
  940. /**
  941. * On pointer out
  942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  943. */
  944. static readonly ACTION_OnPointerOutTrigger: number;
  945. /**
  946. * On every frame
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnEveryFrameTrigger: number;
  950. /**
  951. * On intersection enter
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnIntersectionEnterTrigger: number;
  955. /**
  956. * On intersection exit
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnIntersectionExitTrigger: number;
  960. /**
  961. * On key down
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnKeyDownTrigger: number;
  965. /**
  966. * On key up
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnKeyUpTrigger: number;
  970. /**
  971. * Billboard mode will only apply to Y axis
  972. */
  973. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  974. /**
  975. * Billboard mode will apply to all axes
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  978. /**
  979. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  982. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  983. * Test order :
  984. * Is the bounding sphere outside the frustum ?
  985. * If not, are the bounding box vertices outside the frustum ?
  986. * It not, then the cullable object is in the frustum.
  987. */
  988. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  989. /** Culling strategy : Bounding Sphere Only.
  990. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  991. * It's also less accurate than the standard because some not visible objects can still be selected.
  992. * Test : is the bounding sphere outside the frustum ?
  993. * If not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  996. /** Culling strategy : Optimistic Inclusion.
  997. * This in an inclusion test first, then the standard exclusion test.
  998. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  999. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1000. * Anyway, it's as accurate as the standard strategy.
  1001. * Test :
  1002. * Is the cullable object bounding sphere center in the frustum ?
  1003. * If not, apply the default culling strategy.
  1004. */
  1005. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1006. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1007. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1008. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1009. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1010. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1011. * Test :
  1012. * Is the cullable object bounding sphere center in the frustum ?
  1013. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1016. /**
  1017. * No logging while loading
  1018. */
  1019. static readonly SCENELOADER_NO_LOGGING: number;
  1020. /**
  1021. * Minimal logging while loading
  1022. */
  1023. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1024. /**
  1025. * Summary logging while loading
  1026. */
  1027. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1028. /**
  1029. * Detailled logging while loading
  1030. */
  1031. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * This represents the required contract to create a new type of texture loader.
  1037. */
  1038. export interface IInternalTextureLoader {
  1039. /**
  1040. * Defines wether the loader supports cascade loading the different faces.
  1041. */
  1042. supportCascades: boolean;
  1043. /**
  1044. * This returns if the loader support the current file information.
  1045. * @param extension defines the file extension of the file being loaded
  1046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1047. * @param fallback defines the fallback internal texture if any
  1048. * @param isBase64 defines whether the texture is encoded as a base64
  1049. * @param isBuffer defines whether the texture data are stored as a buffer
  1050. * @returns true if the loader can load the specified file
  1051. */
  1052. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1053. /**
  1054. * Transform the url before loading if required.
  1055. * @param rootUrl the url of the texture
  1056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1057. * @returns the transformed texture
  1058. */
  1059. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1060. /**
  1061. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1062. * @param rootUrl the url of the texture
  1063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1064. * @returns the fallback texture
  1065. */
  1066. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1067. /**
  1068. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module BABYLON {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1100. }
  1101. }
  1102. declare module BABYLON {
  1103. /**
  1104. * Class used to store gfx data (like WebGLBuffer)
  1105. */
  1106. export class DataBuffer {
  1107. /**
  1108. * Gets or sets the number of objects referencing this buffer
  1109. */
  1110. references: number;
  1111. /** Gets or sets the size of the underlying buffer */
  1112. capacity: number;
  1113. /**
  1114. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1115. */
  1116. is32Bits: boolean;
  1117. /**
  1118. * Gets the underlying buffer
  1119. */
  1120. get underlyingResource(): any;
  1121. }
  1122. }
  1123. declare module BABYLON {
  1124. /** @hidden */
  1125. export interface IShaderProcessor {
  1126. attributeProcessor?: (attribute: string) => string;
  1127. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1128. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1129. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1130. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1131. lineProcessor?: (line: string, isFragment: boolean) => string;
  1132. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module BABYLON {
  1155. /** @hidden */
  1156. export class ShaderCodeNode {
  1157. line: string;
  1158. children: ShaderCodeNode[];
  1159. additionalDefineKey?: string;
  1160. additionalDefineValue?: string;
  1161. isValid(preprocessors: {
  1162. [key: string]: string;
  1163. }): boolean;
  1164. process(preprocessors: {
  1165. [key: string]: string;
  1166. }, options: ProcessingOptions): string;
  1167. }
  1168. }
  1169. declare module BABYLON {
  1170. /** @hidden */
  1171. export class ShaderCodeCursor {
  1172. private _lines;
  1173. lineIndex: number;
  1174. get currentLine(): string;
  1175. get canRead(): boolean;
  1176. set lines(value: string[]);
  1177. }
  1178. }
  1179. declare module BABYLON {
  1180. /** @hidden */
  1181. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1182. process(preprocessors: {
  1183. [key: string]: string;
  1184. }, options: ProcessingOptions): string;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /** @hidden */
  1189. export class ShaderDefineExpression {
  1190. isTrue(preprocessors: {
  1191. [key: string]: string;
  1192. }): boolean;
  1193. }
  1194. }
  1195. declare module BABYLON {
  1196. /** @hidden */
  1197. export class ShaderCodeTestNode extends ShaderCodeNode {
  1198. testExpression: ShaderDefineExpression;
  1199. isValid(preprocessors: {
  1200. [key: string]: string;
  1201. }): boolean;
  1202. }
  1203. }
  1204. declare module BABYLON {
  1205. /** @hidden */
  1206. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1207. define: string;
  1208. not: boolean;
  1209. constructor(define: string, not?: boolean);
  1210. isTrue(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1218. leftOperand: ShaderDefineExpression;
  1219. rightOperand: ShaderDefineExpression;
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module BABYLON {
  1248. /**
  1249. * Class used to enable access to offline support
  1250. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1251. */
  1252. export interface IOfflineProvider {
  1253. /**
  1254. * Gets a boolean indicating if scene must be saved in the database
  1255. */
  1256. enableSceneOffline: boolean;
  1257. /**
  1258. * Gets a boolean indicating if textures must be saved in the database
  1259. */
  1260. enableTexturesOffline: boolean;
  1261. /**
  1262. * Open the offline support and make it available
  1263. * @param successCallback defines the callback to call on success
  1264. * @param errorCallback defines the callback to call on error
  1265. */
  1266. open(successCallback: () => void, errorCallback: () => void): void;
  1267. /**
  1268. * Loads an image from the offline support
  1269. * @param url defines the url to load from
  1270. * @param image defines the target DOM image
  1271. */
  1272. loadImage(url: string, image: HTMLImageElement): void;
  1273. /**
  1274. * Loads a file from offline support
  1275. * @param url defines the URL to load from
  1276. * @param sceneLoaded defines a callback to call on success
  1277. * @param progressCallBack defines a callback to call when progress changed
  1278. * @param errorCallback defines a callback to call on error
  1279. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1280. */
  1281. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1282. }
  1283. }
  1284. declare module BABYLON {
  1285. /**
  1286. * Class used to help managing file picking and drag'n'drop
  1287. * File Storage
  1288. */
  1289. export class FilesInputStore {
  1290. /**
  1291. * List of files ready to be loaded
  1292. */
  1293. static FilesToLoad: {
  1294. [key: string]: File;
  1295. };
  1296. }
  1297. }
  1298. declare module BABYLON {
  1299. /**
  1300. * Class used to define a retry strategy when error happens while loading assets
  1301. */
  1302. export class RetryStrategy {
  1303. /**
  1304. * Function used to defines an exponential back off strategy
  1305. * @param maxRetries defines the maximum number of retries (3 by default)
  1306. * @param baseInterval defines the interval between retries
  1307. * @returns the strategy function to use
  1308. */
  1309. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1310. }
  1311. }
  1312. declare module BABYLON {
  1313. /**
  1314. * @ignore
  1315. * Application error to support additional information when loading a file
  1316. */
  1317. export abstract class BaseError extends Error {
  1318. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1319. }
  1320. }
  1321. declare module BABYLON {
  1322. /** @ignore */
  1323. export class LoadFileError extends BaseError {
  1324. request?: WebRequest;
  1325. file?: File;
  1326. /**
  1327. * Creates a new LoadFileError
  1328. * @param message defines the message of the error
  1329. * @param request defines the optional web request
  1330. * @param file defines the optional file
  1331. */
  1332. constructor(message: string, object?: WebRequest | File);
  1333. }
  1334. /** @ignore */
  1335. export class RequestFileError extends BaseError {
  1336. request: WebRequest;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. */
  1342. constructor(message: string, request: WebRequest);
  1343. }
  1344. /** @ignore */
  1345. export class ReadFileError extends BaseError {
  1346. file: File;
  1347. /**
  1348. * Creates a new ReadFileError
  1349. * @param message defines the message of the error
  1350. * @param file defines the optional file
  1351. */
  1352. constructor(message: string, file: File);
  1353. }
  1354. /**
  1355. * @hidden
  1356. */
  1357. export class FileTools {
  1358. /**
  1359. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1360. */
  1361. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1362. /**
  1363. * Gets or sets the base URL to use to load assets
  1364. */
  1365. static BaseUrl: string;
  1366. /**
  1367. * Default behaviour for cors in the application.
  1368. * It can be a string if the expected behavior is identical in the entire app.
  1369. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1370. */
  1371. static CorsBehavior: string | ((url: string | string[]) => string);
  1372. /**
  1373. * Gets or sets a function used to pre-process url before using them to load assets
  1374. */
  1375. static PreprocessUrl: (url: string) => string;
  1376. /**
  1377. * Removes unwanted characters from an url
  1378. * @param url defines the url to clean
  1379. * @returns the cleaned url
  1380. */
  1381. private static _CleanUrl;
  1382. /**
  1383. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1384. * @param url define the url we are trying
  1385. * @param element define the dom element where to configure the cors policy
  1386. */
  1387. static SetCorsBehavior(url: string | string[], element: {
  1388. crossOrigin: string | null;
  1389. }): void;
  1390. /**
  1391. * Loads an image as an HTMLImageElement.
  1392. * @param input url string, ArrayBuffer, or Blob to load
  1393. * @param onLoad callback called when the image successfully loads
  1394. * @param onError callback called when the image fails to load
  1395. * @param offlineProvider offline provider for caching
  1396. * @param mimeType optional mime type
  1397. * @returns the HTMLImageElement of the loaded image
  1398. */
  1399. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1400. /**
  1401. * Reads a file from a File object
  1402. * @param file defines the file to load
  1403. * @param onSuccess defines the callback to call when data is loaded
  1404. * @param onProgress defines the callback to call during loading process
  1405. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1406. * @param onError defines the callback to call when an error occurs
  1407. * @returns a file request object
  1408. */
  1409. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1410. /**
  1411. * Loads a file from a url
  1412. * @param url url to load
  1413. * @param onSuccess callback called when the file successfully loads
  1414. * @param onProgress callback called while file is loading (if the server supports this mode)
  1415. * @param offlineProvider defines the offline provider for caching
  1416. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1417. * @param onError callback called when the file fails to load
  1418. * @returns a file request object
  1419. */
  1420. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @param onOpened callback called when the web request is opened
  1429. * @returns a file request object
  1430. */
  1431. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1432. /**
  1433. * Checks if the loaded document was accessed via `file:`-Protocol.
  1434. * @returns boolean
  1435. */
  1436. static IsFileURL(): boolean;
  1437. }
  1438. }
  1439. declare module BABYLON {
  1440. /** @hidden */
  1441. export class ShaderProcessor {
  1442. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1443. private static _ProcessPrecision;
  1444. private static _ExtractOperation;
  1445. private static _BuildSubExpression;
  1446. private static _BuildExpression;
  1447. private static _MoveCursorWithinIf;
  1448. private static _MoveCursor;
  1449. private static _EvaluatePreProcessors;
  1450. private static _PreparePreProcessors;
  1451. private static _ProcessShaderConversion;
  1452. private static _ProcessIncludes;
  1453. /**
  1454. * Loads a file from a url
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param offlineProvider defines the offline provider for caching
  1459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1460. * @param onError callback called when the file fails to load
  1461. * @returns a file request object
  1462. * @hidden
  1463. */
  1464. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1465. }
  1466. }
  1467. declare module BABYLON {
  1468. /**
  1469. * @hidden
  1470. */
  1471. export interface IColor4Like {
  1472. r: float;
  1473. g: float;
  1474. b: float;
  1475. a: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IColor3Like {
  1481. r: float;
  1482. g: float;
  1483. b: float;
  1484. }
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IVector4Like {
  1489. x: float;
  1490. y: float;
  1491. z: float;
  1492. w: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector3Like {
  1498. x: float;
  1499. y: float;
  1500. z: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector2Like {
  1506. x: float;
  1507. y: float;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IMatrixLike {
  1513. toArray(): DeepImmutable<Float32Array>;
  1514. updateFlag: int;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IViewportLike {
  1520. x: float;
  1521. y: float;
  1522. width: float;
  1523. height: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IPlaneLike {
  1529. normal: IVector3Like;
  1530. d: float;
  1531. normalize(): void;
  1532. }
  1533. }
  1534. declare module BABYLON {
  1535. /**
  1536. * Interface used to define common properties for effect fallbacks
  1537. */
  1538. export interface IEffectFallbacks {
  1539. /**
  1540. * Removes the defines that should be removed when falling back.
  1541. * @param currentDefines defines the current define statements for the shader.
  1542. * @param effect defines the current effect we try to compile
  1543. * @returns The resulting defines with defines of the current rank removed.
  1544. */
  1545. reduce(currentDefines: string, effect: Effect): string;
  1546. /**
  1547. * Removes the fallback from the bound mesh.
  1548. */
  1549. unBindMesh(): void;
  1550. /**
  1551. * Checks to see if more fallbacks are still availible.
  1552. */
  1553. hasMoreFallbacks: boolean;
  1554. }
  1555. }
  1556. declare module BABYLON {
  1557. /**
  1558. * Class used to evalaute queries containing `and` and `or` operators
  1559. */
  1560. export class AndOrNotEvaluator {
  1561. /**
  1562. * Evaluate a query
  1563. * @param query defines the query to evaluate
  1564. * @param evaluateCallback defines the callback used to filter result
  1565. * @returns true if the query matches
  1566. */
  1567. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1568. private static _HandleParenthesisContent;
  1569. private static _SimplifyNegation;
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /**
  1574. * Class used to store custom tags
  1575. */
  1576. export class Tags {
  1577. /**
  1578. * Adds support for tags on the given object
  1579. * @param obj defines the object to use
  1580. */
  1581. static EnableFor(obj: any): void;
  1582. /**
  1583. * Removes tags support
  1584. * @param obj defines the object to use
  1585. */
  1586. static DisableFor(obj: any): void;
  1587. /**
  1588. * Gets a boolean indicating if the given object has tags
  1589. * @param obj defines the object to use
  1590. * @returns a boolean
  1591. */
  1592. static HasTags(obj: any): boolean;
  1593. /**
  1594. * Gets the tags available on a given object
  1595. * @param obj defines the object to use
  1596. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1597. * @returns the tags
  1598. */
  1599. static GetTags(obj: any, asString?: boolean): any;
  1600. /**
  1601. * Adds tags to an object
  1602. * @param obj defines the object to use
  1603. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1604. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1605. */
  1606. static AddTagsTo(obj: any, tagsString: string): void;
  1607. /**
  1608. * @hidden
  1609. */
  1610. static _AddTagTo(obj: any, tag: string): void;
  1611. /**
  1612. * Removes specific tags from a specific object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tags to remove
  1615. */
  1616. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _RemoveTagFrom(obj: any, tag: string): void;
  1621. /**
  1622. * Defines if tags hosted on an object match a given query
  1623. * @param obj defines the object to use
  1624. * @param tagsQuery defines the tag query
  1625. * @returns a boolean
  1626. */
  1627. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Scalar computation library
  1633. */
  1634. export class Scalar {
  1635. /**
  1636. * Two pi constants convenient for computation.
  1637. */
  1638. static TwoPi: number;
  1639. /**
  1640. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1641. * @param a number
  1642. * @param b number
  1643. * @param epsilon (default = 1.401298E-45)
  1644. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1645. */
  1646. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1647. /**
  1648. * Returns a string : the upper case translation of the number i to hexadecimal.
  1649. * @param i number
  1650. * @returns the upper case translation of the number i to hexadecimal.
  1651. */
  1652. static ToHex(i: number): string;
  1653. /**
  1654. * Returns -1 if value is negative and +1 is value is positive.
  1655. * @param value the value
  1656. * @returns the value itself if it's equal to zero.
  1657. */
  1658. static Sign(value: number): number;
  1659. /**
  1660. * Returns the value itself if it's between min and max.
  1661. * Returns min if the value is lower than min.
  1662. * Returns max if the value is greater than max.
  1663. * @param value the value to clmap
  1664. * @param min the min value to clamp to (default: 0)
  1665. * @param max the max value to clamp to (default: 1)
  1666. * @returns the clamped value
  1667. */
  1668. static Clamp(value: number, min?: number, max?: number): number;
  1669. /**
  1670. * the log2 of value.
  1671. * @param value the value to compute log2 of
  1672. * @returns the log2 of value.
  1673. */
  1674. static Log2(value: number): number;
  1675. /**
  1676. * Loops the value, so that it is never larger than length and never smaller than 0.
  1677. *
  1678. * This is similar to the modulo operator but it works with floating point numbers.
  1679. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1680. * With t = 5 and length = 2.5, the result would be 0.0.
  1681. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1682. * @param value the value
  1683. * @param length the length
  1684. * @returns the looped value
  1685. */
  1686. static Repeat(value: number, length: number): number;
  1687. /**
  1688. * Normalize the value between 0.0 and 1.0 using min and max values
  1689. * @param value value to normalize
  1690. * @param min max to normalize between
  1691. * @param max min to normalize between
  1692. * @returns the normalized value
  1693. */
  1694. static Normalize(value: number, min: number, max: number): number;
  1695. /**
  1696. * Denormalize the value from 0.0 and 1.0 using min and max values
  1697. * @param normalized value to denormalize
  1698. * @param min max to denormalize between
  1699. * @param max min to denormalize between
  1700. * @returns the denormalized value
  1701. */
  1702. static Denormalize(normalized: number, min: number, max: number): number;
  1703. /**
  1704. * Calculates the shortest difference between two given angles given in degrees.
  1705. * @param current current angle in degrees
  1706. * @param target target angle in degrees
  1707. * @returns the delta
  1708. */
  1709. static DeltaAngle(current: number, target: number): number;
  1710. /**
  1711. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1712. * @param tx value
  1713. * @param length length
  1714. * @returns The returned value will move back and forth between 0 and length
  1715. */
  1716. static PingPong(tx: number, length: number): number;
  1717. /**
  1718. * Interpolates between min and max with smoothing at the limits.
  1719. *
  1720. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1721. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1722. * @param from from
  1723. * @param to to
  1724. * @param tx value
  1725. * @returns the smooth stepped value
  1726. */
  1727. static SmoothStep(from: number, to: number, tx: number): number;
  1728. /**
  1729. * Moves a value current towards target.
  1730. *
  1731. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1732. * Negative values of maxDelta pushes the value away from target.
  1733. * @param current current value
  1734. * @param target target value
  1735. * @param maxDelta max distance to move
  1736. * @returns resulting value
  1737. */
  1738. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1739. /**
  1740. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1741. *
  1742. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1743. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting angle
  1748. */
  1749. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1752. * @param start start value
  1753. * @param end target value
  1754. * @param amount amount to lerp between
  1755. * @returns the lerped value
  1756. */
  1757. static Lerp(start: number, end: number, amount: number): number;
  1758. /**
  1759. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1760. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1761. * @param start start value
  1762. * @param end target value
  1763. * @param amount amount to lerp between
  1764. * @returns the lerped value
  1765. */
  1766. static LerpAngle(start: number, end: number, amount: number): number;
  1767. /**
  1768. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1769. * @param a start value
  1770. * @param b target value
  1771. * @param value value between a and b
  1772. * @returns the inverseLerp value
  1773. */
  1774. static InverseLerp(a: number, b: number, value: number): number;
  1775. /**
  1776. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1777. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1778. * @param value1 spline value
  1779. * @param tangent1 spline value
  1780. * @param value2 spline value
  1781. * @param tangent2 spline value
  1782. * @param amount input value
  1783. * @returns hermite result
  1784. */
  1785. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1786. /**
  1787. * Returns a random float number between and min and max values
  1788. * @param min min value of random
  1789. * @param max max value of random
  1790. * @returns random value
  1791. */
  1792. static RandomRange(min: number, max: number): number;
  1793. /**
  1794. * This function returns percentage of a number in a given range.
  1795. *
  1796. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1797. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1798. * @param number to convert to percentage
  1799. * @param min min range
  1800. * @param max max range
  1801. * @returns the percentage
  1802. */
  1803. static RangeToPercent(number: number, min: number, max: number): number;
  1804. /**
  1805. * This function returns number that corresponds to the percentage in a given range.
  1806. *
  1807. * PercentToRange(0.34,0,100) will return 34.
  1808. * @param percent to convert to number
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the number
  1812. */
  1813. static PercentToRange(percent: number, min: number, max: number): number;
  1814. /**
  1815. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1816. * @param angle The angle to normalize in radian.
  1817. * @return The converted angle.
  1818. */
  1819. static NormalizeRadians(angle: number): number;
  1820. }
  1821. }
  1822. declare module BABYLON {
  1823. /**
  1824. * Constant used to convert a value to gamma space
  1825. * @ignorenaming
  1826. */
  1827. export const ToGammaSpace: number;
  1828. /**
  1829. * Constant used to convert a value to linear space
  1830. * @ignorenaming
  1831. */
  1832. export const ToLinearSpace = 2.2;
  1833. /**
  1834. * Constant used to define the minimal number value in Babylon.js
  1835. * @ignorenaming
  1836. */
  1837. let Epsilon: number;
  1838. }
  1839. declare module BABYLON {
  1840. /**
  1841. * Class used to represent a viewport on screen
  1842. */
  1843. export class Viewport {
  1844. /** viewport left coordinate */
  1845. x: number;
  1846. /** viewport top coordinate */
  1847. y: number;
  1848. /**viewport width */
  1849. width: number;
  1850. /** viewport height */
  1851. height: number;
  1852. /**
  1853. * Creates a Viewport object located at (x, y) and sized (width, height)
  1854. * @param x defines viewport left coordinate
  1855. * @param y defines viewport top coordinate
  1856. * @param width defines the viewport width
  1857. * @param height defines the viewport height
  1858. */
  1859. constructor(
  1860. /** viewport left coordinate */
  1861. x: number,
  1862. /** viewport top coordinate */
  1863. y: number,
  1864. /**viewport width */
  1865. width: number,
  1866. /** viewport height */
  1867. height: number);
  1868. /**
  1869. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @returns a new Viewport
  1873. */
  1874. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1875. /**
  1876. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1877. * @param renderWidth defines the rendering width
  1878. * @param renderHeight defines the rendering height
  1879. * @param ref defines the target viewport
  1880. * @returns the current viewport
  1881. */
  1882. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1883. /**
  1884. * Returns a new Viewport copied from the current one
  1885. * @returns a new Viewport
  1886. */
  1887. clone(): Viewport;
  1888. }
  1889. }
  1890. declare module BABYLON {
  1891. /**
  1892. * Class containing a set of static utilities functions for arrays.
  1893. */
  1894. export class ArrayTools {
  1895. /**
  1896. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1897. * @param size the number of element to construct and put in the array
  1898. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1899. * @returns a new array filled with new objects
  1900. */
  1901. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1902. }
  1903. }
  1904. declare module BABYLON {
  1905. /**
  1906. * Class representing a vector containing 2 coordinates
  1907. */
  1908. export class Vector2 {
  1909. /** defines the first coordinate */
  1910. x: number;
  1911. /** defines the second coordinate */
  1912. y: number;
  1913. /**
  1914. * Creates a new Vector2 from the given x and y coordinates
  1915. * @param x defines the first coordinate
  1916. * @param y defines the second coordinate
  1917. */
  1918. constructor(
  1919. /** defines the first coordinate */
  1920. x?: number,
  1921. /** defines the second coordinate */
  1922. y?: number);
  1923. /**
  1924. * Gets a string with the Vector2 coordinates
  1925. * @returns a string with the Vector2 coordinates
  1926. */
  1927. toString(): string;
  1928. /**
  1929. * Gets class name
  1930. * @returns the string "Vector2"
  1931. */
  1932. getClassName(): string;
  1933. /**
  1934. * Gets current vector hash code
  1935. * @returns the Vector2 hash code as a number
  1936. */
  1937. getHashCode(): number;
  1938. /**
  1939. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1940. * @param array defines the source array
  1941. * @param index defines the offset in source array
  1942. * @returns the current Vector2
  1943. */
  1944. toArray(array: FloatArray, index?: number): Vector2;
  1945. /**
  1946. * Copy the current vector to an array
  1947. * @returns a new array with 2 elements: the Vector2 coordinates.
  1948. */
  1949. asArray(): number[];
  1950. /**
  1951. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1952. * @param source defines the source Vector2
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. copyFromFloats(x: number, y: number): Vector2;
  1963. /**
  1964. * Sets the Vector2 coordinates with the given floats
  1965. * @param x defines the first coordinate
  1966. * @param y defines the second coordinate
  1967. * @returns the current updated Vector2
  1968. */
  1969. set(x: number, y: number): Vector2;
  1970. /**
  1971. * Add another vector with the current one
  1972. * @param otherVector defines the other vector
  1973. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1974. */
  1975. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1976. /**
  1977. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1978. * @param otherVector defines the other vector
  1979. * @param result defines the target vector
  1980. * @returns the unmodified current Vector2
  1981. */
  1982. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1983. /**
  1984. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1985. * @param otherVector defines the other vector
  1986. * @returns the current updated Vector2
  1987. */
  1988. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1989. /**
  1990. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1991. * @param otherVector defines the other vector
  1992. * @returns a new Vector2
  1993. */
  1994. addVector3(otherVector: Vector3): Vector2;
  1995. /**
  1996. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1997. * @param otherVector defines the other vector
  1998. * @returns a new Vector2
  1999. */
  2000. subtract(otherVector: Vector2): Vector2;
  2001. /**
  2002. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2003. * @param otherVector defines the other vector
  2004. * @param result defines the target vector
  2005. * @returns the unmodified current Vector2
  2006. */
  2007. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2008. /**
  2009. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @returns the current updated Vector2
  2012. */
  2013. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2014. /**
  2015. * Multiplies in place the current Vector2 coordinates by the given ones
  2016. * @param otherVector defines the other vector
  2017. * @returns the current updated Vector2
  2018. */
  2019. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2020. /**
  2021. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2022. * @param otherVector defines the other vector
  2023. * @returns a new Vector2
  2024. */
  2025. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2026. /**
  2027. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2028. * @param otherVector defines the other vector
  2029. * @param result defines the target vector
  2030. * @returns the unmodified current Vector2
  2031. */
  2032. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2033. /**
  2034. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2035. * @param x defines the first coordinate
  2036. * @param y defines the second coordinate
  2037. * @returns a new Vector2
  2038. */
  2039. multiplyByFloats(x: number, y: number): Vector2;
  2040. /**
  2041. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. divide(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Divides the current Vector2 coordinates by the given ones
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Gets a new Vector2 with current Vector2 negated coordinates
  2061. * @returns a new Vector2
  2062. */
  2063. negate(): Vector2;
  2064. /**
  2065. * Negate this vector in place
  2066. * @returns this
  2067. */
  2068. negateInPlace(): Vector2;
  2069. /**
  2070. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2071. * @param result defines the Vector3 object where to store the result
  2072. * @returns the current Vector2
  2073. */
  2074. negateToRef(result: Vector2): Vector2;
  2075. /**
  2076. * Multiply the Vector2 coordinates by scale
  2077. * @param scale defines the scaling factor
  2078. * @returns the current updated Vector2
  2079. */
  2080. scaleInPlace(scale: number): Vector2;
  2081. /**
  2082. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2083. * @param scale defines the scaling factor
  2084. * @returns a new Vector2
  2085. */
  2086. scale(scale: number): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2096. * @param scale defines the scale factor
  2097. * @param result defines the Vector2 object where to store the result
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2101. /**
  2102. * Gets a boolean if two vectors are equals
  2103. * @param otherVector defines the other vector
  2104. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2105. */
  2106. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2107. /**
  2108. * Gets a boolean if two vectors are equals (using an epsilon value)
  2109. * @param otherVector defines the other vector
  2110. * @param epsilon defines the minimal distance to consider equality
  2111. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2112. */
  2113. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2114. /**
  2115. * Gets a new Vector2 from current Vector2 floored values
  2116. * @returns a new Vector2
  2117. */
  2118. floor(): Vector2;
  2119. /**
  2120. * Gets a new Vector2 from current Vector2 floored values
  2121. * @returns a new Vector2
  2122. */
  2123. fract(): Vector2;
  2124. /**
  2125. * Gets the length of the vector
  2126. * @returns the vector length (float)
  2127. */
  2128. length(): number;
  2129. /**
  2130. * Gets the vector squared length
  2131. * @returns the vector squared length (float)
  2132. */
  2133. lengthSquared(): number;
  2134. /**
  2135. * Normalize the vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. normalize(): Vector2;
  2139. /**
  2140. * Gets a new Vector2 copied from the Vector2
  2141. * @returns a new Vector2
  2142. */
  2143. clone(): Vector2;
  2144. /**
  2145. * Gets a new Vector2(0, 0)
  2146. * @returns a new Vector2
  2147. */
  2148. static Zero(): Vector2;
  2149. /**
  2150. * Gets a new Vector2(1, 1)
  2151. * @returns a new Vector2
  2152. */
  2153. static One(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 set from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @returns a new Vector2
  2159. */
  2160. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2161. /**
  2162. * Sets "result" from the given index element of the given array
  2163. * @param array defines the data source
  2164. * @param offset defines the offset in the data source
  2165. * @param result defines the target vector
  2166. */
  2167. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2168. /**
  2169. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2170. * @param value1 defines 1st point of control
  2171. * @param value2 defines 2nd point of control
  2172. * @param value3 defines 3rd point of control
  2173. * @param value4 defines 4th point of control
  2174. * @param amount defines the interpolation factor
  2175. * @returns a new Vector2
  2176. */
  2177. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2178. /**
  2179. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2180. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2181. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2182. * @param value defines the value to clamp
  2183. * @param min defines the lower limit
  2184. * @param max defines the upper limit
  2185. * @returns a new Vector2
  2186. */
  2187. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2190. * @param value1 defines the 1st control point
  2191. * @param tangent1 defines the outgoing tangent
  2192. * @param value2 defines the 2nd control point
  2193. * @param tangent2 defines the incoming tangent
  2194. * @param amount defines the interpolation factor
  2195. * @returns a new Vector2
  2196. */
  2197. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2198. /**
  2199. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2200. * @param start defines the start vector
  2201. * @param end defines the end vector
  2202. * @param amount defines the interpolation factor
  2203. * @returns a new Vector2
  2204. */
  2205. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2206. /**
  2207. * Gets the dot product of the vector "left" and the vector "right"
  2208. * @param left defines first vector
  2209. * @param right defines second vector
  2210. * @returns the dot product (float)
  2211. */
  2212. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2213. /**
  2214. * Returns a new Vector2 equal to the normalized given vector
  2215. * @param vector defines the vector to normalize
  2216. * @returns a new Vector2
  2217. */
  2218. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2228. * @param left defines 1st vector
  2229. * @param right defines 2nd vector
  2230. * @returns a new Vector2
  2231. */
  2232. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2233. /**
  2234. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @returns a new Vector2
  2238. */
  2239. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2240. /**
  2241. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2242. * @param vector defines the vector to transform
  2243. * @param transformation defines the matrix to apply
  2244. * @param result defines the target vector
  2245. */
  2246. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2247. /**
  2248. * Determines if a given vector is included in a triangle
  2249. * @param p defines the vector to test
  2250. * @param p0 defines 1st triangle point
  2251. * @param p1 defines 2nd triangle point
  2252. * @param p2 defines 3rd triangle point
  2253. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2254. */
  2255. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2256. /**
  2257. * Gets the distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the distance between vectors
  2261. */
  2262. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Returns the squared distance between the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns the squared distance between vectors
  2268. */
  2269. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2270. /**
  2271. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2272. * @param value1 defines first vector
  2273. * @param value2 defines second vector
  2274. * @returns a new Vector2
  2275. */
  2276. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2277. /**
  2278. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2279. * @param p defines the middle point
  2280. * @param segA defines one point of the segment
  2281. * @param segB defines the other point of the segment
  2282. * @returns the shortest distance
  2283. */
  2284. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2285. }
  2286. /**
  2287. * Class used to store (x,y,z) vector representation
  2288. * A Vector3 is the main object used in 3D geometry
  2289. * It can represent etiher the coordinates of a point the space, either a direction
  2290. * Reminder: js uses a left handed forward facing system
  2291. */
  2292. export class Vector3 {
  2293. /**
  2294. * Defines the first coordinates (on X axis)
  2295. */
  2296. x: number;
  2297. /**
  2298. * Defines the second coordinates (on Y axis)
  2299. */
  2300. y: number;
  2301. /**
  2302. * Defines the third coordinates (on Z axis)
  2303. */
  2304. z: number;
  2305. private static _UpReadOnly;
  2306. private static _ZeroReadOnly;
  2307. /**
  2308. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2309. * @param x defines the first coordinates (on X axis)
  2310. * @param y defines the second coordinates (on Y axis)
  2311. * @param z defines the third coordinates (on Z axis)
  2312. */
  2313. constructor(
  2314. /**
  2315. * Defines the first coordinates (on X axis)
  2316. */
  2317. x?: number,
  2318. /**
  2319. * Defines the second coordinates (on Y axis)
  2320. */
  2321. y?: number,
  2322. /**
  2323. * Defines the third coordinates (on Z axis)
  2324. */
  2325. z?: number);
  2326. /**
  2327. * Creates a string representation of the Vector3
  2328. * @returns a string with the Vector3 coordinates.
  2329. */
  2330. toString(): string;
  2331. /**
  2332. * Gets the class name
  2333. * @returns the string "Vector3"
  2334. */
  2335. getClassName(): string;
  2336. /**
  2337. * Creates the Vector3 hash code
  2338. * @returns a number which tends to be unique between Vector3 instances
  2339. */
  2340. getHashCode(): number;
  2341. /**
  2342. * Creates an array containing three elements : the coordinates of the Vector3
  2343. * @returns a new array of numbers
  2344. */
  2345. asArray(): number[];
  2346. /**
  2347. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2348. * @param array defines the destination array
  2349. * @param index defines the offset in the destination array
  2350. * @returns the current Vector3
  2351. */
  2352. toArray(array: FloatArray, index?: number): Vector3;
  2353. /**
  2354. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2355. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2356. */
  2357. toQuaternion(): Quaternion;
  2358. /**
  2359. * Adds the given vector to the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the given coordinates to the current Vector3
  2366. * @param x defines the x coordinate of the operand
  2367. * @param y defines the y coordinate of the operand
  2368. * @param z defines the z coordinate of the operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2372. /**
  2373. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Subtract the given vector from the current Vector3
  2387. * @param otherVector defines the second operand
  2388. * @returns the current updated Vector3
  2389. */
  2390. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2391. /**
  2392. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the resulting Vector3
  2395. */
  2396. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2399. * @param otherVector defines the second operand
  2400. * @param result defines the Vector3 object where to store the result
  2401. * @returns the current Vector3
  2402. */
  2403. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2404. /**
  2405. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2406. * @param x defines the x coordinate of the operand
  2407. * @param y defines the y coordinate of the operand
  2408. * @param z defines the z coordinate of the operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2412. /**
  2413. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2414. * @param x defines the x coordinate of the operand
  2415. * @param y defines the y coordinate of the operand
  2416. * @param z defines the z coordinate of the operand
  2417. * @param result defines the Vector3 object where to store the result
  2418. * @returns the current Vector3
  2419. */
  2420. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2421. /**
  2422. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2423. * @returns a new Vector3
  2424. */
  2425. negate(): Vector3;
  2426. /**
  2427. * Negate this vector in place
  2428. * @returns this
  2429. */
  2430. negateInPlace(): Vector3;
  2431. /**
  2432. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. negateToRef(result: Vector3): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. get isNonUniform(): boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. * @deprecated Please use FromArray instead.
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. * @deprecated Please use FromArrayToRef instead.
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static get UpReadOnly(): DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Negate this vector in place
  3160. * @returns this
  3161. */
  3162. negateInPlace(): Vector4;
  3163. /**
  3164. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3165. * @param result defines the Vector3 object where to store the result
  3166. * @returns the current Vector4
  3167. */
  3168. negateToRef(result: Vector4): Vector4;
  3169. /**
  3170. * Multiplies the current Vector4 coordinates by scale (float).
  3171. * @param scale the number to scale with
  3172. * @returns the updated Vector4.
  3173. */
  3174. scaleInPlace(scale: number): Vector4;
  3175. /**
  3176. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3177. * @param scale the number to scale with
  3178. * @returns a new vector with the result
  3179. */
  3180. scale(scale: number): Vector4;
  3181. /**
  3182. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3183. * @param scale the number to scale with
  3184. * @param result a vector to store the result in
  3185. * @returns the current Vector4.
  3186. */
  3187. scaleToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3190. * @param scale defines the scale factor
  3191. * @param result defines the Vector4 object where to store the result
  3192. * @returns the unmodified current Vector4
  3193. */
  3194. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3195. /**
  3196. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3197. * @param otherVector the vector to compare against
  3198. * @returns true if they are equal
  3199. */
  3200. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3201. /**
  3202. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3203. * @param otherVector vector to compare against
  3204. * @param epsilon (Default: very small number)
  3205. * @returns true if they are equal
  3206. */
  3207. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3208. /**
  3209. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3210. * @param x x value to compare against
  3211. * @param y y value to compare against
  3212. * @param z z value to compare against
  3213. * @param w w value to compare against
  3214. * @returns true if equal
  3215. */
  3216. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3217. /**
  3218. * Multiplies in place the current Vector4 by the given one.
  3219. * @param otherVector vector to multiple with
  3220. * @returns the updated Vector4.
  3221. */
  3222. multiplyInPlace(otherVector: Vector4): Vector4;
  3223. /**
  3224. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3225. * @param otherVector vector to multiple with
  3226. * @returns resulting new vector
  3227. */
  3228. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3231. * @param otherVector vector to multiple with
  3232. * @param result vector to store the result
  3233. * @returns the current Vector4.
  3234. */
  3235. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3236. /**
  3237. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3238. * @param x x value multiply with
  3239. * @param y y value multiply with
  3240. * @param z z value multiply with
  3241. * @param w w value multiply with
  3242. * @returns resulting new vector
  3243. */
  3244. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3245. /**
  3246. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3247. * @param otherVector vector to devide with
  3248. * @returns resulting new vector
  3249. */
  3250. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3251. /**
  3252. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3253. * @param otherVector vector to devide with
  3254. * @param result vector to store the result
  3255. * @returns the current Vector4.
  3256. */
  3257. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3258. /**
  3259. * Divides the current Vector3 coordinates by the given ones.
  3260. * @param otherVector vector to devide with
  3261. * @returns the updated Vector3.
  3262. */
  3263. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3266. * @param other defines the second operand
  3267. * @returns the current updated Vector4
  3268. */
  3269. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3270. /**
  3271. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3272. * @param other defines the second operand
  3273. * @returns the current updated Vector4
  3274. */
  3275. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Gets a new Vector4 from current Vector4 floored values
  3278. * @returns a new Vector4
  3279. */
  3280. floor(): Vector4;
  3281. /**
  3282. * Gets a new Vector4 from current Vector3 floored values
  3283. * @returns a new Vector4
  3284. */
  3285. fract(): Vector4;
  3286. /**
  3287. * Returns the Vector4 length (float).
  3288. * @returns the length
  3289. */
  3290. length(): number;
  3291. /**
  3292. * Returns the Vector4 squared length (float).
  3293. * @returns the length squared
  3294. */
  3295. lengthSquared(): number;
  3296. /**
  3297. * Normalizes in place the Vector4.
  3298. * @returns the updated Vector4.
  3299. */
  3300. normalize(): Vector4;
  3301. /**
  3302. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3303. * @returns this converted to a new vector3
  3304. */
  3305. toVector3(): Vector3;
  3306. /**
  3307. * Returns a new Vector4 copied from the current one.
  3308. * @returns the new cloned vector
  3309. */
  3310. clone(): Vector4;
  3311. /**
  3312. * Updates the current Vector4 with the given one coordinates.
  3313. * @param source the source vector to copy from
  3314. * @returns the updated Vector4.
  3315. */
  3316. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3317. /**
  3318. * Updates the current Vector4 coordinates with the given floats.
  3319. * @param x float to copy from
  3320. * @param y float to copy from
  3321. * @param z float to copy from
  3322. * @param w float to copy from
  3323. * @returns the updated Vector4.
  3324. */
  3325. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3326. /**
  3327. * Updates the current Vector4 coordinates with the given floats.
  3328. * @param x float to set from
  3329. * @param y float to set from
  3330. * @param z float to set from
  3331. * @param w float to set from
  3332. * @returns the updated Vector4.
  3333. */
  3334. set(x: number, y: number, z: number, w: number): Vector4;
  3335. /**
  3336. * Copies the given float to the current Vector3 coordinates
  3337. * @param v defines the x, y, z and w coordinates of the operand
  3338. * @returns the current updated Vector3
  3339. */
  3340. setAll(v: number): Vector4;
  3341. /**
  3342. * Returns a new Vector4 set from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @returns the new vector
  3346. */
  3347. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" from the starting index of the given Float32Array.
  3357. * @param array the array to pull values from
  3358. * @param offset the offset into the array to start at
  3359. * @param result the vector to store the result in
  3360. */
  3361. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3362. /**
  3363. * Updates the given vector "result" coordinates from the given floats.
  3364. * @param x float to set from
  3365. * @param y float to set from
  3366. * @param z float to set from
  3367. * @param w float to set from
  3368. * @param result the vector to the floats in
  3369. */
  3370. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3371. /**
  3372. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3373. * @returns the new vector
  3374. */
  3375. static Zero(): Vector4;
  3376. /**
  3377. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3378. * @returns the new vector
  3379. */
  3380. static One(): Vector4;
  3381. /**
  3382. * Returns a new normalized Vector4 from the given one.
  3383. * @param vector the vector to normalize
  3384. * @returns the vector
  3385. */
  3386. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Updates the given vector "result" from the normalization of the given one.
  3389. * @param vector the vector to normalize
  3390. * @param result the vector to store the result in
  3391. */
  3392. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3393. /**
  3394. * Returns a vector with the minimum values from the left and right vectors
  3395. * @param left left vector to minimize
  3396. * @param right right vector to minimize
  3397. * @returns a new vector with the minimum of the left and right vector values
  3398. */
  3399. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns a vector with the maximum values from the left and right vectors
  3402. * @param left left vector to maximize
  3403. * @param right right vector to maximize
  3404. * @returns a new vector with the maximum of the left and right vector values
  3405. */
  3406. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3407. /**
  3408. * Returns the distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors
  3412. */
  3413. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the distance between
  3417. * @param value2 value to calulate the distance between
  3418. * @return the distance between the two vectors squared
  3419. */
  3420. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3421. /**
  3422. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3423. * @param value1 value to calulate the center between
  3424. * @param value2 value to calulate the center between
  3425. * @return the center between the two vectors
  3426. */
  3427. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3430. * This methods computes transformed normalized direction vectors only.
  3431. * @param vector the vector to transform
  3432. * @param transformation the transformation matrix to apply
  3433. * @returns the new vector
  3434. */
  3435. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3436. /**
  3437. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3438. * This methods computes transformed normalized direction vectors only.
  3439. * @param vector the vector to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the result in
  3442. */
  3443. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3446. * This methods computes transformed normalized direction vectors only.
  3447. * @param x value to transform
  3448. * @param y value to transform
  3449. * @param z value to transform
  3450. * @param w value to transform
  3451. * @param transformation the transformation matrix to apply
  3452. * @param result the vector to store the results in
  3453. */
  3454. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3455. /**
  3456. * Creates a new Vector4 from a Vector3
  3457. * @param source defines the source data
  3458. * @param w defines the 4th component (default is 0)
  3459. * @returns a new Vector4
  3460. */
  3461. static FromVector3(source: Vector3, w?: number): Vector4;
  3462. }
  3463. /**
  3464. * Class used to store quaternion data
  3465. * @see https://en.wikipedia.org/wiki/Quaternion
  3466. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3467. */
  3468. export class Quaternion {
  3469. /** defines the first component (0 by default) */
  3470. x: number;
  3471. /** defines the second component (0 by default) */
  3472. y: number;
  3473. /** defines the third component (0 by default) */
  3474. z: number;
  3475. /** defines the fourth component (1.0 by default) */
  3476. w: number;
  3477. /**
  3478. * Creates a new Quaternion from the given floats
  3479. * @param x defines the first component (0 by default)
  3480. * @param y defines the second component (0 by default)
  3481. * @param z defines the third component (0 by default)
  3482. * @param w defines the fourth component (1.0 by default)
  3483. */
  3484. constructor(
  3485. /** defines the first component (0 by default) */
  3486. x?: number,
  3487. /** defines the second component (0 by default) */
  3488. y?: number,
  3489. /** defines the third component (0 by default) */
  3490. z?: number,
  3491. /** defines the fourth component (1.0 by default) */
  3492. w?: number);
  3493. /**
  3494. * Gets a string representation for the current quaternion
  3495. * @returns a string with the Quaternion coordinates
  3496. */
  3497. toString(): string;
  3498. /**
  3499. * Gets the class name of the quaternion
  3500. * @returns the string "Quaternion"
  3501. */
  3502. getClassName(): string;
  3503. /**
  3504. * Gets a hash code for this quaternion
  3505. * @returns the quaternion hash code
  3506. */
  3507. getHashCode(): number;
  3508. /**
  3509. * Copy the quaternion to an array
  3510. * @returns a new array populated with 4 elements from the quaternion coordinates
  3511. */
  3512. asArray(): number[];
  3513. /**
  3514. * Check if two quaternions are equals
  3515. * @param otherQuaternion defines the second operand
  3516. * @return true if the current quaternion and the given one coordinates are strictly equals
  3517. */
  3518. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3519. /**
  3520. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3521. * @param otherQuaternion defines the other quaternion
  3522. * @param epsilon defines the minimal distance to consider equality
  3523. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3524. */
  3525. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3526. /**
  3527. * Clone the current quaternion
  3528. * @returns a new quaternion copied from the current one
  3529. */
  3530. clone(): Quaternion;
  3531. /**
  3532. * Copy a quaternion to the current one
  3533. * @param other defines the other quaternion
  3534. * @returns the updated current quaternion
  3535. */
  3536. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3537. /**
  3538. * Updates the current quaternion with the given float coordinates
  3539. * @param x defines the x coordinate
  3540. * @param y defines the y coordinate
  3541. * @param z defines the z coordinate
  3542. * @param w defines the w coordinate
  3543. * @returns the updated current quaternion
  3544. */
  3545. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3546. /**
  3547. * Updates the current quaternion from the given float coordinates
  3548. * @param x defines the x coordinate
  3549. * @param y defines the y coordinate
  3550. * @param z defines the z coordinate
  3551. * @param w defines the w coordinate
  3552. * @returns the updated current quaternion
  3553. */
  3554. set(x: number, y: number, z: number, w: number): Quaternion;
  3555. /**
  3556. * Adds two quaternions
  3557. * @param other defines the second operand
  3558. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3559. */
  3560. add(other: DeepImmutable<Quaternion>): Quaternion;
  3561. /**
  3562. * Add a quaternion to the current one
  3563. * @param other defines the quaternion to add
  3564. * @returns the current quaternion
  3565. */
  3566. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3567. /**
  3568. * Subtract two quaternions
  3569. * @param other defines the second operand
  3570. * @returns a new quaternion as the subtraction result of the given one from the current one
  3571. */
  3572. subtract(other: Quaternion): Quaternion;
  3573. /**
  3574. * Multiplies the current quaternion by a scale factor
  3575. * @param value defines the scale factor
  3576. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3577. */
  3578. scale(value: number): Quaternion;
  3579. /**
  3580. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3581. * @param scale defines the scale factor
  3582. * @param result defines the Quaternion object where to store the result
  3583. * @returns the unmodified current quaternion
  3584. */
  3585. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3586. /**
  3587. * Multiplies in place the current quaternion by a scale factor
  3588. * @param value defines the scale factor
  3589. * @returns the current modified quaternion
  3590. */
  3591. scaleInPlace(value: number): Quaternion;
  3592. /**
  3593. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3594. * @param scale defines the scale factor
  3595. * @param result defines the Quaternion object where to store the result
  3596. * @returns the unmodified current quaternion
  3597. */
  3598. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies two quaternions
  3601. * @param q1 defines the second operand
  3602. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3603. */
  3604. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3605. /**
  3606. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @param result defines the target quaternion
  3609. * @returns the current quaternion
  3610. */
  3611. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3612. /**
  3613. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3614. * @param q1 defines the second operand
  3615. * @returns the currentupdated quaternion
  3616. */
  3617. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3618. /**
  3619. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3620. * @param ref defines the target quaternion
  3621. * @returns the current quaternion
  3622. */
  3623. conjugateToRef(ref: Quaternion): Quaternion;
  3624. /**
  3625. * Conjugates in place (1-q) the current quaternion
  3626. * @returns the current updated quaternion
  3627. */
  3628. conjugateInPlace(): Quaternion;
  3629. /**
  3630. * Conjugates in place (1-q) the current quaternion
  3631. * @returns a new quaternion
  3632. */
  3633. conjugate(): Quaternion;
  3634. /**
  3635. * Gets length of current quaternion
  3636. * @returns the quaternion length (float)
  3637. */
  3638. length(): number;
  3639. /**
  3640. * Normalize in place the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. normalize(): Quaternion;
  3644. /**
  3645. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns a new Vector3 containing the Euler angles
  3648. */
  3649. toEulerAngles(order?: string): Vector3;
  3650. /**
  3651. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3652. * @param result defines the vector which will be filled with the Euler angles
  3653. * @param order is a reserved parameter and is ignore for now
  3654. * @returns the current unchanged quaternion
  3655. */
  3656. toEulerAnglesToRef(result: Vector3): Quaternion;
  3657. /**
  3658. * Updates the given rotation matrix with the current quaternion values
  3659. * @param result defines the target matrix
  3660. * @returns the current unchanged quaternion
  3661. */
  3662. toRotationMatrix(result: Matrix): Quaternion;
  3663. /**
  3664. * Updates the current quaternion from the given rotation matrix values
  3665. * @param matrix defines the source matrix
  3666. * @returns the current updated quaternion
  3667. */
  3668. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3669. /**
  3670. * Creates a new quaternion from a rotation matrix
  3671. * @param matrix defines the source matrix
  3672. * @returns a new quaternion created from the given rotation matrix values
  3673. */
  3674. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3675. /**
  3676. * Updates the given quaternion with the given rotation matrix values
  3677. * @param matrix defines the source matrix
  3678. * @param result defines the target quaternion
  3679. */
  3680. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3681. /**
  3682. * Returns the dot product (float) between the quaternions "left" and "right"
  3683. * @param left defines the left operand
  3684. * @param right defines the right operand
  3685. * @returns the dot product
  3686. */
  3687. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3688. /**
  3689. * Checks if the two quaternions are close to each other
  3690. * @param quat0 defines the first quaternion to check
  3691. * @param quat1 defines the second quaternion to check
  3692. * @returns true if the two quaternions are close to each other
  3693. */
  3694. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3695. /**
  3696. * Creates an empty quaternion
  3697. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3698. */
  3699. static Zero(): Quaternion;
  3700. /**
  3701. * Inverse a given quaternion
  3702. * @param q defines the source quaternion
  3703. * @returns a new quaternion as the inverted current quaternion
  3704. */
  3705. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3706. /**
  3707. * Inverse a given quaternion
  3708. * @param q defines the source quaternion
  3709. * @param result the quaternion the result will be stored in
  3710. * @returns the result quaternion
  3711. */
  3712. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3713. /**
  3714. * Creates an identity quaternion
  3715. * @returns the identity quaternion
  3716. */
  3717. static Identity(): Quaternion;
  3718. /**
  3719. * Gets a boolean indicating if the given quaternion is identity
  3720. * @param quaternion defines the quaternion to check
  3721. * @returns true if the quaternion is identity
  3722. */
  3723. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3724. /**
  3725. * Creates a quaternion from a rotation around an axis
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3729. */
  3730. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3731. /**
  3732. * Creates a rotation around an axis and stores it into the given quaternion
  3733. * @param axis defines the axis to use
  3734. * @param angle defines the angle to use
  3735. * @param result defines the target quaternion
  3736. * @returns the target quaternion
  3737. */
  3738. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates a new quaternion from data stored into an array
  3741. * @param array defines the data source
  3742. * @param offset defines the offset in the source array where the data starts
  3743. * @returns a new quaternion
  3744. */
  3745. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4923. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @returns a string containing the hexadecimal representation of the Color4 object
  5780. */
  5781. toHexString(): string;
  5782. /**
  5783. * Computes a new Color4 converted from the current one to linear space
  5784. * @returns a new Color4 object
  5785. */
  5786. toLinearSpace(): Color4;
  5787. /**
  5788. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5789. * @param convertedColor defines the Color4 object where to store the linear space version
  5790. * @returns the unmodified Color4
  5791. */
  5792. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to gamma space
  5795. * @returns a new Color4 object
  5796. */
  5797. toGammaSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the gamma space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Creates a new Color4 from the string containing valid hexadecimal values
  5806. * @param hex defines a string containing valid hexadecimal values
  5807. * @returns a new Color4 object
  5808. */
  5809. static FromHexString(hex: string): Color4;
  5810. /**
  5811. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @returns a new Color4 object
  5816. */
  5817. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5818. /**
  5819. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @param result defines the Color4 object where to store data
  5824. */
  5825. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5826. /**
  5827. * Creates a new Color4 from a Color3 and an alpha value
  5828. * @param color3 defines the source Color3 to read from
  5829. * @param alpha defines the alpha component (1.0 by default)
  5830. * @returns a new Color4 object
  5831. */
  5832. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5833. /**
  5834. * Creates a new Color4 from the starting index element of the given array
  5835. * @param array defines the source array to read from
  5836. * @param offset defines the offset in the source array
  5837. * @returns a new Color4 object
  5838. */
  5839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5840. /**
  5841. * Creates a new Color3 from integer values (< 256)
  5842. * @param r defines the red component to read from (value between 0 and 255)
  5843. * @param g defines the green component to read from (value between 0 and 255)
  5844. * @param b defines the blue component to read from (value between 0 and 255)
  5845. * @param a defines the alpha component to read from (value between 0 and 255)
  5846. * @returns a new Color3 object
  5847. */
  5848. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5849. /**
  5850. * Check the content of a given array and convert it to an array containing RGBA data
  5851. * If the original array was already containing count * 4 values then it is returned directly
  5852. * @param colors defines the array to check
  5853. * @param count defines the number of RGBA data to expect
  5854. * @returns an array containing count * 4 values (RGBA)
  5855. */
  5856. static CheckColors4(colors: number[], count: number): number[];
  5857. }
  5858. /**
  5859. * @hidden
  5860. */
  5861. export class TmpColors {
  5862. static Color3: Color3[];
  5863. static Color4: Color4[];
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * Defines an interface which represents an animation key frame
  5869. */
  5870. export interface IAnimationKey {
  5871. /**
  5872. * Frame of the key frame
  5873. */
  5874. frame: number;
  5875. /**
  5876. * Value at the specifies key frame
  5877. */
  5878. value: any;
  5879. /**
  5880. * The input tangent for the cubic hermite spline
  5881. */
  5882. inTangent?: any;
  5883. /**
  5884. * The output tangent for the cubic hermite spline
  5885. */
  5886. outTangent?: any;
  5887. /**
  5888. * The animation interpolation type
  5889. */
  5890. interpolation?: AnimationKeyInterpolation;
  5891. }
  5892. /**
  5893. * Enum for the animation key frame interpolation type
  5894. */
  5895. export enum AnimationKeyInterpolation {
  5896. /**
  5897. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5898. */
  5899. STEP = 1
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * Represents the range of an animation
  5905. */
  5906. export class AnimationRange {
  5907. /**The name of the animation range**/
  5908. name: string;
  5909. /**The starting frame of the animation */
  5910. from: number;
  5911. /**The ending frame of the animation*/
  5912. to: number;
  5913. /**
  5914. * Initializes the range of an animation
  5915. * @param name The name of the animation range
  5916. * @param from The starting frame of the animation
  5917. * @param to The ending frame of the animation
  5918. */
  5919. constructor(
  5920. /**The name of the animation range**/
  5921. name: string,
  5922. /**The starting frame of the animation */
  5923. from: number,
  5924. /**The ending frame of the animation*/
  5925. to: number);
  5926. /**
  5927. * Makes a copy of the animation range
  5928. * @returns A copy of the animation range
  5929. */
  5930. clone(): AnimationRange;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Composed of a frame, and an action function
  5936. */
  5937. export class AnimationEvent {
  5938. /** The frame for which the event is triggered **/
  5939. frame: number;
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void;
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined;
  5944. /**
  5945. * Specifies if the animation event is done
  5946. */
  5947. isDone: boolean;
  5948. /**
  5949. * Initializes the animation event
  5950. * @param frame The frame for which the event is triggered
  5951. * @param action The event to perform when triggered
  5952. * @param onlyOnce Specifies if the event should be triggered only once
  5953. */
  5954. constructor(
  5955. /** The frame for which the event is triggered **/
  5956. frame: number,
  5957. /** The event to perform when triggered **/
  5958. action: (currentFrame: number) => void,
  5959. /** Specifies if the event should be triggered only once**/
  5960. onlyOnce?: boolean | undefined);
  5961. /** @hidden */
  5962. _clone(): AnimationEvent;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * Interface used to define a behavior
  5968. */
  5969. export interface Behavior<T> {
  5970. /** gets or sets behavior's name */
  5971. name: string;
  5972. /**
  5973. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5974. */
  5975. init(): void;
  5976. /**
  5977. * Called when the behavior is attached to a target
  5978. * @param target defines the target where the behavior is attached to
  5979. */
  5980. attach(target: T): void;
  5981. /**
  5982. * Called when the behavior is detached from its target
  5983. */
  5984. detach(): void;
  5985. }
  5986. /**
  5987. * Interface implemented by classes supporting behaviors
  5988. */
  5989. export interface IBehaviorAware<T> {
  5990. /**
  5991. * Attach a behavior
  5992. * @param behavior defines the behavior to attach
  5993. * @returns the current host
  5994. */
  5995. addBehavior(behavior: Behavior<T>): T;
  5996. /**
  5997. * Remove a behavior from the current object
  5998. * @param behavior defines the behavior to detach
  5999. * @returns the current host
  6000. */
  6001. removeBehavior(behavior: Behavior<T>): T;
  6002. /**
  6003. * Gets a behavior using its name to search
  6004. * @param name defines the name to search
  6005. * @returns the behavior or null if not found
  6006. */
  6007. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * Defines an array and its length.
  6013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6014. */
  6015. export interface ISmartArrayLike<T> {
  6016. /**
  6017. * The data of the array.
  6018. */
  6019. data: Array<T>;
  6020. /**
  6021. * The active length of the array.
  6022. */
  6023. length: number;
  6024. }
  6025. /**
  6026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6027. */
  6028. export class SmartArray<T> implements ISmartArrayLike<T> {
  6029. /**
  6030. * The full set of data from the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. protected _id: number;
  6038. /**
  6039. * Instantiates a Smart Array.
  6040. * @param capacity defines the default capacity of the array.
  6041. */
  6042. constructor(capacity: number);
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * @param value defines the object to push in the array.
  6046. */
  6047. push(value: T): void;
  6048. /**
  6049. * Iterates over the active data and apply the lambda to them.
  6050. * @param func defines the action to apply on each value.
  6051. */
  6052. forEach(func: (content: T) => void): void;
  6053. /**
  6054. * Sorts the full sets of data.
  6055. * @param compareFn defines the comparison function to apply.
  6056. */
  6057. sort(compareFn: (a: T, b: T) => number): void;
  6058. /**
  6059. * Resets the active data to an empty array.
  6060. */
  6061. reset(): void;
  6062. /**
  6063. * Releases all the data from the array as well as the array.
  6064. */
  6065. dispose(): void;
  6066. /**
  6067. * Concats the active data with a given array.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concat(array: any): void;
  6071. /**
  6072. * Returns the position of a value in the active data.
  6073. * @param value defines the value to find the index for
  6074. * @returns the index if found in the active data otherwise -1
  6075. */
  6076. indexOf(value: T): number;
  6077. /**
  6078. * Returns whether an element is part of the active data.
  6079. * @param value defines the value to look for
  6080. * @returns true if found in the active data otherwise false
  6081. */
  6082. contains(value: T): boolean;
  6083. private static _GlobalId;
  6084. }
  6085. /**
  6086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6087. * The data in this array can only be present once
  6088. */
  6089. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6090. private _duplicateId;
  6091. /**
  6092. * Pushes a value at the end of the active data.
  6093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Pushes a value at the end of the active data.
  6099. * If the data is already present, it won t be added again
  6100. * @param value defines the object to push in the array.
  6101. * @returns true if added false if it was already present
  6102. */
  6103. pushNoDuplicate(value: T): boolean;
  6104. /**
  6105. * Resets the active data to an empty array.
  6106. */
  6107. reset(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * This ensures no dupplicate will be present in the result.
  6111. * @param array defines the data to concatenate with.
  6112. */
  6113. concatWithNoDuplicate(array: any): void;
  6114. }
  6115. }
  6116. declare module BABYLON {
  6117. /**
  6118. * @ignore
  6119. * This is a list of all the different input types that are available in the application.
  6120. * Fo instance: ArcRotateCameraGamepadInput...
  6121. */
  6122. export var CameraInputTypes: {};
  6123. /**
  6124. * This is the contract to implement in order to create a new input class.
  6125. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6126. */
  6127. export interface ICameraInput<TCamera extends Camera> {
  6128. /**
  6129. * Defines the camera the input is attached to.
  6130. */
  6131. camera: Nullable<TCamera>;
  6132. /**
  6133. * Gets the class name of the current intput.
  6134. * @returns the class name
  6135. */
  6136. getClassName(): string;
  6137. /**
  6138. * Get the friendly name associated with the input class.
  6139. * @returns the input friendly name
  6140. */
  6141. getSimpleName(): string;
  6142. /**
  6143. * Attach the input controls to a specific dom element to get the input from.
  6144. * @param element Defines the element the controls should be listened from
  6145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6148. /**
  6149. * Detach the current controls from the specified dom element.
  6150. * @param element Defines the element to stop listening the inputs from
  6151. */
  6152. detachControl(element: Nullable<HTMLElement>): void;
  6153. /**
  6154. * Update the current camera state depending on the inputs that have been used this frame.
  6155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6156. */
  6157. checkInputs?: () => void;
  6158. }
  6159. /**
  6160. * Represents a map of input types to input instance or input index to input instance.
  6161. */
  6162. export interface CameraInputsMap<TCamera extends Camera> {
  6163. /**
  6164. * Accessor to the input by input type.
  6165. */
  6166. [name: string]: ICameraInput<TCamera>;
  6167. /**
  6168. * Accessor to the input by input index.
  6169. */
  6170. [idx: number]: ICameraInput<TCamera>;
  6171. }
  6172. /**
  6173. * This represents the input manager used within a camera.
  6174. * It helps dealing with all the different kind of input attached to a camera.
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. */
  6177. export class CameraInputsManager<TCamera extends Camera> {
  6178. /**
  6179. * Defines the list of inputs attahed to the camera.
  6180. */
  6181. attached: CameraInputsMap<TCamera>;
  6182. /**
  6183. * Defines the dom element the camera is collecting inputs from.
  6184. * This is null if the controls have not been attached.
  6185. */
  6186. attachedElement: Nullable<HTMLElement>;
  6187. /**
  6188. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6189. */
  6190. noPreventDefault: boolean;
  6191. /**
  6192. * Defined the camera the input manager belongs to.
  6193. */
  6194. camera: TCamera;
  6195. /**
  6196. * Update the current camera state depending on the inputs that have been used this frame.
  6197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6198. */
  6199. checkInputs: () => void;
  6200. /**
  6201. * Instantiate a new Camera Input Manager.
  6202. * @param camera Defines the camera the input manager blongs to
  6203. */
  6204. constructor(camera: TCamera);
  6205. /**
  6206. * Add an input method to a camera
  6207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6208. * @param input camera input method
  6209. */
  6210. add(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input method from a camera
  6213. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6214. * @param inputToRemove camera input method
  6215. */
  6216. remove(inputToRemove: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Remove a specific input type from a camera
  6219. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6220. * @param inputType the type of the input to remove
  6221. */
  6222. removeByType(inputType: string): void;
  6223. private _addCheckInputs;
  6224. /**
  6225. * Attach the input controls to the currently attached dom element to listen the events from.
  6226. * @param input Defines the input to attach
  6227. */
  6228. attachInput(input: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6235. /**
  6236. * Detach the current manager inputs controls from a specific dom element.
  6237. * @param element Defines the dom element to collect the events from
  6238. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6239. */
  6240. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6241. /**
  6242. * Rebuild the dynamic inputCheck function from the current list of
  6243. * defined inputs in the manager.
  6244. */
  6245. rebuildInputCheck(): void;
  6246. /**
  6247. * Remove all attached input methods from a camera
  6248. */
  6249. clear(): void;
  6250. /**
  6251. * Serialize the current input manager attached to a camera.
  6252. * This ensures than once parsed,
  6253. * the input associated to the camera will be identical to the current ones
  6254. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6255. */
  6256. serialize(serializedCamera: any): void;
  6257. /**
  6258. * Parses an input manager serialized JSON to restore the previous list of inputs
  6259. * and states associated to a camera.
  6260. * @param parsedCamera Defines the JSON to parse
  6261. */
  6262. parse(parsedCamera: any): void;
  6263. }
  6264. }
  6265. declare module BABYLON {
  6266. /**
  6267. * Class used to store data that will be store in GPU memory
  6268. */
  6269. export class Buffer {
  6270. private _engine;
  6271. private _buffer;
  6272. /** @hidden */
  6273. _data: Nullable<DataArray>;
  6274. private _updatable;
  6275. private _instanced;
  6276. private _divisor;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. * @param divisor sets an optional divisor for instances (1 by default)
  6291. */
  6292. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6293. /**
  6294. * Create a new VertexBuffer based on the current buffer
  6295. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6296. * @param offset defines offset in the buffer (0 by default)
  6297. * @param size defines the size in floats of attributes (position is 3 for instance)
  6298. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6299. * @param instanced defines if the vertex buffer contains indexed data
  6300. * @param useBytes defines if the offset and stride are in bytes *
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. * @returns the new vertex buffer
  6303. */
  6304. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6305. /**
  6306. * Gets a boolean indicating if the Buffer is updatable?
  6307. * @returns true if the buffer is updatable
  6308. */
  6309. isUpdatable(): boolean;
  6310. /**
  6311. * Gets current buffer's data
  6312. * @returns a DataArray or null
  6313. */
  6314. getData(): Nullable<DataArray>;
  6315. /**
  6316. * Gets underlying native buffer
  6317. * @returns underlying native buffer
  6318. */
  6319. getBuffer(): Nullable<DataBuffer>;
  6320. /**
  6321. * Gets the stride in float32 units (i.e. byte stride / 4).
  6322. * May not be an integer if the byte stride is not divisible by 4.
  6323. * @returns the stride in float32 units
  6324. * @deprecated Please use byteStride instead.
  6325. */
  6326. getStrideSize(): number;
  6327. /**
  6328. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6329. * @param data defines the data to store
  6330. */
  6331. create(data?: Nullable<DataArray>): void;
  6332. /** @hidden */
  6333. _rebuild(): void;
  6334. /**
  6335. * Update current buffer data
  6336. * @param data defines the data to store
  6337. */
  6338. update(data: DataArray): void;
  6339. /**
  6340. * Updates the data directly.
  6341. * @param data the new data
  6342. * @param offset the new offset
  6343. * @param vertexCount the vertex count (optional)
  6344. * @param useBytes set to true if the offset is in bytes
  6345. */
  6346. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6347. /**
  6348. * Release all resources
  6349. */
  6350. dispose(): void;
  6351. }
  6352. /**
  6353. * Specialized buffer used to store vertex data
  6354. */
  6355. export class VertexBuffer {
  6356. /** @hidden */
  6357. _buffer: Buffer;
  6358. private _kind;
  6359. private _size;
  6360. private _ownsBuffer;
  6361. private _instanced;
  6362. private _instanceDivisor;
  6363. /**
  6364. * The byte type.
  6365. */
  6366. static readonly BYTE: number;
  6367. /**
  6368. * The unsigned byte type.
  6369. */
  6370. static readonly UNSIGNED_BYTE: number;
  6371. /**
  6372. * The short type.
  6373. */
  6374. static readonly SHORT: number;
  6375. /**
  6376. * The unsigned short type.
  6377. */
  6378. static readonly UNSIGNED_SHORT: number;
  6379. /**
  6380. * The integer type.
  6381. */
  6382. static readonly INT: number;
  6383. /**
  6384. * The unsigned integer type.
  6385. */
  6386. static readonly UNSIGNED_INT: number;
  6387. /**
  6388. * The float type.
  6389. */
  6390. static readonly FLOAT: number;
  6391. /**
  6392. * Gets or sets the instance divisor when in instanced mode
  6393. */
  6394. get instanceDivisor(): number;
  6395. set instanceDivisor(value: number);
  6396. /**
  6397. * Gets the byte stride.
  6398. */
  6399. readonly byteStride: number;
  6400. /**
  6401. * Gets the byte offset.
  6402. */
  6403. readonly byteOffset: number;
  6404. /**
  6405. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6406. */
  6407. readonly normalized: boolean;
  6408. /**
  6409. * Gets the data type of each component in the array.
  6410. */
  6411. readonly type: number;
  6412. /**
  6413. * Constructor
  6414. * @param engine the engine
  6415. * @param data the data to use for this vertex buffer
  6416. * @param kind the vertex buffer kind
  6417. * @param updatable whether the data is updatable
  6418. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6419. * @param stride the stride (optional)
  6420. * @param instanced whether the buffer is instanced (optional)
  6421. * @param offset the offset of the data (optional)
  6422. * @param size the number of components (optional)
  6423. * @param type the type of the component (optional)
  6424. * @param normalized whether the data contains normalized data (optional)
  6425. * @param useBytes set to true if stride and offset are in bytes (optional)
  6426. * @param divisor defines the instance divisor to use (1 by default)
  6427. */
  6428. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6429. /** @hidden */
  6430. _rebuild(): void;
  6431. /**
  6432. * Returns the kind of the VertexBuffer (string)
  6433. * @returns a string
  6434. */
  6435. getKind(): string;
  6436. /**
  6437. * Gets a boolean indicating if the VertexBuffer is updatable?
  6438. * @returns true if the buffer is updatable
  6439. */
  6440. isUpdatable(): boolean;
  6441. /**
  6442. * Gets current buffer's data
  6443. * @returns a DataArray or null
  6444. */
  6445. getData(): Nullable<DataArray>;
  6446. /**
  6447. * Gets underlying native buffer
  6448. * @returns underlying native buffer
  6449. */
  6450. getBuffer(): Nullable<DataBuffer>;
  6451. /**
  6452. * Gets the stride in float32 units (i.e. byte stride / 4).
  6453. * May not be an integer if the byte stride is not divisible by 4.
  6454. * @returns the stride in float32 units
  6455. * @deprecated Please use byteStride instead.
  6456. */
  6457. getStrideSize(): number;
  6458. /**
  6459. * Returns the offset as a multiple of the type byte length.
  6460. * @returns the offset in bytes
  6461. * @deprecated Please use byteOffset instead.
  6462. */
  6463. getOffset(): number;
  6464. /**
  6465. * Returns the number of components per vertex attribute (integer)
  6466. * @returns the size in float
  6467. */
  6468. getSize(): number;
  6469. /**
  6470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6471. * @returns true if this buffer is instanced
  6472. */
  6473. getIsInstanced(): boolean;
  6474. /**
  6475. * Returns the instancing divisor, zero for non-instanced (integer).
  6476. * @returns a number
  6477. */
  6478. getInstanceDivisor(): number;
  6479. /**
  6480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6481. * @param data defines the data to store
  6482. */
  6483. create(data?: DataArray): void;
  6484. /**
  6485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6486. * This function will create a new buffer if the current one is not updatable
  6487. * @param data defines the data to store
  6488. */
  6489. update(data: DataArray): void;
  6490. /**
  6491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6492. * Returns the directly updated WebGLBuffer.
  6493. * @param data the new data
  6494. * @param offset the new offset
  6495. * @param useBytes set to true if the offset is in bytes
  6496. */
  6497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6498. /**
  6499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Enumerates each value of this vertex buffer as numbers.
  6504. * @param count the number of values to enumerate
  6505. * @param callback the callback function called for each value
  6506. */
  6507. forEach(count: number, callback: (value: number, index: number) => void): void;
  6508. /**
  6509. * Positions
  6510. */
  6511. static readonly PositionKind: string;
  6512. /**
  6513. * Normals
  6514. */
  6515. static readonly NormalKind: string;
  6516. /**
  6517. * Tangents
  6518. */
  6519. static readonly TangentKind: string;
  6520. /**
  6521. * Texture coordinates
  6522. */
  6523. static readonly UVKind: string;
  6524. /**
  6525. * Texture coordinates 2
  6526. */
  6527. static readonly UV2Kind: string;
  6528. /**
  6529. * Texture coordinates 3
  6530. */
  6531. static readonly UV3Kind: string;
  6532. /**
  6533. * Texture coordinates 4
  6534. */
  6535. static readonly UV4Kind: string;
  6536. /**
  6537. * Texture coordinates 5
  6538. */
  6539. static readonly UV5Kind: string;
  6540. /**
  6541. * Texture coordinates 6
  6542. */
  6543. static readonly UV6Kind: string;
  6544. /**
  6545. * Colors
  6546. */
  6547. static readonly ColorKind: string;
  6548. /**
  6549. * Matrix indices (for bones)
  6550. */
  6551. static readonly MatricesIndicesKind: string;
  6552. /**
  6553. * Matrix weights (for bones)
  6554. */
  6555. static readonly MatricesWeightsKind: string;
  6556. /**
  6557. * Additional matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesExtraKind: string;
  6560. /**
  6561. * Additional matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsExtraKind: string;
  6564. /**
  6565. * Deduces the stride given a kind.
  6566. * @param kind The kind string to deduce
  6567. * @returns The deduced stride
  6568. */
  6569. static DeduceStride(kind: string): number;
  6570. /**
  6571. * Gets the byte length of the given type.
  6572. * @param type the type
  6573. * @returns the number of bytes
  6574. */
  6575. static GetTypeByteLength(type: number): number;
  6576. /**
  6577. * Enumerates each value of the given parameters as numbers.
  6578. * @param data the data to enumerate
  6579. * @param byteOffset the byte offset of the data
  6580. * @param byteStride the byte stride of the data
  6581. * @param componentCount the number of components per element
  6582. * @param componentType the type of the component
  6583. * @param count the number of values to enumerate
  6584. * @param normalized whether the data is normalized
  6585. * @param callback the callback function called for each value
  6586. */
  6587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6588. private static _GetFloatValue;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * @hidden
  6594. */
  6595. export class IntersectionInfo {
  6596. bu: Nullable<number>;
  6597. bv: Nullable<number>;
  6598. distance: number;
  6599. faceId: number;
  6600. subMeshId: number;
  6601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module BABYLON {
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module BABYLON {
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /** @hidden */
  6945. export class Collider {
  6946. /** Define if a collision was found */
  6947. collisionFound: boolean;
  6948. /**
  6949. * Define last intersection point in local space
  6950. */
  6951. intersectionPoint: Vector3;
  6952. /**
  6953. * Define last collided mesh
  6954. */
  6955. collidedMesh: Nullable<AbstractMesh>;
  6956. private _collisionPoint;
  6957. private _planeIntersectionPoint;
  6958. private _tempVector;
  6959. private _tempVector2;
  6960. private _tempVector3;
  6961. private _tempVector4;
  6962. private _edge;
  6963. private _baseToVertex;
  6964. private _destinationPoint;
  6965. private _slidePlaneNormal;
  6966. private _displacementVector;
  6967. /** @hidden */
  6968. _radius: Vector3;
  6969. /** @hidden */
  6970. _retry: number;
  6971. private _velocity;
  6972. private _basePoint;
  6973. private _epsilon;
  6974. /** @hidden */
  6975. _velocityWorldLength: number;
  6976. /** @hidden */
  6977. _basePointWorld: Vector3;
  6978. private _velocityWorld;
  6979. private _normalizedVelocity;
  6980. /** @hidden */
  6981. _initialVelocity: Vector3;
  6982. /** @hidden */
  6983. _initialPosition: Vector3;
  6984. private _nearestDistance;
  6985. private _collisionMask;
  6986. get collisionMask(): number;
  6987. set collisionMask(mask: number);
  6988. /**
  6989. * Gets the plane normal used to compute the sliding response (in local space)
  6990. */
  6991. get slidePlaneNormal(): Vector3;
  6992. /** @hidden */
  6993. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6994. /** @hidden */
  6995. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6996. /** @hidden */
  6997. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6998. /** @hidden */
  6999. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7000. /** @hidden */
  7001. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7002. /** @hidden */
  7003. _getResponse(pos: Vector3, vel: Vector3): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Interface for cullable objects
  7009. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7010. */
  7011. export interface ICullable {
  7012. /**
  7013. * Checks if the object or part of the object is in the frustum
  7014. * @param frustumPlanes Camera near/planes
  7015. * @returns true if the object is in frustum otherwise false
  7016. */
  7017. isInFrustum(frustumPlanes: Plane[]): boolean;
  7018. /**
  7019. * Checks if a cullable object (mesh...) is in the camera frustum
  7020. * Unlike isInFrustum this cheks the full bounding box
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7025. }
  7026. /**
  7027. * Info for a bounding data of a mesh
  7028. */
  7029. export class BoundingInfo implements ICullable {
  7030. /**
  7031. * Bounding box for the mesh
  7032. */
  7033. readonly boundingBox: BoundingBox;
  7034. /**
  7035. * Bounding sphere for the mesh
  7036. */
  7037. readonly boundingSphere: BoundingSphere;
  7038. private _isLocked;
  7039. private static readonly TmpVector3;
  7040. /**
  7041. * Constructs bounding info
  7042. * @param minimum min vector of the bounding box/sphere
  7043. * @param maximum max vector of the bounding box/sphere
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * min vector of the bounding box/sphere
  7056. */
  7057. get minimum(): Vector3;
  7058. /**
  7059. * max vector of the bounding box/sphere
  7060. */
  7061. get maximum(): Vector3;
  7062. /**
  7063. * If the info is locked and won't be updated to avoid perf overhead
  7064. */
  7065. get isLocked(): boolean;
  7066. set isLocked(value: boolean);
  7067. /**
  7068. * Updates the bounding sphere and box
  7069. * @param world world matrix to be used to update
  7070. */
  7071. update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7074. * @param center New center of the bounding info
  7075. * @param extend New extend of the bounding info
  7076. * @returns the current bounding info
  7077. */
  7078. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7079. /**
  7080. * Scale the current bounding info by applying a scale factor
  7081. * @param factor defines the scale factor to apply
  7082. * @returns the current bounding info
  7083. */
  7084. scale(factor: number): BoundingInfo;
  7085. /**
  7086. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7087. * @param frustumPlanes defines the frustum to test
  7088. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7089. * @returns true if the bounding info is in the frustum planes
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7092. /**
  7093. * Gets the world distance between the min and max points of the bounding box
  7094. */
  7095. get diagonalLength(): number;
  7096. /**
  7097. * Checks if a cullable object (mesh...) is in the camera frustum
  7098. * Unlike isInFrustum this cheks the full bounding box
  7099. * @param frustumPlanes Camera near/planes
  7100. * @returns true if the object is in frustum otherwise false
  7101. */
  7102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7103. /** @hidden */
  7104. _checkCollision(collider: Collider): boolean;
  7105. /**
  7106. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7107. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7108. * @param point the point to check intersection with
  7109. * @returns if the point intersects
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7114. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7115. * @param boundingInfo the bounding info to check intersection with
  7116. * @param precise if the intersection should be done using OBB
  7117. * @returns if the bounding info intersects
  7118. */
  7119. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Extracts minimum and maximum values from a list of indexed positions
  7125. * @param positions defines the positions to use
  7126. * @param indices defines the indices to the positions
  7127. * @param indexStart defines the start index
  7128. * @param indexCount defines the end index
  7129. * @param bias defines bias value to add to the result
  7130. * @return minimum and maximum values
  7131. */
  7132. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7133. minimum: Vector3;
  7134. maximum: Vector3;
  7135. };
  7136. /**
  7137. * Extracts minimum and maximum values from a list of positions
  7138. * @param positions defines the positions to use
  7139. * @param start defines the start index in the positions array
  7140. * @param count defines the number of positions to handle
  7141. * @param bias defines bias value to add to the result
  7142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7143. * @return minimum and maximum values
  7144. */
  7145. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7146. minimum: Vector3;
  7147. maximum: Vector3;
  7148. };
  7149. }
  7150. declare module BABYLON {
  7151. /** @hidden */
  7152. export class WebGLDataBuffer extends DataBuffer {
  7153. private _buffer;
  7154. constructor(resource: WebGLBuffer);
  7155. get underlyingResource(): any;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /** @hidden */
  7160. export class WebGLPipelineContext implements IPipelineContext {
  7161. engine: ThinEngine;
  7162. program: Nullable<WebGLProgram>;
  7163. context?: WebGLRenderingContext;
  7164. vertexShader?: WebGLShader;
  7165. fragmentShader?: WebGLShader;
  7166. isParallelCompiled: boolean;
  7167. onCompiled?: () => void;
  7168. transformFeedback?: WebGLTransformFeedback | null;
  7169. vertexCompilationError: Nullable<string>;
  7170. fragmentCompilationError: Nullable<string>;
  7171. programLinkError: Nullable<string>;
  7172. programValidationError: Nullable<string>;
  7173. get isAsync(): boolean;
  7174. get isReady(): boolean;
  7175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7176. }
  7177. }
  7178. declare module BABYLON {
  7179. interface ThinEngine {
  7180. /**
  7181. * Create an uniform buffer
  7182. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7183. * @param elements defines the content of the uniform buffer
  7184. * @returns the webGL uniform buffer
  7185. */
  7186. createUniformBuffer(elements: FloatArray): DataBuffer;
  7187. /**
  7188. * Create a dynamic uniform buffer
  7189. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7190. * @param elements defines the content of the uniform buffer
  7191. * @returns the webGL uniform buffer
  7192. */
  7193. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7194. /**
  7195. * Update an existing uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param uniformBuffer defines the target uniform buffer
  7198. * @param elements defines the content to update
  7199. * @param offset defines the offset in the uniform buffer where update should start
  7200. * @param count defines the size of the data to update
  7201. */
  7202. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7203. /**
  7204. * Bind an uniform buffer to the current webGL context
  7205. * @param buffer defines the buffer to bind
  7206. */
  7207. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7208. /**
  7209. * Bind a buffer to the current webGL context at a given location
  7210. * @param buffer defines the buffer to bind
  7211. * @param location defines the index where to bind the buffer
  7212. */
  7213. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7214. /**
  7215. * Bind a specific block at a given index in a specific shader program
  7216. * @param pipelineContext defines the pipeline context to use
  7217. * @param blockName defines the block name
  7218. * @param index defines the index where to bind the block
  7219. */
  7220. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7221. }
  7222. }
  7223. declare module BABYLON {
  7224. /**
  7225. * Uniform buffer objects.
  7226. *
  7227. * Handles blocks of uniform on the GPU.
  7228. *
  7229. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7230. *
  7231. * For more information, please refer to :
  7232. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7233. */
  7234. export class UniformBuffer {
  7235. private _engine;
  7236. private _buffer;
  7237. private _data;
  7238. private _bufferData;
  7239. private _dynamic?;
  7240. private _uniformLocations;
  7241. private _uniformSizes;
  7242. private _uniformLocationPointer;
  7243. private _needSync;
  7244. private _noUBO;
  7245. private _currentEffect;
  7246. /** @hidden */
  7247. _alreadyBound: boolean;
  7248. private static _MAX_UNIFORM_SIZE;
  7249. private static _tempBuffer;
  7250. /**
  7251. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7252. * This is dynamic to allow compat with webgl 1 and 2.
  7253. * You will need to pass the name of the uniform as well as the value.
  7254. */
  7255. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7256. /**
  7257. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7258. * This is dynamic to allow compat with webgl 1 and 2.
  7259. * You will need to pass the name of the uniform as well as the value.
  7260. */
  7261. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7262. /**
  7263. * Lambda to Update a single float in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateFloat: (name: string, x: number) => void;
  7268. /**
  7269. * Lambda to Update a vec2 of float in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7274. /**
  7275. * Lambda to Update a vec3 of float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7280. /**
  7281. * Lambda to Update a vec4 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix: (name: string, mat: Matrix) => void;
  7292. /**
  7293. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateVector3: (name: string, vector: Vector3) => void;
  7298. /**
  7299. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateVector4: (name: string, vector: Vector4) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7316. /**
  7317. * Instantiates a new Uniform buffer objects.
  7318. *
  7319. * Handles blocks of uniform on the GPU.
  7320. *
  7321. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7322. *
  7323. * For more information, please refer to :
  7324. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7325. * @param engine Define the engine the buffer is associated with
  7326. * @param data Define the data contained in the buffer
  7327. * @param dynamic Define if the buffer is updatable
  7328. */
  7329. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7330. /**
  7331. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7332. * or just falling back on setUniformXXX calls.
  7333. */
  7334. get useUbo(): boolean;
  7335. /**
  7336. * Indicates if the WebGL underlying uniform buffer is in sync
  7337. * with the javascript cache data.
  7338. */
  7339. get isSync(): boolean;
  7340. /**
  7341. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7342. * Also, a dynamic UniformBuffer will disable cache verification and always
  7343. * update the underlying WebGL uniform buffer to the GPU.
  7344. * @returns if Dynamic, otherwise false
  7345. */
  7346. isDynamic(): boolean;
  7347. /**
  7348. * The data cache on JS side.
  7349. * @returns the underlying data as a float array
  7350. */
  7351. getData(): Float32Array;
  7352. /**
  7353. * The underlying WebGL Uniform buffer.
  7354. * @returns the webgl buffer
  7355. */
  7356. getBuffer(): Nullable<DataBuffer>;
  7357. /**
  7358. * std140 layout specifies how to align data within an UBO structure.
  7359. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7360. * for specs.
  7361. */
  7362. private _fillAlignment;
  7363. /**
  7364. * Adds an uniform in the buffer.
  7365. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7366. * for the layout to be correct !
  7367. * @param name Name of the uniform, as used in the uniform block in the shader.
  7368. * @param size Data size, or data directly.
  7369. */
  7370. addUniform(name: string, size: number | number[]): void;
  7371. /**
  7372. * Adds a Matrix 4x4 to the uniform buffer.
  7373. * @param name Name of the uniform, as used in the uniform block in the shader.
  7374. * @param mat A 4x4 matrix.
  7375. */
  7376. addMatrix(name: string, mat: Matrix): void;
  7377. /**
  7378. * Adds a vec2 to the uniform buffer.
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param x Define the x component value of the vec2
  7381. * @param y Define the y component value of the vec2
  7382. */
  7383. addFloat2(name: string, x: number, y: number): void;
  7384. /**
  7385. * Adds a vec3 to the uniform buffer.
  7386. * @param name Name of the uniform, as used in the uniform block in the shader.
  7387. * @param x Define the x component value of the vec3
  7388. * @param y Define the y component value of the vec3
  7389. * @param z Define the z component value of the vec3
  7390. */
  7391. addFloat3(name: string, x: number, y: number, z: number): void;
  7392. /**
  7393. * Adds a vec3 to the uniform buffer.
  7394. * @param name Name of the uniform, as used in the uniform block in the shader.
  7395. * @param color Define the vec3 from a Color
  7396. */
  7397. addColor3(name: string, color: Color3): void;
  7398. /**
  7399. * Adds a vec4 to the uniform buffer.
  7400. * @param name Name of the uniform, as used in the uniform block in the shader.
  7401. * @param color Define the rgb components from a Color
  7402. * @param alpha Define the a component of the vec4
  7403. */
  7404. addColor4(name: string, color: Color3, alpha: number): void;
  7405. /**
  7406. * Adds a vec3 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param vector Define the vec3 components from a Vector
  7409. */
  7410. addVector3(name: string, vector: Vector3): void;
  7411. /**
  7412. * Adds a Matrix 3x3 to the uniform buffer.
  7413. * @param name Name of the uniform, as used in the uniform block in the shader.
  7414. */
  7415. addMatrix3x3(name: string): void;
  7416. /**
  7417. * Adds a Matrix 2x2 to the uniform buffer.
  7418. * @param name Name of the uniform, as used in the uniform block in the shader.
  7419. */
  7420. addMatrix2x2(name: string): void;
  7421. /**
  7422. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7423. */
  7424. create(): void;
  7425. /** @hidden */
  7426. _rebuild(): void;
  7427. /**
  7428. * Updates the WebGL Uniform Buffer on the GPU.
  7429. * If the `dynamic` flag is set to true, no cache comparison is done.
  7430. * Otherwise, the buffer will be updated only if the cache differs.
  7431. */
  7432. update(): void;
  7433. /**
  7434. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7435. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7436. * @param data Define the flattened data
  7437. * @param size Define the size of the data.
  7438. */
  7439. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7440. private _valueCache;
  7441. private _cacheMatrix;
  7442. private _updateMatrix3x3ForUniform;
  7443. private _updateMatrix3x3ForEffect;
  7444. private _updateMatrix2x2ForEffect;
  7445. private _updateMatrix2x2ForUniform;
  7446. private _updateFloatForEffect;
  7447. private _updateFloatForUniform;
  7448. private _updateFloat2ForEffect;
  7449. private _updateFloat2ForUniform;
  7450. private _updateFloat3ForEffect;
  7451. private _updateFloat3ForUniform;
  7452. private _updateFloat4ForEffect;
  7453. private _updateFloat4ForUniform;
  7454. private _updateMatrixForEffect;
  7455. private _updateMatrixForUniform;
  7456. private _updateVector3ForEffect;
  7457. private _updateVector3ForUniform;
  7458. private _updateVector4ForEffect;
  7459. private _updateVector4ForUniform;
  7460. private _updateColor3ForEffect;
  7461. private _updateColor3ForUniform;
  7462. private _updateColor4ForEffect;
  7463. private _updateColor4ForUniform;
  7464. /**
  7465. * Sets a sampler uniform on the effect.
  7466. * @param name Define the name of the sampler.
  7467. * @param texture Define the texture to set in the sampler
  7468. */
  7469. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7470. /**
  7471. * Directly updates the value of the uniform in the cache AND on the GPU.
  7472. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7473. * @param data Define the flattened data
  7474. */
  7475. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7476. /**
  7477. * Binds this uniform buffer to an effect.
  7478. * @param effect Define the effect to bind the buffer to
  7479. * @param name Name of the uniform block in the shader.
  7480. */
  7481. bindToEffect(effect: Effect, name: string): void;
  7482. /**
  7483. * Disposes the uniform buffer.
  7484. */
  7485. dispose(): void;
  7486. }
  7487. }
  7488. declare module BABYLON {
  7489. /**
  7490. * Enum that determines the text-wrapping mode to use.
  7491. */
  7492. export enum InspectableType {
  7493. /**
  7494. * Checkbox for booleans
  7495. */
  7496. Checkbox = 0,
  7497. /**
  7498. * Sliders for numbers
  7499. */
  7500. Slider = 1,
  7501. /**
  7502. * Vector3
  7503. */
  7504. Vector3 = 2,
  7505. /**
  7506. * Quaternions
  7507. */
  7508. Quaternion = 3,
  7509. /**
  7510. * Color3
  7511. */
  7512. Color3 = 4,
  7513. /**
  7514. * String
  7515. */
  7516. String = 5
  7517. }
  7518. /**
  7519. * Interface used to define custom inspectable properties.
  7520. * This interface is used by the inspector to display custom property grids
  7521. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7522. */
  7523. export interface IInspectable {
  7524. /**
  7525. * Gets the label to display
  7526. */
  7527. label: string;
  7528. /**
  7529. * Gets the name of the property to edit
  7530. */
  7531. propertyName: string;
  7532. /**
  7533. * Gets the type of the editor to use
  7534. */
  7535. type: InspectableType;
  7536. /**
  7537. * Gets the minimum value of the property when using in "slider" mode
  7538. */
  7539. min?: number;
  7540. /**
  7541. * Gets the maximum value of the property when using in "slider" mode
  7542. */
  7543. max?: number;
  7544. /**
  7545. * Gets the setp to use when using in "slider" mode
  7546. */
  7547. step?: number;
  7548. }
  7549. }
  7550. declare module BABYLON {
  7551. /**
  7552. * Class used to provide helper for timing
  7553. */
  7554. export class TimingTools {
  7555. /**
  7556. * Polyfill for setImmediate
  7557. * @param action defines the action to execute after the current execution block
  7558. */
  7559. static SetImmediate(action: () => void): void;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to enable instatition of objects by class name
  7565. */
  7566. export class InstantiationTools {
  7567. /**
  7568. * Use this object to register external classes like custom textures or material
  7569. * to allow the laoders to instantiate them
  7570. */
  7571. static RegisteredExternalClasses: {
  7572. [key: string]: Object;
  7573. };
  7574. /**
  7575. * Tries to instantiate a new object from a given class name
  7576. * @param className defines the class name to instantiate
  7577. * @returns the new object or null if the system was not able to do the instantiation
  7578. */
  7579. static Instantiate(className: string): any;
  7580. }
  7581. }
  7582. declare module BABYLON {
  7583. /**
  7584. * Define options used to create a depth texture
  7585. */
  7586. export class DepthTextureCreationOptions {
  7587. /** Specifies whether or not a stencil should be allocated in the texture */
  7588. generateStencil?: boolean;
  7589. /** Specifies whether or not bilinear filtering is enable on the texture */
  7590. bilinearFiltering?: boolean;
  7591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7592. comparisonFunction?: number;
  7593. /** Specifies if the created texture is a cube texture */
  7594. isCube?: boolean;
  7595. }
  7596. }
  7597. declare module BABYLON {
  7598. interface ThinEngine {
  7599. /**
  7600. * Creates a depth stencil cube texture.
  7601. * This is only available in WebGL 2.
  7602. * @param size The size of face edge in the cube texture.
  7603. * @param options The options defining the cube texture.
  7604. * @returns The cube texture
  7605. */
  7606. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7607. /**
  7608. * Creates a cube texture
  7609. * @param rootUrl defines the url where the files to load is located
  7610. * @param scene defines the current scene
  7611. * @param files defines the list of files to load (1 per face)
  7612. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7613. * @param onLoad defines an optional callback raised when the texture is loaded
  7614. * @param onError defines an optional callback raised if there is an issue to load the texture
  7615. * @param format defines the format of the data
  7616. * @param forcedExtension defines the extension to use to pick the right loader
  7617. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7618. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7619. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7620. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7621. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7622. * @returns the cube texture as an InternalTexture
  7623. */
  7624. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7625. /**
  7626. * Creates a cube texture
  7627. * @param rootUrl defines the url where the files to load is located
  7628. * @param scene defines the current scene
  7629. * @param files defines the list of files to load (1 per face)
  7630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7631. * @param onLoad defines an optional callback raised when the texture is loaded
  7632. * @param onError defines an optional callback raised if there is an issue to load the texture
  7633. * @param format defines the format of the data
  7634. * @param forcedExtension defines the extension to use to pick the right loader
  7635. * @returns the cube texture as an InternalTexture
  7636. */
  7637. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7638. /**
  7639. * Creates a cube texture
  7640. * @param rootUrl defines the url where the files to load is located
  7641. * @param scene defines the current scene
  7642. * @param files defines the list of files to load (1 per face)
  7643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7644. * @param onLoad defines an optional callback raised when the texture is loaded
  7645. * @param onError defines an optional callback raised if there is an issue to load the texture
  7646. * @param format defines the format of the data
  7647. * @param forcedExtension defines the extension to use to pick the right loader
  7648. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7649. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7650. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7654. /** @hidden */
  7655. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7656. /** @hidden */
  7657. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7658. /** @hidden */
  7659. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7660. /** @hidden */
  7661. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7662. /**
  7663. * @hidden
  7664. */
  7665. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7666. }
  7667. }
  7668. declare module BABYLON {
  7669. /**
  7670. * Class for creating a cube texture
  7671. */
  7672. export class CubeTexture extends BaseTexture {
  7673. private _delayedOnLoad;
  7674. /**
  7675. * Observable triggered once the texture has been loaded.
  7676. */
  7677. onLoadObservable: Observable<CubeTexture>;
  7678. /**
  7679. * The url of the texture
  7680. */
  7681. url: string;
  7682. /**
  7683. * Gets or sets the center of the bounding box associated with the cube texture.
  7684. * It must define where the camera used to render the texture was set
  7685. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7686. */
  7687. boundingBoxPosition: Vector3;
  7688. private _boundingBoxSize;
  7689. /**
  7690. * Gets or sets the size of the bounding box associated with the cube texture
  7691. * When defined, the cubemap will switch to local mode
  7692. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7693. * @example https://www.babylonjs-playground.com/#RNASML
  7694. */
  7695. set boundingBoxSize(value: Vector3);
  7696. /**
  7697. * Returns the bounding box size
  7698. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7699. */
  7700. get boundingBoxSize(): Vector3;
  7701. protected _rotationY: number;
  7702. /**
  7703. * Sets texture matrix rotation angle around Y axis in radians.
  7704. */
  7705. set rotationY(value: number);
  7706. /**
  7707. * Gets texture matrix rotation angle around Y axis radians.
  7708. */
  7709. get rotationY(): number;
  7710. /**
  7711. * Are mip maps generated for this texture or not.
  7712. */
  7713. get noMipmap(): boolean;
  7714. private _noMipmap;
  7715. private _files;
  7716. protected _forcedExtension: Nullable<string>;
  7717. private _extensions;
  7718. private _textureMatrix;
  7719. private _format;
  7720. private _createPolynomials;
  7721. /** @hidden */
  7722. _prefiltered: boolean;
  7723. /**
  7724. * Creates a cube texture from an array of image urls
  7725. * @param files defines an array of image urls
  7726. * @param scene defines the hosting scene
  7727. * @param noMipmap specifies if mip maps are not used
  7728. * @returns a cube texture
  7729. */
  7730. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7731. /**
  7732. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7733. * @param url defines the url of the prefiltered texture
  7734. * @param scene defines the scene the texture is attached to
  7735. * @param forcedExtension defines the extension of the file if different from the url
  7736. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7737. * @return the prefiltered texture
  7738. */
  7739. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7740. /**
  7741. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7742. * as prefiltered data.
  7743. * @param rootUrl defines the url of the texture or the root name of the six images
  7744. * @param scene defines the scene the texture is attached to
  7745. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7746. * @param noMipmap defines if mipmaps should be created or not
  7747. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7748. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7749. * @param onError defines a callback triggered in case of error during load
  7750. * @param format defines the internal format to use for the texture once loaded
  7751. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7752. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7753. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7754. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7755. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7756. * @return the cube texture
  7757. */
  7758. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7759. /**
  7760. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7761. */
  7762. get isPrefiltered(): boolean;
  7763. /**
  7764. * Get the current class name of the texture useful for serialization or dynamic coding.
  7765. * @returns "CubeTexture"
  7766. */
  7767. getClassName(): string;
  7768. /**
  7769. * Update the url (and optional buffer) of this texture if url was null during construction.
  7770. * @param url the url of the texture
  7771. * @param forcedExtension defines the extension to use
  7772. * @param onLoad callback called when the texture is loaded (defaults to null)
  7773. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7774. */
  7775. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7776. /**
  7777. * Delays loading of the cube texture
  7778. * @param forcedExtension defines the extension to use
  7779. */
  7780. delayLoad(forcedExtension?: string): void;
  7781. /**
  7782. * Returns the reflection texture matrix
  7783. * @returns the reflection texture matrix
  7784. */
  7785. getReflectionTextureMatrix(): Matrix;
  7786. /**
  7787. * Sets the reflection texture matrix
  7788. * @param value Reflection texture matrix
  7789. */
  7790. setReflectionTextureMatrix(value: Matrix): void;
  7791. /**
  7792. * Parses text to create a cube texture
  7793. * @param parsedTexture define the serialized text to read from
  7794. * @param scene defines the hosting scene
  7795. * @param rootUrl defines the root url of the cube texture
  7796. * @returns a cube texture
  7797. */
  7798. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7799. /**
  7800. * Makes a clone, or deep copy, of the cube texture
  7801. * @returns a new cube texture
  7802. */
  7803. clone(): CubeTexture;
  7804. }
  7805. }
  7806. declare module BABYLON {
  7807. /**
  7808. * Manages the defines for the Material
  7809. */
  7810. export class MaterialDefines {
  7811. /** @hidden */
  7812. protected _keys: string[];
  7813. private _isDirty;
  7814. /** @hidden */
  7815. _renderId: number;
  7816. /** @hidden */
  7817. _areLightsDirty: boolean;
  7818. /** @hidden */
  7819. _areLightsDisposed: boolean;
  7820. /** @hidden */
  7821. _areAttributesDirty: boolean;
  7822. /** @hidden */
  7823. _areTexturesDirty: boolean;
  7824. /** @hidden */
  7825. _areFresnelDirty: boolean;
  7826. /** @hidden */
  7827. _areMiscDirty: boolean;
  7828. /** @hidden */
  7829. _areImageProcessingDirty: boolean;
  7830. /** @hidden */
  7831. _normals: boolean;
  7832. /** @hidden */
  7833. _uvs: boolean;
  7834. /** @hidden */
  7835. _needNormals: boolean;
  7836. /** @hidden */
  7837. _needUVs: boolean;
  7838. [id: string]: any;
  7839. /**
  7840. * Specifies if the material needs to be re-calculated
  7841. */
  7842. get isDirty(): boolean;
  7843. /**
  7844. * Marks the material to indicate that it has been re-calculated
  7845. */
  7846. markAsProcessed(): void;
  7847. /**
  7848. * Marks the material to indicate that it needs to be re-calculated
  7849. */
  7850. markAsUnprocessed(): void;
  7851. /**
  7852. * Marks the material to indicate all of its defines need to be re-calculated
  7853. */
  7854. markAllAsDirty(): void;
  7855. /**
  7856. * Marks the material to indicate that image processing needs to be re-calculated
  7857. */
  7858. markAsImageProcessingDirty(): void;
  7859. /**
  7860. * Marks the material to indicate the lights need to be re-calculated
  7861. * @param disposed Defines whether the light is dirty due to dispose or not
  7862. */
  7863. markAsLightDirty(disposed?: boolean): void;
  7864. /**
  7865. * Marks the attribute state as changed
  7866. */
  7867. markAsAttributesDirty(): void;
  7868. /**
  7869. * Marks the texture state as changed
  7870. */
  7871. markAsTexturesDirty(): void;
  7872. /**
  7873. * Marks the fresnel state as changed
  7874. */
  7875. markAsFresnelDirty(): void;
  7876. /**
  7877. * Marks the misc state as changed
  7878. */
  7879. markAsMiscDirty(): void;
  7880. /**
  7881. * Rebuilds the material defines
  7882. */
  7883. rebuild(): void;
  7884. /**
  7885. * Specifies if two material defines are equal
  7886. * @param other - A material define instance to compare to
  7887. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7888. */
  7889. isEqual(other: MaterialDefines): boolean;
  7890. /**
  7891. * Clones this instance's defines to another instance
  7892. * @param other - material defines to clone values to
  7893. */
  7894. cloneTo(other: MaterialDefines): void;
  7895. /**
  7896. * Resets the material define values
  7897. */
  7898. reset(): void;
  7899. /**
  7900. * Converts the material define values to a string
  7901. * @returns - String of material define information
  7902. */
  7903. toString(): string;
  7904. }
  7905. }
  7906. declare module BABYLON {
  7907. /**
  7908. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7909. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7910. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7911. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7912. */
  7913. export class ColorCurves {
  7914. private _dirty;
  7915. private _tempColor;
  7916. private _globalCurve;
  7917. private _highlightsCurve;
  7918. private _midtonesCurve;
  7919. private _shadowsCurve;
  7920. private _positiveCurve;
  7921. private _negativeCurve;
  7922. private _globalHue;
  7923. private _globalDensity;
  7924. private _globalSaturation;
  7925. private _globalExposure;
  7926. /**
  7927. * Gets the global Hue value.
  7928. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7929. */
  7930. get globalHue(): number;
  7931. /**
  7932. * Sets the global Hue value.
  7933. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7934. */
  7935. set globalHue(value: number);
  7936. /**
  7937. * Gets the global Density value.
  7938. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. get globalDensity(): number;
  7942. /**
  7943. * Sets the global Density value.
  7944. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. set globalDensity(value: number);
  7948. /**
  7949. * Gets the global Saturation value.
  7950. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7951. */
  7952. get globalSaturation(): number;
  7953. /**
  7954. * Sets the global Saturation value.
  7955. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7956. */
  7957. set globalSaturation(value: number);
  7958. /**
  7959. * Gets the global Exposure value.
  7960. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7961. */
  7962. get globalExposure(): number;
  7963. /**
  7964. * Sets the global Exposure value.
  7965. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7966. */
  7967. set globalExposure(value: number);
  7968. private _highlightsHue;
  7969. private _highlightsDensity;
  7970. private _highlightsSaturation;
  7971. private _highlightsExposure;
  7972. /**
  7973. * Gets the highlights Hue value.
  7974. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7975. */
  7976. get highlightsHue(): number;
  7977. /**
  7978. * Sets the highlights Hue value.
  7979. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7980. */
  7981. set highlightsHue(value: number);
  7982. /**
  7983. * Gets the highlights Density value.
  7984. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. get highlightsDensity(): number;
  7988. /**
  7989. * Sets the highlights Density value.
  7990. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7991. * Values less than zero provide a filter of opposite hue.
  7992. */
  7993. set highlightsDensity(value: number);
  7994. /**
  7995. * Gets the highlights Saturation value.
  7996. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7997. */
  7998. get highlightsSaturation(): number;
  7999. /**
  8000. * Sets the highlights Saturation value.
  8001. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8002. */
  8003. set highlightsSaturation(value: number);
  8004. /**
  8005. * Gets the highlights Exposure value.
  8006. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8007. */
  8008. get highlightsExposure(): number;
  8009. /**
  8010. * Sets the highlights Exposure value.
  8011. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8012. */
  8013. set highlightsExposure(value: number);
  8014. private _midtonesHue;
  8015. private _midtonesDensity;
  8016. private _midtonesSaturation;
  8017. private _midtonesExposure;
  8018. /**
  8019. * Gets the midtones Hue value.
  8020. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8021. */
  8022. get midtonesHue(): number;
  8023. /**
  8024. * Sets the midtones Hue value.
  8025. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8026. */
  8027. set midtonesHue(value: number);
  8028. /**
  8029. * Gets the midtones Density value.
  8030. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. get midtonesDensity(): number;
  8034. /**
  8035. * Sets the midtones Density value.
  8036. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8037. * Values less than zero provide a filter of opposite hue.
  8038. */
  8039. set midtonesDensity(value: number);
  8040. /**
  8041. * Gets the midtones Saturation value.
  8042. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8043. */
  8044. get midtonesSaturation(): number;
  8045. /**
  8046. * Sets the midtones Saturation value.
  8047. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8048. */
  8049. set midtonesSaturation(value: number);
  8050. /**
  8051. * Gets the midtones Exposure value.
  8052. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8053. */
  8054. get midtonesExposure(): number;
  8055. /**
  8056. * Sets the midtones Exposure value.
  8057. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8058. */
  8059. set midtonesExposure(value: number);
  8060. private _shadowsHue;
  8061. private _shadowsDensity;
  8062. private _shadowsSaturation;
  8063. private _shadowsExposure;
  8064. /**
  8065. * Gets the shadows Hue value.
  8066. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8067. */
  8068. get shadowsHue(): number;
  8069. /**
  8070. * Sets the shadows Hue value.
  8071. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8072. */
  8073. set shadowsHue(value: number);
  8074. /**
  8075. * Gets the shadows Density value.
  8076. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8077. * Values less than zero provide a filter of opposite hue.
  8078. */
  8079. get shadowsDensity(): number;
  8080. /**
  8081. * Sets the shadows Density value.
  8082. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8083. * Values less than zero provide a filter of opposite hue.
  8084. */
  8085. set shadowsDensity(value: number);
  8086. /**
  8087. * Gets the shadows Saturation value.
  8088. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8089. */
  8090. get shadowsSaturation(): number;
  8091. /**
  8092. * Sets the shadows Saturation value.
  8093. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8094. */
  8095. set shadowsSaturation(value: number);
  8096. /**
  8097. * Gets the shadows Exposure value.
  8098. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8099. */
  8100. get shadowsExposure(): number;
  8101. /**
  8102. * Sets the shadows Exposure value.
  8103. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8104. */
  8105. set shadowsExposure(value: number);
  8106. /**
  8107. * Returns the class name
  8108. * @returns The class name
  8109. */
  8110. getClassName(): string;
  8111. /**
  8112. * Binds the color curves to the shader.
  8113. * @param colorCurves The color curve to bind
  8114. * @param effect The effect to bind to
  8115. * @param positiveUniform The positive uniform shader parameter
  8116. * @param neutralUniform The neutral uniform shader parameter
  8117. * @param negativeUniform The negative uniform shader parameter
  8118. */
  8119. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8120. /**
  8121. * Prepare the list of uniforms associated with the ColorCurves effects.
  8122. * @param uniformsList The list of uniforms used in the effect
  8123. */
  8124. static PrepareUniforms(uniformsList: string[]): void;
  8125. /**
  8126. * Returns color grading data based on a hue, density, saturation and exposure value.
  8127. * @param filterHue The hue of the color filter.
  8128. * @param filterDensity The density of the color filter.
  8129. * @param saturation The saturation.
  8130. * @param exposure The exposure.
  8131. * @param result The result data container.
  8132. */
  8133. private getColorGradingDataToRef;
  8134. /**
  8135. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8136. * @param value The input slider value in range [-100,100].
  8137. * @returns Adjusted value.
  8138. */
  8139. private static applyColorGradingSliderNonlinear;
  8140. /**
  8141. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8142. * @param hue The hue (H) input.
  8143. * @param saturation The saturation (S) input.
  8144. * @param brightness The brightness (B) input.
  8145. * @result An RGBA color represented as Vector4.
  8146. */
  8147. private static fromHSBToRef;
  8148. /**
  8149. * Returns a value clamped between min and max
  8150. * @param value The value to clamp
  8151. * @param min The minimum of value
  8152. * @param max The maximum of value
  8153. * @returns The clamped value.
  8154. */
  8155. private static clamp;
  8156. /**
  8157. * Clones the current color curve instance.
  8158. * @return The cloned curves
  8159. */
  8160. clone(): ColorCurves;
  8161. /**
  8162. * Serializes the current color curve instance to a json representation.
  8163. * @return a JSON representation
  8164. */
  8165. serialize(): any;
  8166. /**
  8167. * Parses the color curve from a json representation.
  8168. * @param source the JSON source to parse
  8169. * @return The parsed curves
  8170. */
  8171. static Parse(source: any): ColorCurves;
  8172. }
  8173. }
  8174. declare module BABYLON {
  8175. /**
  8176. * Interface to follow in your material defines to integrate easily the
  8177. * Image proccessing functions.
  8178. * @hidden
  8179. */
  8180. export interface IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. EXPOSURE: boolean;
  8189. COLORCURVES: boolean;
  8190. COLORGRADING: boolean;
  8191. COLORGRADING3D: boolean;
  8192. SAMPLER3DGREENDEPTH: boolean;
  8193. SAMPLER3DBGRMAP: boolean;
  8194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8195. }
  8196. /**
  8197. * @hidden
  8198. */
  8199. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8200. IMAGEPROCESSING: boolean;
  8201. VIGNETTE: boolean;
  8202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8203. VIGNETTEBLENDMODEOPAQUE: boolean;
  8204. TONEMAPPING: boolean;
  8205. TONEMAPPING_ACES: boolean;
  8206. CONTRAST: boolean;
  8207. COLORCURVES: boolean;
  8208. COLORGRADING: boolean;
  8209. COLORGRADING3D: boolean;
  8210. SAMPLER3DGREENDEPTH: boolean;
  8211. SAMPLER3DBGRMAP: boolean;
  8212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8213. EXPOSURE: boolean;
  8214. constructor();
  8215. }
  8216. /**
  8217. * This groups together the common properties used for image processing either in direct forward pass
  8218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8219. * or not.
  8220. */
  8221. export class ImageProcessingConfiguration {
  8222. /**
  8223. * Default tone mapping applied in BabylonJS.
  8224. */
  8225. static readonly TONEMAPPING_STANDARD: number;
  8226. /**
  8227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8228. * to other engines rendering to increase portability.
  8229. */
  8230. static readonly TONEMAPPING_ACES: number;
  8231. /**
  8232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8233. */
  8234. colorCurves: Nullable<ColorCurves>;
  8235. private _colorCurvesEnabled;
  8236. /**
  8237. * Gets wether the color curves effect is enabled.
  8238. */
  8239. get colorCurvesEnabled(): boolean;
  8240. /**
  8241. * Sets wether the color curves effect is enabled.
  8242. */
  8243. set colorCurvesEnabled(value: boolean);
  8244. private _colorGradingTexture;
  8245. /**
  8246. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8247. */
  8248. get colorGradingTexture(): Nullable<BaseTexture>;
  8249. /**
  8250. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8251. */
  8252. set colorGradingTexture(value: Nullable<BaseTexture>);
  8253. private _colorGradingEnabled;
  8254. /**
  8255. * Gets wether the color grading effect is enabled.
  8256. */
  8257. get colorGradingEnabled(): boolean;
  8258. /**
  8259. * Sets wether the color grading effect is enabled.
  8260. */
  8261. set colorGradingEnabled(value: boolean);
  8262. private _colorGradingWithGreenDepth;
  8263. /**
  8264. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8265. */
  8266. get colorGradingWithGreenDepth(): boolean;
  8267. /**
  8268. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8269. */
  8270. set colorGradingWithGreenDepth(value: boolean);
  8271. private _colorGradingBGR;
  8272. /**
  8273. * Gets wether the color grading texture contains BGR values.
  8274. */
  8275. get colorGradingBGR(): boolean;
  8276. /**
  8277. * Sets wether the color grading texture contains BGR values.
  8278. */
  8279. set colorGradingBGR(value: boolean);
  8280. /** @hidden */
  8281. _exposure: number;
  8282. /**
  8283. * Gets the Exposure used in the effect.
  8284. */
  8285. get exposure(): number;
  8286. /**
  8287. * Sets the Exposure used in the effect.
  8288. */
  8289. set exposure(value: number);
  8290. private _toneMappingEnabled;
  8291. /**
  8292. * Gets wether the tone mapping effect is enabled.
  8293. */
  8294. get toneMappingEnabled(): boolean;
  8295. /**
  8296. * Sets wether the tone mapping effect is enabled.
  8297. */
  8298. set toneMappingEnabled(value: boolean);
  8299. private _toneMappingType;
  8300. /**
  8301. * Gets the type of tone mapping effect.
  8302. */
  8303. get toneMappingType(): number;
  8304. /**
  8305. * Sets the type of tone mapping effect used in BabylonJS.
  8306. */
  8307. set toneMappingType(value: number);
  8308. protected _contrast: number;
  8309. /**
  8310. * Gets the contrast used in the effect.
  8311. */
  8312. get contrast(): number;
  8313. /**
  8314. * Sets the contrast used in the effect.
  8315. */
  8316. set contrast(value: number);
  8317. /**
  8318. * Vignette stretch size.
  8319. */
  8320. vignetteStretch: number;
  8321. /**
  8322. * Vignette centre X Offset.
  8323. */
  8324. vignetteCentreX: number;
  8325. /**
  8326. * Vignette centre Y Offset.
  8327. */
  8328. vignetteCentreY: number;
  8329. /**
  8330. * Vignette weight or intensity of the vignette effect.
  8331. */
  8332. vignetteWeight: number;
  8333. /**
  8334. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8335. * if vignetteEnabled is set to true.
  8336. */
  8337. vignetteColor: Color4;
  8338. /**
  8339. * Camera field of view used by the Vignette effect.
  8340. */
  8341. vignetteCameraFov: number;
  8342. private _vignetteBlendMode;
  8343. /**
  8344. * Gets the vignette blend mode allowing different kind of effect.
  8345. */
  8346. get vignetteBlendMode(): number;
  8347. /**
  8348. * Sets the vignette blend mode allowing different kind of effect.
  8349. */
  8350. set vignetteBlendMode(value: number);
  8351. private _vignetteEnabled;
  8352. /**
  8353. * Gets wether the vignette effect is enabled.
  8354. */
  8355. get vignetteEnabled(): boolean;
  8356. /**
  8357. * Sets wether the vignette effect is enabled.
  8358. */
  8359. set vignetteEnabled(value: boolean);
  8360. private _applyByPostProcess;
  8361. /**
  8362. * Gets wether the image processing is applied through a post process or not.
  8363. */
  8364. get applyByPostProcess(): boolean;
  8365. /**
  8366. * Sets wether the image processing is applied through a post process or not.
  8367. */
  8368. set applyByPostProcess(value: boolean);
  8369. private _isEnabled;
  8370. /**
  8371. * Gets wether the image processing is enabled or not.
  8372. */
  8373. get isEnabled(): boolean;
  8374. /**
  8375. * Sets wether the image processing is enabled or not.
  8376. */
  8377. set isEnabled(value: boolean);
  8378. /**
  8379. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8380. */
  8381. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8382. /**
  8383. * Method called each time the image processing information changes requires to recompile the effect.
  8384. */
  8385. protected _updateParameters(): void;
  8386. /**
  8387. * Gets the current class name.
  8388. * @return "ImageProcessingConfiguration"
  8389. */
  8390. getClassName(): string;
  8391. /**
  8392. * Prepare the list of uniforms associated with the Image Processing effects.
  8393. * @param uniforms The list of uniforms used in the effect
  8394. * @param defines the list of defines currently in use
  8395. */
  8396. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8397. /**
  8398. * Prepare the list of samplers associated with the Image Processing effects.
  8399. * @param samplersList The list of uniforms used in the effect
  8400. * @param defines the list of defines currently in use
  8401. */
  8402. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8403. /**
  8404. * Prepare the list of defines associated to the shader.
  8405. * @param defines the list of defines to complete
  8406. * @param forPostProcess Define if we are currently in post process mode or not
  8407. */
  8408. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8409. /**
  8410. * Returns true if all the image processing information are ready.
  8411. * @returns True if ready, otherwise, false
  8412. */
  8413. isReady(): boolean;
  8414. /**
  8415. * Binds the image processing to the shader.
  8416. * @param effect The effect to bind to
  8417. * @param overrideAspectRatio Override the aspect ratio of the effect
  8418. */
  8419. bind(effect: Effect, overrideAspectRatio?: number): void;
  8420. /**
  8421. * Clones the current image processing instance.
  8422. * @return The cloned image processing
  8423. */
  8424. clone(): ImageProcessingConfiguration;
  8425. /**
  8426. * Serializes the current image processing instance to a json representation.
  8427. * @return a JSON representation
  8428. */
  8429. serialize(): any;
  8430. /**
  8431. * Parses the image processing from a json representation.
  8432. * @param source the JSON source to parse
  8433. * @return The parsed image processing
  8434. */
  8435. static Parse(source: any): ImageProcessingConfiguration;
  8436. private static _VIGNETTEMODE_MULTIPLY;
  8437. private static _VIGNETTEMODE_OPAQUE;
  8438. /**
  8439. * Used to apply the vignette as a mix with the pixel color.
  8440. */
  8441. static get VIGNETTEMODE_MULTIPLY(): number;
  8442. /**
  8443. * Used to apply the vignette as a replacement of the pixel color.
  8444. */
  8445. static get VIGNETTEMODE_OPAQUE(): number;
  8446. }
  8447. }
  8448. declare module BABYLON {
  8449. /** @hidden */
  8450. export var postprocessVertexShader: {
  8451. name: string;
  8452. shader: string;
  8453. };
  8454. }
  8455. declare module BABYLON {
  8456. interface ThinEngine {
  8457. /**
  8458. * Creates a new render target texture
  8459. * @param size defines the size of the texture
  8460. * @param options defines the options used to create the texture
  8461. * @returns a new render target texture stored in an InternalTexture
  8462. */
  8463. createRenderTargetTexture(size: number | {
  8464. width: number;
  8465. height: number;
  8466. layers?: number;
  8467. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8468. /**
  8469. * Creates a depth stencil texture.
  8470. * This is only available in WebGL 2 or with the depth texture extension available.
  8471. * @param size The size of face edge in the texture.
  8472. * @param options The options defining the texture.
  8473. * @returns The texture
  8474. */
  8475. createDepthStencilTexture(size: number | {
  8476. width: number;
  8477. height: number;
  8478. layers?: number;
  8479. }, options: DepthTextureCreationOptions): InternalTexture;
  8480. /** @hidden */
  8481. _createDepthStencilTexture(size: number | {
  8482. width: number;
  8483. height: number;
  8484. layers?: number;
  8485. }, options: DepthTextureCreationOptions): InternalTexture;
  8486. }
  8487. }
  8488. declare module BABYLON {
  8489. /** Defines supported spaces */
  8490. export enum Space {
  8491. /** Local (object) space */
  8492. LOCAL = 0,
  8493. /** World space */
  8494. WORLD = 1,
  8495. /** Bone space */
  8496. BONE = 2
  8497. }
  8498. /** Defines the 3 main axes */
  8499. export class Axis {
  8500. /** X axis */
  8501. static X: Vector3;
  8502. /** Y axis */
  8503. static Y: Vector3;
  8504. /** Z axis */
  8505. static Z: Vector3;
  8506. }
  8507. }
  8508. declare module BABYLON {
  8509. /**
  8510. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8511. * This is the base of the follow, arc rotate cameras and Free camera
  8512. * @see http://doc.babylonjs.com/features/cameras
  8513. */
  8514. export class TargetCamera extends Camera {
  8515. private static _RigCamTransformMatrix;
  8516. private static _TargetTransformMatrix;
  8517. private static _TargetFocalPoint;
  8518. /**
  8519. * Define the current direction the camera is moving to
  8520. */
  8521. cameraDirection: Vector3;
  8522. /**
  8523. * Define the current rotation the camera is rotating to
  8524. */
  8525. cameraRotation: Vector2;
  8526. /**
  8527. * When set, the up vector of the camera will be updated by the rotation of the camera
  8528. */
  8529. updateUpVectorFromRotation: boolean;
  8530. private _tmpQuaternion;
  8531. /**
  8532. * Define the current rotation of the camera
  8533. */
  8534. rotation: Vector3;
  8535. /**
  8536. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8537. */
  8538. rotationQuaternion: Quaternion;
  8539. /**
  8540. * Define the current speed of the camera
  8541. */
  8542. speed: number;
  8543. /**
  8544. * Add constraint to the camera to prevent it to move freely in all directions and
  8545. * around all axis.
  8546. */
  8547. noRotationConstraint: boolean;
  8548. /**
  8549. * Define the current target of the camera as an object or a position.
  8550. */
  8551. lockedTarget: any;
  8552. /** @hidden */
  8553. _currentTarget: Vector3;
  8554. /** @hidden */
  8555. _initialFocalDistance: number;
  8556. /** @hidden */
  8557. _viewMatrix: Matrix;
  8558. /** @hidden */
  8559. _camMatrix: Matrix;
  8560. /** @hidden */
  8561. _cameraTransformMatrix: Matrix;
  8562. /** @hidden */
  8563. _cameraRotationMatrix: Matrix;
  8564. /** @hidden */
  8565. _referencePoint: Vector3;
  8566. /** @hidden */
  8567. _transformedReferencePoint: Vector3;
  8568. protected _globalCurrentTarget: Vector3;
  8569. protected _globalCurrentUpVector: Vector3;
  8570. /** @hidden */
  8571. _reset: () => void;
  8572. private _defaultUp;
  8573. /**
  8574. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8575. * This is the base of the follow, arc rotate cameras and Free camera
  8576. * @see http://doc.babylonjs.com/features/cameras
  8577. * @param name Defines the name of the camera in the scene
  8578. * @param position Defines the start position of the camera in the scene
  8579. * @param scene Defines the scene the camera belongs to
  8580. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8581. */
  8582. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8583. /**
  8584. * Gets the position in front of the camera at a given distance.
  8585. * @param distance The distance from the camera we want the position to be
  8586. * @returns the position
  8587. */
  8588. getFrontPosition(distance: number): Vector3;
  8589. /** @hidden */
  8590. _getLockedTargetPosition(): Nullable<Vector3>;
  8591. private _storedPosition;
  8592. private _storedRotation;
  8593. private _storedRotationQuaternion;
  8594. /**
  8595. * Store current camera state of the camera (fov, position, rotation, etc..)
  8596. * @returns the camera
  8597. */
  8598. storeState(): Camera;
  8599. /**
  8600. * Restored camera state. You must call storeState() first
  8601. * @returns whether it was successful or not
  8602. * @hidden
  8603. */
  8604. _restoreStateValues(): boolean;
  8605. /** @hidden */
  8606. _initCache(): void;
  8607. /** @hidden */
  8608. _updateCache(ignoreParentClass?: boolean): void;
  8609. /** @hidden */
  8610. _isSynchronizedViewMatrix(): boolean;
  8611. /** @hidden */
  8612. _computeLocalCameraSpeed(): number;
  8613. /**
  8614. * Defines the target the camera should look at.
  8615. * @param target Defines the new target as a Vector or a mesh
  8616. */
  8617. setTarget(target: Vector3): void;
  8618. /**
  8619. * Return the current target position of the camera. This value is expressed in local space.
  8620. * @returns the target position
  8621. */
  8622. getTarget(): Vector3;
  8623. /** @hidden */
  8624. _decideIfNeedsToMove(): boolean;
  8625. /** @hidden */
  8626. _updatePosition(): void;
  8627. /** @hidden */
  8628. _checkInputs(): void;
  8629. protected _updateCameraRotationMatrix(): void;
  8630. /**
  8631. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8632. * @returns the current camera
  8633. */
  8634. private _rotateUpVectorWithCameraRotationMatrix;
  8635. private _cachedRotationZ;
  8636. private _cachedQuaternionRotationZ;
  8637. /** @hidden */
  8638. _getViewMatrix(): Matrix;
  8639. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8640. /**
  8641. * @hidden
  8642. */
  8643. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8644. /**
  8645. * @hidden
  8646. */
  8647. _updateRigCameras(): void;
  8648. private _getRigCamPositionAndTarget;
  8649. /**
  8650. * Gets the current object class name.
  8651. * @return the class name
  8652. */
  8653. getClassName(): string;
  8654. }
  8655. }
  8656. declare module BABYLON {
  8657. /**
  8658. * Gather the list of keyboard event types as constants.
  8659. */
  8660. export class KeyboardEventTypes {
  8661. /**
  8662. * The keydown event is fired when a key becomes active (pressed).
  8663. */
  8664. static readonly KEYDOWN: number;
  8665. /**
  8666. * The keyup event is fired when a key has been released.
  8667. */
  8668. static readonly KEYUP: number;
  8669. }
  8670. /**
  8671. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8672. */
  8673. export class KeyboardInfo {
  8674. /**
  8675. * Defines the type of event (KeyboardEventTypes)
  8676. */
  8677. type: number;
  8678. /**
  8679. * Defines the related dom event
  8680. */
  8681. event: KeyboardEvent;
  8682. /**
  8683. * Instantiates a new keyboard info.
  8684. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8685. * @param type Defines the type of event (KeyboardEventTypes)
  8686. * @param event Defines the related dom event
  8687. */
  8688. constructor(
  8689. /**
  8690. * Defines the type of event (KeyboardEventTypes)
  8691. */
  8692. type: number,
  8693. /**
  8694. * Defines the related dom event
  8695. */
  8696. event: KeyboardEvent);
  8697. }
  8698. /**
  8699. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8700. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8701. */
  8702. export class KeyboardInfoPre extends KeyboardInfo {
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number;
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent;
  8711. /**
  8712. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8713. */
  8714. skipOnPointerObservable: boolean;
  8715. /**
  8716. * Instantiates a new keyboard pre info.
  8717. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8718. * @param type Defines the type of event (KeyboardEventTypes)
  8719. * @param event Defines the related dom event
  8720. */
  8721. constructor(
  8722. /**
  8723. * Defines the type of event (KeyboardEventTypes)
  8724. */
  8725. type: number,
  8726. /**
  8727. * Defines the related dom event
  8728. */
  8729. event: KeyboardEvent);
  8730. }
  8731. }
  8732. declare module BABYLON {
  8733. /**
  8734. * Manage the keyboard inputs to control the movement of a free camera.
  8735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8736. */
  8737. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8738. /**
  8739. * Defines the camera the input is attached to.
  8740. */
  8741. camera: FreeCamera;
  8742. /**
  8743. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8744. */
  8745. keysUp: number[];
  8746. /**
  8747. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8748. */
  8749. keysDown: number[];
  8750. /**
  8751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8752. */
  8753. keysLeft: number[];
  8754. /**
  8755. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8756. */
  8757. keysRight: number[];
  8758. private _keys;
  8759. private _onCanvasBlurObserver;
  8760. private _onKeyboardObserver;
  8761. private _engine;
  8762. private _scene;
  8763. /**
  8764. * Attach the input controls to a specific dom element to get the input from.
  8765. * @param element Defines the element the controls should be listened from
  8766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8767. */
  8768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8769. /**
  8770. * Detach the current controls from the specified dom element.
  8771. * @param element Defines the element to stop listening the inputs from
  8772. */
  8773. detachControl(element: Nullable<HTMLElement>): void;
  8774. /**
  8775. * Update the current camera state depending on the inputs that have been used this frame.
  8776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8777. */
  8778. checkInputs(): void;
  8779. /**
  8780. * Gets the class name of the current intput.
  8781. * @returns the class name
  8782. */
  8783. getClassName(): string;
  8784. /** @hidden */
  8785. _onLostFocus(): void;
  8786. /**
  8787. * Get the friendly name associated with the input class.
  8788. * @returns the input friendly name
  8789. */
  8790. getSimpleName(): string;
  8791. }
  8792. }
  8793. declare module BABYLON {
  8794. /**
  8795. * Interface describing all the common properties and methods a shadow light needs to implement.
  8796. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8797. * as well as binding the different shadow properties to the effects.
  8798. */
  8799. export interface IShadowLight extends Light {
  8800. /**
  8801. * The light id in the scene (used in scene.findLighById for instance)
  8802. */
  8803. id: string;
  8804. /**
  8805. * The position the shdow will be casted from.
  8806. */
  8807. position: Vector3;
  8808. /**
  8809. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8810. */
  8811. direction: Vector3;
  8812. /**
  8813. * The transformed position. Position of the light in world space taking parenting in account.
  8814. */
  8815. transformedPosition: Vector3;
  8816. /**
  8817. * The transformed direction. Direction of the light in world space taking parenting in account.
  8818. */
  8819. transformedDirection: Vector3;
  8820. /**
  8821. * The friendly name of the light in the scene.
  8822. */
  8823. name: string;
  8824. /**
  8825. * Defines the shadow projection clipping minimum z value.
  8826. */
  8827. shadowMinZ: number;
  8828. /**
  8829. * Defines the shadow projection clipping maximum z value.
  8830. */
  8831. shadowMaxZ: number;
  8832. /**
  8833. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8834. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8835. */
  8836. computeTransformedInformation(): boolean;
  8837. /**
  8838. * Gets the scene the light belongs to.
  8839. * @returns The scene
  8840. */
  8841. getScene(): Scene;
  8842. /**
  8843. * Callback defining a custom Projection Matrix Builder.
  8844. * This can be used to override the default projection matrix computation.
  8845. */
  8846. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. /**
  8856. * Gets the current depth scale used in ESM.
  8857. * @returns The scale
  8858. */
  8859. getDepthScale(): number;
  8860. /**
  8861. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8862. * @returns true if a cube texture needs to be use
  8863. */
  8864. needCube(): boolean;
  8865. /**
  8866. * Detects if the projection matrix requires to be recomputed this frame.
  8867. * @returns true if it requires to be recomputed otherwise, false.
  8868. */
  8869. needProjectionMatrixCompute(): boolean;
  8870. /**
  8871. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8872. */
  8873. forceProjectionMatrixCompute(): void;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Gets the minZ used for shadow according to both the scene and the light.
  8882. * @param activeCamera The camera we are returning the min for
  8883. * @returns the depth min z
  8884. */
  8885. getDepthMinZ(activeCamera: Camera): number;
  8886. /**
  8887. * Gets the maxZ used for shadow according to both the scene and the light.
  8888. * @param activeCamera The camera we are returning the max for
  8889. * @returns the depth max z
  8890. */
  8891. getDepthMaxZ(activeCamera: Camera): number;
  8892. }
  8893. /**
  8894. * Base implementation IShadowLight
  8895. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8896. */
  8897. export abstract class ShadowLight extends Light implements IShadowLight {
  8898. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8899. protected _position: Vector3;
  8900. protected _setPosition(value: Vector3): void;
  8901. /**
  8902. * Sets the position the shadow will be casted from. Also use as the light position for both
  8903. * point and spot lights.
  8904. */
  8905. get position(): Vector3;
  8906. /**
  8907. * Sets the position the shadow will be casted from. Also use as the light position for both
  8908. * point and spot lights.
  8909. */
  8910. set position(value: Vector3);
  8911. protected _direction: Vector3;
  8912. protected _setDirection(value: Vector3): void;
  8913. /**
  8914. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8915. * Also use as the light direction on spot and directional lights.
  8916. */
  8917. get direction(): Vector3;
  8918. /**
  8919. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8920. * Also use as the light direction on spot and directional lights.
  8921. */
  8922. set direction(value: Vector3);
  8923. protected _shadowMinZ: number;
  8924. /**
  8925. * Gets the shadow projection clipping minimum z value.
  8926. */
  8927. get shadowMinZ(): number;
  8928. /**
  8929. * Sets the shadow projection clipping minimum z value.
  8930. */
  8931. set shadowMinZ(value: number);
  8932. protected _shadowMaxZ: number;
  8933. /**
  8934. * Sets the shadow projection clipping maximum z value.
  8935. */
  8936. get shadowMaxZ(): number;
  8937. /**
  8938. * Gets the shadow projection clipping maximum z value.
  8939. */
  8940. set shadowMaxZ(value: number);
  8941. /**
  8942. * Callback defining a custom Projection Matrix Builder.
  8943. * This can be used to override the default projection matrix computation.
  8944. */
  8945. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8946. /**
  8947. * The transformed position. Position of the light in world space taking parenting in account.
  8948. */
  8949. transformedPosition: Vector3;
  8950. /**
  8951. * The transformed direction. Direction of the light in world space taking parenting in account.
  8952. */
  8953. transformedDirection: Vector3;
  8954. private _needProjectionMatrixCompute;
  8955. /**
  8956. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8957. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8958. */
  8959. computeTransformedInformation(): boolean;
  8960. /**
  8961. * Return the depth scale used for the shadow map.
  8962. * @returns the depth scale.
  8963. */
  8964. getDepthScale(): number;
  8965. /**
  8966. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8967. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8968. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8969. */
  8970. getShadowDirection(faceIndex?: number): Vector3;
  8971. /**
  8972. * Returns the ShadowLight absolute position in the World.
  8973. * @returns the position vector in world space
  8974. */
  8975. getAbsolutePosition(): Vector3;
  8976. /**
  8977. * Sets the ShadowLight direction toward the passed target.
  8978. * @param target The point to target in local space
  8979. * @returns the updated ShadowLight direction
  8980. */
  8981. setDirectionToTarget(target: Vector3): Vector3;
  8982. /**
  8983. * Returns the light rotation in euler definition.
  8984. * @returns the x y z rotation in local space.
  8985. */
  8986. getRotation(): Vector3;
  8987. /**
  8988. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8989. * @returns true if a cube texture needs to be use
  8990. */
  8991. needCube(): boolean;
  8992. /**
  8993. * Detects if the projection matrix requires to be recomputed this frame.
  8994. * @returns true if it requires to be recomputed otherwise, false.
  8995. */
  8996. needProjectionMatrixCompute(): boolean;
  8997. /**
  8998. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8999. */
  9000. forceProjectionMatrixCompute(): void;
  9001. /** @hidden */
  9002. _initCache(): void;
  9003. /** @hidden */
  9004. _isSynchronized(): boolean;
  9005. /**
  9006. * Computes the world matrix of the node
  9007. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9008. * @returns the world matrix
  9009. */
  9010. computeWorldMatrix(force?: boolean): Matrix;
  9011. /**
  9012. * Gets the minZ used for shadow according to both the scene and the light.
  9013. * @param activeCamera The camera we are returning the min for
  9014. * @returns the depth min z
  9015. */
  9016. getDepthMinZ(activeCamera: Camera): number;
  9017. /**
  9018. * Gets the maxZ used for shadow according to both the scene and the light.
  9019. * @param activeCamera The camera we are returning the max for
  9020. * @returns the depth max z
  9021. */
  9022. getDepthMaxZ(activeCamera: Camera): number;
  9023. /**
  9024. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9025. * @param matrix The materix to updated with the projection information
  9026. * @param viewMatrix The transform matrix of the light
  9027. * @param renderList The list of mesh to render in the map
  9028. * @returns The current light
  9029. */
  9030. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9031. }
  9032. }
  9033. declare module BABYLON {
  9034. /**
  9035. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9036. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9037. */
  9038. export class EffectFallbacks implements IEffectFallbacks {
  9039. private _defines;
  9040. private _currentRank;
  9041. private _maxRank;
  9042. private _mesh;
  9043. /**
  9044. * Removes the fallback from the bound mesh.
  9045. */
  9046. unBindMesh(): void;
  9047. /**
  9048. * Adds a fallback on the specified property.
  9049. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9050. * @param define The name of the define in the shader
  9051. */
  9052. addFallback(rank: number, define: string): void;
  9053. /**
  9054. * Sets the mesh to use CPU skinning when needing to fallback.
  9055. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9056. * @param mesh The mesh to use the fallbacks.
  9057. */
  9058. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9059. /**
  9060. * Checks to see if more fallbacks are still availible.
  9061. */
  9062. get hasMoreFallbacks(): boolean;
  9063. /**
  9064. * Removes the defines that should be removed when falling back.
  9065. * @param currentDefines defines the current define statements for the shader.
  9066. * @param effect defines the current effect we try to compile
  9067. * @returns The resulting defines with defines of the current rank removed.
  9068. */
  9069. reduce(currentDefines: string, effect: Effect): string;
  9070. }
  9071. }
  9072. declare module BABYLON {
  9073. /**
  9074. * "Static Class" containing the most commonly used helper while dealing with material for
  9075. * rendering purpose.
  9076. *
  9077. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9078. *
  9079. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9080. */
  9081. export class MaterialHelper {
  9082. /**
  9083. * Bind the current view position to an effect.
  9084. * @param effect The effect to be bound
  9085. * @param scene The scene the eyes position is used from
  9086. */
  9087. static BindEyePosition(effect: Effect, scene: Scene): void;
  9088. /**
  9089. * Helps preparing the defines values about the UVs in used in the effect.
  9090. * UVs are shared as much as we can accross channels in the shaders.
  9091. * @param texture The texture we are preparing the UVs for
  9092. * @param defines The defines to update
  9093. * @param key The channel key "diffuse", "specular"... used in the shader
  9094. */
  9095. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9096. /**
  9097. * Binds a texture matrix value to its corrsponding uniform
  9098. * @param texture The texture to bind the matrix for
  9099. * @param uniformBuffer The uniform buffer receivin the data
  9100. * @param key The channel key "diffuse", "specular"... used in the shader
  9101. */
  9102. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9103. /**
  9104. * Gets the current status of the fog (should it be enabled?)
  9105. * @param mesh defines the mesh to evaluate for fog support
  9106. * @param scene defines the hosting scene
  9107. * @returns true if fog must be enabled
  9108. */
  9109. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9110. /**
  9111. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9112. * @param mesh defines the current mesh
  9113. * @param scene defines the current scene
  9114. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9115. * @param pointsCloud defines if point cloud rendering has to be turned on
  9116. * @param fogEnabled defines if fog has to be turned on
  9117. * @param alphaTest defines if alpha testing has to be turned on
  9118. * @param defines defines the current list of defines
  9119. */
  9120. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9121. /**
  9122. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9123. * @param scene defines the current scene
  9124. * @param engine defines the current engine
  9125. * @param defines specifies the list of active defines
  9126. * @param useInstances defines if instances have to be turned on
  9127. * @param useClipPlane defines if clip plane have to be turned on
  9128. */
  9129. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9130. /**
  9131. * Prepares the defines for bones
  9132. * @param mesh The mesh containing the geometry data we will draw
  9133. * @param defines The defines to update
  9134. */
  9135. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9136. /**
  9137. * Prepares the defines for morph targets
  9138. * @param mesh The mesh containing the geometry data we will draw
  9139. * @param defines The defines to update
  9140. */
  9141. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9142. /**
  9143. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9144. * @param mesh The mesh containing the geometry data we will draw
  9145. * @param defines The defines to update
  9146. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9147. * @param useBones Precise whether bones should be used or not (override mesh info)
  9148. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9149. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9150. * @returns false if defines are considered not dirty and have not been checked
  9151. */
  9152. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9153. /**
  9154. * Prepares the defines related to multiview
  9155. * @param scene The scene we are intending to draw
  9156. * @param defines The defines to update
  9157. */
  9158. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9159. /**
  9160. * Prepares the defines related to the light information passed in parameter
  9161. * @param scene The scene we are intending to draw
  9162. * @param mesh The mesh the effect is compiling for
  9163. * @param light The light the effect is compiling for
  9164. * @param lightIndex The index of the light
  9165. * @param defines The defines to update
  9166. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9167. * @param state Defines the current state regarding what is needed (normals, etc...)
  9168. */
  9169. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9170. needNormals: boolean;
  9171. needRebuild: boolean;
  9172. shadowEnabled: boolean;
  9173. specularEnabled: boolean;
  9174. lightmapMode: boolean;
  9175. }): void;
  9176. /**
  9177. * Prepares the defines related to the light information passed in parameter
  9178. * @param scene The scene we are intending to draw
  9179. * @param mesh The mesh the effect is compiling for
  9180. * @param defines The defines to update
  9181. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9182. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9183. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9184. * @returns true if normals will be required for the rest of the effect
  9185. */
  9186. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9187. /**
  9188. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9189. * @param lightIndex defines the light index
  9190. * @param uniformsList The uniform list
  9191. * @param samplersList The sampler list
  9192. * @param projectedLightTexture defines if projected texture must be used
  9193. * @param uniformBuffersList defines an optional list of uniform buffers
  9194. */
  9195. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9196. /**
  9197. * Prepares the uniforms and samplers list to be used in the effect
  9198. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9199. * @param samplersList The sampler list
  9200. * @param defines The defines helping in the list generation
  9201. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9202. */
  9203. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9204. /**
  9205. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9206. * @param defines The defines to update while falling back
  9207. * @param fallbacks The authorized effect fallbacks
  9208. * @param maxSimultaneousLights The maximum number of lights allowed
  9209. * @param rank the current rank of the Effect
  9210. * @returns The newly affected rank
  9211. */
  9212. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9213. private static _TmpMorphInfluencers;
  9214. /**
  9215. * Prepares the list of attributes required for morph targets according to the effect defines.
  9216. * @param attribs The current list of supported attribs
  9217. * @param mesh The mesh to prepare the morph targets attributes for
  9218. * @param influencers The number of influencers
  9219. */
  9220. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9221. /**
  9222. * Prepares the list of attributes required for morph targets according to the effect defines.
  9223. * @param attribs The current list of supported attribs
  9224. * @param mesh The mesh to prepare the morph targets attributes for
  9225. * @param defines The current Defines of the effect
  9226. */
  9227. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9228. /**
  9229. * Prepares the list of attributes required for bones according to the effect defines.
  9230. * @param attribs The current list of supported attribs
  9231. * @param mesh The mesh to prepare the bones attributes for
  9232. * @param defines The current Defines of the effect
  9233. * @param fallbacks The current efffect fallback strategy
  9234. */
  9235. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9236. /**
  9237. * Check and prepare the list of attributes required for instances according to the effect defines.
  9238. * @param attribs The current list of supported attribs
  9239. * @param defines The current MaterialDefines of the effect
  9240. */
  9241. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9242. /**
  9243. * Add the list of attributes required for instances to the attribs array.
  9244. * @param attribs The current list of supported attribs
  9245. */
  9246. static PushAttributesForInstances(attribs: string[]): void;
  9247. /**
  9248. * Binds the light information to the effect.
  9249. * @param light The light containing the generator
  9250. * @param effect The effect we are binding the data to
  9251. * @param lightIndex The light index in the effect used to render
  9252. */
  9253. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9254. /**
  9255. * Binds the lights information from the scene to the effect for the given mesh.
  9256. * @param light Light to bind
  9257. * @param lightIndex Light index
  9258. * @param scene The scene where the light belongs to
  9259. * @param effect The effect we are binding the data to
  9260. * @param useSpecular Defines if specular is supported
  9261. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9262. */
  9263. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9264. /**
  9265. * Binds the lights information from the scene to the effect for the given mesh.
  9266. * @param scene The scene the lights belongs to
  9267. * @param mesh The mesh we are binding the information to render
  9268. * @param effect The effect we are binding the data to
  9269. * @param defines The generated defines for the effect
  9270. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9271. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9272. */
  9273. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9274. private static _tempFogColor;
  9275. /**
  9276. * Binds the fog information from the scene to the effect for the given mesh.
  9277. * @param scene The scene the lights belongs to
  9278. * @param mesh The mesh we are binding the information to render
  9279. * @param effect The effect we are binding the data to
  9280. * @param linearSpace Defines if the fog effect is applied in linear space
  9281. */
  9282. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9283. /**
  9284. * Binds the bones information from the mesh to the effect.
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. */
  9288. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9289. /**
  9290. * Binds the morph targets information from the mesh to the effect.
  9291. * @param abstractMesh The mesh we are binding the information to render
  9292. * @param effect The effect we are binding the data to
  9293. */
  9294. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9295. /**
  9296. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9297. * @param defines The generated defines used in the effect
  9298. * @param effect The effect we are binding the data to
  9299. * @param scene The scene we are willing to render with logarithmic scale for
  9300. */
  9301. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9302. /**
  9303. * Binds the clip plane information from the scene to the effect.
  9304. * @param scene The scene the clip plane information are extracted from
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindClipPlane(effect: Effect, scene: Scene): void;
  9308. }
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var packingFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var clipPlaneFragmentDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var clipPlaneFragment: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var shadowMapPixelShader: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var bonesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var morphTargetsVertexGlobalDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var morphTargetsVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var instancesDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var helperFunctions: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var clipPlaneVertexDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var morphTargetsVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var instancesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var bonesVertex: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var clipPlaneVertex: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var shadowMapVertexShader: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var depthBoxBlurPixelShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /**
  9424. * Class representing a ray with position and direction
  9425. */
  9426. export class Ray {
  9427. /** origin point */
  9428. origin: Vector3;
  9429. /** direction */
  9430. direction: Vector3;
  9431. /** length of the ray */
  9432. length: number;
  9433. private static readonly TmpVector3;
  9434. private _tmpRay;
  9435. /**
  9436. * Creates a new ray
  9437. * @param origin origin point
  9438. * @param direction direction
  9439. * @param length length of the ray
  9440. */
  9441. constructor(
  9442. /** origin point */
  9443. origin: Vector3,
  9444. /** direction */
  9445. direction: Vector3,
  9446. /** length of the ray */
  9447. length?: number);
  9448. /**
  9449. * Checks if the ray intersects a box
  9450. * @param minimum bound of the box
  9451. * @param maximum bound of the box
  9452. * @param intersectionTreshold extra extend to be added to the box in all direction
  9453. * @returns if the box was hit
  9454. */
  9455. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9456. /**
  9457. * Checks if the ray intersects a box
  9458. * @param box the bounding box to check
  9459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9460. * @returns if the box was hit
  9461. */
  9462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9463. /**
  9464. * If the ray hits a sphere
  9465. * @param sphere the bounding sphere to check
  9466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9467. * @returns true if it hits the sphere
  9468. */
  9469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9470. /**
  9471. * If the ray hits a triange
  9472. * @param vertex0 triangle vertex
  9473. * @param vertex1 triangle vertex
  9474. * @param vertex2 triangle vertex
  9475. * @returns intersection information if hit
  9476. */
  9477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9478. /**
  9479. * Checks if ray intersects a plane
  9480. * @param plane the plane to check
  9481. * @returns the distance away it was hit
  9482. */
  9483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9484. /**
  9485. * Calculate the intercept of a ray on a given axis
  9486. * @param axis to check 'x' | 'y' | 'z'
  9487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9489. */
  9490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9491. /**
  9492. * Checks if ray intersects a mesh
  9493. * @param mesh the mesh to check
  9494. * @param fastCheck if only the bounding box should checked
  9495. * @returns picking info of the intersecton
  9496. */
  9497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9498. /**
  9499. * Checks if ray intersects a mesh
  9500. * @param meshes the meshes to check
  9501. * @param fastCheck if only the bounding box should checked
  9502. * @param results array to store result in
  9503. * @returns Array of picking infos
  9504. */
  9505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9506. private _comparePickingInfo;
  9507. private static smallnum;
  9508. private static rayl;
  9509. /**
  9510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9511. * @param sega the first point of the segment to test the intersection against
  9512. * @param segb the second point of the segment to test the intersection against
  9513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9515. */
  9516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9517. /**
  9518. * Update the ray from viewport position
  9519. * @param x position
  9520. * @param y y position
  9521. * @param viewportWidth viewport width
  9522. * @param viewportHeight viewport height
  9523. * @param world world matrix
  9524. * @param view view matrix
  9525. * @param projection projection matrix
  9526. * @returns this ray updated
  9527. */
  9528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9529. /**
  9530. * Creates a ray with origin and direction of 0,0,0
  9531. * @returns the new ray
  9532. */
  9533. static Zero(): Ray;
  9534. /**
  9535. * Creates a new ray from screen space and viewport
  9536. * @param x position
  9537. * @param y y position
  9538. * @param viewportWidth viewport width
  9539. * @param viewportHeight viewport height
  9540. * @param world world matrix
  9541. * @param view view matrix
  9542. * @param projection projection matrix
  9543. * @returns new ray
  9544. */
  9545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9546. /**
  9547. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9548. * transformed to the given world matrix.
  9549. * @param origin The origin point
  9550. * @param end The end point
  9551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9552. * @returns the new ray
  9553. */
  9554. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9555. /**
  9556. * Transforms a ray by a matrix
  9557. * @param ray ray to transform
  9558. * @param matrix matrix to apply
  9559. * @returns the resulting new ray
  9560. */
  9561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9562. /**
  9563. * Transforms a ray by a matrix
  9564. * @param ray ray to transform
  9565. * @param matrix matrix to apply
  9566. * @param result ray to store result in
  9567. */
  9568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9569. /**
  9570. * Unproject a ray from screen space to object space
  9571. * @param sourceX defines the screen space x coordinate to use
  9572. * @param sourceY defines the screen space y coordinate to use
  9573. * @param viewportWidth defines the current width of the viewport
  9574. * @param viewportHeight defines the current height of the viewport
  9575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9576. * @param view defines the view matrix to use
  9577. * @param projection defines the projection matrix to use
  9578. */
  9579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9580. }
  9581. /**
  9582. * Type used to define predicate used to select faces when a mesh intersection is detected
  9583. */
  9584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9585. interface Scene {
  9586. /** @hidden */
  9587. _tempPickingRay: Nullable<Ray>;
  9588. /** @hidden */
  9589. _cachedRayForTransform: Ray;
  9590. /** @hidden */
  9591. _pickWithRayInverseMatrix: Matrix;
  9592. /** @hidden */
  9593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9594. /** @hidden */
  9595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9596. }
  9597. }
  9598. declare module BABYLON {
  9599. /**
  9600. * Groups all the scene component constants in one place to ease maintenance.
  9601. * @hidden
  9602. */
  9603. export class SceneComponentConstants {
  9604. static readonly NAME_EFFECTLAYER: string;
  9605. static readonly NAME_LAYER: string;
  9606. static readonly NAME_LENSFLARESYSTEM: string;
  9607. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9608. static readonly NAME_PARTICLESYSTEM: string;
  9609. static readonly NAME_GAMEPAD: string;
  9610. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9611. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9612. static readonly NAME_DEPTHRENDERER: string;
  9613. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9614. static readonly NAME_SPRITE: string;
  9615. static readonly NAME_OUTLINERENDERER: string;
  9616. static readonly NAME_PROCEDURALTEXTURE: string;
  9617. static readonly NAME_SHADOWGENERATOR: string;
  9618. static readonly NAME_OCTREE: string;
  9619. static readonly NAME_PHYSICSENGINE: string;
  9620. static readonly NAME_AUDIO: string;
  9621. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9622. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9623. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9624. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9625. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9626. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9627. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9628. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9629. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9630. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9631. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9632. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9633. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9634. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9635. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9636. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9637. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9638. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9639. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9640. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9641. static readonly STEP_AFTERRENDER_AUDIO: number;
  9642. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9643. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9644. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9645. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9646. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9647. static readonly STEP_POINTERMOVE_SPRITE: number;
  9648. static readonly STEP_POINTERDOWN_SPRITE: number;
  9649. static readonly STEP_POINTERUP_SPRITE: number;
  9650. }
  9651. /**
  9652. * This represents a scene component.
  9653. *
  9654. * This is used to decouple the dependency the scene is having on the different workloads like
  9655. * layers, post processes...
  9656. */
  9657. export interface ISceneComponent {
  9658. /**
  9659. * The name of the component. Each component must have a unique name.
  9660. */
  9661. name: string;
  9662. /**
  9663. * The scene the component belongs to.
  9664. */
  9665. scene: Scene;
  9666. /**
  9667. * Register the component to one instance of a scene.
  9668. */
  9669. register(): void;
  9670. /**
  9671. * Rebuilds the elements related to this component in case of
  9672. * context lost for instance.
  9673. */
  9674. rebuild(): void;
  9675. /**
  9676. * Disposes the component and the associated ressources.
  9677. */
  9678. dispose(): void;
  9679. }
  9680. /**
  9681. * This represents a SERIALIZABLE scene component.
  9682. *
  9683. * This extends Scene Component to add Serialization methods on top.
  9684. */
  9685. export interface ISceneSerializableComponent extends ISceneComponent {
  9686. /**
  9687. * Adds all the elements from the container to the scene
  9688. * @param container the container holding the elements
  9689. */
  9690. addFromContainer(container: AbstractScene): void;
  9691. /**
  9692. * Removes all the elements in the container from the scene
  9693. * @param container contains the elements to remove
  9694. * @param dispose if the removed element should be disposed (default: false)
  9695. */
  9696. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9697. /**
  9698. * Serializes the component data to the specified json object
  9699. * @param serializationObject The object to serialize to
  9700. */
  9701. serialize(serializationObject: any): void;
  9702. }
  9703. /**
  9704. * Strong typing of a Mesh related stage step action
  9705. */
  9706. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9707. /**
  9708. * Strong typing of a Evaluate Sub Mesh related stage step action
  9709. */
  9710. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9711. /**
  9712. * Strong typing of a Active Mesh related stage step action
  9713. */
  9714. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9715. /**
  9716. * Strong typing of a Camera related stage step action
  9717. */
  9718. export type CameraStageAction = (camera: Camera) => void;
  9719. /**
  9720. * Strong typing of a Camera Frame buffer related stage step action
  9721. */
  9722. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9723. /**
  9724. * Strong typing of a Render Target related stage step action
  9725. */
  9726. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9727. /**
  9728. * Strong typing of a RenderingGroup related stage step action
  9729. */
  9730. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9731. /**
  9732. * Strong typing of a Mesh Render related stage step action
  9733. */
  9734. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9735. /**
  9736. * Strong typing of a simple stage step action
  9737. */
  9738. export type SimpleStageAction = () => void;
  9739. /**
  9740. * Strong typing of a render target action.
  9741. */
  9742. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9743. /**
  9744. * Strong typing of a pointer move action.
  9745. */
  9746. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9747. /**
  9748. * Strong typing of a pointer up/down action.
  9749. */
  9750. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9751. /**
  9752. * Representation of a stage in the scene (Basically a list of ordered steps)
  9753. * @hidden
  9754. */
  9755. export class Stage<T extends Function> extends Array<{
  9756. index: number;
  9757. component: ISceneComponent;
  9758. action: T;
  9759. }> {
  9760. /**
  9761. * Hide ctor from the rest of the world.
  9762. * @param items The items to add.
  9763. */
  9764. private constructor();
  9765. /**
  9766. * Creates a new Stage.
  9767. * @returns A new instance of a Stage
  9768. */
  9769. static Create<T extends Function>(): Stage<T>;
  9770. /**
  9771. * Registers a step in an ordered way in the targeted stage.
  9772. * @param index Defines the position to register the step in
  9773. * @param component Defines the component attached to the step
  9774. * @param action Defines the action to launch during the step
  9775. */
  9776. registerStep(index: number, component: ISceneComponent, action: T): void;
  9777. /**
  9778. * Clears all the steps from the stage.
  9779. */
  9780. clear(): void;
  9781. }
  9782. }
  9783. declare module BABYLON {
  9784. interface Scene {
  9785. /** @hidden */
  9786. _pointerOverSprite: Nullable<Sprite>;
  9787. /** @hidden */
  9788. _pickedDownSprite: Nullable<Sprite>;
  9789. /** @hidden */
  9790. _tempSpritePickingRay: Nullable<Ray>;
  9791. /**
  9792. * All of the sprite managers added to this scene
  9793. * @see http://doc.babylonjs.com/babylon101/sprites
  9794. */
  9795. spriteManagers: Array<ISpriteManager>;
  9796. /**
  9797. * An event triggered when sprites rendering is about to start
  9798. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9799. */
  9800. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9801. /**
  9802. * An event triggered when sprites rendering is done
  9803. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9804. */
  9805. onAfterSpritesRenderingObservable: Observable<Scene>;
  9806. /** @hidden */
  9807. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9808. /** Launch a ray to try to pick a sprite in the scene
  9809. * @param x position on screen
  9810. * @param y position on screen
  9811. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9812. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9813. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9814. * @returns a PickingInfo
  9815. */
  9816. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9817. /** Use the given ray to pick a sprite in the scene
  9818. * @param ray The ray (in world space) to use to pick meshes
  9819. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9820. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9821. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9822. * @returns a PickingInfo
  9823. */
  9824. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9825. /** @hidden */
  9826. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9827. /** Launch a ray to try to pick sprites in the scene
  9828. * @param x position on screen
  9829. * @param y position on screen
  9830. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9832. * @returns a PickingInfo array
  9833. */
  9834. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9835. /** Use the given ray to pick sprites in the scene
  9836. * @param ray The ray (in world space) to use to pick meshes
  9837. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9838. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9839. * @returns a PickingInfo array
  9840. */
  9841. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9842. /**
  9843. * Force the sprite under the pointer
  9844. * @param sprite defines the sprite to use
  9845. */
  9846. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9847. /**
  9848. * Gets the sprite under the pointer
  9849. * @returns a Sprite or null if no sprite is under the pointer
  9850. */
  9851. getPointerOverSprite(): Nullable<Sprite>;
  9852. }
  9853. /**
  9854. * Defines the sprite scene component responsible to manage sprites
  9855. * in a given scene.
  9856. */
  9857. export class SpriteSceneComponent implements ISceneComponent {
  9858. /**
  9859. * The component name helpfull to identify the component in the list of scene components.
  9860. */
  9861. readonly name: string;
  9862. /**
  9863. * The scene the component belongs to.
  9864. */
  9865. scene: Scene;
  9866. /** @hidden */
  9867. private _spritePredicate;
  9868. /**
  9869. * Creates a new instance of the component for the given scene
  9870. * @param scene Defines the scene to register the component in
  9871. */
  9872. constructor(scene: Scene);
  9873. /**
  9874. * Registers the component in a given scene
  9875. */
  9876. register(): void;
  9877. /**
  9878. * Rebuilds the elements related to this component in case of
  9879. * context lost for instance.
  9880. */
  9881. rebuild(): void;
  9882. /**
  9883. * Disposes the component and the associated ressources.
  9884. */
  9885. dispose(): void;
  9886. private _pickSpriteButKeepRay;
  9887. private _pointerMove;
  9888. private _pointerDown;
  9889. private _pointerUp;
  9890. }
  9891. }
  9892. declare module BABYLON {
  9893. /** @hidden */
  9894. export var fogFragmentDeclaration: {
  9895. name: string;
  9896. shader: string;
  9897. };
  9898. }
  9899. declare module BABYLON {
  9900. /** @hidden */
  9901. export var fogFragment: {
  9902. name: string;
  9903. shader: string;
  9904. };
  9905. }
  9906. declare module BABYLON {
  9907. /** @hidden */
  9908. export var spritesPixelShader: {
  9909. name: string;
  9910. shader: string;
  9911. };
  9912. }
  9913. declare module BABYLON {
  9914. /** @hidden */
  9915. export var fogVertexDeclaration: {
  9916. name: string;
  9917. shader: string;
  9918. };
  9919. }
  9920. declare module BABYLON {
  9921. /** @hidden */
  9922. export var spritesVertexShader: {
  9923. name: string;
  9924. shader: string;
  9925. };
  9926. }
  9927. declare module BABYLON {
  9928. /**
  9929. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9930. */
  9931. export interface ISpriteManager extends IDisposable {
  9932. /**
  9933. * Restricts the camera to viewing objects with the same layerMask.
  9934. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9935. */
  9936. layerMask: number;
  9937. /**
  9938. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9939. */
  9940. isPickable: boolean;
  9941. /**
  9942. * Specifies the rendering group id for this mesh (0 by default)
  9943. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9944. */
  9945. renderingGroupId: number;
  9946. /**
  9947. * Defines the list of sprites managed by the manager.
  9948. */
  9949. sprites: Array<Sprite>;
  9950. /**
  9951. * Tests the intersection of a sprite with a specific ray.
  9952. * @param ray The ray we are sending to test the collision
  9953. * @param camera The camera space we are sending rays in
  9954. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9955. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9956. * @returns picking info or null.
  9957. */
  9958. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9959. /**
  9960. * Intersects the sprites with a ray
  9961. * @param ray defines the ray to intersect with
  9962. * @param camera defines the current active camera
  9963. * @param predicate defines a predicate used to select candidate sprites
  9964. * @returns null if no hit or a PickingInfo array
  9965. */
  9966. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9967. /**
  9968. * Renders the list of sprites on screen.
  9969. */
  9970. render(): void;
  9971. }
  9972. /**
  9973. * Class used to manage multiple sprites on the same spritesheet
  9974. * @see http://doc.babylonjs.com/babylon101/sprites
  9975. */
  9976. export class SpriteManager implements ISpriteManager {
  9977. /** defines the manager's name */
  9978. name: string;
  9979. /** Gets the list of sprites */
  9980. sprites: Sprite[];
  9981. /** Gets or sets the rendering group id (0 by default) */
  9982. renderingGroupId: number;
  9983. /** Gets or sets camera layer mask */
  9984. layerMask: number;
  9985. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9986. fogEnabled: boolean;
  9987. /** Gets or sets a boolean indicating if the sprites are pickable */
  9988. isPickable: boolean;
  9989. /** Defines the default width of a cell in the spritesheet */
  9990. cellWidth: number;
  9991. /** Defines the default height of a cell in the spritesheet */
  9992. cellHeight: number;
  9993. /** Associative array from JSON sprite data file */
  9994. private _cellData;
  9995. /** Array of sprite names from JSON sprite data file */
  9996. private _spriteMap;
  9997. /** True when packed cell data from JSON file is ready*/
  9998. private _packedAndReady;
  9999. /**
  10000. * An event triggered when the manager is disposed.
  10001. */
  10002. onDisposeObservable: Observable<SpriteManager>;
  10003. private _onDisposeObserver;
  10004. /**
  10005. * Callback called when the manager is disposed
  10006. */
  10007. set onDispose(callback: () => void);
  10008. private _capacity;
  10009. private _fromPacked;
  10010. private _spriteTexture;
  10011. private _epsilon;
  10012. private _scene;
  10013. private _vertexData;
  10014. private _buffer;
  10015. private _vertexBuffers;
  10016. private _indexBuffer;
  10017. private _effectBase;
  10018. private _effectFog;
  10019. /**
  10020. * Gets or sets the spritesheet texture
  10021. */
  10022. get texture(): Texture;
  10023. set texture(value: Texture);
  10024. /**
  10025. * Creates a new sprite manager
  10026. * @param name defines the manager's name
  10027. * @param imgUrl defines the sprite sheet url
  10028. * @param capacity defines the maximum allowed number of sprites
  10029. * @param cellSize defines the size of a sprite cell
  10030. * @param scene defines the hosting scene
  10031. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10032. * @param samplingMode defines the smapling mode to use with spritesheet
  10033. * @param fromPacked set to false; do not alter
  10034. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10035. */
  10036. constructor(
  10037. /** defines the manager's name */
  10038. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10039. private _makePacked;
  10040. private _appendSpriteVertex;
  10041. /**
  10042. * Intersects the sprites with a ray
  10043. * @param ray defines the ray to intersect with
  10044. * @param camera defines the current active camera
  10045. * @param predicate defines a predicate used to select candidate sprites
  10046. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10047. * @returns null if no hit or a PickingInfo
  10048. */
  10049. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10050. /**
  10051. * Intersects the sprites with a ray
  10052. * @param ray defines the ray to intersect with
  10053. * @param camera defines the current active camera
  10054. * @param predicate defines a predicate used to select candidate sprites
  10055. * @returns null if no hit or a PickingInfo array
  10056. */
  10057. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10058. /**
  10059. * Render all child sprites
  10060. */
  10061. render(): void;
  10062. /**
  10063. * Release associated resources
  10064. */
  10065. dispose(): void;
  10066. }
  10067. }
  10068. declare module BABYLON {
  10069. /** Interface used by value gradients (color, factor, ...) */
  10070. export interface IValueGradient {
  10071. /**
  10072. * Gets or sets the gradient value (between 0 and 1)
  10073. */
  10074. gradient: number;
  10075. }
  10076. /** Class used to store color4 gradient */
  10077. export class ColorGradient implements IValueGradient {
  10078. /**
  10079. * Gets or sets the gradient value (between 0 and 1)
  10080. */
  10081. gradient: number;
  10082. /**
  10083. * Gets or sets first associated color
  10084. */
  10085. color1: Color4;
  10086. /**
  10087. * Gets or sets second associated color
  10088. */
  10089. color2?: Color4;
  10090. /**
  10091. * Will get a color picked randomly between color1 and color2.
  10092. * If color2 is undefined then color1 will be used
  10093. * @param result defines the target Color4 to store the result in
  10094. */
  10095. getColorToRef(result: Color4): void;
  10096. }
  10097. /** Class used to store color 3 gradient */
  10098. export class Color3Gradient implements IValueGradient {
  10099. /**
  10100. * Gets or sets the gradient value (between 0 and 1)
  10101. */
  10102. gradient: number;
  10103. /**
  10104. * Gets or sets the associated color
  10105. */
  10106. color: Color3;
  10107. }
  10108. /** Class used to store factor gradient */
  10109. export class FactorGradient 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 factor
  10116. */
  10117. factor1: number;
  10118. /**
  10119. * Gets or sets second associated factor
  10120. */
  10121. factor2?: number;
  10122. /**
  10123. * Will get a number picked randomly between factor1 and factor2.
  10124. * If factor2 is undefined then factor1 will be used
  10125. * @returns the picked number
  10126. */
  10127. getFactor(): number;
  10128. }
  10129. /**
  10130. * Helper used to simplify some generic gradient tasks
  10131. */
  10132. export class GradientHelper {
  10133. /**
  10134. * Gets the current gradient from an array of IValueGradient
  10135. * @param ratio defines the current ratio to get
  10136. * @param gradients defines the array of IValueGradient
  10137. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10138. */
  10139. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Interface for the size containing width and height
  10145. */
  10146. export interface ISize {
  10147. /**
  10148. * Width
  10149. */
  10150. width: number;
  10151. /**
  10152. * Heighht
  10153. */
  10154. height: number;
  10155. }
  10156. /**
  10157. * Size containing widht and height
  10158. */
  10159. export class Size implements ISize {
  10160. /**
  10161. * Width
  10162. */
  10163. width: number;
  10164. /**
  10165. * Height
  10166. */
  10167. height: number;
  10168. /**
  10169. * Creates a Size object from the given width and height (floats).
  10170. * @param width width of the new size
  10171. * @param height height of the new size
  10172. */
  10173. constructor(width: number, height: number);
  10174. /**
  10175. * Returns a string with the Size width and height
  10176. * @returns a string with the Size width and height
  10177. */
  10178. toString(): string;
  10179. /**
  10180. * "Size"
  10181. * @returns the string "Size"
  10182. */
  10183. getClassName(): string;
  10184. /**
  10185. * Returns the Size hash code.
  10186. * @returns a hash code for a unique width and height
  10187. */
  10188. getHashCode(): number;
  10189. /**
  10190. * Updates the current size from the given one.
  10191. * @param src the given size
  10192. */
  10193. copyFrom(src: Size): void;
  10194. /**
  10195. * Updates in place the current Size from the given floats.
  10196. * @param width width of the new size
  10197. * @param height height of the new size
  10198. * @returns the updated Size.
  10199. */
  10200. copyFromFloats(width: number, height: number): Size;
  10201. /**
  10202. * Updates in place the current Size from the given floats.
  10203. * @param width width to set
  10204. * @param height height to set
  10205. * @returns the updated Size.
  10206. */
  10207. set(width: number, height: number): Size;
  10208. /**
  10209. * Multiplies the width and height by numbers
  10210. * @param w factor to multiple the width by
  10211. * @param h factor to multiple the height by
  10212. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10213. */
  10214. multiplyByFloats(w: number, h: number): Size;
  10215. /**
  10216. * Clones the size
  10217. * @returns a new Size copied from the given one.
  10218. */
  10219. clone(): Size;
  10220. /**
  10221. * True if the current Size and the given one width and height are strictly equal.
  10222. * @param other the other size to compare against
  10223. * @returns True if the current Size and the given one width and height are strictly equal.
  10224. */
  10225. equals(other: Size): boolean;
  10226. /**
  10227. * The surface of the Size : width * height (float).
  10228. */
  10229. get surface(): number;
  10230. /**
  10231. * Create a new size of zero
  10232. * @returns a new Size set to (0.0, 0.0)
  10233. */
  10234. static Zero(): Size;
  10235. /**
  10236. * Sums the width and height of two sizes
  10237. * @param otherSize size to add to this size
  10238. * @returns a new Size set as the addition result of the current Size and the given one.
  10239. */
  10240. add(otherSize: Size): Size;
  10241. /**
  10242. * Subtracts the width and height of two
  10243. * @param otherSize size to subtract to this size
  10244. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10245. */
  10246. subtract(otherSize: Size): Size;
  10247. /**
  10248. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10249. * @param start starting size to lerp between
  10250. * @param end end size to lerp between
  10251. * @param amount amount to lerp between the start and end values
  10252. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10253. */
  10254. static Lerp(start: Size, end: Size, amount: number): Size;
  10255. }
  10256. }
  10257. declare module BABYLON {
  10258. interface ThinEngine {
  10259. /**
  10260. * Creates a dynamic texture
  10261. * @param width defines the width of the texture
  10262. * @param height defines the height of the texture
  10263. * @param generateMipMaps defines if the engine should generate the mip levels
  10264. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10265. * @returns the dynamic texture inside an InternalTexture
  10266. */
  10267. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10268. /**
  10269. * Update the content of a dynamic texture
  10270. * @param texture defines the texture to update
  10271. * @param canvas defines the canvas containing the source
  10272. * @param invertY defines if data must be stored with Y axis inverted
  10273. * @param premulAlpha defines if alpha is stored as premultiplied
  10274. * @param format defines the format of the data
  10275. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10276. */
  10277. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Helper class used to generate a canvas to manipulate images
  10283. */
  10284. export class CanvasGenerator {
  10285. /**
  10286. * Create a new canvas (or offscreen canvas depending on the context)
  10287. * @param width defines the expected width
  10288. * @param height defines the expected height
  10289. * @return a new canvas or offscreen canvas
  10290. */
  10291. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10292. }
  10293. }
  10294. declare module BABYLON {
  10295. /**
  10296. * A class extending Texture allowing drawing on a texture
  10297. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10298. */
  10299. export class DynamicTexture extends Texture {
  10300. private _generateMipMaps;
  10301. private _canvas;
  10302. private _context;
  10303. private _engine;
  10304. /**
  10305. * Creates a DynamicTexture
  10306. * @param name defines the name of the texture
  10307. * @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
  10308. * @param scene defines the scene where you want the texture
  10309. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10310. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10311. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10312. */
  10313. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10314. /**
  10315. * Get the current class name of the texture useful for serialization or dynamic coding.
  10316. * @returns "DynamicTexture"
  10317. */
  10318. getClassName(): string;
  10319. /**
  10320. * Gets the current state of canRescale
  10321. */
  10322. get canRescale(): boolean;
  10323. private _recreate;
  10324. /**
  10325. * Scales the texture
  10326. * @param ratio the scale factor to apply to both width and height
  10327. */
  10328. scale(ratio: number): void;
  10329. /**
  10330. * Resizes the texture
  10331. * @param width the new width
  10332. * @param height the new height
  10333. */
  10334. scaleTo(width: number, height: number): void;
  10335. /**
  10336. * Gets the context of the canvas used by the texture
  10337. * @returns the canvas context of the dynamic texture
  10338. */
  10339. getContext(): CanvasRenderingContext2D;
  10340. /**
  10341. * Clears the texture
  10342. */
  10343. clear(): void;
  10344. /**
  10345. * Updates the texture
  10346. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10347. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10348. */
  10349. update(invertY?: boolean, premulAlpha?: boolean): void;
  10350. /**
  10351. * Draws text onto the texture
  10352. * @param text defines the text to be drawn
  10353. * @param x defines the placement of the text from the left
  10354. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10355. * @param font defines the font to be used with font-style, font-size, font-name
  10356. * @param color defines the color used for the text
  10357. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10358. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10359. * @param update defines whether texture is immediately update (default is true)
  10360. */
  10361. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10362. /**
  10363. * Clones the texture
  10364. * @returns the clone of the texture.
  10365. */
  10366. clone(): DynamicTexture;
  10367. /**
  10368. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10369. * @returns a serialized dynamic texture object
  10370. */
  10371. serialize(): any;
  10372. /** @hidden */
  10373. _rebuild(): void;
  10374. }
  10375. }
  10376. declare module BABYLON {
  10377. interface Engine {
  10378. /**
  10379. * Creates a raw texture
  10380. * @param data defines the data to store in the texture
  10381. * @param width defines the width of the texture
  10382. * @param height defines the height of the texture
  10383. * @param format defines the format of the data
  10384. * @param generateMipMaps defines if the engine should generate the mip levels
  10385. * @param invertY defines if data must be stored with Y axis inverted
  10386. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10387. * @param compression defines the compression used (null by default)
  10388. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10389. * @returns the raw texture inside an InternalTexture
  10390. */
  10391. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10392. /**
  10393. * Update a raw texture
  10394. * @param texture defines the texture to update
  10395. * @param data defines the data to store in the texture
  10396. * @param format defines the format of the data
  10397. * @param invertY defines if data must be stored with Y axis inverted
  10398. */
  10399. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10400. /**
  10401. * Update a raw texture
  10402. * @param texture defines the texture to update
  10403. * @param data defines the data to store in the texture
  10404. * @param format defines the format of the data
  10405. * @param invertY defines if data must be stored with Y axis inverted
  10406. * @param compression defines the compression used (null by default)
  10407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10408. */
  10409. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10410. /**
  10411. * Creates a new raw cube texture
  10412. * @param data defines the array of data to use to create each face
  10413. * @param size defines the size of the textures
  10414. * @param format defines the format of the data
  10415. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10416. * @param generateMipMaps defines if the engine should generate the mip levels
  10417. * @param invertY defines if data must be stored with Y axis inverted
  10418. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10419. * @param compression defines the compression used (null by default)
  10420. * @returns the cube texture as an InternalTexture
  10421. */
  10422. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10423. /**
  10424. * Update a raw cube texture
  10425. * @param texture defines the texture to udpdate
  10426. * @param data defines the data to store
  10427. * @param format defines the data format
  10428. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10429. * @param invertY defines if data must be stored with Y axis inverted
  10430. */
  10431. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10432. /**
  10433. * Update a raw cube texture
  10434. * @param texture defines the texture to udpdate
  10435. * @param data defines the data to store
  10436. * @param format defines the data format
  10437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10438. * @param invertY defines if data must be stored with Y axis inverted
  10439. * @param compression defines the compression used (null by default)
  10440. */
  10441. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10442. /**
  10443. * Update a raw cube texture
  10444. * @param texture defines the texture to udpdate
  10445. * @param data defines the data to store
  10446. * @param format defines the data format
  10447. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10448. * @param invertY defines if data must be stored with Y axis inverted
  10449. * @param compression defines the compression used (null by default)
  10450. * @param level defines which level of the texture to update
  10451. */
  10452. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10453. /**
  10454. * Creates a new raw cube texture from a specified url
  10455. * @param url defines the url where the data is located
  10456. * @param scene defines the current scene
  10457. * @param size defines the size of the textures
  10458. * @param format defines the format of the data
  10459. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10460. * @param noMipmap defines if the engine should avoid generating the mip levels
  10461. * @param callback defines a callback used to extract texture data from loaded data
  10462. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10463. * @param onLoad defines a callback called when texture is loaded
  10464. * @param onError defines a callback called if there is an error
  10465. * @returns the cube texture as an InternalTexture
  10466. */
  10467. 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;
  10468. /**
  10469. * Creates a new raw cube texture from a specified url
  10470. * @param url defines the url where the data is located
  10471. * @param scene defines the current scene
  10472. * @param size defines the size of the textures
  10473. * @param format defines the format of the data
  10474. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10475. * @param noMipmap defines if the engine should avoid generating the mip levels
  10476. * @param callback defines a callback used to extract texture data from loaded data
  10477. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10478. * @param onLoad defines a callback called when texture is loaded
  10479. * @param onError defines a callback called if there is an error
  10480. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10481. * @param invertY defines if data must be stored with Y axis inverted
  10482. * @returns the cube texture as an InternalTexture
  10483. */
  10484. 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;
  10485. /**
  10486. * Creates a new raw 3D texture
  10487. * @param data defines the data used to create the texture
  10488. * @param width defines the width of the texture
  10489. * @param height defines the height of the texture
  10490. * @param depth defines the depth of the texture
  10491. * @param format defines the format of the texture
  10492. * @param generateMipMaps defines if the engine must generate mip levels
  10493. * @param invertY defines if data must be stored with Y axis inverted
  10494. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10495. * @param compression defines the compressed used (can be null)
  10496. * @param textureType defines the compressed used (can be null)
  10497. * @returns a new raw 3D texture (stored in an InternalTexture)
  10498. */
  10499. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10500. /**
  10501. * Update a raw 3D texture
  10502. * @param texture defines the texture to update
  10503. * @param data defines the data to store
  10504. * @param format defines the data format
  10505. * @param invertY defines if data must be stored with Y axis inverted
  10506. */
  10507. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10508. /**
  10509. * Update a raw 3D texture
  10510. * @param texture defines the texture to update
  10511. * @param data defines the data to store
  10512. * @param format defines the data format
  10513. * @param invertY defines if data must be stored with Y axis inverted
  10514. * @param compression defines the used compression (can be null)
  10515. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10516. */
  10517. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10518. /**
  10519. * Creates a new raw 2D array texture
  10520. * @param data defines the data used to create the texture
  10521. * @param width defines the width of the texture
  10522. * @param height defines the height of the texture
  10523. * @param depth defines the number of layers of the texture
  10524. * @param format defines the format of the texture
  10525. * @param generateMipMaps defines if the engine must generate mip levels
  10526. * @param invertY defines if data must be stored with Y axis inverted
  10527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10528. * @param compression defines the compressed used (can be null)
  10529. * @param textureType defines the compressed used (can be null)
  10530. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10531. */
  10532. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10533. /**
  10534. * Update a raw 2D array texture
  10535. * @param texture defines the texture to update
  10536. * @param data defines the data to store
  10537. * @param format defines the data format
  10538. * @param invertY defines if data must be stored with Y axis inverted
  10539. */
  10540. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10541. /**
  10542. * Update a raw 2D array texture
  10543. * @param texture defines the texture to update
  10544. * @param data defines the data to store
  10545. * @param format defines the data format
  10546. * @param invertY defines if data must be stored with Y axis inverted
  10547. * @param compression defines the used compression (can be null)
  10548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10549. */
  10550. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10551. }
  10552. }
  10553. declare module BABYLON {
  10554. /**
  10555. * Raw texture can help creating a texture directly from an array of data.
  10556. * This can be super useful if you either get the data from an uncompressed source or
  10557. * if you wish to create your texture pixel by pixel.
  10558. */
  10559. export class RawTexture extends Texture {
  10560. /**
  10561. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10562. */
  10563. format: number;
  10564. private _engine;
  10565. /**
  10566. * Instantiates a new RawTexture.
  10567. * Raw texture can help creating a texture directly from an array of data.
  10568. * This can be super useful if you either get the data from an uncompressed source or
  10569. * if you wish to create your texture pixel by pixel.
  10570. * @param data define the array of data to use to create the texture
  10571. * @param width define the width of the texture
  10572. * @param height define the height of the texture
  10573. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10574. * @param scene define the scene the texture belongs to
  10575. * @param generateMipMaps define whether mip maps should be generated or not
  10576. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10577. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10578. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10579. */
  10580. constructor(data: ArrayBufferView, width: number, height: number,
  10581. /**
  10582. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10583. */
  10584. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10585. /**
  10586. * Updates the texture underlying data.
  10587. * @param data Define the new data of the texture
  10588. */
  10589. update(data: ArrayBufferView): void;
  10590. /**
  10591. * Creates a luminance texture from some data.
  10592. * @param data Define the texture data
  10593. * @param width Define the width of the texture
  10594. * @param height Define the height of the texture
  10595. * @param scene Define the scene the texture belongs to
  10596. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10599. * @returns the luminance texture
  10600. */
  10601. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10602. /**
  10603. * Creates a luminance alpha texture from some data.
  10604. * @param data Define the texture data
  10605. * @param width Define the width of the texture
  10606. * @param height Define the height of the texture
  10607. * @param scene Define the scene the texture belongs to
  10608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10611. * @returns the luminance alpha texture
  10612. */
  10613. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10614. /**
  10615. * Creates an alpha texture from some data.
  10616. * @param data Define the texture data
  10617. * @param width Define the width of the texture
  10618. * @param height Define the height of the texture
  10619. * @param scene Define the scene the texture belongs to
  10620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10623. * @returns the alpha texture
  10624. */
  10625. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10626. /**
  10627. * Creates a RGB texture from some data.
  10628. * @param data Define the texture data
  10629. * @param width Define the width of the texture
  10630. * @param height Define the height of the texture
  10631. * @param scene Define the scene the texture belongs to
  10632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10635. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10636. * @returns the RGB alpha texture
  10637. */
  10638. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10639. /**
  10640. * Creates a RGBA texture from some data.
  10641. * @param data Define the texture data
  10642. * @param width Define the width of the texture
  10643. * @param height Define the height of the texture
  10644. * @param scene Define the scene the texture belongs to
  10645. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10649. * @returns the RGBA texture
  10650. */
  10651. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10652. /**
  10653. * Creates a R texture from some data.
  10654. * @param data Define the texture data
  10655. * @param width Define the width of the texture
  10656. * @param height Define the height of the texture
  10657. * @param scene Define the scene the texture belongs to
  10658. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10661. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10662. * @returns the R texture
  10663. */
  10664. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10665. }
  10666. }
  10667. declare module BABYLON {
  10668. interface AbstractScene {
  10669. /**
  10670. * The list of procedural textures added to the scene
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10672. */
  10673. proceduralTextures: Array<ProceduralTexture>;
  10674. }
  10675. /**
  10676. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10677. * in a given scene.
  10678. */
  10679. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10680. /**
  10681. * The component name helpfull to identify the component in the list of scene components.
  10682. */
  10683. readonly name: string;
  10684. /**
  10685. * The scene the component belongs to.
  10686. */
  10687. scene: Scene;
  10688. /**
  10689. * Creates a new instance of the component for the given scene
  10690. * @param scene Defines the scene to register the component in
  10691. */
  10692. constructor(scene: Scene);
  10693. /**
  10694. * Registers the component in a given scene
  10695. */
  10696. register(): void;
  10697. /**
  10698. * Rebuilds the elements related to this component in case of
  10699. * context lost for instance.
  10700. */
  10701. rebuild(): void;
  10702. /**
  10703. * Disposes the component and the associated ressources.
  10704. */
  10705. dispose(): void;
  10706. private _beforeClear;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. interface ThinEngine {
  10711. /**
  10712. * Creates a new render target cube texture
  10713. * @param size defines the size of the texture
  10714. * @param options defines the options used to create the texture
  10715. * @returns a new render target cube texture stored in an InternalTexture
  10716. */
  10717. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10718. }
  10719. }
  10720. declare module BABYLON {
  10721. /** @hidden */
  10722. export var proceduralVertexShader: {
  10723. name: string;
  10724. shader: string;
  10725. };
  10726. }
  10727. declare module BABYLON {
  10728. /**
  10729. * 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.
  10730. * This is the base class of any Procedural texture and contains most of the shareable code.
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10732. */
  10733. export class ProceduralTexture extends Texture {
  10734. isCube: boolean;
  10735. /**
  10736. * Define if the texture is enabled or not (disabled texture will not render)
  10737. */
  10738. isEnabled: boolean;
  10739. /**
  10740. * Define if the texture must be cleared before rendering (default is true)
  10741. */
  10742. autoClear: boolean;
  10743. /**
  10744. * Callback called when the texture is generated
  10745. */
  10746. onGenerated: () => void;
  10747. /**
  10748. * Event raised when the texture is generated
  10749. */
  10750. onGeneratedObservable: Observable<ProceduralTexture>;
  10751. /** @hidden */
  10752. _generateMipMaps: boolean;
  10753. /** @hidden **/
  10754. _effect: Effect;
  10755. /** @hidden */
  10756. _textures: {
  10757. [key: string]: Texture;
  10758. };
  10759. private _size;
  10760. private _currentRefreshId;
  10761. private _frameId;
  10762. private _refreshRate;
  10763. private _vertexBuffers;
  10764. private _indexBuffer;
  10765. private _uniforms;
  10766. private _samplers;
  10767. private _fragment;
  10768. private _floats;
  10769. private _ints;
  10770. private _floatsArrays;
  10771. private _colors3;
  10772. private _colors4;
  10773. private _vectors2;
  10774. private _vectors3;
  10775. private _matrices;
  10776. private _fallbackTexture;
  10777. private _fallbackTextureUsed;
  10778. private _engine;
  10779. private _cachedDefines;
  10780. private _contentUpdateId;
  10781. private _contentData;
  10782. /**
  10783. * Instantiates a new procedural texture.
  10784. * 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.
  10785. * This is the base class of any Procedural texture and contains most of the shareable code.
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10787. * @param name Define the name of the texture
  10788. * @param size Define the size of the texture to create
  10789. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10790. * @param scene Define the scene the texture belongs to
  10791. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10792. * @param generateMipMaps Define if the texture should creates mip maps or not
  10793. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10794. */
  10795. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10796. /**
  10797. * The effect that is created when initializing the post process.
  10798. * @returns The created effect corresponding the the postprocess.
  10799. */
  10800. getEffect(): Effect;
  10801. /**
  10802. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10803. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10804. */
  10805. getContent(): Nullable<ArrayBufferView>;
  10806. private _createIndexBuffer;
  10807. /** @hidden */
  10808. _rebuild(): void;
  10809. /**
  10810. * Resets the texture in order to recreate its associated resources.
  10811. * This can be called in case of context loss
  10812. */
  10813. reset(): void;
  10814. protected _getDefines(): string;
  10815. /**
  10816. * Is the texture ready to be used ? (rendered at least once)
  10817. * @returns true if ready, otherwise, false.
  10818. */
  10819. isReady(): boolean;
  10820. /**
  10821. * Resets the refresh counter of the texture and start bak from scratch.
  10822. * Could be useful to regenerate the texture if it is setup to render only once.
  10823. */
  10824. resetRefreshCounter(): void;
  10825. /**
  10826. * Set the fragment shader to use in order to render the texture.
  10827. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10828. */
  10829. setFragment(fragment: any): void;
  10830. /**
  10831. * Define the refresh rate of the texture or the rendering frequency.
  10832. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10833. */
  10834. get refreshRate(): number;
  10835. set refreshRate(value: number);
  10836. /** @hidden */
  10837. _shouldRender(): boolean;
  10838. /**
  10839. * Get the size the texture is rendering at.
  10840. * @returns the size (texture is always squared)
  10841. */
  10842. getRenderSize(): number;
  10843. /**
  10844. * Resize the texture to new value.
  10845. * @param size Define the new size the texture should have
  10846. * @param generateMipMaps Define whether the new texture should create mip maps
  10847. */
  10848. resize(size: number, generateMipMaps: boolean): void;
  10849. private _checkUniform;
  10850. /**
  10851. * Set a texture in the shader program used to render.
  10852. * @param name Define the name of the uniform samplers as defined in the shader
  10853. * @param texture Define the texture to bind to this sampler
  10854. * @return the texture itself allowing "fluent" like uniform updates
  10855. */
  10856. setTexture(name: string, texture: Texture): ProceduralTexture;
  10857. /**
  10858. * Set a float in the shader.
  10859. * @param name Define the name of the uniform as defined in the shader
  10860. * @param value Define the value to give to the uniform
  10861. * @return the texture itself allowing "fluent" like uniform updates
  10862. */
  10863. setFloat(name: string, value: number): ProceduralTexture;
  10864. /**
  10865. * Set a int in the shader.
  10866. * @param name Define the name of the uniform as defined in the shader
  10867. * @param value Define the value to give to the uniform
  10868. * @return the texture itself allowing "fluent" like uniform updates
  10869. */
  10870. setInt(name: string, value: number): ProceduralTexture;
  10871. /**
  10872. * Set an array of floats in the shader.
  10873. * @param name Define the name of the uniform as defined in the shader
  10874. * @param value Define the value to give to the uniform
  10875. * @return the texture itself allowing "fluent" like uniform updates
  10876. */
  10877. setFloats(name: string, value: number[]): ProceduralTexture;
  10878. /**
  10879. * Set a vec3 in the shader from a Color3.
  10880. * @param name Define the name of the uniform as defined in the shader
  10881. * @param value Define the value to give to the uniform
  10882. * @return the texture itself allowing "fluent" like uniform updates
  10883. */
  10884. setColor3(name: string, value: Color3): ProceduralTexture;
  10885. /**
  10886. * Set a vec4 in the shader from a Color4.
  10887. * @param name Define the name of the uniform as defined in the shader
  10888. * @param value Define the value to give to the uniform
  10889. * @return the texture itself allowing "fluent" like uniform updates
  10890. */
  10891. setColor4(name: string, value: Color4): ProceduralTexture;
  10892. /**
  10893. * Set a vec2 in the shader from a Vector2.
  10894. * @param name Define the name of the uniform as defined in the shader
  10895. * @param value Define the value to give to the uniform
  10896. * @return the texture itself allowing "fluent" like uniform updates
  10897. */
  10898. setVector2(name: string, value: Vector2): ProceduralTexture;
  10899. /**
  10900. * Set a vec3 in the shader from a Vector3.
  10901. * @param name Define the name of the uniform as defined in the shader
  10902. * @param value Define the value to give to the uniform
  10903. * @return the texture itself allowing "fluent" like uniform updates
  10904. */
  10905. setVector3(name: string, value: Vector3): ProceduralTexture;
  10906. /**
  10907. * Set a mat4 in the shader from a MAtrix.
  10908. * @param name Define the name of the uniform as defined in the shader
  10909. * @param value Define the value to give to the uniform
  10910. * @return the texture itself allowing "fluent" like uniform updates
  10911. */
  10912. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10913. /**
  10914. * Render the texture to its associated render target.
  10915. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10916. */
  10917. render(useCameraPostProcess?: boolean): void;
  10918. /**
  10919. * Clone the texture.
  10920. * @returns the cloned texture
  10921. */
  10922. clone(): ProceduralTexture;
  10923. /**
  10924. * Dispose the texture and release its asoociated resources.
  10925. */
  10926. dispose(): void;
  10927. }
  10928. }
  10929. declare module BABYLON {
  10930. /**
  10931. * This represents the base class for particle system in Babylon.
  10932. * 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.
  10933. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10934. * @example https://doc.babylonjs.com/babylon101/particles
  10935. */
  10936. export class BaseParticleSystem {
  10937. /**
  10938. * Source color is added to the destination color without alpha affecting the result
  10939. */
  10940. static BLENDMODE_ONEONE: number;
  10941. /**
  10942. * Blend current color and particle color using particle’s alpha
  10943. */
  10944. static BLENDMODE_STANDARD: number;
  10945. /**
  10946. * Add current color and particle color multiplied by particle’s alpha
  10947. */
  10948. static BLENDMODE_ADD: number;
  10949. /**
  10950. * Multiply current color with particle color
  10951. */
  10952. static BLENDMODE_MULTIPLY: number;
  10953. /**
  10954. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10955. */
  10956. static BLENDMODE_MULTIPLYADD: number;
  10957. /**
  10958. * List of animations used by the particle system.
  10959. */
  10960. animations: Animation[];
  10961. /**
  10962. * The id of the Particle system.
  10963. */
  10964. id: string;
  10965. /**
  10966. * The friendly name of the Particle system.
  10967. */
  10968. name: string;
  10969. /**
  10970. * The rendering group used by the Particle system to chose when to render.
  10971. */
  10972. renderingGroupId: number;
  10973. /**
  10974. * The emitter represents the Mesh or position we are attaching the particle system to.
  10975. */
  10976. emitter: Nullable<AbstractMesh | Vector3>;
  10977. /**
  10978. * The maximum number of particles to emit per frame
  10979. */
  10980. emitRate: number;
  10981. /**
  10982. * If you want to launch only a few particles at once, that can be done, as well.
  10983. */
  10984. manualEmitCount: number;
  10985. /**
  10986. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  10987. */
  10988. updateSpeed: number;
  10989. /**
  10990. * The amount of time the particle system is running (depends of the overall update speed).
  10991. */
  10992. targetStopDuration: number;
  10993. /**
  10994. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  10995. */
  10996. disposeOnStop: boolean;
  10997. /**
  10998. * Minimum power of emitting particles.
  10999. */
  11000. minEmitPower: number;
  11001. /**
  11002. * Maximum power of emitting particles.
  11003. */
  11004. maxEmitPower: number;
  11005. /**
  11006. * Minimum life time of emitting particles.
  11007. */
  11008. minLifeTime: number;
  11009. /**
  11010. * Maximum life time of emitting particles.
  11011. */
  11012. maxLifeTime: number;
  11013. /**
  11014. * Minimum Size of emitting particles.
  11015. */
  11016. minSize: number;
  11017. /**
  11018. * Maximum Size of emitting particles.
  11019. */
  11020. maxSize: number;
  11021. /**
  11022. * Minimum scale of emitting particles on X axis.
  11023. */
  11024. minScaleX: number;
  11025. /**
  11026. * Maximum scale of emitting particles on X axis.
  11027. */
  11028. maxScaleX: number;
  11029. /**
  11030. * Minimum scale of emitting particles on Y axis.
  11031. */
  11032. minScaleY: number;
  11033. /**
  11034. * Maximum scale of emitting particles on Y axis.
  11035. */
  11036. maxScaleY: number;
  11037. /**
  11038. * Gets or sets the minimal initial rotation in radians.
  11039. */
  11040. minInitialRotation: number;
  11041. /**
  11042. * Gets or sets the maximal initial rotation in radians.
  11043. */
  11044. maxInitialRotation: number;
  11045. /**
  11046. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11047. */
  11048. minAngularSpeed: number;
  11049. /**
  11050. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11051. */
  11052. maxAngularSpeed: number;
  11053. /**
  11054. * The texture used to render each particle. (this can be a spritesheet)
  11055. */
  11056. particleTexture: Nullable<Texture>;
  11057. /**
  11058. * The layer mask we are rendering the particles through.
  11059. */
  11060. layerMask: number;
  11061. /**
  11062. * This can help using your own shader to render the particle system.
  11063. * The according effect will be created
  11064. */
  11065. customShader: any;
  11066. /**
  11067. * By default particle system starts as soon as they are created. This prevents the
  11068. * automatic start to happen and let you decide when to start emitting particles.
  11069. */
  11070. preventAutoStart: boolean;
  11071. private _noiseTexture;
  11072. /**
  11073. * Gets or sets a texture used to add random noise to particle positions
  11074. */
  11075. get noiseTexture(): Nullable<ProceduralTexture>;
  11076. set noiseTexture(value: Nullable<ProceduralTexture>);
  11077. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11078. noiseStrength: Vector3;
  11079. /**
  11080. * Callback triggered when the particle animation is ending.
  11081. */
  11082. onAnimationEnd: Nullable<() => void>;
  11083. /**
  11084. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11085. */
  11086. blendMode: number;
  11087. /**
  11088. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11089. * to override the particles.
  11090. */
  11091. forceDepthWrite: boolean;
  11092. /** 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 */
  11093. preWarmCycles: number;
  11094. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11095. preWarmStepOffset: number;
  11096. /**
  11097. * 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)
  11098. */
  11099. spriteCellChangeSpeed: number;
  11100. /**
  11101. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11102. */
  11103. startSpriteCellID: number;
  11104. /**
  11105. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11106. */
  11107. endSpriteCellID: number;
  11108. /**
  11109. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11110. */
  11111. spriteCellWidth: number;
  11112. /**
  11113. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11114. */
  11115. spriteCellHeight: number;
  11116. /**
  11117. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11118. */
  11119. spriteRandomStartCell: boolean;
  11120. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11121. translationPivot: Vector2;
  11122. /** @hidden */
  11123. protected _isAnimationSheetEnabled: boolean;
  11124. /**
  11125. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11126. */
  11127. beginAnimationOnStart: boolean;
  11128. /**
  11129. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11130. */
  11131. beginAnimationFrom: number;
  11132. /**
  11133. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11134. */
  11135. beginAnimationTo: number;
  11136. /**
  11137. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11138. */
  11139. beginAnimationLoop: boolean;
  11140. /**
  11141. * Gets or sets a world offset applied to all particles
  11142. */
  11143. worldOffset: Vector3;
  11144. /**
  11145. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11146. */
  11147. get isAnimationSheetEnabled(): boolean;
  11148. set isAnimationSheetEnabled(value: boolean);
  11149. /**
  11150. * Get hosting scene
  11151. * @returns the scene
  11152. */
  11153. getScene(): Scene;
  11154. /**
  11155. * You can use gravity if you want to give an orientation to your particles.
  11156. */
  11157. gravity: Vector3;
  11158. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11159. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11160. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11161. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11162. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11163. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11164. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11165. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11166. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11167. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11168. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11169. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11170. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11171. /**
  11172. * Defines the delay in milliseconds before starting the system (0 by default)
  11173. */
  11174. startDelay: number;
  11175. /**
  11176. * Gets the current list of drag gradients.
  11177. * You must use addDragGradient and removeDragGradient to udpate this list
  11178. * @returns the list of drag gradients
  11179. */
  11180. getDragGradients(): Nullable<Array<FactorGradient>>;
  11181. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11182. limitVelocityDamping: number;
  11183. /**
  11184. * Gets the current list of limit velocity gradients.
  11185. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11186. * @returns the list of limit velocity gradients
  11187. */
  11188. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11189. /**
  11190. * Gets the current list of color gradients.
  11191. * You must use addColorGradient and removeColorGradient to udpate this list
  11192. * @returns the list of color gradients
  11193. */
  11194. getColorGradients(): Nullable<Array<ColorGradient>>;
  11195. /**
  11196. * Gets the current list of size gradients.
  11197. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11198. * @returns the list of size gradients
  11199. */
  11200. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11201. /**
  11202. * Gets the current list of color remap gradients.
  11203. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11204. * @returns the list of color remap gradients
  11205. */
  11206. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11207. /**
  11208. * Gets the current list of alpha remap gradients.
  11209. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11210. * @returns the list of alpha remap gradients
  11211. */
  11212. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11213. /**
  11214. * Gets the current list of life time gradients.
  11215. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11216. * @returns the list of life time gradients
  11217. */
  11218. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11219. /**
  11220. * Gets the current list of angular speed gradients.
  11221. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11222. * @returns the list of angular speed gradients
  11223. */
  11224. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11225. /**
  11226. * Gets the current list of velocity gradients.
  11227. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11228. * @returns the list of velocity gradients
  11229. */
  11230. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11231. /**
  11232. * Gets the current list of start size gradients.
  11233. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11234. * @returns the list of start size gradients
  11235. */
  11236. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11237. /**
  11238. * Gets the current list of emit rate gradients.
  11239. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11240. * @returns the list of emit rate gradients
  11241. */
  11242. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11243. /**
  11244. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11245. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11246. */
  11247. get direction1(): Vector3;
  11248. set direction1(value: Vector3);
  11249. /**
  11250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11252. */
  11253. get direction2(): Vector3;
  11254. set direction2(value: Vector3);
  11255. /**
  11256. * 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.
  11257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11258. */
  11259. get minEmitBox(): Vector3;
  11260. set minEmitBox(value: Vector3);
  11261. /**
  11262. * 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.
  11263. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11264. */
  11265. get maxEmitBox(): Vector3;
  11266. set maxEmitBox(value: Vector3);
  11267. /**
  11268. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11269. */
  11270. color1: Color4;
  11271. /**
  11272. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11273. */
  11274. color2: Color4;
  11275. /**
  11276. * Color the particle will have at the end of its lifetime
  11277. */
  11278. colorDead: Color4;
  11279. /**
  11280. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11281. */
  11282. textureMask: Color4;
  11283. /**
  11284. * The particle emitter type defines the emitter used by the particle system.
  11285. * It can be for example box, sphere, or cone...
  11286. */
  11287. particleEmitterType: IParticleEmitterType;
  11288. /** @hidden */
  11289. _isSubEmitter: boolean;
  11290. /**
  11291. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11292. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11293. */
  11294. billboardMode: number;
  11295. protected _isBillboardBased: boolean;
  11296. /**
  11297. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11298. */
  11299. get isBillboardBased(): boolean;
  11300. set isBillboardBased(value: boolean);
  11301. /**
  11302. * The scene the particle system belongs to.
  11303. */
  11304. protected _scene: Scene;
  11305. /**
  11306. * Local cache of defines for image processing.
  11307. */
  11308. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11309. /**
  11310. * Default configuration related to image processing available in the standard Material.
  11311. */
  11312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11313. /**
  11314. * Gets the image processing configuration used either in this material.
  11315. */
  11316. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11317. /**
  11318. * Sets the Default image processing configuration used either in the this material.
  11319. *
  11320. * If sets to null, the scene one is in use.
  11321. */
  11322. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11323. /**
  11324. * Attaches a new image processing configuration to the Standard Material.
  11325. * @param configuration
  11326. */
  11327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11328. /** @hidden */
  11329. protected _reset(): void;
  11330. /** @hidden */
  11331. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11332. /**
  11333. * Instantiates a particle system.
  11334. * 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.
  11335. * @param name The name of the particle system
  11336. */
  11337. constructor(name: string);
  11338. /**
  11339. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11342. * @returns the emitter
  11343. */
  11344. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11345. /**
  11346. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11347. * @param radius The radius of the hemisphere to emit from
  11348. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11349. * @returns the emitter
  11350. */
  11351. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11352. /**
  11353. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11354. * @param radius The radius of the sphere to emit from
  11355. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11356. * @returns the emitter
  11357. */
  11358. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11359. /**
  11360. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11361. * @param radius The radius of the sphere to emit from
  11362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11364. * @returns the emitter
  11365. */
  11366. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11367. /**
  11368. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11369. * @param radius The radius of the emission cylinder
  11370. * @param height The height of the emission cylinder
  11371. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11372. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11373. * @returns the emitter
  11374. */
  11375. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11376. /**
  11377. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11378. * @param radius The radius of the cylinder to emit from
  11379. * @param height The height of the emission cylinder
  11380. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11383. * @returns the emitter
  11384. */
  11385. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11386. /**
  11387. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11388. * @param radius The radius of the cone to emit from
  11389. * @param angle The base angle of the cone
  11390. * @returns the emitter
  11391. */
  11392. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11393. /**
  11394. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11397. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11398. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11399. * @returns the emitter
  11400. */
  11401. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11402. }
  11403. }
  11404. declare module BABYLON {
  11405. /**
  11406. * Type of sub emitter
  11407. */
  11408. export enum SubEmitterType {
  11409. /**
  11410. * Attached to the particle over it's lifetime
  11411. */
  11412. ATTACHED = 0,
  11413. /**
  11414. * Created when the particle dies
  11415. */
  11416. END = 1
  11417. }
  11418. /**
  11419. * Sub emitter class used to emit particles from an existing particle
  11420. */
  11421. export class SubEmitter {
  11422. /**
  11423. * the particle system to be used by the sub emitter
  11424. */
  11425. particleSystem: ParticleSystem;
  11426. /**
  11427. * Type of the submitter (Default: END)
  11428. */
  11429. type: SubEmitterType;
  11430. /**
  11431. * 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)
  11432. * Note: This only is supported when using an emitter of type Mesh
  11433. */
  11434. inheritDirection: boolean;
  11435. /**
  11436. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11437. */
  11438. inheritedVelocityAmount: number;
  11439. /**
  11440. * Creates a sub emitter
  11441. * @param particleSystem the particle system to be used by the sub emitter
  11442. */
  11443. constructor(
  11444. /**
  11445. * the particle system to be used by the sub emitter
  11446. */
  11447. particleSystem: ParticleSystem);
  11448. /**
  11449. * Clones the sub emitter
  11450. * @returns the cloned sub emitter
  11451. */
  11452. clone(): SubEmitter;
  11453. /**
  11454. * Serialize current object to a JSON object
  11455. * @returns the serialized object
  11456. */
  11457. serialize(): any;
  11458. /** @hidden */
  11459. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11460. /**
  11461. * Creates a new SubEmitter from a serialized JSON version
  11462. * @param serializationObject defines the JSON object to read from
  11463. * @param scene defines the hosting scene
  11464. * @param rootUrl defines the rootUrl for data loading
  11465. * @returns a new SubEmitter
  11466. */
  11467. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11468. /** Release associated resources */
  11469. dispose(): void;
  11470. }
  11471. }
  11472. declare module BABYLON {
  11473. /** @hidden */
  11474. export var imageProcessingDeclaration: {
  11475. name: string;
  11476. shader: string;
  11477. };
  11478. }
  11479. declare module BABYLON {
  11480. /** @hidden */
  11481. export var imageProcessingFunctions: {
  11482. name: string;
  11483. shader: string;
  11484. };
  11485. }
  11486. declare module BABYLON {
  11487. /** @hidden */
  11488. export var particlesPixelShader: {
  11489. name: string;
  11490. shader: string;
  11491. };
  11492. }
  11493. declare module BABYLON {
  11494. /** @hidden */
  11495. export var particlesVertexShader: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module BABYLON {
  11501. /**
  11502. * This represents a particle system in Babylon.
  11503. * 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.
  11504. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11505. * @example https://doc.babylonjs.com/babylon101/particles
  11506. */
  11507. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11508. /**
  11509. * Billboard mode will only apply to Y axis
  11510. */
  11511. static readonly BILLBOARDMODE_Y: number;
  11512. /**
  11513. * Billboard mode will apply to all axes
  11514. */
  11515. static readonly BILLBOARDMODE_ALL: number;
  11516. /**
  11517. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11518. */
  11519. static readonly BILLBOARDMODE_STRETCHED: number;
  11520. /**
  11521. * This function can be defined to provide custom update for active particles.
  11522. * This function will be called instead of regular update (age, position, color, etc.).
  11523. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11524. */
  11525. updateFunction: (particles: Particle[]) => void;
  11526. private _emitterWorldMatrix;
  11527. /**
  11528. * This function can be defined to specify initial direction for every new particle.
  11529. * It by default use the emitterType defined function
  11530. */
  11531. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11532. /**
  11533. * This function can be defined to specify initial position for every new particle.
  11534. * It by default use the emitterType defined function
  11535. */
  11536. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11537. /**
  11538. * @hidden
  11539. */
  11540. _inheritedVelocityOffset: Vector3;
  11541. /**
  11542. * An event triggered when the system is disposed
  11543. */
  11544. onDisposeObservable: Observable<ParticleSystem>;
  11545. private _onDisposeObserver;
  11546. /**
  11547. * Sets a callback that will be triggered when the system is disposed
  11548. */
  11549. set onDispose(callback: () => void);
  11550. private _particles;
  11551. private _epsilon;
  11552. private _capacity;
  11553. private _stockParticles;
  11554. private _newPartsExcess;
  11555. private _vertexData;
  11556. private _vertexBuffer;
  11557. private _vertexBuffers;
  11558. private _spriteBuffer;
  11559. private _indexBuffer;
  11560. private _effect;
  11561. private _customEffect;
  11562. private _cachedDefines;
  11563. private _scaledColorStep;
  11564. private _colorDiff;
  11565. private _scaledDirection;
  11566. private _scaledGravity;
  11567. private _currentRenderId;
  11568. private _alive;
  11569. private _useInstancing;
  11570. private _started;
  11571. private _stopped;
  11572. private _actualFrame;
  11573. private _scaledUpdateSpeed;
  11574. private _vertexBufferSize;
  11575. /** @hidden */
  11576. _currentEmitRateGradient: Nullable<FactorGradient>;
  11577. /** @hidden */
  11578. _currentEmitRate1: number;
  11579. /** @hidden */
  11580. _currentEmitRate2: number;
  11581. /** @hidden */
  11582. _currentStartSizeGradient: Nullable<FactorGradient>;
  11583. /** @hidden */
  11584. _currentStartSize1: number;
  11585. /** @hidden */
  11586. _currentStartSize2: number;
  11587. private readonly _rawTextureWidth;
  11588. private _rampGradientsTexture;
  11589. private _useRampGradients;
  11590. /** Gets or sets a boolean indicating that ramp gradients must be used
  11591. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11592. */
  11593. get useRampGradients(): boolean;
  11594. set useRampGradients(value: boolean);
  11595. /**
  11596. * 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.
  11597. * 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: [])
  11598. */
  11599. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11600. private _subEmitters;
  11601. /**
  11602. * @hidden
  11603. * If the particle systems emitter should be disposed when the particle system is disposed
  11604. */
  11605. _disposeEmitterOnDispose: boolean;
  11606. /**
  11607. * The current active Sub-systems, this property is used by the root particle system only.
  11608. */
  11609. activeSubSystems: Array<ParticleSystem>;
  11610. private _rootParticleSystem;
  11611. /**
  11612. * Gets the current list of active particles
  11613. */
  11614. get particles(): Particle[];
  11615. /**
  11616. * Returns the string "ParticleSystem"
  11617. * @returns a string containing the class name
  11618. */
  11619. getClassName(): string;
  11620. /**
  11621. * Instantiates a particle system.
  11622. * 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.
  11623. * @param name The name of the particle system
  11624. * @param capacity The max number of particles alive at the same time
  11625. * @param scene The scene the particle system belongs to
  11626. * @param customEffect a custom effect used to change the way particles are rendered by default
  11627. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11628. * @param epsilon Offset used to render the particles
  11629. */
  11630. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11631. private _addFactorGradient;
  11632. private _removeFactorGradient;
  11633. /**
  11634. * Adds a new life time gradient
  11635. * @param gradient defines the gradient to use (between 0 and 1)
  11636. * @param factor defines the life time factor to affect to the specified gradient
  11637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11638. * @returns the current particle system
  11639. */
  11640. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11641. /**
  11642. * Remove a specific life time gradient
  11643. * @param gradient defines the gradient to remove
  11644. * @returns the current particle system
  11645. */
  11646. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11647. /**
  11648. * Adds a new size gradient
  11649. * @param gradient defines the gradient to use (between 0 and 1)
  11650. * @param factor defines the size factor to affect to the specified gradient
  11651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11652. * @returns the current particle system
  11653. */
  11654. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11655. /**
  11656. * Remove a specific size gradient
  11657. * @param gradient defines the gradient to remove
  11658. * @returns the current particle system
  11659. */
  11660. removeSizeGradient(gradient: number): IParticleSystem;
  11661. /**
  11662. * Adds a new color remap gradient
  11663. * @param gradient defines the gradient to use (between 0 and 1)
  11664. * @param min defines the color remap minimal range
  11665. * @param max defines the color remap maximal range
  11666. * @returns the current particle system
  11667. */
  11668. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11669. /**
  11670. * Remove a specific color remap gradient
  11671. * @param gradient defines the gradient to remove
  11672. * @returns the current particle system
  11673. */
  11674. removeColorRemapGradient(gradient: number): IParticleSystem;
  11675. /**
  11676. * Adds a new alpha remap gradient
  11677. * @param gradient defines the gradient to use (between 0 and 1)
  11678. * @param min defines the alpha remap minimal range
  11679. * @param max defines the alpha remap maximal range
  11680. * @returns the current particle system
  11681. */
  11682. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11683. /**
  11684. * Remove a specific alpha remap gradient
  11685. * @param gradient defines the gradient to remove
  11686. * @returns the current particle system
  11687. */
  11688. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11689. /**
  11690. * Adds a new angular speed gradient
  11691. * @param gradient defines the gradient to use (between 0 and 1)
  11692. * @param factor defines the angular speed to affect to the specified gradient
  11693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11694. * @returns the current particle system
  11695. */
  11696. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11697. /**
  11698. * Remove a specific angular speed gradient
  11699. * @param gradient defines the gradient to remove
  11700. * @returns the current particle system
  11701. */
  11702. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11703. /**
  11704. * Adds a new velocity gradient
  11705. * @param gradient defines the gradient to use (between 0 and 1)
  11706. * @param factor defines the velocity to affect to the specified gradient
  11707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11708. * @returns the current particle system
  11709. */
  11710. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11711. /**
  11712. * Remove a specific velocity gradient
  11713. * @param gradient defines the gradient to remove
  11714. * @returns the current particle system
  11715. */
  11716. removeVelocityGradient(gradient: number): IParticleSystem;
  11717. /**
  11718. * Adds a new limit velocity gradient
  11719. * @param gradient defines the gradient to use (between 0 and 1)
  11720. * @param factor defines the limit velocity value to affect to the specified gradient
  11721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11722. * @returns the current particle system
  11723. */
  11724. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11725. /**
  11726. * Remove a specific limit velocity gradient
  11727. * @param gradient defines the gradient to remove
  11728. * @returns the current particle system
  11729. */
  11730. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11731. /**
  11732. * Adds a new drag gradient
  11733. * @param gradient defines the gradient to use (between 0 and 1)
  11734. * @param factor defines the drag value to affect to the specified gradient
  11735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11736. * @returns the current particle system
  11737. */
  11738. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11739. /**
  11740. * Remove a specific drag gradient
  11741. * @param gradient defines the gradient to remove
  11742. * @returns the current particle system
  11743. */
  11744. removeDragGradient(gradient: number): IParticleSystem;
  11745. /**
  11746. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11747. * @param gradient defines the gradient to use (between 0 and 1)
  11748. * @param factor defines the emit rate value to affect to the specified gradient
  11749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11750. * @returns the current particle system
  11751. */
  11752. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11753. /**
  11754. * Remove a specific emit rate gradient
  11755. * @param gradient defines the gradient to remove
  11756. * @returns the current particle system
  11757. */
  11758. removeEmitRateGradient(gradient: number): IParticleSystem;
  11759. /**
  11760. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11761. * @param gradient defines the gradient to use (between 0 and 1)
  11762. * @param factor defines the start size value to affect to the specified gradient
  11763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11764. * @returns the current particle system
  11765. */
  11766. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11767. /**
  11768. * Remove a specific start size gradient
  11769. * @param gradient defines the gradient to remove
  11770. * @returns the current particle system
  11771. */
  11772. removeStartSizeGradient(gradient: number): IParticleSystem;
  11773. private _createRampGradientTexture;
  11774. /**
  11775. * Gets the current list of ramp gradients.
  11776. * You must use addRampGradient and removeRampGradient to udpate this list
  11777. * @returns the list of ramp gradients
  11778. */
  11779. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11780. /**
  11781. * Adds a new ramp gradient used to remap particle colors
  11782. * @param gradient defines the gradient to use (between 0 and 1)
  11783. * @param color defines the color to affect to the specified gradient
  11784. * @returns the current particle system
  11785. */
  11786. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11787. /**
  11788. * Remove a specific ramp gradient
  11789. * @param gradient defines the gradient to remove
  11790. * @returns the current particle system
  11791. */
  11792. removeRampGradient(gradient: number): ParticleSystem;
  11793. /**
  11794. * Adds a new color gradient
  11795. * @param gradient defines the gradient to use (between 0 and 1)
  11796. * @param color1 defines the color to affect to the specified gradient
  11797. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11798. * @returns this particle system
  11799. */
  11800. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11801. /**
  11802. * Remove a specific color gradient
  11803. * @param gradient defines the gradient to remove
  11804. * @returns this particle system
  11805. */
  11806. removeColorGradient(gradient: number): IParticleSystem;
  11807. private _fetchR;
  11808. protected _reset(): void;
  11809. private _resetEffect;
  11810. private _createVertexBuffers;
  11811. private _createIndexBuffer;
  11812. /**
  11813. * Gets the maximum number of particles active at the same time.
  11814. * @returns The max number of active particles.
  11815. */
  11816. getCapacity(): number;
  11817. /**
  11818. * Gets whether there are still active particles in the system.
  11819. * @returns True if it is alive, otherwise false.
  11820. */
  11821. isAlive(): boolean;
  11822. /**
  11823. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11824. * @returns True if it has been started, otherwise false.
  11825. */
  11826. isStarted(): boolean;
  11827. private _prepareSubEmitterInternalArray;
  11828. /**
  11829. * Starts the particle system and begins to emit
  11830. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11831. */
  11832. start(delay?: number): void;
  11833. /**
  11834. * Stops the particle system.
  11835. * @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.
  11836. */
  11837. stop(stopSubEmitters?: boolean): void;
  11838. /**
  11839. * Remove all active particles
  11840. */
  11841. reset(): void;
  11842. /**
  11843. * @hidden (for internal use only)
  11844. */
  11845. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11846. /**
  11847. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11848. * Its lifetime will start back at 0.
  11849. */
  11850. recycleParticle: (particle: Particle) => void;
  11851. private _stopSubEmitters;
  11852. private _createParticle;
  11853. private _removeFromRoot;
  11854. private _emitFromParticle;
  11855. private _update;
  11856. /** @hidden */
  11857. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11858. /** @hidden */
  11859. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11860. /** @hidden */
  11861. private _getEffect;
  11862. /**
  11863. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11864. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11865. */
  11866. animate(preWarmOnly?: boolean): void;
  11867. private _appendParticleVertices;
  11868. /**
  11869. * Rebuilds the particle system.
  11870. */
  11871. rebuild(): void;
  11872. /**
  11873. * Is this system ready to be used/rendered
  11874. * @return true if the system is ready
  11875. */
  11876. isReady(): boolean;
  11877. private _render;
  11878. /**
  11879. * Renders the particle system in its current state.
  11880. * @returns the current number of particles
  11881. */
  11882. render(): number;
  11883. /**
  11884. * Disposes the particle system and free the associated resources
  11885. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11886. */
  11887. dispose(disposeTexture?: boolean): void;
  11888. /**
  11889. * Clones the particle system.
  11890. * @param name The name of the cloned object
  11891. * @param newEmitter The new emitter to use
  11892. * @returns the cloned particle system
  11893. */
  11894. clone(name: string, newEmitter: any): ParticleSystem;
  11895. /**
  11896. * Serializes the particle system to a JSON object.
  11897. * @returns the JSON object
  11898. */
  11899. serialize(): any;
  11900. /** @hidden */
  11901. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11902. /** @hidden */
  11903. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11904. /**
  11905. * Parses a JSON object to create a particle system.
  11906. * @param parsedParticleSystem The JSON object to parse
  11907. * @param scene The scene to create the particle system in
  11908. * @param rootUrl The root url to use to load external dependencies like texture
  11909. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11910. * @returns the Parsed particle system
  11911. */
  11912. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11913. }
  11914. }
  11915. declare module BABYLON {
  11916. /**
  11917. * A particle represents one of the element emitted by a particle system.
  11918. * This is mainly define by its coordinates, direction, velocity and age.
  11919. */
  11920. export class Particle {
  11921. /**
  11922. * The particle system the particle belongs to.
  11923. */
  11924. particleSystem: ParticleSystem;
  11925. private static _Count;
  11926. /**
  11927. * Unique ID of the particle
  11928. */
  11929. id: number;
  11930. /**
  11931. * The world position of the particle in the scene.
  11932. */
  11933. position: Vector3;
  11934. /**
  11935. * The world direction of the particle in the scene.
  11936. */
  11937. direction: Vector3;
  11938. /**
  11939. * The color of the particle.
  11940. */
  11941. color: Color4;
  11942. /**
  11943. * The color change of the particle per step.
  11944. */
  11945. colorStep: Color4;
  11946. /**
  11947. * Defines how long will the life of the particle be.
  11948. */
  11949. lifeTime: number;
  11950. /**
  11951. * The current age of the particle.
  11952. */
  11953. age: number;
  11954. /**
  11955. * The current size of the particle.
  11956. */
  11957. size: number;
  11958. /**
  11959. * The current scale of the particle.
  11960. */
  11961. scale: Vector2;
  11962. /**
  11963. * The current angle of the particle.
  11964. */
  11965. angle: number;
  11966. /**
  11967. * Defines how fast is the angle changing.
  11968. */
  11969. angularSpeed: number;
  11970. /**
  11971. * Defines the cell index used by the particle to be rendered from a sprite.
  11972. */
  11973. cellIndex: number;
  11974. /**
  11975. * The information required to support color remapping
  11976. */
  11977. remapData: Vector4;
  11978. /** @hidden */
  11979. _randomCellOffset?: number;
  11980. /** @hidden */
  11981. _initialDirection: Nullable<Vector3>;
  11982. /** @hidden */
  11983. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  11984. /** @hidden */
  11985. _initialStartSpriteCellID: number;
  11986. /** @hidden */
  11987. _initialEndSpriteCellID: number;
  11988. /** @hidden */
  11989. _currentColorGradient: Nullable<ColorGradient>;
  11990. /** @hidden */
  11991. _currentColor1: Color4;
  11992. /** @hidden */
  11993. _currentColor2: Color4;
  11994. /** @hidden */
  11995. _currentSizeGradient: Nullable<FactorGradient>;
  11996. /** @hidden */
  11997. _currentSize1: number;
  11998. /** @hidden */
  11999. _currentSize2: number;
  12000. /** @hidden */
  12001. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12002. /** @hidden */
  12003. _currentAngularSpeed1: number;
  12004. /** @hidden */
  12005. _currentAngularSpeed2: number;
  12006. /** @hidden */
  12007. _currentVelocityGradient: Nullable<FactorGradient>;
  12008. /** @hidden */
  12009. _currentVelocity1: number;
  12010. /** @hidden */
  12011. _currentVelocity2: number;
  12012. /** @hidden */
  12013. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12014. /** @hidden */
  12015. _currentLimitVelocity1: number;
  12016. /** @hidden */
  12017. _currentLimitVelocity2: number;
  12018. /** @hidden */
  12019. _currentDragGradient: Nullable<FactorGradient>;
  12020. /** @hidden */
  12021. _currentDrag1: number;
  12022. /** @hidden */
  12023. _currentDrag2: number;
  12024. /** @hidden */
  12025. _randomNoiseCoordinates1: Vector3;
  12026. /** @hidden */
  12027. _randomNoiseCoordinates2: Vector3;
  12028. /**
  12029. * Creates a new instance Particle
  12030. * @param particleSystem the particle system the particle belongs to
  12031. */
  12032. constructor(
  12033. /**
  12034. * The particle system the particle belongs to.
  12035. */
  12036. particleSystem: ParticleSystem);
  12037. private updateCellInfoFromSystem;
  12038. /**
  12039. * Defines how the sprite cell index is updated for the particle
  12040. */
  12041. updateCellIndex(): void;
  12042. /** @hidden */
  12043. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12044. /** @hidden */
  12045. _inheritParticleInfoToSubEmitters(): void;
  12046. /** @hidden */
  12047. _reset(): void;
  12048. /**
  12049. * Copy the properties of particle to another one.
  12050. * @param other the particle to copy the information to.
  12051. */
  12052. copyTo(other: Particle): void;
  12053. }
  12054. }
  12055. declare module BABYLON {
  12056. /**
  12057. * Particle emitter represents a volume emitting particles.
  12058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12059. */
  12060. export interface IParticleEmitterType {
  12061. /**
  12062. * Called by the particle System when the direction is computed for the created particle.
  12063. * @param worldMatrix is the world matrix of the particle system
  12064. * @param directionToUpdate is the direction vector to update with the result
  12065. * @param particle is the particle we are computed the direction for
  12066. */
  12067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12068. /**
  12069. * Called by the particle System when the position is computed for the created particle.
  12070. * @param worldMatrix is the world matrix of the particle system
  12071. * @param positionToUpdate is the position vector to update with the result
  12072. * @param particle is the particle we are computed the position for
  12073. */
  12074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12075. /**
  12076. * Clones the current emitter and returns a copy of it
  12077. * @returns the new emitter
  12078. */
  12079. clone(): IParticleEmitterType;
  12080. /**
  12081. * Called by the GPUParticleSystem to setup the update shader
  12082. * @param effect defines the update shader
  12083. */
  12084. applyToShader(effect: Effect): void;
  12085. /**
  12086. * Returns a string to use to update the GPU particles update shader
  12087. * @returns the effect defines string
  12088. */
  12089. getEffectDefines(): string;
  12090. /**
  12091. * Returns a string representing the class name
  12092. * @returns a string containing the class name
  12093. */
  12094. getClassName(): string;
  12095. /**
  12096. * Serializes the particle system to a JSON object.
  12097. * @returns the JSON object
  12098. */
  12099. serialize(): any;
  12100. /**
  12101. * Parse properties from a JSON object
  12102. * @param serializationObject defines the JSON object
  12103. * @param scene defines the hosting scene
  12104. */
  12105. parse(serializationObject: any, scene: Scene): void;
  12106. }
  12107. }
  12108. declare module BABYLON {
  12109. /**
  12110. * Particle emitter emitting particles from the inside of a box.
  12111. * It emits the particles randomly between 2 given directions.
  12112. */
  12113. export class BoxParticleEmitter implements IParticleEmitterType {
  12114. /**
  12115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12116. */
  12117. direction1: Vector3;
  12118. /**
  12119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12120. */
  12121. direction2: Vector3;
  12122. /**
  12123. * 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.
  12124. */
  12125. minEmitBox: Vector3;
  12126. /**
  12127. * 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.
  12128. */
  12129. maxEmitBox: Vector3;
  12130. /**
  12131. * Creates a new instance BoxParticleEmitter
  12132. */
  12133. constructor();
  12134. /**
  12135. * Called by the particle System when the direction is computed for the created particle.
  12136. * @param worldMatrix is the world matrix of the particle system
  12137. * @param directionToUpdate is the direction vector to update with the result
  12138. * @param particle is the particle we are computed the direction for
  12139. */
  12140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12141. /**
  12142. * Called by the particle System when the position is computed for the created particle.
  12143. * @param worldMatrix is the world matrix of the particle system
  12144. * @param positionToUpdate is the position vector to update with the result
  12145. * @param particle is the particle we are computed the position for
  12146. */
  12147. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12148. /**
  12149. * Clones the current emitter and returns a copy of it
  12150. * @returns the new emitter
  12151. */
  12152. clone(): BoxParticleEmitter;
  12153. /**
  12154. * Called by the GPUParticleSystem to setup the update shader
  12155. * @param effect defines the update shader
  12156. */
  12157. applyToShader(effect: Effect): void;
  12158. /**
  12159. * Returns a string to use to update the GPU particles update shader
  12160. * @returns a string containng the defines string
  12161. */
  12162. getEffectDefines(): string;
  12163. /**
  12164. * Returns the string "BoxParticleEmitter"
  12165. * @returns a string containing the class name
  12166. */
  12167. getClassName(): string;
  12168. /**
  12169. * Serializes the particle system to a JSON object.
  12170. * @returns the JSON object
  12171. */
  12172. serialize(): any;
  12173. /**
  12174. * Parse properties from a JSON object
  12175. * @param serializationObject defines the JSON object
  12176. */
  12177. parse(serializationObject: any): void;
  12178. }
  12179. }
  12180. declare module BABYLON {
  12181. /**
  12182. * Particle emitter emitting particles from the inside of a cone.
  12183. * It emits the particles alongside the cone volume from the base to the particle.
  12184. * The emission direction might be randomized.
  12185. */
  12186. export class ConeParticleEmitter implements IParticleEmitterType {
  12187. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12188. directionRandomizer: number;
  12189. private _radius;
  12190. private _angle;
  12191. private _height;
  12192. /**
  12193. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12194. */
  12195. radiusRange: number;
  12196. /**
  12197. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12198. */
  12199. heightRange: number;
  12200. /**
  12201. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12202. */
  12203. emitFromSpawnPointOnly: boolean;
  12204. /**
  12205. * Gets or sets the radius of the emission cone
  12206. */
  12207. get radius(): number;
  12208. set radius(value: number);
  12209. /**
  12210. * Gets or sets the angle of the emission cone
  12211. */
  12212. get angle(): number;
  12213. set angle(value: number);
  12214. private _buildHeight;
  12215. /**
  12216. * Creates a new instance ConeParticleEmitter
  12217. * @param radius the radius of the emission cone (1 by default)
  12218. * @param angle the cone base angle (PI by default)
  12219. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12220. */
  12221. constructor(radius?: number, angle?: number,
  12222. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12223. directionRandomizer?: number);
  12224. /**
  12225. * Called by the particle System when the direction is computed for the created particle.
  12226. * @param worldMatrix is the world matrix of the particle system
  12227. * @param directionToUpdate is the direction vector to update with the result
  12228. * @param particle is the particle we are computed the direction for
  12229. */
  12230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12231. /**
  12232. * Called by the particle System when the position is computed for the created particle.
  12233. * @param worldMatrix is the world matrix of the particle system
  12234. * @param positionToUpdate is the position vector to update with the result
  12235. * @param particle is the particle we are computed the position for
  12236. */
  12237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12238. /**
  12239. * Clones the current emitter and returns a copy of it
  12240. * @returns the new emitter
  12241. */
  12242. clone(): ConeParticleEmitter;
  12243. /**
  12244. * Called by the GPUParticleSystem to setup the update shader
  12245. * @param effect defines the update shader
  12246. */
  12247. applyToShader(effect: Effect): void;
  12248. /**
  12249. * Returns a string to use to update the GPU particles update shader
  12250. * @returns a string containng the defines string
  12251. */
  12252. getEffectDefines(): string;
  12253. /**
  12254. * Returns the string "ConeParticleEmitter"
  12255. * @returns a string containing the class name
  12256. */
  12257. getClassName(): string;
  12258. /**
  12259. * Serializes the particle system to a JSON object.
  12260. * @returns the JSON object
  12261. */
  12262. serialize(): any;
  12263. /**
  12264. * Parse properties from a JSON object
  12265. * @param serializationObject defines the JSON object
  12266. */
  12267. parse(serializationObject: any): void;
  12268. }
  12269. }
  12270. declare module BABYLON {
  12271. /**
  12272. * Particle emitter emitting particles from the inside of a cylinder.
  12273. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12274. */
  12275. export class CylinderParticleEmitter implements IParticleEmitterType {
  12276. /**
  12277. * The radius of the emission cylinder.
  12278. */
  12279. radius: number;
  12280. /**
  12281. * The height of the emission cylinder.
  12282. */
  12283. height: number;
  12284. /**
  12285. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12286. */
  12287. radiusRange: number;
  12288. /**
  12289. * How much to randomize the particle direction [0-1].
  12290. */
  12291. directionRandomizer: number;
  12292. /**
  12293. * Creates a new instance CylinderParticleEmitter
  12294. * @param radius the radius of the emission cylinder (1 by default)
  12295. * @param height the height of the emission cylinder (1 by default)
  12296. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12297. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12298. */
  12299. constructor(
  12300. /**
  12301. * The radius of the emission cylinder.
  12302. */
  12303. radius?: number,
  12304. /**
  12305. * The height of the emission cylinder.
  12306. */
  12307. height?: number,
  12308. /**
  12309. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12310. */
  12311. radiusRange?: number,
  12312. /**
  12313. * How much to randomize the particle direction [0-1].
  12314. */
  12315. directionRandomizer?: number);
  12316. /**
  12317. * Called by the particle System when the direction is computed for the created particle.
  12318. * @param worldMatrix is the world matrix of the particle system
  12319. * @param directionToUpdate is the direction vector to update with the result
  12320. * @param particle is the particle we are computed the direction for
  12321. */
  12322. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12323. /**
  12324. * Called by the particle System when the position is computed for the created particle.
  12325. * @param worldMatrix is the world matrix of the particle system
  12326. * @param positionToUpdate is the position vector to update with the result
  12327. * @param particle is the particle we are computed the position for
  12328. */
  12329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12330. /**
  12331. * Clones the current emitter and returns a copy of it
  12332. * @returns the new emitter
  12333. */
  12334. clone(): CylinderParticleEmitter;
  12335. /**
  12336. * Called by the GPUParticleSystem to setup the update shader
  12337. * @param effect defines the update shader
  12338. */
  12339. applyToShader(effect: Effect): void;
  12340. /**
  12341. * Returns a string to use to update the GPU particles update shader
  12342. * @returns a string containng the defines string
  12343. */
  12344. getEffectDefines(): string;
  12345. /**
  12346. * Returns the string "CylinderParticleEmitter"
  12347. * @returns a string containing the class name
  12348. */
  12349. getClassName(): string;
  12350. /**
  12351. * Serializes the particle system to a JSON object.
  12352. * @returns the JSON object
  12353. */
  12354. serialize(): any;
  12355. /**
  12356. * Parse properties from a JSON object
  12357. * @param serializationObject defines the JSON object
  12358. */
  12359. parse(serializationObject: any): void;
  12360. }
  12361. /**
  12362. * Particle emitter emitting particles from the inside of a cylinder.
  12363. * It emits the particles randomly between two vectors.
  12364. */
  12365. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12366. /**
  12367. * The min limit of the emission direction.
  12368. */
  12369. direction1: Vector3;
  12370. /**
  12371. * The max limit of the emission direction.
  12372. */
  12373. direction2: Vector3;
  12374. /**
  12375. * Creates a new instance CylinderDirectedParticleEmitter
  12376. * @param radius the radius of the emission cylinder (1 by default)
  12377. * @param height the height of the emission cylinder (1 by default)
  12378. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12379. * @param direction1 the min limit of the emission direction (up vector by default)
  12380. * @param direction2 the max limit of the emission direction (up vector by default)
  12381. */
  12382. constructor(radius?: number, height?: number, radiusRange?: number,
  12383. /**
  12384. * The min limit of the emission direction.
  12385. */
  12386. direction1?: Vector3,
  12387. /**
  12388. * The max limit of the emission direction.
  12389. */
  12390. direction2?: Vector3);
  12391. /**
  12392. * Called by the particle System when the direction is computed for the created particle.
  12393. * @param worldMatrix is the world matrix of the particle system
  12394. * @param directionToUpdate is the direction vector to update with the result
  12395. * @param particle is the particle we are computed the direction for
  12396. */
  12397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12398. /**
  12399. * Clones the current emitter and returns a copy of it
  12400. * @returns the new emitter
  12401. */
  12402. clone(): CylinderDirectedParticleEmitter;
  12403. /**
  12404. * Called by the GPUParticleSystem to setup the update shader
  12405. * @param effect defines the update shader
  12406. */
  12407. applyToShader(effect: Effect): void;
  12408. /**
  12409. * Returns a string to use to update the GPU particles update shader
  12410. * @returns a string containng the defines string
  12411. */
  12412. getEffectDefines(): string;
  12413. /**
  12414. * Returns the string "CylinderDirectedParticleEmitter"
  12415. * @returns a string containing the class name
  12416. */
  12417. getClassName(): string;
  12418. /**
  12419. * Serializes the particle system to a JSON object.
  12420. * @returns the JSON object
  12421. */
  12422. serialize(): any;
  12423. /**
  12424. * Parse properties from a JSON object
  12425. * @param serializationObject defines the JSON object
  12426. */
  12427. parse(serializationObject: any): void;
  12428. }
  12429. }
  12430. declare module BABYLON {
  12431. /**
  12432. * Particle emitter emitting particles from the inside of a hemisphere.
  12433. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12434. */
  12435. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12436. /**
  12437. * The radius of the emission hemisphere.
  12438. */
  12439. radius: number;
  12440. /**
  12441. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12442. */
  12443. radiusRange: number;
  12444. /**
  12445. * How much to randomize the particle direction [0-1].
  12446. */
  12447. directionRandomizer: number;
  12448. /**
  12449. * Creates a new instance HemisphericParticleEmitter
  12450. * @param radius the radius of the emission hemisphere (1 by default)
  12451. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12453. */
  12454. constructor(
  12455. /**
  12456. * The radius of the emission hemisphere.
  12457. */
  12458. radius?: number,
  12459. /**
  12460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12461. */
  12462. radiusRange?: number,
  12463. /**
  12464. * How much to randomize the particle direction [0-1].
  12465. */
  12466. directionRandomizer?: number);
  12467. /**
  12468. * Called by the particle System when the direction is computed for the created particle.
  12469. * @param worldMatrix is the world matrix of the particle system
  12470. * @param directionToUpdate is the direction vector to update with the result
  12471. * @param particle is the particle we are computed the direction for
  12472. */
  12473. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12474. /**
  12475. * Called by the particle System when the position is computed for the created particle.
  12476. * @param worldMatrix is the world matrix of the particle system
  12477. * @param positionToUpdate is the position vector to update with the result
  12478. * @param particle is the particle we are computed the position for
  12479. */
  12480. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12481. /**
  12482. * Clones the current emitter and returns a copy of it
  12483. * @returns the new emitter
  12484. */
  12485. clone(): HemisphericParticleEmitter;
  12486. /**
  12487. * Called by the GPUParticleSystem to setup the update shader
  12488. * @param effect defines the update shader
  12489. */
  12490. applyToShader(effect: Effect): void;
  12491. /**
  12492. * Returns a string to use to update the GPU particles update shader
  12493. * @returns a string containng the defines string
  12494. */
  12495. getEffectDefines(): string;
  12496. /**
  12497. * Returns the string "HemisphericParticleEmitter"
  12498. * @returns a string containing the class name
  12499. */
  12500. getClassName(): string;
  12501. /**
  12502. * Serializes the particle system to a JSON object.
  12503. * @returns the JSON object
  12504. */
  12505. serialize(): any;
  12506. /**
  12507. * Parse properties from a JSON object
  12508. * @param serializationObject defines the JSON object
  12509. */
  12510. parse(serializationObject: any): void;
  12511. }
  12512. }
  12513. declare module BABYLON {
  12514. /**
  12515. * Particle emitter emitting particles from a point.
  12516. * It emits the particles randomly between 2 given directions.
  12517. */
  12518. export class PointParticleEmitter implements IParticleEmitterType {
  12519. /**
  12520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12521. */
  12522. direction1: Vector3;
  12523. /**
  12524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12525. */
  12526. direction2: Vector3;
  12527. /**
  12528. * Creates a new instance PointParticleEmitter
  12529. */
  12530. constructor();
  12531. /**
  12532. * Called by the particle System when the direction is computed for the created particle.
  12533. * @param worldMatrix is the world matrix of the particle system
  12534. * @param directionToUpdate is the direction vector to update with the result
  12535. * @param particle is the particle we are computed the direction for
  12536. */
  12537. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12538. /**
  12539. * Called by the particle System when the position is computed for the created particle.
  12540. * @param worldMatrix is the world matrix of the particle system
  12541. * @param positionToUpdate is the position vector to update with the result
  12542. * @param particle is the particle we are computed the position for
  12543. */
  12544. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12545. /**
  12546. * Clones the current emitter and returns a copy of it
  12547. * @returns the new emitter
  12548. */
  12549. clone(): PointParticleEmitter;
  12550. /**
  12551. * Called by the GPUParticleSystem to setup the update shader
  12552. * @param effect defines the update shader
  12553. */
  12554. applyToShader(effect: Effect): void;
  12555. /**
  12556. * Returns a string to use to update the GPU particles update shader
  12557. * @returns a string containng the defines string
  12558. */
  12559. getEffectDefines(): string;
  12560. /**
  12561. * Returns the string "PointParticleEmitter"
  12562. * @returns a string containing the class name
  12563. */
  12564. getClassName(): string;
  12565. /**
  12566. * Serializes the particle system to a JSON object.
  12567. * @returns the JSON object
  12568. */
  12569. serialize(): any;
  12570. /**
  12571. * Parse properties from a JSON object
  12572. * @param serializationObject defines the JSON object
  12573. */
  12574. parse(serializationObject: any): void;
  12575. }
  12576. }
  12577. declare module BABYLON {
  12578. /**
  12579. * Particle emitter emitting particles from the inside of a sphere.
  12580. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12581. */
  12582. export class SphereParticleEmitter implements IParticleEmitterType {
  12583. /**
  12584. * The radius of the emission sphere.
  12585. */
  12586. radius: number;
  12587. /**
  12588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12589. */
  12590. radiusRange: number;
  12591. /**
  12592. * How much to randomize the particle direction [0-1].
  12593. */
  12594. directionRandomizer: number;
  12595. /**
  12596. * Creates a new instance SphereParticleEmitter
  12597. * @param radius the radius of the emission sphere (1 by default)
  12598. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12599. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12600. */
  12601. constructor(
  12602. /**
  12603. * The radius of the emission sphere.
  12604. */
  12605. radius?: number,
  12606. /**
  12607. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12608. */
  12609. radiusRange?: number,
  12610. /**
  12611. * How much to randomize the particle direction [0-1].
  12612. */
  12613. directionRandomizer?: number);
  12614. /**
  12615. * Called by the particle System when the direction is computed for the created particle.
  12616. * @param worldMatrix is the world matrix of the particle system
  12617. * @param directionToUpdate is the direction vector to update with the result
  12618. * @param particle is the particle we are computed the direction for
  12619. */
  12620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12621. /**
  12622. * Called by the particle System when the position is computed for the created particle.
  12623. * @param worldMatrix is the world matrix of the particle system
  12624. * @param positionToUpdate is the position vector to update with the result
  12625. * @param particle is the particle we are computed the position for
  12626. */
  12627. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12628. /**
  12629. * Clones the current emitter and returns a copy of it
  12630. * @returns the new emitter
  12631. */
  12632. clone(): SphereParticleEmitter;
  12633. /**
  12634. * Called by the GPUParticleSystem to setup the update shader
  12635. * @param effect defines the update shader
  12636. */
  12637. applyToShader(effect: Effect): void;
  12638. /**
  12639. * Returns a string to use to update the GPU particles update shader
  12640. * @returns a string containng the defines string
  12641. */
  12642. getEffectDefines(): string;
  12643. /**
  12644. * Returns the string "SphereParticleEmitter"
  12645. * @returns a string containing the class name
  12646. */
  12647. getClassName(): string;
  12648. /**
  12649. * Serializes the particle system to a JSON object.
  12650. * @returns the JSON object
  12651. */
  12652. serialize(): any;
  12653. /**
  12654. * Parse properties from a JSON object
  12655. * @param serializationObject defines the JSON object
  12656. */
  12657. parse(serializationObject: any): void;
  12658. }
  12659. /**
  12660. * Particle emitter emitting particles from the inside of a sphere.
  12661. * It emits the particles randomly between two vectors.
  12662. */
  12663. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12664. /**
  12665. * The min limit of the emission direction.
  12666. */
  12667. direction1: Vector3;
  12668. /**
  12669. * The max limit of the emission direction.
  12670. */
  12671. direction2: Vector3;
  12672. /**
  12673. * Creates a new instance SphereDirectedParticleEmitter
  12674. * @param radius the radius of the emission sphere (1 by default)
  12675. * @param direction1 the min limit of the emission direction (up vector by default)
  12676. * @param direction2 the max limit of the emission direction (up vector by default)
  12677. */
  12678. constructor(radius?: number,
  12679. /**
  12680. * The min limit of the emission direction.
  12681. */
  12682. direction1?: Vector3,
  12683. /**
  12684. * The max limit of the emission direction.
  12685. */
  12686. direction2?: Vector3);
  12687. /**
  12688. * Called by the particle System when the direction is computed for the created particle.
  12689. * @param worldMatrix is the world matrix of the particle system
  12690. * @param directionToUpdate is the direction vector to update with the result
  12691. * @param particle is the particle we are computed the direction for
  12692. */
  12693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12694. /**
  12695. * Clones the current emitter and returns a copy of it
  12696. * @returns the new emitter
  12697. */
  12698. clone(): SphereDirectedParticleEmitter;
  12699. /**
  12700. * Called by the GPUParticleSystem to setup the update shader
  12701. * @param effect defines the update shader
  12702. */
  12703. applyToShader(effect: Effect): void;
  12704. /**
  12705. * Returns a string to use to update the GPU particles update shader
  12706. * @returns a string containng the defines string
  12707. */
  12708. getEffectDefines(): string;
  12709. /**
  12710. * Returns the string "SphereDirectedParticleEmitter"
  12711. * @returns a string containing the class name
  12712. */
  12713. getClassName(): string;
  12714. /**
  12715. * Serializes the particle system to a JSON object.
  12716. * @returns the JSON object
  12717. */
  12718. serialize(): any;
  12719. /**
  12720. * Parse properties from a JSON object
  12721. * @param serializationObject defines the JSON object
  12722. */
  12723. parse(serializationObject: any): void;
  12724. }
  12725. }
  12726. declare module BABYLON {
  12727. /**
  12728. * Particle emitter emitting particles from a custom list of positions.
  12729. */
  12730. export class CustomParticleEmitter implements IParticleEmitterType {
  12731. /**
  12732. * Gets or sets the position generator that will create the inital position of each particle.
  12733. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12734. */
  12735. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12736. /**
  12737. * Gets or sets the destination generator that will create the final destination of each particle.
  12738. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12739. */
  12740. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12741. /**
  12742. * Creates a new instance CustomParticleEmitter
  12743. */
  12744. constructor();
  12745. /**
  12746. * Called by the particle System when the direction is computed for the created particle.
  12747. * @param worldMatrix is the world matrix of the particle system
  12748. * @param directionToUpdate is the direction vector to update with the result
  12749. * @param particle is the particle we are computed the direction for
  12750. */
  12751. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12752. /**
  12753. * Called by the particle System when the position is computed for the created particle.
  12754. * @param worldMatrix is the world matrix of the particle system
  12755. * @param positionToUpdate is the position vector to update with the result
  12756. * @param particle is the particle we are computed the position for
  12757. */
  12758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12759. /**
  12760. * Clones the current emitter and returns a copy of it
  12761. * @returns the new emitter
  12762. */
  12763. clone(): CustomParticleEmitter;
  12764. /**
  12765. * Called by the GPUParticleSystem to setup the update shader
  12766. * @param effect defines the update shader
  12767. */
  12768. applyToShader(effect: Effect): void;
  12769. /**
  12770. * Returns a string to use to update the GPU particles update shader
  12771. * @returns a string containng the defines string
  12772. */
  12773. getEffectDefines(): string;
  12774. /**
  12775. * Returns the string "PointParticleEmitter"
  12776. * @returns a string containing the class name
  12777. */
  12778. getClassName(): string;
  12779. /**
  12780. * Serializes the particle system to a JSON object.
  12781. * @returns the JSON object
  12782. */
  12783. serialize(): any;
  12784. /**
  12785. * Parse properties from a JSON object
  12786. * @param serializationObject defines the JSON object
  12787. */
  12788. parse(serializationObject: any): void;
  12789. }
  12790. }
  12791. declare module BABYLON {
  12792. /**
  12793. * Particle emitter emitting particles from the inside of a box.
  12794. * It emits the particles randomly between 2 given directions.
  12795. */
  12796. export class MeshParticleEmitter implements IParticleEmitterType {
  12797. /** Defines the mesh to use as source */
  12798. mesh?: AbstractMesh | undefined;
  12799. private _indices;
  12800. private _positions;
  12801. private _normals;
  12802. private _storedNormal;
  12803. /**
  12804. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12805. */
  12806. direction1: Vector3;
  12807. /**
  12808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12809. */
  12810. direction2: Vector3;
  12811. /**
  12812. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12813. */
  12814. useMeshNormalsForDirection: boolean;
  12815. /**
  12816. * Creates a new instance MeshParticleEmitter
  12817. * @param mesh defines the mesh to use as source
  12818. */
  12819. constructor(
  12820. /** Defines the mesh to use as source */
  12821. mesh?: AbstractMesh | undefined);
  12822. /**
  12823. * Called by the particle System when the direction is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param directionToUpdate is the direction vector to update with the result
  12826. * @param particle is the particle we are computed the direction for
  12827. */
  12828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Called by the particle System when the position is computed for the created particle.
  12831. * @param worldMatrix is the world matrix of the particle system
  12832. * @param positionToUpdate is the position vector to update with the result
  12833. * @param particle is the particle we are computed the position for
  12834. */
  12835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12836. /**
  12837. * Clones the current emitter and returns a copy of it
  12838. * @returns the new emitter
  12839. */
  12840. clone(): MeshParticleEmitter;
  12841. /**
  12842. * Called by the GPUParticleSystem to setup the update shader
  12843. * @param effect defines the update shader
  12844. */
  12845. applyToShader(effect: Effect): void;
  12846. /**
  12847. * Returns a string to use to update the GPU particles update shader
  12848. * @returns a string containng the defines string
  12849. */
  12850. getEffectDefines(): string;
  12851. /**
  12852. * Returns the string "BoxParticleEmitter"
  12853. * @returns a string containing the class name
  12854. */
  12855. getClassName(): string;
  12856. /**
  12857. * Serializes the particle system to a JSON object.
  12858. * @returns the JSON object
  12859. */
  12860. serialize(): any;
  12861. /**
  12862. * Parse properties from a JSON object
  12863. * @param serializationObject defines the JSON object
  12864. * @param scene defines the hosting scene
  12865. */
  12866. parse(serializationObject: any, scene: Scene): void;
  12867. }
  12868. }
  12869. declare module BABYLON {
  12870. /**
  12871. * Interface representing a particle system in Babylon.js.
  12872. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12873. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12874. */
  12875. export interface IParticleSystem {
  12876. /**
  12877. * List of animations used by the particle system.
  12878. */
  12879. animations: Animation[];
  12880. /**
  12881. * The id of the Particle system.
  12882. */
  12883. id: string;
  12884. /**
  12885. * The name of the Particle system.
  12886. */
  12887. name: string;
  12888. /**
  12889. * The emitter represents the Mesh or position we are attaching the particle system to.
  12890. */
  12891. emitter: Nullable<AbstractMesh | Vector3>;
  12892. /**
  12893. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12894. */
  12895. isBillboardBased: boolean;
  12896. /**
  12897. * The rendering group used by the Particle system to chose when to render.
  12898. */
  12899. renderingGroupId: number;
  12900. /**
  12901. * The layer mask we are rendering the particles through.
  12902. */
  12903. layerMask: number;
  12904. /**
  12905. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12906. */
  12907. updateSpeed: number;
  12908. /**
  12909. * The amount of time the particle system is running (depends of the overall update speed).
  12910. */
  12911. targetStopDuration: number;
  12912. /**
  12913. * The texture used to render each particle. (this can be a spritesheet)
  12914. */
  12915. particleTexture: Nullable<Texture>;
  12916. /**
  12917. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12918. */
  12919. blendMode: number;
  12920. /**
  12921. * Minimum life time of emitting particles.
  12922. */
  12923. minLifeTime: number;
  12924. /**
  12925. * Maximum life time of emitting particles.
  12926. */
  12927. maxLifeTime: number;
  12928. /**
  12929. * Minimum Size of emitting particles.
  12930. */
  12931. minSize: number;
  12932. /**
  12933. * Maximum Size of emitting particles.
  12934. */
  12935. maxSize: number;
  12936. /**
  12937. * Minimum scale of emitting particles on X axis.
  12938. */
  12939. minScaleX: number;
  12940. /**
  12941. * Maximum scale of emitting particles on X axis.
  12942. */
  12943. maxScaleX: number;
  12944. /**
  12945. * Minimum scale of emitting particles on Y axis.
  12946. */
  12947. minScaleY: number;
  12948. /**
  12949. * Maximum scale of emitting particles on Y axis.
  12950. */
  12951. maxScaleY: number;
  12952. /**
  12953. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12954. */
  12955. color1: Color4;
  12956. /**
  12957. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12958. */
  12959. color2: Color4;
  12960. /**
  12961. * Color the particle will have at the end of its lifetime.
  12962. */
  12963. colorDead: Color4;
  12964. /**
  12965. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  12966. */
  12967. emitRate: number;
  12968. /**
  12969. * You can use gravity if you want to give an orientation to your particles.
  12970. */
  12971. gravity: Vector3;
  12972. /**
  12973. * Minimum power of emitting particles.
  12974. */
  12975. minEmitPower: number;
  12976. /**
  12977. * Maximum power of emitting particles.
  12978. */
  12979. maxEmitPower: number;
  12980. /**
  12981. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12982. */
  12983. minAngularSpeed: number;
  12984. /**
  12985. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12986. */
  12987. maxAngularSpeed: number;
  12988. /**
  12989. * Gets or sets the minimal initial rotation in radians.
  12990. */
  12991. minInitialRotation: number;
  12992. /**
  12993. * Gets or sets the maximal initial rotation in radians.
  12994. */
  12995. maxInitialRotation: number;
  12996. /**
  12997. * The particle emitter type defines the emitter used by the particle system.
  12998. * It can be for example box, sphere, or cone...
  12999. */
  13000. particleEmitterType: Nullable<IParticleEmitterType>;
  13001. /**
  13002. * Defines the delay in milliseconds before starting the system (0 by default)
  13003. */
  13004. startDelay: number;
  13005. /**
  13006. * 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
  13007. */
  13008. preWarmCycles: number;
  13009. /**
  13010. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13011. */
  13012. preWarmStepOffset: number;
  13013. /**
  13014. * 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)
  13015. */
  13016. spriteCellChangeSpeed: number;
  13017. /**
  13018. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13019. */
  13020. startSpriteCellID: number;
  13021. /**
  13022. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13023. */
  13024. endSpriteCellID: number;
  13025. /**
  13026. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13027. */
  13028. spriteCellWidth: number;
  13029. /**
  13030. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13031. */
  13032. spriteCellHeight: number;
  13033. /**
  13034. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13035. */
  13036. spriteRandomStartCell: boolean;
  13037. /**
  13038. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13039. */
  13040. isAnimationSheetEnabled: boolean;
  13041. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13042. translationPivot: Vector2;
  13043. /**
  13044. * Gets or sets a texture used to add random noise to particle positions
  13045. */
  13046. noiseTexture: Nullable<BaseTexture>;
  13047. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13048. noiseStrength: Vector3;
  13049. /**
  13050. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13051. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13052. */
  13053. billboardMode: number;
  13054. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13055. limitVelocityDamping: number;
  13056. /**
  13057. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13058. */
  13059. beginAnimationOnStart: boolean;
  13060. /**
  13061. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13062. */
  13063. beginAnimationFrom: number;
  13064. /**
  13065. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13066. */
  13067. beginAnimationTo: number;
  13068. /**
  13069. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13070. */
  13071. beginAnimationLoop: boolean;
  13072. /**
  13073. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13074. */
  13075. disposeOnStop: boolean;
  13076. /**
  13077. * Gets the maximum number of particles active at the same time.
  13078. * @returns The max number of active particles.
  13079. */
  13080. getCapacity(): number;
  13081. /**
  13082. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13083. * @returns True if it has been started, otherwise false.
  13084. */
  13085. isStarted(): boolean;
  13086. /**
  13087. * Animates the particle system for this frame.
  13088. */
  13089. animate(): void;
  13090. /**
  13091. * Renders the particle system in its current state.
  13092. * @returns the current number of particles
  13093. */
  13094. render(): number;
  13095. /**
  13096. * Dispose the particle system and frees its associated resources.
  13097. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13098. */
  13099. dispose(disposeTexture?: boolean): void;
  13100. /**
  13101. * Clones the particle system.
  13102. * @param name The name of the cloned object
  13103. * @param newEmitter The new emitter to use
  13104. * @returns the cloned particle system
  13105. */
  13106. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13107. /**
  13108. * Serializes the particle system to a JSON object.
  13109. * @returns the JSON object
  13110. */
  13111. serialize(): any;
  13112. /**
  13113. * Rebuild the particle system
  13114. */
  13115. rebuild(): void;
  13116. /**
  13117. * Starts the particle system and begins to emit
  13118. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13119. */
  13120. start(delay?: number): void;
  13121. /**
  13122. * Stops the particle system.
  13123. */
  13124. stop(): void;
  13125. /**
  13126. * Remove all active particles
  13127. */
  13128. reset(): void;
  13129. /**
  13130. * Is this system ready to be used/rendered
  13131. * @return true if the system is ready
  13132. */
  13133. isReady(): boolean;
  13134. /**
  13135. * Adds a new color gradient
  13136. * @param gradient defines the gradient to use (between 0 and 1)
  13137. * @param color1 defines the color to affect to the specified gradient
  13138. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13139. * @returns the current particle system
  13140. */
  13141. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13142. /**
  13143. * Remove a specific color gradient
  13144. * @param gradient defines the gradient to remove
  13145. * @returns the current particle system
  13146. */
  13147. removeColorGradient(gradient: number): IParticleSystem;
  13148. /**
  13149. * Adds a new size gradient
  13150. * @param gradient defines the gradient to use (between 0 and 1)
  13151. * @param factor defines the size factor to affect to the specified gradient
  13152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13153. * @returns the current particle system
  13154. */
  13155. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13156. /**
  13157. * Remove a specific size gradient
  13158. * @param gradient defines the gradient to remove
  13159. * @returns the current particle system
  13160. */
  13161. removeSizeGradient(gradient: number): IParticleSystem;
  13162. /**
  13163. * Gets the current list of color gradients.
  13164. * You must use addColorGradient and removeColorGradient to udpate this list
  13165. * @returns the list of color gradients
  13166. */
  13167. getColorGradients(): Nullable<Array<ColorGradient>>;
  13168. /**
  13169. * Gets the current list of size gradients.
  13170. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13171. * @returns the list of size gradients
  13172. */
  13173. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13174. /**
  13175. * Gets the current list of angular speed gradients.
  13176. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13177. * @returns the list of angular speed gradients
  13178. */
  13179. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13180. /**
  13181. * Adds a new angular speed gradient
  13182. * @param gradient defines the gradient to use (between 0 and 1)
  13183. * @param factor defines the angular speed to affect to the specified gradient
  13184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13185. * @returns the current particle system
  13186. */
  13187. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13188. /**
  13189. * Remove a specific angular speed gradient
  13190. * @param gradient defines the gradient to remove
  13191. * @returns the current particle system
  13192. */
  13193. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13194. /**
  13195. * Gets the current list of velocity gradients.
  13196. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13197. * @returns the list of velocity gradients
  13198. */
  13199. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13200. /**
  13201. * Adds a new velocity gradient
  13202. * @param gradient defines the gradient to use (between 0 and 1)
  13203. * @param factor defines the velocity to affect to the specified gradient
  13204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13205. * @returns the current particle system
  13206. */
  13207. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13208. /**
  13209. * Remove a specific velocity gradient
  13210. * @param gradient defines the gradient to remove
  13211. * @returns the current particle system
  13212. */
  13213. removeVelocityGradient(gradient: number): IParticleSystem;
  13214. /**
  13215. * Gets the current list of limit velocity gradients.
  13216. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13217. * @returns the list of limit velocity gradients
  13218. */
  13219. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13220. /**
  13221. * Adds a new limit velocity gradient
  13222. * @param gradient defines the gradient to use (between 0 and 1)
  13223. * @param factor defines the limit velocity to affect to the specified gradient
  13224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13225. * @returns the current particle system
  13226. */
  13227. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13228. /**
  13229. * Remove a specific limit velocity gradient
  13230. * @param gradient defines the gradient to remove
  13231. * @returns the current particle system
  13232. */
  13233. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13234. /**
  13235. * Adds a new drag gradient
  13236. * @param gradient defines the gradient to use (between 0 and 1)
  13237. * @param factor defines the drag to affect to the specified gradient
  13238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13239. * @returns the current particle system
  13240. */
  13241. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13242. /**
  13243. * Remove a specific drag gradient
  13244. * @param gradient defines the gradient to remove
  13245. * @returns the current particle system
  13246. */
  13247. removeDragGradient(gradient: number): IParticleSystem;
  13248. /**
  13249. * Gets the current list of drag gradients.
  13250. * You must use addDragGradient and removeDragGradient to udpate this list
  13251. * @returns the list of drag gradients
  13252. */
  13253. getDragGradients(): Nullable<Array<FactorGradient>>;
  13254. /**
  13255. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13256. * @param gradient defines the gradient to use (between 0 and 1)
  13257. * @param factor defines the emit rate to affect to the specified gradient
  13258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13259. * @returns the current particle system
  13260. */
  13261. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13262. /**
  13263. * Remove a specific emit rate gradient
  13264. * @param gradient defines the gradient to remove
  13265. * @returns the current particle system
  13266. */
  13267. removeEmitRateGradient(gradient: number): IParticleSystem;
  13268. /**
  13269. * Gets the current list of emit rate gradients.
  13270. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13271. * @returns the list of emit rate gradients
  13272. */
  13273. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13274. /**
  13275. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13276. * @param gradient defines the gradient to use (between 0 and 1)
  13277. * @param factor defines the start size to affect to the specified gradient
  13278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13279. * @returns the current particle system
  13280. */
  13281. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13282. /**
  13283. * Remove a specific start size gradient
  13284. * @param gradient defines the gradient to remove
  13285. * @returns the current particle system
  13286. */
  13287. removeStartSizeGradient(gradient: number): IParticleSystem;
  13288. /**
  13289. * Gets the current list of start size gradients.
  13290. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13291. * @returns the list of start size gradients
  13292. */
  13293. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13294. /**
  13295. * Adds a new life time gradient
  13296. * @param gradient defines the gradient to use (between 0 and 1)
  13297. * @param factor defines the life time factor to affect to the specified gradient
  13298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13299. * @returns the current particle system
  13300. */
  13301. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13302. /**
  13303. * Remove a specific life time gradient
  13304. * @param gradient defines the gradient to remove
  13305. * @returns the current particle system
  13306. */
  13307. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13308. /**
  13309. * Gets the current list of life time gradients.
  13310. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13311. * @returns the list of life time gradients
  13312. */
  13313. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13314. /**
  13315. * Gets the current list of color gradients.
  13316. * You must use addColorGradient and removeColorGradient to udpate this list
  13317. * @returns the list of color gradients
  13318. */
  13319. getColorGradients(): Nullable<Array<ColorGradient>>;
  13320. /**
  13321. * Adds a new ramp gradient used to remap particle colors
  13322. * @param gradient defines the gradient to use (between 0 and 1)
  13323. * @param color defines the color to affect to the specified gradient
  13324. * @returns the current particle system
  13325. */
  13326. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13327. /**
  13328. * Gets the current list of ramp gradients.
  13329. * You must use addRampGradient and removeRampGradient to udpate this list
  13330. * @returns the list of ramp gradients
  13331. */
  13332. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13333. /** Gets or sets a boolean indicating that ramp gradients must be used
  13334. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13335. */
  13336. useRampGradients: boolean;
  13337. /**
  13338. * Adds a new color remap gradient
  13339. * @param gradient defines the gradient to use (between 0 and 1)
  13340. * @param min defines the color remap minimal range
  13341. * @param max defines the color remap maximal range
  13342. * @returns the current particle system
  13343. */
  13344. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13345. /**
  13346. * Gets the current list of color remap gradients.
  13347. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13348. * @returns the list of color remap gradients
  13349. */
  13350. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13351. /**
  13352. * Adds a new alpha remap gradient
  13353. * @param gradient defines the gradient to use (between 0 and 1)
  13354. * @param min defines the alpha remap minimal range
  13355. * @param max defines the alpha remap maximal range
  13356. * @returns the current particle system
  13357. */
  13358. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13359. /**
  13360. * Gets the current list of alpha remap gradients.
  13361. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13362. * @returns the list of alpha remap gradients
  13363. */
  13364. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13365. /**
  13366. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13367. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13368. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13369. * @returns the emitter
  13370. */
  13371. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13372. /**
  13373. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13374. * @param radius The radius of the hemisphere to emit from
  13375. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13376. * @returns the emitter
  13377. */
  13378. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13379. /**
  13380. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13381. * @param radius The radius of the sphere to emit from
  13382. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13383. * @returns the emitter
  13384. */
  13385. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13386. /**
  13387. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13388. * @param radius The radius of the sphere to emit from
  13389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13391. * @returns the emitter
  13392. */
  13393. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13394. /**
  13395. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13396. * @param radius The radius of the emission cylinder
  13397. * @param height The height of the emission cylinder
  13398. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13399. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13400. * @returns the emitter
  13401. */
  13402. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13403. /**
  13404. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13405. * @param radius The radius of the cylinder to emit from
  13406. * @param height The height of the emission cylinder
  13407. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13410. * @returns the emitter
  13411. */
  13412. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13413. /**
  13414. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13415. * @param radius The radius of the cone to emit from
  13416. * @param angle The base angle of the cone
  13417. * @returns the emitter
  13418. */
  13419. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13420. /**
  13421. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13424. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13425. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13426. * @returns the emitter
  13427. */
  13428. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13429. /**
  13430. * Get hosting scene
  13431. * @returns the scene
  13432. */
  13433. getScene(): Scene;
  13434. }
  13435. }
  13436. declare module BABYLON {
  13437. /**
  13438. * 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.
  13439. * @see https://doc.babylonjs.com/how_to/transformnode
  13440. */
  13441. export class TransformNode extends Node {
  13442. /**
  13443. * Object will not rotate to face the camera
  13444. */
  13445. static BILLBOARDMODE_NONE: number;
  13446. /**
  13447. * Object will rotate to face the camera but only on the x axis
  13448. */
  13449. static BILLBOARDMODE_X: number;
  13450. /**
  13451. * Object will rotate to face the camera but only on the y axis
  13452. */
  13453. static BILLBOARDMODE_Y: number;
  13454. /**
  13455. * Object will rotate to face the camera but only on the z axis
  13456. */
  13457. static BILLBOARDMODE_Z: number;
  13458. /**
  13459. * Object will rotate to face the camera
  13460. */
  13461. static BILLBOARDMODE_ALL: number;
  13462. /**
  13463. * Object will rotate to face the camera's position instead of orientation
  13464. */
  13465. static BILLBOARDMODE_USE_POSITION: number;
  13466. private _forward;
  13467. private _forwardInverted;
  13468. private _up;
  13469. private _right;
  13470. private _rightInverted;
  13471. private _position;
  13472. private _rotation;
  13473. private _rotationQuaternion;
  13474. protected _scaling: Vector3;
  13475. protected _isDirty: boolean;
  13476. private _transformToBoneReferal;
  13477. private _isAbsoluteSynced;
  13478. private _billboardMode;
  13479. /**
  13480. * Gets or sets the billboard mode. Default is 0.
  13481. *
  13482. * | Value | Type | Description |
  13483. * | --- | --- | --- |
  13484. * | 0 | BILLBOARDMODE_NONE | |
  13485. * | 1 | BILLBOARDMODE_X | |
  13486. * | 2 | BILLBOARDMODE_Y | |
  13487. * | 4 | BILLBOARDMODE_Z | |
  13488. * | 7 | BILLBOARDMODE_ALL | |
  13489. *
  13490. */
  13491. get billboardMode(): number;
  13492. set billboardMode(value: number);
  13493. private _preserveParentRotationForBillboard;
  13494. /**
  13495. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13496. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13497. */
  13498. get preserveParentRotationForBillboard(): boolean;
  13499. set preserveParentRotationForBillboard(value: boolean);
  13500. /**
  13501. * 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
  13502. */
  13503. scalingDeterminant: number;
  13504. private _infiniteDistance;
  13505. /**
  13506. * Gets or sets the distance of the object to max, often used by skybox
  13507. */
  13508. get infiniteDistance(): boolean;
  13509. set infiniteDistance(value: boolean);
  13510. /**
  13511. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13512. * By default the system will update normals to compensate
  13513. */
  13514. ignoreNonUniformScaling: boolean;
  13515. /**
  13516. * 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
  13517. */
  13518. reIntegrateRotationIntoRotationQuaternion: boolean;
  13519. /** @hidden */
  13520. _poseMatrix: Nullable<Matrix>;
  13521. /** @hidden */
  13522. _localMatrix: Matrix;
  13523. private _usePivotMatrix;
  13524. private _absolutePosition;
  13525. private _absoluteScaling;
  13526. private _absoluteRotationQuaternion;
  13527. private _pivotMatrix;
  13528. private _pivotMatrixInverse;
  13529. protected _postMultiplyPivotMatrix: boolean;
  13530. protected _isWorldMatrixFrozen: boolean;
  13531. /** @hidden */
  13532. _indexInSceneTransformNodesArray: number;
  13533. /**
  13534. * An event triggered after the world matrix is updated
  13535. */
  13536. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13537. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13538. /**
  13539. * Gets a string identifying the name of the class
  13540. * @returns "TransformNode" string
  13541. */
  13542. getClassName(): string;
  13543. /**
  13544. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13545. */
  13546. get position(): Vector3;
  13547. set position(newPosition: Vector3);
  13548. /**
  13549. * 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)).
  13550. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13551. */
  13552. get rotation(): Vector3;
  13553. set rotation(newRotation: Vector3);
  13554. /**
  13555. * 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)).
  13556. */
  13557. get scaling(): Vector3;
  13558. set scaling(newScaling: Vector3);
  13559. /**
  13560. * 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).
  13561. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13562. */
  13563. get rotationQuaternion(): Nullable<Quaternion>;
  13564. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13565. /**
  13566. * The forward direction of that transform in world space.
  13567. */
  13568. get forward(): Vector3;
  13569. /**
  13570. * The up direction of that transform in world space.
  13571. */
  13572. get up(): Vector3;
  13573. /**
  13574. * The right direction of that transform in world space.
  13575. */
  13576. get right(): Vector3;
  13577. /**
  13578. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13579. * @param matrix the matrix to copy the pose from
  13580. * @returns this TransformNode.
  13581. */
  13582. updatePoseMatrix(matrix: Matrix): TransformNode;
  13583. /**
  13584. * Returns the mesh Pose matrix.
  13585. * @returns the pose matrix
  13586. */
  13587. getPoseMatrix(): Matrix;
  13588. /** @hidden */
  13589. _isSynchronized(): boolean;
  13590. /** @hidden */
  13591. _initCache(): void;
  13592. /**
  13593. * Flag the transform node as dirty (Forcing it to update everything)
  13594. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13595. * @returns this transform node
  13596. */
  13597. markAsDirty(property: string): TransformNode;
  13598. /**
  13599. * Returns the current mesh absolute position.
  13600. * Returns a Vector3.
  13601. */
  13602. get absolutePosition(): Vector3;
  13603. /**
  13604. * Returns the current mesh absolute scaling.
  13605. * Returns a Vector3.
  13606. */
  13607. get absoluteScaling(): Vector3;
  13608. /**
  13609. * Returns the current mesh absolute rotation.
  13610. * Returns a Quaternion.
  13611. */
  13612. get absoluteRotationQuaternion(): Quaternion;
  13613. /**
  13614. * Sets a new matrix to apply before all other transformation
  13615. * @param matrix defines the transform matrix
  13616. * @returns the current TransformNode
  13617. */
  13618. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13619. /**
  13620. * Sets a new pivot matrix to the current node
  13621. * @param matrix defines the new pivot matrix to use
  13622. * @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
  13623. * @returns the current TransformNode
  13624. */
  13625. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13626. /**
  13627. * Returns the mesh pivot matrix.
  13628. * Default : Identity.
  13629. * @returns the matrix
  13630. */
  13631. getPivotMatrix(): Matrix;
  13632. /**
  13633. * Instantiate (when possible) or clone that node with its hierarchy
  13634. * @param newParent defines the new parent to use for the instance (or clone)
  13635. * @param options defines options to configure how copy is done
  13636. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13637. * @returns an instance (or a clone) of the current node with its hiearchy
  13638. */
  13639. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13640. doNotInstantiate: boolean;
  13641. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13642. /**
  13643. * Prevents the World matrix to be computed any longer
  13644. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13645. * @returns the TransformNode.
  13646. */
  13647. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13648. /**
  13649. * Allows back the World matrix computation.
  13650. * @returns the TransformNode.
  13651. */
  13652. unfreezeWorldMatrix(): this;
  13653. /**
  13654. * True if the World matrix has been frozen.
  13655. */
  13656. get isWorldMatrixFrozen(): boolean;
  13657. /**
  13658. * Retuns the mesh absolute position in the World.
  13659. * @returns a Vector3.
  13660. */
  13661. getAbsolutePosition(): Vector3;
  13662. /**
  13663. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13664. * @param absolutePosition the absolute position to set
  13665. * @returns the TransformNode.
  13666. */
  13667. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13668. /**
  13669. * Sets the mesh position in its local space.
  13670. * @param vector3 the position to set in localspace
  13671. * @returns the TransformNode.
  13672. */
  13673. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13674. /**
  13675. * Returns the mesh position in the local space from the current World matrix values.
  13676. * @returns a new Vector3.
  13677. */
  13678. getPositionExpressedInLocalSpace(): Vector3;
  13679. /**
  13680. * Translates the mesh along the passed Vector3 in its local space.
  13681. * @param vector3 the distance to translate in localspace
  13682. * @returns the TransformNode.
  13683. */
  13684. locallyTranslate(vector3: Vector3): TransformNode;
  13685. private static _lookAtVectorCache;
  13686. /**
  13687. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13688. * @param targetPoint the position (must be in same space as current mesh) to look at
  13689. * @param yawCor optional yaw (y-axis) correction in radians
  13690. * @param pitchCor optional pitch (x-axis) correction in radians
  13691. * @param rollCor optional roll (z-axis) correction in radians
  13692. * @param space the choosen space of the target
  13693. * @returns the TransformNode.
  13694. */
  13695. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13696. /**
  13697. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13698. * This Vector3 is expressed in the World space.
  13699. * @param localAxis axis to rotate
  13700. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13701. */
  13702. getDirection(localAxis: Vector3): Vector3;
  13703. /**
  13704. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13705. * localAxis is expressed in the mesh local space.
  13706. * result is computed in the Wordl space from the mesh World matrix.
  13707. * @param localAxis axis to rotate
  13708. * @param result the resulting transformnode
  13709. * @returns this TransformNode.
  13710. */
  13711. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13712. /**
  13713. * Sets this transform node rotation to the given local axis.
  13714. * @param localAxis the axis in local space
  13715. * @param yawCor optional yaw (y-axis) correction in radians
  13716. * @param pitchCor optional pitch (x-axis) correction in radians
  13717. * @param rollCor optional roll (z-axis) correction in radians
  13718. * @returns this TransformNode
  13719. */
  13720. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13721. /**
  13722. * Sets a new pivot point to the current node
  13723. * @param point defines the new pivot point to use
  13724. * @param space defines if the point is in world or local space (local by default)
  13725. * @returns the current TransformNode
  13726. */
  13727. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13728. /**
  13729. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13730. * @returns the pivot point
  13731. */
  13732. getPivotPoint(): Vector3;
  13733. /**
  13734. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13735. * @param result the vector3 to store the result
  13736. * @returns this TransformNode.
  13737. */
  13738. getPivotPointToRef(result: Vector3): TransformNode;
  13739. /**
  13740. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13741. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13742. */
  13743. getAbsolutePivotPoint(): Vector3;
  13744. /**
  13745. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13746. * @param result vector3 to store the result
  13747. * @returns this TransformNode.
  13748. */
  13749. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13750. /**
  13751. * Defines the passed node as the parent of the current node.
  13752. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13753. * @see https://doc.babylonjs.com/how_to/parenting
  13754. * @param node the node ot set as the parent
  13755. * @returns this TransformNode.
  13756. */
  13757. setParent(node: Nullable<Node>): TransformNode;
  13758. private _nonUniformScaling;
  13759. /**
  13760. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13761. */
  13762. get nonUniformScaling(): boolean;
  13763. /** @hidden */
  13764. _updateNonUniformScalingState(value: boolean): boolean;
  13765. /**
  13766. * Attach the current TransformNode to another TransformNode associated with a bone
  13767. * @param bone Bone affecting the TransformNode
  13768. * @param affectedTransformNode TransformNode associated with the bone
  13769. * @returns this object
  13770. */
  13771. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13772. /**
  13773. * Detach the transform node if its associated with a bone
  13774. * @returns this object
  13775. */
  13776. detachFromBone(): TransformNode;
  13777. private static _rotationAxisCache;
  13778. /**
  13779. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13780. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13781. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13782. * The passed axis is also normalized.
  13783. * @param axis the axis to rotate around
  13784. * @param amount the amount to rotate in radians
  13785. * @param space Space to rotate in (Default: local)
  13786. * @returns the TransformNode.
  13787. */
  13788. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13789. /**
  13790. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13791. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13792. * The passed axis is also normalized. .
  13793. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13794. * @param point the point to rotate around
  13795. * @param axis the axis to rotate around
  13796. * @param amount the amount to rotate in radians
  13797. * @returns the TransformNode
  13798. */
  13799. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13800. /**
  13801. * Translates the mesh along the axis vector for the passed distance in the given space.
  13802. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13803. * @param axis the axis to translate in
  13804. * @param distance the distance to translate
  13805. * @param space Space to rotate in (Default: local)
  13806. * @returns the TransformNode.
  13807. */
  13808. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13809. /**
  13810. * Adds a rotation step to the mesh current rotation.
  13811. * x, y, z are Euler angles expressed in radians.
  13812. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13813. * This means this rotation is made in the mesh local space only.
  13814. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13815. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13816. * ```javascript
  13817. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13818. * ```
  13819. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13820. * 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.
  13821. * @param x Rotation to add
  13822. * @param y Rotation to add
  13823. * @param z Rotation to add
  13824. * @returns the TransformNode.
  13825. */
  13826. addRotation(x: number, y: number, z: number): TransformNode;
  13827. /**
  13828. * @hidden
  13829. */
  13830. protected _getEffectiveParent(): Nullable<Node>;
  13831. /**
  13832. * Computes the world matrix of the node
  13833. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13834. * @returns the world matrix
  13835. */
  13836. computeWorldMatrix(force?: boolean): Matrix;
  13837. /**
  13838. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13839. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13840. */
  13841. resetLocalMatrix(independentOfChildren?: boolean): void;
  13842. protected _afterComputeWorldMatrix(): void;
  13843. /**
  13844. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13845. * @param func callback function to add
  13846. *
  13847. * @returns the TransformNode.
  13848. */
  13849. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13850. /**
  13851. * Removes a registered callback function.
  13852. * @param func callback function to remove
  13853. * @returns the TransformNode.
  13854. */
  13855. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13856. /**
  13857. * Gets the position of the current mesh in camera space
  13858. * @param camera defines the camera to use
  13859. * @returns a position
  13860. */
  13861. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13862. /**
  13863. * Returns the distance from the mesh to the active camera
  13864. * @param camera defines the camera to use
  13865. * @returns the distance
  13866. */
  13867. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13868. /**
  13869. * Clone the current transform node
  13870. * @param name Name of the new clone
  13871. * @param newParent New parent for the clone
  13872. * @param doNotCloneChildren Do not clone children hierarchy
  13873. * @returns the new transform node
  13874. */
  13875. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13876. /**
  13877. * Serializes the objects information.
  13878. * @param currentSerializationObject defines the object to serialize in
  13879. * @returns the serialized object
  13880. */
  13881. serialize(currentSerializationObject?: any): any;
  13882. /**
  13883. * Returns a new TransformNode object parsed from the source provided.
  13884. * @param parsedTransformNode is the source.
  13885. * @param scene the scne the object belongs to
  13886. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13887. * @returns a new TransformNode object parsed from the source provided.
  13888. */
  13889. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13890. /**
  13891. * Get all child-transformNodes of this node
  13892. * @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
  13893. * @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
  13894. * @returns an array of TransformNode
  13895. */
  13896. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13897. /**
  13898. * Releases resources associated with this transform node.
  13899. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13900. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13901. */
  13902. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13903. /**
  13904. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13905. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13906. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13907. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13908. * @returns the current mesh
  13909. */
  13910. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13911. private _syncAbsoluteScalingAndRotation;
  13912. }
  13913. }
  13914. declare module BABYLON {
  13915. /**
  13916. * Class used to override all child animations of a given target
  13917. */
  13918. export class AnimationPropertiesOverride {
  13919. /**
  13920. * Gets or sets a value indicating if animation blending must be used
  13921. */
  13922. enableBlending: boolean;
  13923. /**
  13924. * Gets or sets the blending speed to use when enableBlending is true
  13925. */
  13926. blendingSpeed: number;
  13927. /**
  13928. * Gets or sets the default loop mode to use
  13929. */
  13930. loopMode: number;
  13931. }
  13932. }
  13933. declare module BABYLON {
  13934. /**
  13935. * Class used to store bone information
  13936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13937. */
  13938. export class Bone extends Node {
  13939. /**
  13940. * defines the bone name
  13941. */
  13942. name: string;
  13943. private static _tmpVecs;
  13944. private static _tmpQuat;
  13945. private static _tmpMats;
  13946. /**
  13947. * Gets the list of child bones
  13948. */
  13949. children: Bone[];
  13950. /** Gets the animations associated with this bone */
  13951. animations: Animation[];
  13952. /**
  13953. * Gets or sets bone length
  13954. */
  13955. length: number;
  13956. /**
  13957. * @hidden Internal only
  13958. * Set this value to map this bone to a different index in the transform matrices
  13959. * Set this value to -1 to exclude the bone from the transform matrices
  13960. */
  13961. _index: Nullable<number>;
  13962. private _skeleton;
  13963. private _localMatrix;
  13964. private _restPose;
  13965. private _baseMatrix;
  13966. private _absoluteTransform;
  13967. private _invertedAbsoluteTransform;
  13968. private _parent;
  13969. private _scalingDeterminant;
  13970. private _worldTransform;
  13971. private _localScaling;
  13972. private _localRotation;
  13973. private _localPosition;
  13974. private _needToDecompose;
  13975. private _needToCompose;
  13976. /** @hidden */
  13977. _linkedTransformNode: Nullable<TransformNode>;
  13978. /** @hidden */
  13979. _waitingTransformNodeId: Nullable<string>;
  13980. /** @hidden */
  13981. get _matrix(): Matrix;
  13982. /** @hidden */
  13983. set _matrix(value: Matrix);
  13984. /**
  13985. * Create a new bone
  13986. * @param name defines the bone name
  13987. * @param skeleton defines the parent skeleton
  13988. * @param parentBone defines the parent (can be null if the bone is the root)
  13989. * @param localMatrix defines the local matrix
  13990. * @param restPose defines the rest pose matrix
  13991. * @param baseMatrix defines the base matrix
  13992. * @param index defines index of the bone in the hiearchy
  13993. */
  13994. constructor(
  13995. /**
  13996. * defines the bone name
  13997. */
  13998. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13999. /**
  14000. * Gets the current object class name.
  14001. * @return the class name
  14002. */
  14003. getClassName(): string;
  14004. /**
  14005. * Gets the parent skeleton
  14006. * @returns a skeleton
  14007. */
  14008. getSkeleton(): Skeleton;
  14009. /**
  14010. * Gets parent bone
  14011. * @returns a bone or null if the bone is the root of the bone hierarchy
  14012. */
  14013. getParent(): Nullable<Bone>;
  14014. /**
  14015. * Returns an array containing the root bones
  14016. * @returns an array containing the root bones
  14017. */
  14018. getChildren(): Array<Bone>;
  14019. /**
  14020. * Gets the node index in matrix array generated for rendering
  14021. * @returns the node index
  14022. */
  14023. getIndex(): number;
  14024. /**
  14025. * Sets the parent bone
  14026. * @param parent defines the parent (can be null if the bone is the root)
  14027. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14028. */
  14029. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14030. /**
  14031. * Gets the local matrix
  14032. * @returns a matrix
  14033. */
  14034. getLocalMatrix(): Matrix;
  14035. /**
  14036. * Gets the base matrix (initial matrix which remains unchanged)
  14037. * @returns a matrix
  14038. */
  14039. getBaseMatrix(): Matrix;
  14040. /**
  14041. * Gets the rest pose matrix
  14042. * @returns a matrix
  14043. */
  14044. getRestPose(): Matrix;
  14045. /**
  14046. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14047. */
  14048. getWorldMatrix(): Matrix;
  14049. /**
  14050. * Sets the local matrix to rest pose matrix
  14051. */
  14052. returnToRest(): void;
  14053. /**
  14054. * Gets the inverse of the absolute transform matrix.
  14055. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14056. * @returns a matrix
  14057. */
  14058. getInvertedAbsoluteTransform(): Matrix;
  14059. /**
  14060. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14061. * @returns a matrix
  14062. */
  14063. getAbsoluteTransform(): Matrix;
  14064. /**
  14065. * Links with the given transform node.
  14066. * The local matrix of this bone is copied from the transform node every frame.
  14067. * @param transformNode defines the transform node to link to
  14068. */
  14069. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14070. /**
  14071. * Gets the node used to drive the bone's transformation
  14072. * @returns a transform node or null
  14073. */
  14074. getTransformNode(): Nullable<TransformNode>;
  14075. /** Gets or sets current position (in local space) */
  14076. get position(): Vector3;
  14077. set position(newPosition: Vector3);
  14078. /** Gets or sets current rotation (in local space) */
  14079. get rotation(): Vector3;
  14080. set rotation(newRotation: Vector3);
  14081. /** Gets or sets current rotation quaternion (in local space) */
  14082. get rotationQuaternion(): Quaternion;
  14083. set rotationQuaternion(newRotation: Quaternion);
  14084. /** Gets or sets current scaling (in local space) */
  14085. get scaling(): Vector3;
  14086. set scaling(newScaling: Vector3);
  14087. /**
  14088. * Gets the animation properties override
  14089. */
  14090. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14091. private _decompose;
  14092. private _compose;
  14093. /**
  14094. * Update the base and local matrices
  14095. * @param matrix defines the new base or local matrix
  14096. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14097. * @param updateLocalMatrix defines if the local matrix should be updated
  14098. */
  14099. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14100. /** @hidden */
  14101. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14102. /**
  14103. * Flag the bone as dirty (Forcing it to update everything)
  14104. */
  14105. markAsDirty(): void;
  14106. /** @hidden */
  14107. _markAsDirtyAndCompose(): void;
  14108. private _markAsDirtyAndDecompose;
  14109. /**
  14110. * Translate the bone in local or world space
  14111. * @param vec The amount to translate the bone
  14112. * @param space The space that the translation is in
  14113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14114. */
  14115. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14116. /**
  14117. * Set the postion of the bone in local or world space
  14118. * @param position The position to set the bone
  14119. * @param space The space that the position is in
  14120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14121. */
  14122. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14123. /**
  14124. * Set the absolute position of the bone (world space)
  14125. * @param position The position to set the bone
  14126. * @param mesh The mesh that this bone is attached to
  14127. */
  14128. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14129. /**
  14130. * Scale the bone on the x, y and z axes (in local space)
  14131. * @param x The amount to scale the bone on the x axis
  14132. * @param y The amount to scale the bone on the y axis
  14133. * @param z The amount to scale the bone on the z axis
  14134. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14135. */
  14136. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14137. /**
  14138. * Set the bone scaling in local space
  14139. * @param scale defines the scaling vector
  14140. */
  14141. setScale(scale: Vector3): void;
  14142. /**
  14143. * Gets the current scaling in local space
  14144. * @returns the current scaling vector
  14145. */
  14146. getScale(): Vector3;
  14147. /**
  14148. * Gets the current scaling in local space and stores it in a target vector
  14149. * @param result defines the target vector
  14150. */
  14151. getScaleToRef(result: Vector3): void;
  14152. /**
  14153. * Set the yaw, pitch, and roll of the bone in local or world space
  14154. * @param yaw The rotation of the bone on the y axis
  14155. * @param pitch The rotation of the bone on the x axis
  14156. * @param roll The rotation of the bone on the z axis
  14157. * @param space The space that the axes of rotation are in
  14158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14159. */
  14160. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14161. /**
  14162. * Add a rotation to the bone on an axis in local or world space
  14163. * @param axis The axis to rotate the bone on
  14164. * @param amount The amount to rotate the bone
  14165. * @param space The space that the axis is in
  14166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14167. */
  14168. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14169. /**
  14170. * Set the rotation of the bone to a particular axis angle in local or world space
  14171. * @param axis The axis to rotate the bone on
  14172. * @param angle The angle that the bone should be rotated to
  14173. * @param space The space that the axis is in
  14174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14175. */
  14176. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14177. /**
  14178. * Set the euler rotation of the bone in local of world space
  14179. * @param rotation The euler rotation that the bone should be set to
  14180. * @param space The space that the rotation is in
  14181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14182. */
  14183. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14184. /**
  14185. * Set the quaternion rotation of the bone in local of world space
  14186. * @param quat The quaternion rotation that the bone should be set to
  14187. * @param space The space that the rotation is in
  14188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14189. */
  14190. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14191. /**
  14192. * Set the rotation matrix of the bone in local of world space
  14193. * @param rotMat The rotation matrix that the bone should be set to
  14194. * @param space The space that the rotation is in
  14195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14196. */
  14197. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14198. private _rotateWithMatrix;
  14199. private _getNegativeRotationToRef;
  14200. /**
  14201. * Get the position of the bone in local or world space
  14202. * @param space The space that the returned position is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. * @returns The position of the bone
  14205. */
  14206. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14207. /**
  14208. * Copy the position of the bone to a vector3 in local or world space
  14209. * @param space The space that the returned position is in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. * @param result The vector3 to copy the position to
  14212. */
  14213. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14214. /**
  14215. * Get the absolute position of the bone (world space)
  14216. * @param mesh The mesh that this bone is attached to
  14217. * @returns The absolute position of the bone
  14218. */
  14219. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14220. /**
  14221. * Copy the absolute position of the bone (world space) to the result param
  14222. * @param mesh The mesh that this bone is attached to
  14223. * @param result The vector3 to copy the absolute position to
  14224. */
  14225. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14226. /**
  14227. * Compute the absolute transforms of this bone and its children
  14228. */
  14229. computeAbsoluteTransforms(): void;
  14230. /**
  14231. * Get the world direction from an axis that is in the local space of the bone
  14232. * @param localAxis The local direction that is used to compute the world direction
  14233. * @param mesh The mesh that this bone is attached to
  14234. * @returns The world direction
  14235. */
  14236. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14237. /**
  14238. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14239. * @param localAxis The local direction that is used to compute the world direction
  14240. * @param mesh The mesh that this bone is attached to
  14241. * @param result The vector3 that the world direction will be copied to
  14242. */
  14243. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14244. /**
  14245. * Get the euler rotation of the bone in local or world space
  14246. * @param space The space that the rotation should be in
  14247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14248. * @returns The euler rotation
  14249. */
  14250. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14251. /**
  14252. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14253. * @param space The space that the rotation should be in
  14254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14255. * @param result The vector3 that the rotation should be copied to
  14256. */
  14257. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14258. /**
  14259. * Get the quaternion rotation of the bone in either local or world space
  14260. * @param space The space that the rotation should be in
  14261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14262. * @returns The quaternion rotation
  14263. */
  14264. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14265. /**
  14266. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14267. * @param space The space that the rotation should be in
  14268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14269. * @param result The quaternion that the rotation should be copied to
  14270. */
  14271. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14272. /**
  14273. * Get the rotation matrix of the bone in local or world space
  14274. * @param space The space that the rotation should be in
  14275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14276. * @returns The rotation matrix
  14277. */
  14278. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14279. /**
  14280. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14281. * @param space The space that the rotation should be in
  14282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14283. * @param result The quaternion that the rotation should be copied to
  14284. */
  14285. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14286. /**
  14287. * Get the world position of a point that is in the local space of the bone
  14288. * @param position The local position
  14289. * @param mesh The mesh that this bone is attached to
  14290. * @returns The world position
  14291. */
  14292. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14293. /**
  14294. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14295. * @param position The local position
  14296. * @param mesh The mesh that this bone is attached to
  14297. * @param result The vector3 that the world position should be copied to
  14298. */
  14299. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14300. /**
  14301. * Get the local position of a point that is in world space
  14302. * @param position The world position
  14303. * @param mesh The mesh that this bone is attached to
  14304. * @returns The local position
  14305. */
  14306. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14307. /**
  14308. * Get the local position of a point that is in world space and copy it to the result param
  14309. * @param position The world position
  14310. * @param mesh The mesh that this bone is attached to
  14311. * @param result The vector3 that the local position should be copied to
  14312. */
  14313. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14314. }
  14315. }
  14316. declare module BABYLON {
  14317. /**
  14318. * Defines a runtime animation
  14319. */
  14320. export class RuntimeAnimation {
  14321. private _events;
  14322. /**
  14323. * The current frame of the runtime animation
  14324. */
  14325. private _currentFrame;
  14326. /**
  14327. * The animation used by the runtime animation
  14328. */
  14329. private _animation;
  14330. /**
  14331. * The target of the runtime animation
  14332. */
  14333. private _target;
  14334. /**
  14335. * The initiating animatable
  14336. */
  14337. private _host;
  14338. /**
  14339. * The original value of the runtime animation
  14340. */
  14341. private _originalValue;
  14342. /**
  14343. * The original blend value of the runtime animation
  14344. */
  14345. private _originalBlendValue;
  14346. /**
  14347. * The offsets cache of the runtime animation
  14348. */
  14349. private _offsetsCache;
  14350. /**
  14351. * The high limits cache of the runtime animation
  14352. */
  14353. private _highLimitsCache;
  14354. /**
  14355. * Specifies if the runtime animation has been stopped
  14356. */
  14357. private _stopped;
  14358. /**
  14359. * The blending factor of the runtime animation
  14360. */
  14361. private _blendingFactor;
  14362. /**
  14363. * The BabylonJS scene
  14364. */
  14365. private _scene;
  14366. /**
  14367. * The current value of the runtime animation
  14368. */
  14369. private _currentValue;
  14370. /** @hidden */
  14371. _animationState: _IAnimationState;
  14372. /**
  14373. * The active target of the runtime animation
  14374. */
  14375. private _activeTargets;
  14376. private _currentActiveTarget;
  14377. private _directTarget;
  14378. /**
  14379. * The target path of the runtime animation
  14380. */
  14381. private _targetPath;
  14382. /**
  14383. * The weight of the runtime animation
  14384. */
  14385. private _weight;
  14386. /**
  14387. * The ratio offset of the runtime animation
  14388. */
  14389. private _ratioOffset;
  14390. /**
  14391. * The previous delay of the runtime animation
  14392. */
  14393. private _previousDelay;
  14394. /**
  14395. * The previous ratio of the runtime animation
  14396. */
  14397. private _previousRatio;
  14398. private _enableBlending;
  14399. private _keys;
  14400. private _minFrame;
  14401. private _maxFrame;
  14402. private _minValue;
  14403. private _maxValue;
  14404. private _targetIsArray;
  14405. /**
  14406. * Gets the current frame of the runtime animation
  14407. */
  14408. get currentFrame(): number;
  14409. /**
  14410. * Gets the weight of the runtime animation
  14411. */
  14412. get weight(): number;
  14413. /**
  14414. * Gets the current value of the runtime animation
  14415. */
  14416. get currentValue(): any;
  14417. /**
  14418. * Gets the target path of the runtime animation
  14419. */
  14420. get targetPath(): string;
  14421. /**
  14422. * Gets the actual target of the runtime animation
  14423. */
  14424. get target(): any;
  14425. /** @hidden */
  14426. _onLoop: () => void;
  14427. /**
  14428. * Create a new RuntimeAnimation object
  14429. * @param target defines the target of the animation
  14430. * @param animation defines the source animation object
  14431. * @param scene defines the hosting scene
  14432. * @param host defines the initiating Animatable
  14433. */
  14434. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14435. private _preparePath;
  14436. /**
  14437. * Gets the animation from the runtime animation
  14438. */
  14439. get animation(): Animation;
  14440. /**
  14441. * Resets the runtime animation to the beginning
  14442. * @param restoreOriginal defines whether to restore the target property to the original value
  14443. */
  14444. reset(restoreOriginal?: boolean): void;
  14445. /**
  14446. * Specifies if the runtime animation is stopped
  14447. * @returns Boolean specifying if the runtime animation is stopped
  14448. */
  14449. isStopped(): boolean;
  14450. /**
  14451. * Disposes of the runtime animation
  14452. */
  14453. dispose(): void;
  14454. /**
  14455. * Apply the interpolated value to the target
  14456. * @param currentValue defines the value computed by the animation
  14457. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14458. */
  14459. setValue(currentValue: any, weight: number): void;
  14460. private _getOriginalValues;
  14461. private _setValue;
  14462. /**
  14463. * Gets the loop pmode of the runtime animation
  14464. * @returns Loop Mode
  14465. */
  14466. private _getCorrectLoopMode;
  14467. /**
  14468. * Move the current animation to a given frame
  14469. * @param frame defines the frame to move to
  14470. */
  14471. goToFrame(frame: number): void;
  14472. /**
  14473. * @hidden Internal use only
  14474. */
  14475. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14476. /**
  14477. * Execute the current animation
  14478. * @param delay defines the delay to add to the current frame
  14479. * @param from defines the lower bound of the animation range
  14480. * @param to defines the upper bound of the animation range
  14481. * @param loop defines if the current animation must loop
  14482. * @param speedRatio defines the current speed ratio
  14483. * @param weight defines the weight of the animation (default is -1 so no weight)
  14484. * @param onLoop optional callback called when animation loops
  14485. * @returns a boolean indicating if the animation is running
  14486. */
  14487. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14488. }
  14489. }
  14490. declare module BABYLON {
  14491. /**
  14492. * Class used to store an actual running animation
  14493. */
  14494. export class Animatable {
  14495. /** defines the target object */
  14496. target: any;
  14497. /** defines the starting frame number (default is 0) */
  14498. fromFrame: number;
  14499. /** defines the ending frame number (default is 100) */
  14500. toFrame: number;
  14501. /** defines if the animation must loop (default is false) */
  14502. loopAnimation: boolean;
  14503. /** defines a callback to call when animation ends if it is not looping */
  14504. onAnimationEnd?: (() => void) | null | undefined;
  14505. /** defines a callback to call when animation loops */
  14506. onAnimationLoop?: (() => void) | null | undefined;
  14507. private _localDelayOffset;
  14508. private _pausedDelay;
  14509. private _runtimeAnimations;
  14510. private _paused;
  14511. private _scene;
  14512. private _speedRatio;
  14513. private _weight;
  14514. private _syncRoot;
  14515. /**
  14516. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14517. * This will only apply for non looping animation (default is true)
  14518. */
  14519. disposeOnEnd: boolean;
  14520. /**
  14521. * Gets a boolean indicating if the animation has started
  14522. */
  14523. animationStarted: boolean;
  14524. /**
  14525. * Observer raised when the animation ends
  14526. */
  14527. onAnimationEndObservable: Observable<Animatable>;
  14528. /**
  14529. * Observer raised when the animation loops
  14530. */
  14531. onAnimationLoopObservable: Observable<Animatable>;
  14532. /**
  14533. * Gets the root Animatable used to synchronize and normalize animations
  14534. */
  14535. get syncRoot(): Nullable<Animatable>;
  14536. /**
  14537. * Gets the current frame of the first RuntimeAnimation
  14538. * Used to synchronize Animatables
  14539. */
  14540. get masterFrame(): number;
  14541. /**
  14542. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14543. */
  14544. get weight(): number;
  14545. set weight(value: number);
  14546. /**
  14547. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14548. */
  14549. get speedRatio(): number;
  14550. set speedRatio(value: number);
  14551. /**
  14552. * Creates a new Animatable
  14553. * @param scene defines the hosting scene
  14554. * @param target defines the target object
  14555. * @param fromFrame defines the starting frame number (default is 0)
  14556. * @param toFrame defines the ending frame number (default is 100)
  14557. * @param loopAnimation defines if the animation must loop (default is false)
  14558. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14559. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14560. * @param animations defines a group of animation to add to the new Animatable
  14561. * @param onAnimationLoop defines a callback to call when animation loops
  14562. */
  14563. constructor(scene: Scene,
  14564. /** defines the target object */
  14565. target: any,
  14566. /** defines the starting frame number (default is 0) */
  14567. fromFrame?: number,
  14568. /** defines the ending frame number (default is 100) */
  14569. toFrame?: number,
  14570. /** defines if the animation must loop (default is false) */
  14571. loopAnimation?: boolean, speedRatio?: number,
  14572. /** defines a callback to call when animation ends if it is not looping */
  14573. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14574. /** defines a callback to call when animation loops */
  14575. onAnimationLoop?: (() => void) | null | undefined);
  14576. /**
  14577. * Synchronize and normalize current Animatable with a source Animatable
  14578. * This is useful when using animation weights and when animations are not of the same length
  14579. * @param root defines the root Animatable to synchronize with
  14580. * @returns the current Animatable
  14581. */
  14582. syncWith(root: Animatable): Animatable;
  14583. /**
  14584. * Gets the list of runtime animations
  14585. * @returns an array of RuntimeAnimation
  14586. */
  14587. getAnimations(): RuntimeAnimation[];
  14588. /**
  14589. * Adds more animations to the current animatable
  14590. * @param target defines the target of the animations
  14591. * @param animations defines the new animations to add
  14592. */
  14593. appendAnimations(target: any, animations: Animation[]): void;
  14594. /**
  14595. * Gets the source animation for a specific property
  14596. * @param property defines the propertyu to look for
  14597. * @returns null or the source animation for the given property
  14598. */
  14599. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14600. /**
  14601. * Gets the runtime animation for a specific property
  14602. * @param property defines the propertyu to look for
  14603. * @returns null or the runtime animation for the given property
  14604. */
  14605. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14606. /**
  14607. * Resets the animatable to its original state
  14608. */
  14609. reset(): void;
  14610. /**
  14611. * Allows the animatable to blend with current running animations
  14612. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14613. * @param blendingSpeed defines the blending speed to use
  14614. */
  14615. enableBlending(blendingSpeed: number): void;
  14616. /**
  14617. * Disable animation blending
  14618. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14619. */
  14620. disableBlending(): void;
  14621. /**
  14622. * Jump directly to a given frame
  14623. * @param frame defines the frame to jump to
  14624. */
  14625. goToFrame(frame: number): void;
  14626. /**
  14627. * Pause the animation
  14628. */
  14629. pause(): void;
  14630. /**
  14631. * Restart the animation
  14632. */
  14633. restart(): void;
  14634. private _raiseOnAnimationEnd;
  14635. /**
  14636. * Stop and delete the current animation
  14637. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14638. * @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)
  14639. */
  14640. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14641. /**
  14642. * Wait asynchronously for the animation to end
  14643. * @returns a promise which will be fullfilled when the animation ends
  14644. */
  14645. waitAsync(): Promise<Animatable>;
  14646. /** @hidden */
  14647. _animate(delay: number): boolean;
  14648. }
  14649. interface Scene {
  14650. /** @hidden */
  14651. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14652. /** @hidden */
  14653. _processLateAnimationBindingsForMatrices(holder: {
  14654. totalWeight: number;
  14655. animations: RuntimeAnimation[];
  14656. originalValue: Matrix;
  14657. }): any;
  14658. /** @hidden */
  14659. _processLateAnimationBindingsForQuaternions(holder: {
  14660. totalWeight: number;
  14661. animations: RuntimeAnimation[];
  14662. originalValue: Quaternion;
  14663. }, refQuaternion: Quaternion): Quaternion;
  14664. /** @hidden */
  14665. _processLateAnimationBindings(): void;
  14666. /**
  14667. * Will start the animation sequence of a given target
  14668. * @param target defines the target
  14669. * @param from defines from which frame should animation start
  14670. * @param to defines until which frame should animation run.
  14671. * @param weight defines the weight to apply to the animation (1.0 by default)
  14672. * @param loop defines if the animation loops
  14673. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14674. * @param onAnimationEnd defines the function to be executed when the animation ends
  14675. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14676. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14677. * @param onAnimationLoop defines the callback to call when an animation loops
  14678. * @returns the animatable object created for this animation
  14679. */
  14680. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14681. /**
  14682. * Will start the animation sequence of a given target
  14683. * @param target defines the target
  14684. * @param from defines from which frame should animation start
  14685. * @param to defines until which frame should animation run.
  14686. * @param loop defines if the animation loops
  14687. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14688. * @param onAnimationEnd defines the function to be executed when the animation ends
  14689. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14690. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14691. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14692. * @param onAnimationLoop defines the callback to call when an animation loops
  14693. * @returns the animatable object created for this animation
  14694. */
  14695. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14696. /**
  14697. * Will start the animation sequence of a given target and its hierarchy
  14698. * @param target defines the target
  14699. * @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.
  14700. * @param from defines from which frame should animation start
  14701. * @param to defines until which frame should animation run.
  14702. * @param loop defines if the animation loops
  14703. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14704. * @param onAnimationEnd defines the function to be executed when the animation ends
  14705. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14706. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14707. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14708. * @param onAnimationLoop defines the callback to call when an animation loops
  14709. * @returns the list of created animatables
  14710. */
  14711. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  14712. /**
  14713. * Begin a new animation on a given node
  14714. * @param target defines the target where the animation will take place
  14715. * @param animations defines the list of animations to start
  14716. * @param from defines the initial value
  14717. * @param to defines the final value
  14718. * @param loop defines if you want animation to loop (off by default)
  14719. * @param speedRatio defines the speed ratio to apply to all animations
  14720. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14721. * @param onAnimationLoop defines the callback to call when an animation loops
  14722. * @returns the list of created animatables
  14723. */
  14724. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14725. /**
  14726. * Begin a new animation on a given node and its hierarchy
  14727. * @param target defines the root node where the animation will take place
  14728. * @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.
  14729. * @param animations defines the list of animations to start
  14730. * @param from defines the initial value
  14731. * @param to defines the final value
  14732. * @param loop defines if you want animation to loop (off by default)
  14733. * @param speedRatio defines the speed ratio to apply to all animations
  14734. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14735. * @param onAnimationLoop defines the callback to call when an animation loops
  14736. * @returns the list of animatables created for all nodes
  14737. */
  14738. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14739. /**
  14740. * Gets the animatable associated with a specific target
  14741. * @param target defines the target of the animatable
  14742. * @returns the required animatable if found
  14743. */
  14744. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14745. /**
  14746. * Gets all animatables associated with a given target
  14747. * @param target defines the target to look animatables for
  14748. * @returns an array of Animatables
  14749. */
  14750. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14751. /**
  14752. * Stops and removes all animations that have been applied to the scene
  14753. */
  14754. stopAllAnimations(): void;
  14755. /**
  14756. * Gets the current delta time used by animation engine
  14757. */
  14758. deltaTime: number;
  14759. }
  14760. interface Bone {
  14761. /**
  14762. * Copy an animation range from another bone
  14763. * @param source defines the source bone
  14764. * @param rangeName defines the range name to copy
  14765. * @param frameOffset defines the frame offset
  14766. * @param rescaleAsRequired defines if rescaling must be applied if required
  14767. * @param skelDimensionsRatio defines the scaling ratio
  14768. * @returns true if operation was successful
  14769. */
  14770. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14771. }
  14772. }
  14773. declare module BABYLON {
  14774. /**
  14775. * Class used to handle skinning animations
  14776. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14777. */
  14778. export class Skeleton implements IAnimatable {
  14779. /** defines the skeleton name */
  14780. name: string;
  14781. /** defines the skeleton Id */
  14782. id: string;
  14783. /**
  14784. * Defines the list of child bones
  14785. */
  14786. bones: Bone[];
  14787. /**
  14788. * Defines an estimate of the dimension of the skeleton at rest
  14789. */
  14790. dimensionsAtRest: Vector3;
  14791. /**
  14792. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14793. */
  14794. needInitialSkinMatrix: boolean;
  14795. /**
  14796. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14797. */
  14798. overrideMesh: Nullable<AbstractMesh>;
  14799. /**
  14800. * Gets the list of animations attached to this skeleton
  14801. */
  14802. animations: Array<Animation>;
  14803. private _scene;
  14804. private _isDirty;
  14805. private _transformMatrices;
  14806. private _transformMatrixTexture;
  14807. private _meshesWithPoseMatrix;
  14808. private _animatables;
  14809. private _identity;
  14810. private _synchronizedWithMesh;
  14811. private _ranges;
  14812. private _lastAbsoluteTransformsUpdateId;
  14813. private _canUseTextureForBones;
  14814. private _uniqueId;
  14815. /** @hidden */
  14816. _numBonesWithLinkedTransformNode: number;
  14817. /** @hidden */
  14818. _hasWaitingData: Nullable<boolean>;
  14819. /**
  14820. * Specifies if the skeleton should be serialized
  14821. */
  14822. doNotSerialize: boolean;
  14823. private _useTextureToStoreBoneMatrices;
  14824. /**
  14825. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14826. * Please note that this option is not available if the hardware does not support it
  14827. */
  14828. get useTextureToStoreBoneMatrices(): boolean;
  14829. set useTextureToStoreBoneMatrices(value: boolean);
  14830. private _animationPropertiesOverride;
  14831. /**
  14832. * Gets or sets the animation properties override
  14833. */
  14834. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14835. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14836. /**
  14837. * List of inspectable custom properties (used by the Inspector)
  14838. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14839. */
  14840. inspectableCustomProperties: IInspectable[];
  14841. /**
  14842. * An observable triggered before computing the skeleton's matrices
  14843. */
  14844. onBeforeComputeObservable: Observable<Skeleton>;
  14845. /**
  14846. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14847. */
  14848. get isUsingTextureForMatrices(): boolean;
  14849. /**
  14850. * Gets the unique ID of this skeleton
  14851. */
  14852. get uniqueId(): number;
  14853. /**
  14854. * Creates a new skeleton
  14855. * @param name defines the skeleton name
  14856. * @param id defines the skeleton Id
  14857. * @param scene defines the hosting scene
  14858. */
  14859. constructor(
  14860. /** defines the skeleton name */
  14861. name: string,
  14862. /** defines the skeleton Id */
  14863. id: string, scene: Scene);
  14864. /**
  14865. * Gets the current object class name.
  14866. * @return the class name
  14867. */
  14868. getClassName(): string;
  14869. /**
  14870. * Returns an array containing the root bones
  14871. * @returns an array containing the root bones
  14872. */
  14873. getChildren(): Array<Bone>;
  14874. /**
  14875. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14876. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14877. * @returns a Float32Array containing matrices data
  14878. */
  14879. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14880. /**
  14881. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14882. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14883. * @returns a raw texture containing the data
  14884. */
  14885. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14886. /**
  14887. * Gets the current hosting scene
  14888. * @returns a scene object
  14889. */
  14890. getScene(): Scene;
  14891. /**
  14892. * Gets a string representing the current skeleton data
  14893. * @param fullDetails defines a boolean indicating if we want a verbose version
  14894. * @returns a string representing the current skeleton data
  14895. */
  14896. toString(fullDetails?: boolean): string;
  14897. /**
  14898. * Get bone's index searching by name
  14899. * @param name defines bone's name to search for
  14900. * @return the indice of the bone. Returns -1 if not found
  14901. */
  14902. getBoneIndexByName(name: string): number;
  14903. /**
  14904. * Creater a new animation range
  14905. * @param name defines the name of the range
  14906. * @param from defines the start key
  14907. * @param to defines the end key
  14908. */
  14909. createAnimationRange(name: string, from: number, to: number): void;
  14910. /**
  14911. * Delete a specific animation range
  14912. * @param name defines the name of the range
  14913. * @param deleteFrames defines if frames must be removed as well
  14914. */
  14915. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14916. /**
  14917. * Gets a specific animation range
  14918. * @param name defines the name of the range to look for
  14919. * @returns the requested animation range or null if not found
  14920. */
  14921. getAnimationRange(name: string): Nullable<AnimationRange>;
  14922. /**
  14923. * Gets the list of all animation ranges defined on this skeleton
  14924. * @returns an array
  14925. */
  14926. getAnimationRanges(): Nullable<AnimationRange>[];
  14927. /**
  14928. * Copy animation range from a source skeleton.
  14929. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14930. * @param source defines the source skeleton
  14931. * @param name defines the name of the range to copy
  14932. * @param rescaleAsRequired defines if rescaling must be applied if required
  14933. * @returns true if operation was successful
  14934. */
  14935. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14936. /**
  14937. * Forces the skeleton to go to rest pose
  14938. */
  14939. returnToRest(): void;
  14940. private _getHighestAnimationFrame;
  14941. /**
  14942. * Begin a specific animation range
  14943. * @param name defines the name of the range to start
  14944. * @param loop defines if looping must be turned on (false by default)
  14945. * @param speedRatio defines the speed ratio to apply (1 by default)
  14946. * @param onAnimationEnd defines a callback which will be called when animation will end
  14947. * @returns a new animatable
  14948. */
  14949. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  14950. /** @hidden */
  14951. _markAsDirty(): void;
  14952. /** @hidden */
  14953. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14954. /** @hidden */
  14955. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14956. private _computeTransformMatrices;
  14957. /**
  14958. * Build all resources required to render a skeleton
  14959. */
  14960. prepare(): void;
  14961. /**
  14962. * Gets the list of animatables currently running for this skeleton
  14963. * @returns an array of animatables
  14964. */
  14965. getAnimatables(): IAnimatable[];
  14966. /**
  14967. * Clone the current skeleton
  14968. * @param name defines the name of the new skeleton
  14969. * @param id defines the id of the new skeleton
  14970. * @returns the new skeleton
  14971. */
  14972. clone(name: string, id?: string): Skeleton;
  14973. /**
  14974. * Enable animation blending for this skeleton
  14975. * @param blendingSpeed defines the blending speed to apply
  14976. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14977. */
  14978. enableBlending(blendingSpeed?: number): void;
  14979. /**
  14980. * Releases all resources associated with the current skeleton
  14981. */
  14982. dispose(): void;
  14983. /**
  14984. * Serialize the skeleton in a JSON object
  14985. * @returns a JSON object
  14986. */
  14987. serialize(): any;
  14988. /**
  14989. * Creates a new skeleton from serialized data
  14990. * @param parsedSkeleton defines the serialized data
  14991. * @param scene defines the hosting scene
  14992. * @returns a new skeleton
  14993. */
  14994. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  14995. /**
  14996. * Compute all node absolute transforms
  14997. * @param forceUpdate defines if computation must be done even if cache is up to date
  14998. */
  14999. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15000. /**
  15001. * Gets the root pose matrix
  15002. * @returns a matrix
  15003. */
  15004. getPoseMatrix(): Nullable<Matrix>;
  15005. /**
  15006. * Sorts bones per internal index
  15007. */
  15008. sortBones(): void;
  15009. private _sortBones;
  15010. }
  15011. }
  15012. declare module BABYLON {
  15013. /**
  15014. * Creates an instance based on a source mesh.
  15015. */
  15016. export class InstancedMesh extends AbstractMesh {
  15017. private _sourceMesh;
  15018. private _currentLOD;
  15019. /** @hidden */
  15020. _indexInSourceMeshInstanceArray: number;
  15021. constructor(name: string, source: Mesh);
  15022. /**
  15023. * Returns the string "InstancedMesh".
  15024. */
  15025. getClassName(): string;
  15026. /** Gets the list of lights affecting that mesh */
  15027. get lightSources(): Light[];
  15028. _resyncLightSources(): void;
  15029. _resyncLightSource(light: Light): void;
  15030. _removeLightSource(light: Light, dispose: boolean): void;
  15031. /**
  15032. * If the source mesh receives shadows
  15033. */
  15034. get receiveShadows(): boolean;
  15035. /**
  15036. * The material of the source mesh
  15037. */
  15038. get material(): Nullable<Material>;
  15039. /**
  15040. * Visibility of the source mesh
  15041. */
  15042. get visibility(): number;
  15043. /**
  15044. * Skeleton of the source mesh
  15045. */
  15046. get skeleton(): Nullable<Skeleton>;
  15047. /**
  15048. * Rendering ground id of the source mesh
  15049. */
  15050. get renderingGroupId(): number;
  15051. set renderingGroupId(value: number);
  15052. /**
  15053. * Returns the total number of vertices (integer).
  15054. */
  15055. getTotalVertices(): number;
  15056. /**
  15057. * Returns a positive integer : the total number of indices in this mesh geometry.
  15058. * @returns the numner of indices or zero if the mesh has no geometry.
  15059. */
  15060. getTotalIndices(): number;
  15061. /**
  15062. * The source mesh of the instance
  15063. */
  15064. get sourceMesh(): Mesh;
  15065. /**
  15066. * Is this node ready to be used/rendered
  15067. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15068. * @return {boolean} is it ready
  15069. */
  15070. isReady(completeCheck?: boolean): boolean;
  15071. /**
  15072. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15073. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15074. * @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.
  15075. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15076. */
  15077. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15078. /**
  15079. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15080. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15081. * The `data` are either a numeric array either a Float32Array.
  15082. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15083. * 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).
  15084. * Note that a new underlying VertexBuffer object is created each call.
  15085. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15086. *
  15087. * Possible `kind` values :
  15088. * - VertexBuffer.PositionKind
  15089. * - VertexBuffer.UVKind
  15090. * - VertexBuffer.UV2Kind
  15091. * - VertexBuffer.UV3Kind
  15092. * - VertexBuffer.UV4Kind
  15093. * - VertexBuffer.UV5Kind
  15094. * - VertexBuffer.UV6Kind
  15095. * - VertexBuffer.ColorKind
  15096. * - VertexBuffer.MatricesIndicesKind
  15097. * - VertexBuffer.MatricesIndicesExtraKind
  15098. * - VertexBuffer.MatricesWeightsKind
  15099. * - VertexBuffer.MatricesWeightsExtraKind
  15100. *
  15101. * Returns the Mesh.
  15102. */
  15103. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15104. /**
  15105. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15106. * If the mesh has no geometry, it is simply returned as it is.
  15107. * The `data` are either a numeric array either a Float32Array.
  15108. * No new underlying VertexBuffer object is created.
  15109. * 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.
  15110. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15111. *
  15112. * Possible `kind` values :
  15113. * - VertexBuffer.PositionKind
  15114. * - VertexBuffer.UVKind
  15115. * - VertexBuffer.UV2Kind
  15116. * - VertexBuffer.UV3Kind
  15117. * - VertexBuffer.UV4Kind
  15118. * - VertexBuffer.UV5Kind
  15119. * - VertexBuffer.UV6Kind
  15120. * - VertexBuffer.ColorKind
  15121. * - VertexBuffer.MatricesIndicesKind
  15122. * - VertexBuffer.MatricesIndicesExtraKind
  15123. * - VertexBuffer.MatricesWeightsKind
  15124. * - VertexBuffer.MatricesWeightsExtraKind
  15125. *
  15126. * Returns the Mesh.
  15127. */
  15128. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15129. /**
  15130. * Sets the mesh indices.
  15131. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15132. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15133. * This method creates a new index buffer each call.
  15134. * Returns the Mesh.
  15135. */
  15136. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15137. /**
  15138. * Boolean : True if the mesh owns the requested kind of data.
  15139. */
  15140. isVerticesDataPresent(kind: string): boolean;
  15141. /**
  15142. * Returns an array of indices (IndicesArray).
  15143. */
  15144. getIndices(): Nullable<IndicesArray>;
  15145. get _positions(): Nullable<Vector3[]>;
  15146. /**
  15147. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15148. * This means the mesh underlying bounding box and sphere are recomputed.
  15149. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15150. * @returns the current mesh
  15151. */
  15152. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15153. /** @hidden */
  15154. _preActivate(): InstancedMesh;
  15155. /** @hidden */
  15156. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15157. /** @hidden */
  15158. _postActivate(): void;
  15159. getWorldMatrix(): Matrix;
  15160. get isAnInstance(): boolean;
  15161. /**
  15162. * Returns the current associated LOD AbstractMesh.
  15163. */
  15164. getLOD(camera: Camera): AbstractMesh;
  15165. /** @hidden */
  15166. _syncSubMeshes(): InstancedMesh;
  15167. /** @hidden */
  15168. _generatePointsArray(): boolean;
  15169. /**
  15170. * Creates a new InstancedMesh from the current mesh.
  15171. * - name (string) : the cloned mesh name
  15172. * - newParent (optional Node) : the optional Node to parent the clone to.
  15173. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15174. *
  15175. * Returns the clone.
  15176. */
  15177. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15178. /**
  15179. * Disposes the InstancedMesh.
  15180. * Returns nothing.
  15181. */
  15182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15183. }
  15184. interface Mesh {
  15185. /**
  15186. * Register a custom buffer that will be instanced
  15187. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15188. * @param kind defines the buffer kind
  15189. * @param stride defines the stride in floats
  15190. */
  15191. registerInstancedBuffer(kind: string, stride: number): void;
  15192. /** @hidden */
  15193. _userInstancedBuffersStorage: {
  15194. data: {
  15195. [key: string]: Float32Array;
  15196. };
  15197. sizes: {
  15198. [key: string]: number;
  15199. };
  15200. vertexBuffers: {
  15201. [key: string]: Nullable<VertexBuffer>;
  15202. };
  15203. strides: {
  15204. [key: string]: number;
  15205. };
  15206. };
  15207. }
  15208. interface AbstractMesh {
  15209. /**
  15210. * Object used to store instanced buffers defined by user
  15211. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15212. */
  15213. instancedBuffers: {
  15214. [key: string]: any;
  15215. };
  15216. }
  15217. }
  15218. declare module BABYLON {
  15219. /**
  15220. * Defines the options associated with the creation of a shader material.
  15221. */
  15222. export interface IShaderMaterialOptions {
  15223. /**
  15224. * Does the material work in alpha blend mode
  15225. */
  15226. needAlphaBlending: boolean;
  15227. /**
  15228. * Does the material work in alpha test mode
  15229. */
  15230. needAlphaTesting: boolean;
  15231. /**
  15232. * The list of attribute names used in the shader
  15233. */
  15234. attributes: string[];
  15235. /**
  15236. * The list of unifrom names used in the shader
  15237. */
  15238. uniforms: string[];
  15239. /**
  15240. * The list of UBO names used in the shader
  15241. */
  15242. uniformBuffers: string[];
  15243. /**
  15244. * The list of sampler names used in the shader
  15245. */
  15246. samplers: string[];
  15247. /**
  15248. * The list of defines used in the shader
  15249. */
  15250. defines: string[];
  15251. }
  15252. /**
  15253. * 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.
  15254. *
  15255. * This returned material effects how the mesh will look based on the code in the shaders.
  15256. *
  15257. * @see http://doc.babylonjs.com/how_to/shader_material
  15258. */
  15259. export class ShaderMaterial extends Material {
  15260. private _shaderPath;
  15261. private _options;
  15262. private _textures;
  15263. private _textureArrays;
  15264. private _floats;
  15265. private _ints;
  15266. private _floatsArrays;
  15267. private _colors3;
  15268. private _colors3Arrays;
  15269. private _colors4;
  15270. private _colors4Arrays;
  15271. private _vectors2;
  15272. private _vectors3;
  15273. private _vectors4;
  15274. private _matrices;
  15275. private _matrixArrays;
  15276. private _matrices3x3;
  15277. private _matrices2x2;
  15278. private _vectors2Arrays;
  15279. private _vectors3Arrays;
  15280. private _vectors4Arrays;
  15281. private _cachedWorldViewMatrix;
  15282. private _cachedWorldViewProjectionMatrix;
  15283. private _renderId;
  15284. private _multiview;
  15285. /**
  15286. * Instantiate a new shader material.
  15287. * 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.
  15288. * This returned material effects how the mesh will look based on the code in the shaders.
  15289. * @see http://doc.babylonjs.com/how_to/shader_material
  15290. * @param name Define the name of the material in the scene
  15291. * @param scene Define the scene the material belongs to
  15292. * @param shaderPath Defines the route to the shader code in one of three ways:
  15293. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15294. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15295. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15296. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15297. * @param options Define the options used to create the shader
  15298. */
  15299. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15300. /**
  15301. * Gets the shader path used to define the shader code
  15302. * It can be modified to trigger a new compilation
  15303. */
  15304. get shaderPath(): any;
  15305. /**
  15306. * Sets the shader path used to define the shader code
  15307. * It can be modified to trigger a new compilation
  15308. */
  15309. set shaderPath(shaderPath: any);
  15310. /**
  15311. * Gets the options used to compile the shader.
  15312. * They can be modified to trigger a new compilation
  15313. */
  15314. get options(): IShaderMaterialOptions;
  15315. /**
  15316. * Gets the current class name of the material e.g. "ShaderMaterial"
  15317. * Mainly use in serialization.
  15318. * @returns the class name
  15319. */
  15320. getClassName(): string;
  15321. /**
  15322. * Specifies if the material will require alpha blending
  15323. * @returns a boolean specifying if alpha blending is needed
  15324. */
  15325. needAlphaBlending(): boolean;
  15326. /**
  15327. * Specifies if this material should be rendered in alpha test mode
  15328. * @returns a boolean specifying if an alpha test is needed.
  15329. */
  15330. needAlphaTesting(): boolean;
  15331. private _checkUniform;
  15332. /**
  15333. * Set a texture in the shader.
  15334. * @param name Define the name of the uniform samplers as defined in the shader
  15335. * @param texture Define the texture to bind to this sampler
  15336. * @return the material itself allowing "fluent" like uniform updates
  15337. */
  15338. setTexture(name: string, texture: Texture): ShaderMaterial;
  15339. /**
  15340. * Set a texture array in the shader.
  15341. * @param name Define the name of the uniform sampler array as defined in the shader
  15342. * @param textures Define the list of textures to bind to this sampler
  15343. * @return the material itself allowing "fluent" like uniform updates
  15344. */
  15345. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15346. /**
  15347. * Set a float in the shader.
  15348. * @param name Define the name of the uniform as defined in the shader
  15349. * @param value Define the value to give to the uniform
  15350. * @return the material itself allowing "fluent" like uniform updates
  15351. */
  15352. setFloat(name: string, value: number): ShaderMaterial;
  15353. /**
  15354. * Set a int in the shader.
  15355. * @param name Define the name of the uniform as defined in the shader
  15356. * @param value Define the value to give to the uniform
  15357. * @return the material itself allowing "fluent" like uniform updates
  15358. */
  15359. setInt(name: string, value: number): ShaderMaterial;
  15360. /**
  15361. * Set an array of floats in the shader.
  15362. * @param name Define the name of the uniform as defined in the shader
  15363. * @param value Define the value to give to the uniform
  15364. * @return the material itself allowing "fluent" like uniform updates
  15365. */
  15366. setFloats(name: string, value: number[]): ShaderMaterial;
  15367. /**
  15368. * Set a vec3 in the shader from a Color3.
  15369. * @param name Define the name of the uniform as defined in the shader
  15370. * @param value Define the value to give to the uniform
  15371. * @return the material itself allowing "fluent" like uniform updates
  15372. */
  15373. setColor3(name: string, value: Color3): ShaderMaterial;
  15374. /**
  15375. * Set a vec3 array in the shader from a Color3 array.
  15376. * @param name Define the name of the uniform as defined in the shader
  15377. * @param value Define the value to give to the uniform
  15378. * @return the material itself allowing "fluent" like uniform updates
  15379. */
  15380. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15381. /**
  15382. * Set a vec4 in the shader from a Color4.
  15383. * @param name Define the name of the uniform as defined in the shader
  15384. * @param value Define the value to give to the uniform
  15385. * @return the material itself allowing "fluent" like uniform updates
  15386. */
  15387. setColor4(name: string, value: Color4): ShaderMaterial;
  15388. /**
  15389. * Set a vec4 array in the shader from a Color4 array.
  15390. * @param name Define the name of the uniform as defined in the shader
  15391. * @param value Define the value to give to the uniform
  15392. * @return the material itself allowing "fluent" like uniform updates
  15393. */
  15394. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15395. /**
  15396. * Set a vec2 in the shader from a Vector2.
  15397. * @param name Define the name of the uniform as defined in the shader
  15398. * @param value Define the value to give to the uniform
  15399. * @return the material itself allowing "fluent" like uniform updates
  15400. */
  15401. setVector2(name: string, value: Vector2): ShaderMaterial;
  15402. /**
  15403. * Set a vec3 in the shader from a Vector3.
  15404. * @param name Define the name of the uniform as defined in the shader
  15405. * @param value Define the value to give to the uniform
  15406. * @return the material itself allowing "fluent" like uniform updates
  15407. */
  15408. setVector3(name: string, value: Vector3): ShaderMaterial;
  15409. /**
  15410. * Set a vec4 in the shader from a Vector4.
  15411. * @param name Define the name of the uniform as defined in the shader
  15412. * @param value Define the value to give to the uniform
  15413. * @return the material itself allowing "fluent" like uniform updates
  15414. */
  15415. setVector4(name: string, value: Vector4): ShaderMaterial;
  15416. /**
  15417. * Set a mat4 in the shader from a Matrix.
  15418. * @param name Define the name of the uniform as defined in the shader
  15419. * @param value Define the value to give to the uniform
  15420. * @return the material itself allowing "fluent" like uniform updates
  15421. */
  15422. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15423. /**
  15424. * Set a float32Array in the shader from a matrix array.
  15425. * @param name Define the name of the uniform as defined in the shader
  15426. * @param value Define the value to give to the uniform
  15427. * @return the material itself allowing "fluent" like uniform updates
  15428. */
  15429. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15430. /**
  15431. * Set a mat3 in the shader from a Float32Array.
  15432. * @param name Define the name of the uniform as defined in the shader
  15433. * @param value Define the value to give to the uniform
  15434. * @return the material itself allowing "fluent" like uniform updates
  15435. */
  15436. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15437. /**
  15438. * Set a mat2 in the shader from a Float32Array.
  15439. * @param name Define the name of the uniform as defined in the shader
  15440. * @param value Define the value to give to the uniform
  15441. * @return the material itself allowing "fluent" like uniform updates
  15442. */
  15443. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15444. /**
  15445. * Set a vec2 array in the shader from a number array.
  15446. * @param name Define the name of the uniform as defined in the shader
  15447. * @param value Define the value to give to the uniform
  15448. * @return the material itself allowing "fluent" like uniform updates
  15449. */
  15450. setArray2(name: string, value: number[]): ShaderMaterial;
  15451. /**
  15452. * Set a vec3 array in the shader from a number array.
  15453. * @param name Define the name of the uniform as defined in the shader
  15454. * @param value Define the value to give to the uniform
  15455. * @return the material itself allowing "fluent" like uniform updates
  15456. */
  15457. setArray3(name: string, value: number[]): ShaderMaterial;
  15458. /**
  15459. * Set a vec4 array in the shader from a number array.
  15460. * @param name Define the name of the uniform as defined in the shader
  15461. * @param value Define the value to give to the uniform
  15462. * @return the material itself allowing "fluent" like uniform updates
  15463. */
  15464. setArray4(name: string, value: number[]): ShaderMaterial;
  15465. private _checkCache;
  15466. /**
  15467. * Specifies that the submesh is ready to be used
  15468. * @param mesh defines the mesh to check
  15469. * @param subMesh defines which submesh to check
  15470. * @param useInstances specifies that instances should be used
  15471. * @returns a boolean indicating that the submesh is ready or not
  15472. */
  15473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15474. /**
  15475. * Checks if the material is ready to render the requested mesh
  15476. * @param mesh Define the mesh to render
  15477. * @param useInstances Define whether or not the material is used with instances
  15478. * @returns true if ready, otherwise false
  15479. */
  15480. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15481. /**
  15482. * Binds the world matrix to the material
  15483. * @param world defines the world transformation matrix
  15484. */
  15485. bindOnlyWorldMatrix(world: Matrix): void;
  15486. /**
  15487. * Binds the material to the mesh
  15488. * @param world defines the world transformation matrix
  15489. * @param mesh defines the mesh to bind the material to
  15490. */
  15491. bind(world: Matrix, mesh?: Mesh): void;
  15492. /**
  15493. * Gets the active textures from the material
  15494. * @returns an array of textures
  15495. */
  15496. getActiveTextures(): BaseTexture[];
  15497. /**
  15498. * Specifies if the material uses a texture
  15499. * @param texture defines the texture to check against the material
  15500. * @returns a boolean specifying if the material uses the texture
  15501. */
  15502. hasTexture(texture: BaseTexture): boolean;
  15503. /**
  15504. * Makes a duplicate of the material, and gives it a new name
  15505. * @param name defines the new name for the duplicated material
  15506. * @returns the cloned material
  15507. */
  15508. clone(name: string): ShaderMaterial;
  15509. /**
  15510. * Disposes the material
  15511. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15512. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15513. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15514. */
  15515. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15516. /**
  15517. * Serializes this material in a JSON representation
  15518. * @returns the serialized material object
  15519. */
  15520. serialize(): any;
  15521. /**
  15522. * Creates a shader material from parsed shader material data
  15523. * @param source defines the JSON represnetation of the material
  15524. * @param scene defines the hosting scene
  15525. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15526. * @returns a new material
  15527. */
  15528. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15529. }
  15530. }
  15531. declare module BABYLON {
  15532. /** @hidden */
  15533. export var colorPixelShader: {
  15534. name: string;
  15535. shader: string;
  15536. };
  15537. }
  15538. declare module BABYLON {
  15539. /** @hidden */
  15540. export var colorVertexShader: {
  15541. name: string;
  15542. shader: string;
  15543. };
  15544. }
  15545. declare module BABYLON {
  15546. /**
  15547. * Line mesh
  15548. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15549. */
  15550. export class LinesMesh extends Mesh {
  15551. /**
  15552. * If vertex color should be applied to the mesh
  15553. */
  15554. readonly useVertexColor?: boolean | undefined;
  15555. /**
  15556. * If vertex alpha should be applied to the mesh
  15557. */
  15558. readonly useVertexAlpha?: boolean | undefined;
  15559. /**
  15560. * Color of the line (Default: White)
  15561. */
  15562. color: Color3;
  15563. /**
  15564. * Alpha of the line (Default: 1)
  15565. */
  15566. alpha: number;
  15567. /**
  15568. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15569. * This margin is expressed in world space coordinates, so its value may vary.
  15570. * Default value is 0.1
  15571. */
  15572. intersectionThreshold: number;
  15573. private _colorShader;
  15574. private color4;
  15575. /**
  15576. * Creates a new LinesMesh
  15577. * @param name defines the name
  15578. * @param scene defines the hosting scene
  15579. * @param parent defines the parent mesh if any
  15580. * @param source defines the optional source LinesMesh used to clone data from
  15581. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15582. * When false, achieved by calling a clone(), also passing False.
  15583. * This will make creation of children, recursive.
  15584. * @param useVertexColor defines if this LinesMesh supports vertex color
  15585. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15586. */
  15587. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15588. /**
  15589. * If vertex color should be applied to the mesh
  15590. */
  15591. useVertexColor?: boolean | undefined,
  15592. /**
  15593. * If vertex alpha should be applied to the mesh
  15594. */
  15595. useVertexAlpha?: boolean | undefined);
  15596. private _addClipPlaneDefine;
  15597. private _removeClipPlaneDefine;
  15598. isReady(): boolean;
  15599. /**
  15600. * Returns the string "LineMesh"
  15601. */
  15602. getClassName(): string;
  15603. /**
  15604. * @hidden
  15605. */
  15606. get material(): Material;
  15607. /**
  15608. * @hidden
  15609. */
  15610. set material(value: Material);
  15611. /**
  15612. * @hidden
  15613. */
  15614. get checkCollisions(): boolean;
  15615. /** @hidden */
  15616. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15617. /** @hidden */
  15618. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15619. /**
  15620. * Disposes of the line mesh
  15621. * @param doNotRecurse If children should be disposed
  15622. */
  15623. dispose(doNotRecurse?: boolean): void;
  15624. /**
  15625. * Returns a new LineMesh object cloned from the current one.
  15626. */
  15627. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15628. /**
  15629. * Creates a new InstancedLinesMesh object from the mesh model.
  15630. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15631. * @param name defines the name of the new instance
  15632. * @returns a new InstancedLinesMesh
  15633. */
  15634. createInstance(name: string): InstancedLinesMesh;
  15635. }
  15636. /**
  15637. * Creates an instance based on a source LinesMesh
  15638. */
  15639. export class InstancedLinesMesh extends InstancedMesh {
  15640. /**
  15641. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15642. * This margin is expressed in world space coordinates, so its value may vary.
  15643. * Initilized with the intersectionThreshold value of the source LinesMesh
  15644. */
  15645. intersectionThreshold: number;
  15646. constructor(name: string, source: LinesMesh);
  15647. /**
  15648. * Returns the string "InstancedLinesMesh".
  15649. */
  15650. getClassName(): string;
  15651. }
  15652. }
  15653. declare module BABYLON {
  15654. /** @hidden */
  15655. export var linePixelShader: {
  15656. name: string;
  15657. shader: string;
  15658. };
  15659. }
  15660. declare module BABYLON {
  15661. /** @hidden */
  15662. export var lineVertexShader: {
  15663. name: string;
  15664. shader: string;
  15665. };
  15666. }
  15667. declare module BABYLON {
  15668. interface AbstractMesh {
  15669. /**
  15670. * Gets the edgesRenderer associated with the mesh
  15671. */
  15672. edgesRenderer: Nullable<EdgesRenderer>;
  15673. }
  15674. interface LinesMesh {
  15675. /**
  15676. * Enables the edge rendering mode on the mesh.
  15677. * This mode makes the mesh edges visible
  15678. * @param epsilon defines the maximal distance between two angles to detect a face
  15679. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15680. * @returns the currentAbstractMesh
  15681. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15682. */
  15683. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15684. }
  15685. interface InstancedLinesMesh {
  15686. /**
  15687. * Enables the edge rendering mode on the mesh.
  15688. * This mode makes the mesh edges visible
  15689. * @param epsilon defines the maximal distance between two angles to detect a face
  15690. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15691. * @returns the current InstancedLinesMesh
  15692. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15693. */
  15694. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15695. }
  15696. /**
  15697. * Defines the minimum contract an Edges renderer should follow.
  15698. */
  15699. export interface IEdgesRenderer extends IDisposable {
  15700. /**
  15701. * Gets or sets a boolean indicating if the edgesRenderer is active
  15702. */
  15703. isEnabled: boolean;
  15704. /**
  15705. * Renders the edges of the attached mesh,
  15706. */
  15707. render(): void;
  15708. /**
  15709. * Checks wether or not the edges renderer is ready to render.
  15710. * @return true if ready, otherwise false.
  15711. */
  15712. isReady(): boolean;
  15713. }
  15714. /**
  15715. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15716. */
  15717. export class EdgesRenderer implements IEdgesRenderer {
  15718. /**
  15719. * Define the size of the edges with an orthographic camera
  15720. */
  15721. edgesWidthScalerForOrthographic: number;
  15722. /**
  15723. * Define the size of the edges with a perspective camera
  15724. */
  15725. edgesWidthScalerForPerspective: number;
  15726. protected _source: AbstractMesh;
  15727. protected _linesPositions: number[];
  15728. protected _linesNormals: number[];
  15729. protected _linesIndices: number[];
  15730. protected _epsilon: number;
  15731. protected _indicesCount: number;
  15732. protected _lineShader: ShaderMaterial;
  15733. protected _ib: DataBuffer;
  15734. protected _buffers: {
  15735. [key: string]: Nullable<VertexBuffer>;
  15736. };
  15737. protected _checkVerticesInsteadOfIndices: boolean;
  15738. private _meshRebuildObserver;
  15739. private _meshDisposeObserver;
  15740. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15741. isEnabled: boolean;
  15742. /**
  15743. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15744. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15745. * @param source Mesh used to create edges
  15746. * @param epsilon sum of angles in adjacency to check for edge
  15747. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15748. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15749. */
  15750. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15751. protected _prepareRessources(): void;
  15752. /** @hidden */
  15753. _rebuild(): void;
  15754. /**
  15755. * Releases the required resources for the edges renderer
  15756. */
  15757. dispose(): void;
  15758. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15759. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15760. /**
  15761. * Checks if the pair of p0 and p1 is en edge
  15762. * @param faceIndex
  15763. * @param edge
  15764. * @param faceNormals
  15765. * @param p0
  15766. * @param p1
  15767. * @private
  15768. */
  15769. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15770. /**
  15771. * push line into the position, normal and index buffer
  15772. * @protected
  15773. */
  15774. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15775. /**
  15776. * Generates lines edges from adjacencjes
  15777. * @private
  15778. */
  15779. _generateEdgesLines(): void;
  15780. /**
  15781. * Checks wether or not the edges renderer is ready to render.
  15782. * @return true if ready, otherwise false.
  15783. */
  15784. isReady(): boolean;
  15785. /**
  15786. * Renders the edges of the attached mesh,
  15787. */
  15788. render(): void;
  15789. }
  15790. /**
  15791. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15792. */
  15793. export class LineEdgesRenderer extends EdgesRenderer {
  15794. /**
  15795. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15796. * @param source LineMesh used to generate edges
  15797. * @param epsilon not important (specified angle for edge detection)
  15798. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15799. */
  15800. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15801. /**
  15802. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15803. */
  15804. _generateEdgesLines(): void;
  15805. }
  15806. }
  15807. declare module BABYLON {
  15808. /**
  15809. * This represents the object necessary to create a rendering group.
  15810. * This is exclusively used and created by the rendering manager.
  15811. * To modify the behavior, you use the available helpers in your scene or meshes.
  15812. * @hidden
  15813. */
  15814. export class RenderingGroup {
  15815. index: number;
  15816. private static _zeroVector;
  15817. private _scene;
  15818. private _opaqueSubMeshes;
  15819. private _transparentSubMeshes;
  15820. private _alphaTestSubMeshes;
  15821. private _depthOnlySubMeshes;
  15822. private _particleSystems;
  15823. private _spriteManagers;
  15824. private _opaqueSortCompareFn;
  15825. private _alphaTestSortCompareFn;
  15826. private _transparentSortCompareFn;
  15827. private _renderOpaque;
  15828. private _renderAlphaTest;
  15829. private _renderTransparent;
  15830. /** @hidden */
  15831. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15832. onBeforeTransparentRendering: () => void;
  15833. /**
  15834. * Set the opaque sort comparison function.
  15835. * If null the sub meshes will be render in the order they were created
  15836. */
  15837. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15838. /**
  15839. * Set the alpha test sort comparison function.
  15840. * If null the sub meshes will be render in the order they were created
  15841. */
  15842. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15843. /**
  15844. * Set the transparent sort comparison function.
  15845. * If null the sub meshes will be render in the order they were created
  15846. */
  15847. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15848. /**
  15849. * Creates a new rendering group.
  15850. * @param index The rendering group index
  15851. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15852. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15853. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15854. */
  15855. 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>);
  15856. /**
  15857. * Render all the sub meshes contained in the group.
  15858. * @param customRenderFunction Used to override the default render behaviour of the group.
  15859. * @returns true if rendered some submeshes.
  15860. */
  15861. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15862. /**
  15863. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15864. * @param subMeshes The submeshes to render
  15865. */
  15866. private renderOpaqueSorted;
  15867. /**
  15868. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15869. * @param subMeshes The submeshes to render
  15870. */
  15871. private renderAlphaTestSorted;
  15872. /**
  15873. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15874. * @param subMeshes The submeshes to render
  15875. */
  15876. private renderTransparentSorted;
  15877. /**
  15878. * Renders the submeshes in a specified order.
  15879. * @param subMeshes The submeshes to sort before render
  15880. * @param sortCompareFn The comparison function use to sort
  15881. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15882. * @param transparent Specifies to activate blending if true
  15883. */
  15884. private static renderSorted;
  15885. /**
  15886. * Renders the submeshes in the order they were dispatched (no sort applied).
  15887. * @param subMeshes The submeshes to render
  15888. */
  15889. private static renderUnsorted;
  15890. /**
  15891. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15892. * are rendered back to front if in the same alpha index.
  15893. *
  15894. * @param a The first submesh
  15895. * @param b The second submesh
  15896. * @returns The result of the comparison
  15897. */
  15898. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15899. /**
  15900. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15901. * are rendered back to front.
  15902. *
  15903. * @param a The first submesh
  15904. * @param b The second submesh
  15905. * @returns The result of the comparison
  15906. */
  15907. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15908. /**
  15909. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15910. * are rendered front to back (prevent overdraw).
  15911. *
  15912. * @param a The first submesh
  15913. * @param b The second submesh
  15914. * @returns The result of the comparison
  15915. */
  15916. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15917. /**
  15918. * Resets the different lists of submeshes to prepare a new frame.
  15919. */
  15920. prepare(): void;
  15921. dispose(): void;
  15922. /**
  15923. * Inserts the submesh in its correct queue depending on its material.
  15924. * @param subMesh The submesh to dispatch
  15925. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15926. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15927. */
  15928. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15929. dispatchSprites(spriteManager: ISpriteManager): void;
  15930. dispatchParticles(particleSystem: IParticleSystem): void;
  15931. private _renderParticles;
  15932. private _renderSprites;
  15933. }
  15934. }
  15935. declare module BABYLON {
  15936. /**
  15937. * Interface describing the different options available in the rendering manager
  15938. * regarding Auto Clear between groups.
  15939. */
  15940. export interface IRenderingManagerAutoClearSetup {
  15941. /**
  15942. * Defines whether or not autoclear is enable.
  15943. */
  15944. autoClear: boolean;
  15945. /**
  15946. * Defines whether or not to autoclear the depth buffer.
  15947. */
  15948. depth: boolean;
  15949. /**
  15950. * Defines whether or not to autoclear the stencil buffer.
  15951. */
  15952. stencil: boolean;
  15953. }
  15954. /**
  15955. * This class is used by the onRenderingGroupObservable
  15956. */
  15957. export class RenderingGroupInfo {
  15958. /**
  15959. * The Scene that being rendered
  15960. */
  15961. scene: Scene;
  15962. /**
  15963. * The camera currently used for the rendering pass
  15964. */
  15965. camera: Nullable<Camera>;
  15966. /**
  15967. * The ID of the renderingGroup being processed
  15968. */
  15969. renderingGroupId: number;
  15970. }
  15971. /**
  15972. * This is the manager responsible of all the rendering for meshes sprites and particles.
  15973. * It is enable to manage the different groups as well as the different necessary sort functions.
  15974. * This should not be used directly aside of the few static configurations
  15975. */
  15976. export class RenderingManager {
  15977. /**
  15978. * The max id used for rendering groups (not included)
  15979. */
  15980. static MAX_RENDERINGGROUPS: number;
  15981. /**
  15982. * The min id used for rendering groups (included)
  15983. */
  15984. static MIN_RENDERINGGROUPS: number;
  15985. /**
  15986. * Used to globally prevent autoclearing scenes.
  15987. */
  15988. static AUTOCLEAR: boolean;
  15989. /**
  15990. * @hidden
  15991. */
  15992. _useSceneAutoClearSetup: boolean;
  15993. private _scene;
  15994. private _renderingGroups;
  15995. private _depthStencilBufferAlreadyCleaned;
  15996. private _autoClearDepthStencil;
  15997. private _customOpaqueSortCompareFn;
  15998. private _customAlphaTestSortCompareFn;
  15999. private _customTransparentSortCompareFn;
  16000. private _renderingGroupInfo;
  16001. /**
  16002. * Instantiates a new rendering group for a particular scene
  16003. * @param scene Defines the scene the groups belongs to
  16004. */
  16005. constructor(scene: Scene);
  16006. private _clearDepthStencilBuffer;
  16007. /**
  16008. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16009. * @hidden
  16010. */
  16011. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16012. /**
  16013. * Resets the different information of the group to prepare a new frame
  16014. * @hidden
  16015. */
  16016. reset(): void;
  16017. /**
  16018. * Dispose and release the group and its associated resources.
  16019. * @hidden
  16020. */
  16021. dispose(): void;
  16022. /**
  16023. * Clear the info related to rendering groups preventing retention points during dispose.
  16024. */
  16025. freeRenderingGroups(): void;
  16026. private _prepareRenderingGroup;
  16027. /**
  16028. * Add a sprite manager to the rendering manager in order to render it this frame.
  16029. * @param spriteManager Define the sprite manager to render
  16030. */
  16031. dispatchSprites(spriteManager: ISpriteManager): void;
  16032. /**
  16033. * Add a particle system to the rendering manager in order to render it this frame.
  16034. * @param particleSystem Define the particle system to render
  16035. */
  16036. dispatchParticles(particleSystem: IParticleSystem): void;
  16037. /**
  16038. * Add a submesh to the manager in order to render it this frame
  16039. * @param subMesh The submesh to dispatch
  16040. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16041. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16042. */
  16043. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16044. /**
  16045. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16046. * This allowed control for front to back rendering or reversly depending of the special needs.
  16047. *
  16048. * @param renderingGroupId The rendering group id corresponding to its index
  16049. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16050. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16051. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16052. */
  16053. 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;
  16054. /**
  16055. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16056. *
  16057. * @param renderingGroupId The rendering group id corresponding to its index
  16058. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16059. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16060. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16061. */
  16062. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16063. /**
  16064. * Gets the current auto clear configuration for one rendering group of the rendering
  16065. * manager.
  16066. * @param index the rendering group index to get the information for
  16067. * @returns The auto clear setup for the requested rendering group
  16068. */
  16069. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16070. }
  16071. }
  16072. declare module BABYLON {
  16073. /**
  16074. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16075. */
  16076. export interface ICustomShaderOptions {
  16077. /**
  16078. * Gets or sets the custom shader name to use
  16079. */
  16080. shaderName: string;
  16081. /**
  16082. * The list of attribute names used in the shader
  16083. */
  16084. attributes?: string[];
  16085. /**
  16086. * The list of unifrom names used in the shader
  16087. */
  16088. uniforms?: string[];
  16089. /**
  16090. * The list of sampler names used in the shader
  16091. */
  16092. samplers?: string[];
  16093. /**
  16094. * The list of defines used in the shader
  16095. */
  16096. defines?: string[];
  16097. }
  16098. /**
  16099. * Interface to implement to create a shadow generator compatible with BJS.
  16100. */
  16101. export interface IShadowGenerator {
  16102. /**
  16103. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16104. * @returns The render target texture if present otherwise, null
  16105. */
  16106. getShadowMap(): Nullable<RenderTargetTexture>;
  16107. /**
  16108. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16109. * @param subMesh The submesh we want to render in the shadow map
  16110. * @param useInstances Defines wether will draw in the map using instances
  16111. * @returns true if ready otherwise, false
  16112. */
  16113. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16114. /**
  16115. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16116. * @param defines Defines of the material we want to update
  16117. * @param lightIndex Index of the light in the enabled light list of the material
  16118. */
  16119. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16120. /**
  16121. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16122. * defined in the generator but impacting the effect).
  16123. * It implies the unifroms available on the materials are the standard BJS ones.
  16124. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16125. * @param effect The effect we are binfing the information for
  16126. */
  16127. bindShadowLight(lightIndex: string, effect: Effect): void;
  16128. /**
  16129. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16130. * (eq to shadow prjection matrix * light transform matrix)
  16131. * @returns The transform matrix used to create the shadow map
  16132. */
  16133. getTransformMatrix(): Matrix;
  16134. /**
  16135. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16136. * Cube and 2D textures for instance.
  16137. */
  16138. recreateShadowMap(): void;
  16139. /**
  16140. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16141. * @param onCompiled Callback triggered at the and of the effects compilation
  16142. * @param options Sets of optional options forcing the compilation with different modes
  16143. */
  16144. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16145. useInstances: boolean;
  16146. }>): void;
  16147. /**
  16148. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16149. * @param options Sets of optional options forcing the compilation with different modes
  16150. * @returns A promise that resolves when the compilation completes
  16151. */
  16152. forceCompilationAsync(options?: Partial<{
  16153. useInstances: boolean;
  16154. }>): Promise<void>;
  16155. /**
  16156. * Serializes the shadow generator setup to a json object.
  16157. * @returns The serialized JSON object
  16158. */
  16159. serialize(): any;
  16160. /**
  16161. * Disposes the Shadow map and related Textures and effects.
  16162. */
  16163. dispose(): void;
  16164. }
  16165. /**
  16166. * Default implementation IShadowGenerator.
  16167. * This is the main object responsible of generating shadows in the framework.
  16168. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16169. */
  16170. export class ShadowGenerator implements IShadowGenerator {
  16171. /**
  16172. * Name of the shadow generator class
  16173. */
  16174. static CLASSNAME: string;
  16175. /**
  16176. * Shadow generator mode None: no filtering applied.
  16177. */
  16178. static readonly FILTER_NONE: number;
  16179. /**
  16180. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16181. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16182. */
  16183. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16184. /**
  16185. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16186. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16187. */
  16188. static readonly FILTER_POISSONSAMPLING: number;
  16189. /**
  16190. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16191. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16192. */
  16193. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16194. /**
  16195. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16196. * edge artifacts on steep falloff.
  16197. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16198. */
  16199. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16200. /**
  16201. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16202. * edge artifacts on steep falloff.
  16203. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16204. */
  16205. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16206. /**
  16207. * Shadow generator mode PCF: Percentage Closer Filtering
  16208. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16209. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16210. */
  16211. static readonly FILTER_PCF: number;
  16212. /**
  16213. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16214. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16215. * Contact Hardening
  16216. */
  16217. static readonly FILTER_PCSS: number;
  16218. /**
  16219. * Reserved for PCF and PCSS
  16220. * Highest Quality.
  16221. *
  16222. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16223. *
  16224. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16225. */
  16226. static readonly QUALITY_HIGH: number;
  16227. /**
  16228. * Reserved for PCF and PCSS
  16229. * Good tradeoff for quality/perf cross devices
  16230. *
  16231. * Execute PCF on a 3*3 kernel.
  16232. *
  16233. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16234. */
  16235. static readonly QUALITY_MEDIUM: number;
  16236. /**
  16237. * Reserved for PCF and PCSS
  16238. * The lowest quality but the fastest.
  16239. *
  16240. * Execute PCF on a 1*1 kernel.
  16241. *
  16242. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16243. */
  16244. static readonly QUALITY_LOW: number;
  16245. /** Gets or sets the custom shader name to use */
  16246. customShaderOptions: ICustomShaderOptions;
  16247. /**
  16248. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16249. */
  16250. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16251. /**
  16252. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16253. */
  16254. onAfterShadowMapRenderObservable: Observable<Effect>;
  16255. /**
  16256. * Observable triggered before a mesh is rendered in the shadow map.
  16257. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16258. */
  16259. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16260. /**
  16261. * Observable triggered after a mesh is rendered in the shadow map.
  16262. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16263. */
  16264. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16265. protected _bias: number;
  16266. /**
  16267. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16268. */
  16269. get bias(): number;
  16270. /**
  16271. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16272. */
  16273. set bias(bias: number);
  16274. protected _normalBias: number;
  16275. /**
  16276. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16277. */
  16278. get normalBias(): number;
  16279. /**
  16280. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16281. */
  16282. set normalBias(normalBias: number);
  16283. protected _blurBoxOffset: number;
  16284. /**
  16285. * Gets the blur box offset: offset applied during the blur pass.
  16286. * Only useful if useKernelBlur = false
  16287. */
  16288. get blurBoxOffset(): number;
  16289. /**
  16290. * Sets the blur box offset: offset applied during the blur pass.
  16291. * Only useful if useKernelBlur = false
  16292. */
  16293. set blurBoxOffset(value: number);
  16294. protected _blurScale: number;
  16295. /**
  16296. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16297. * 2 means half of the size.
  16298. */
  16299. get blurScale(): number;
  16300. /**
  16301. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16302. * 2 means half of the size.
  16303. */
  16304. set blurScale(value: number);
  16305. protected _blurKernel: number;
  16306. /**
  16307. * Gets the blur kernel: kernel size of the blur pass.
  16308. * Only useful if useKernelBlur = true
  16309. */
  16310. get blurKernel(): number;
  16311. /**
  16312. * Sets the blur kernel: kernel size of the blur pass.
  16313. * Only useful if useKernelBlur = true
  16314. */
  16315. set blurKernel(value: number);
  16316. protected _useKernelBlur: boolean;
  16317. /**
  16318. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16319. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16320. */
  16321. get useKernelBlur(): boolean;
  16322. /**
  16323. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16324. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16325. */
  16326. set useKernelBlur(value: boolean);
  16327. protected _depthScale: number;
  16328. /**
  16329. * Gets the depth scale used in ESM mode.
  16330. */
  16331. get depthScale(): number;
  16332. /**
  16333. * Sets the depth scale used in ESM mode.
  16334. * This can override the scale stored on the light.
  16335. */
  16336. set depthScale(value: number);
  16337. protected _validateFilter(filter: number): number;
  16338. protected _filter: number;
  16339. /**
  16340. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16341. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16342. */
  16343. get filter(): number;
  16344. /**
  16345. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16346. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16347. */
  16348. set filter(value: number);
  16349. /**
  16350. * Gets if the current filter is set to Poisson Sampling.
  16351. */
  16352. get usePoissonSampling(): boolean;
  16353. /**
  16354. * Sets the current filter to Poisson Sampling.
  16355. */
  16356. set usePoissonSampling(value: boolean);
  16357. /**
  16358. * Gets if the current filter is set to ESM.
  16359. */
  16360. get useExponentialShadowMap(): boolean;
  16361. /**
  16362. * Sets the current filter is to ESM.
  16363. */
  16364. set useExponentialShadowMap(value: boolean);
  16365. /**
  16366. * Gets if the current filter is set to filtered ESM.
  16367. */
  16368. get useBlurExponentialShadowMap(): boolean;
  16369. /**
  16370. * Gets if the current filter is set to filtered ESM.
  16371. */
  16372. set useBlurExponentialShadowMap(value: boolean);
  16373. /**
  16374. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16375. * exponential to prevent steep falloff artifacts).
  16376. */
  16377. get useCloseExponentialShadowMap(): boolean;
  16378. /**
  16379. * Sets the current filter to "close ESM" (using the inverse of the
  16380. * exponential to prevent steep falloff artifacts).
  16381. */
  16382. set useCloseExponentialShadowMap(value: boolean);
  16383. /**
  16384. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16385. * exponential to prevent steep falloff artifacts).
  16386. */
  16387. get useBlurCloseExponentialShadowMap(): boolean;
  16388. /**
  16389. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16390. * exponential to prevent steep falloff artifacts).
  16391. */
  16392. set useBlurCloseExponentialShadowMap(value: boolean);
  16393. /**
  16394. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16395. */
  16396. get usePercentageCloserFiltering(): boolean;
  16397. /**
  16398. * Sets the current filter to "PCF" (percentage closer filtering).
  16399. */
  16400. set usePercentageCloserFiltering(value: boolean);
  16401. protected _filteringQuality: number;
  16402. /**
  16403. * Gets the PCF or PCSS Quality.
  16404. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16405. */
  16406. get filteringQuality(): number;
  16407. /**
  16408. * Sets the PCF or PCSS Quality.
  16409. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16410. */
  16411. set filteringQuality(filteringQuality: number);
  16412. /**
  16413. * Gets if the current filter is set to "PCSS" (contact hardening).
  16414. */
  16415. get useContactHardeningShadow(): boolean;
  16416. /**
  16417. * Sets the current filter to "PCSS" (contact hardening).
  16418. */
  16419. set useContactHardeningShadow(value: boolean);
  16420. protected _contactHardeningLightSizeUVRatio: number;
  16421. /**
  16422. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16423. * Using a ratio helps keeping shape stability independently of the map size.
  16424. *
  16425. * It does not account for the light projection as it was having too much
  16426. * instability during the light setup or during light position changes.
  16427. *
  16428. * Only valid if useContactHardeningShadow is true.
  16429. */
  16430. get contactHardeningLightSizeUVRatio(): number;
  16431. /**
  16432. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16433. * Using a ratio helps keeping shape stability independently of the map size.
  16434. *
  16435. * It does not account for the light projection as it was having too much
  16436. * instability during the light setup or during light position changes.
  16437. *
  16438. * Only valid if useContactHardeningShadow is true.
  16439. */
  16440. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16441. protected _darkness: number;
  16442. /** Gets or sets the actual darkness of a shadow */
  16443. get darkness(): number;
  16444. set darkness(value: number);
  16445. /**
  16446. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16447. * 0 means strongest and 1 would means no shadow.
  16448. * @returns the darkness.
  16449. */
  16450. getDarkness(): number;
  16451. /**
  16452. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16453. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16454. * @returns the shadow generator allowing fluent coding.
  16455. */
  16456. setDarkness(darkness: number): ShadowGenerator;
  16457. protected _transparencyShadow: boolean;
  16458. /** Gets or sets the ability to have transparent shadow */
  16459. get transparencyShadow(): boolean;
  16460. set transparencyShadow(value: boolean);
  16461. /**
  16462. * Sets the ability to have transparent shadow (boolean).
  16463. * @param transparent True if transparent else False
  16464. * @returns the shadow generator allowing fluent coding
  16465. */
  16466. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16467. protected _shadowMap: Nullable<RenderTargetTexture>;
  16468. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16469. /**
  16470. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16471. * @returns The render target texture if present otherwise, null
  16472. */
  16473. getShadowMap(): Nullable<RenderTargetTexture>;
  16474. /**
  16475. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16476. * @returns The render target texture if the shadow map is present otherwise, null
  16477. */
  16478. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16479. /**
  16480. * Gets the class name of that object
  16481. * @returns "ShadowGenerator"
  16482. */
  16483. getClassName(): string;
  16484. /**
  16485. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16486. * @param mesh Mesh to add
  16487. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16488. * @returns the Shadow Generator itself
  16489. */
  16490. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16491. /**
  16492. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16493. * @param mesh Mesh to remove
  16494. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16495. * @returns the Shadow Generator itself
  16496. */
  16497. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16498. /**
  16499. * Controls the extent to which the shadows fade out at the edge of the frustum
  16500. */
  16501. frustumEdgeFalloff: number;
  16502. protected _light: IShadowLight;
  16503. /**
  16504. * Returns the associated light object.
  16505. * @returns the light generating the shadow
  16506. */
  16507. getLight(): IShadowLight;
  16508. /**
  16509. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16510. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16511. * It might on the other hand introduce peter panning.
  16512. */
  16513. forceBackFacesOnly: boolean;
  16514. protected _scene: Scene;
  16515. protected _lightDirection: Vector3;
  16516. protected _effect: Effect;
  16517. protected _viewMatrix: Matrix;
  16518. protected _projectionMatrix: Matrix;
  16519. protected _transformMatrix: Matrix;
  16520. protected _cachedPosition: Vector3;
  16521. protected _cachedDirection: Vector3;
  16522. protected _cachedDefines: string;
  16523. protected _currentRenderID: number;
  16524. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16525. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16526. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16527. protected _blurPostProcesses: PostProcess[];
  16528. protected _mapSize: number;
  16529. protected _currentFaceIndex: number;
  16530. protected _currentFaceIndexCache: number;
  16531. protected _textureType: number;
  16532. protected _defaultTextureMatrix: Matrix;
  16533. protected _storedUniqueId: Nullable<number>;
  16534. /** @hidden */
  16535. static _SceneComponentInitialization: (scene: Scene) => void;
  16536. /**
  16537. * Creates a ShadowGenerator object.
  16538. * A ShadowGenerator is the required tool to use the shadows.
  16539. * Each light casting shadows needs to use its own ShadowGenerator.
  16540. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16541. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16542. * @param light The light object generating the shadows.
  16543. * @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.
  16544. */
  16545. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16546. protected _initializeGenerator(): void;
  16547. protected _createTargetRenderTexture(): void;
  16548. protected _initializeShadowMap(): void;
  16549. protected _initializeBlurRTTAndPostProcesses(): void;
  16550. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16551. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16552. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16553. protected _applyFilterValues(): void;
  16554. /**
  16555. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16556. * @param onCompiled Callback triggered at the and of the effects compilation
  16557. * @param options Sets of optional options forcing the compilation with different modes
  16558. */
  16559. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16560. useInstances: boolean;
  16561. }>): void;
  16562. /**
  16563. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16564. * @param options Sets of optional options forcing the compilation with different modes
  16565. * @returns A promise that resolves when the compilation completes
  16566. */
  16567. forceCompilationAsync(options?: Partial<{
  16568. useInstances: boolean;
  16569. }>): Promise<void>;
  16570. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16571. /**
  16572. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16573. * @param subMesh The submesh we want to render in the shadow map
  16574. * @param useInstances Defines wether will draw in the map using instances
  16575. * @returns true if ready otherwise, false
  16576. */
  16577. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16578. /**
  16579. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16580. * @param defines Defines of the material we want to update
  16581. * @param lightIndex Index of the light in the enabled light list of the material
  16582. */
  16583. prepareDefines(defines: any, lightIndex: number): void;
  16584. /**
  16585. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16586. * defined in the generator but impacting the effect).
  16587. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16588. * @param effect The effect we are binfing the information for
  16589. */
  16590. bindShadowLight(lightIndex: string, effect: Effect): void;
  16591. /**
  16592. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16593. * (eq to shadow prjection matrix * light transform matrix)
  16594. * @returns The transform matrix used to create the shadow map
  16595. */
  16596. getTransformMatrix(): Matrix;
  16597. /**
  16598. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16599. * Cube and 2D textures for instance.
  16600. */
  16601. recreateShadowMap(): void;
  16602. protected _disposeBlurPostProcesses(): void;
  16603. protected _disposeRTTandPostProcesses(): void;
  16604. /**
  16605. * Disposes the ShadowGenerator.
  16606. * Returns nothing.
  16607. */
  16608. dispose(): void;
  16609. /**
  16610. * Serializes the shadow generator setup to a json object.
  16611. * @returns The serialized JSON object
  16612. */
  16613. serialize(): any;
  16614. /**
  16615. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16616. * @param parsedShadowGenerator The JSON object to parse
  16617. * @param scene The scene to create the shadow map for
  16618. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16619. * @returns The parsed shadow generator
  16620. */
  16621. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16622. }
  16623. }
  16624. declare module BABYLON {
  16625. /**
  16626. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16627. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16628. * 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.
  16629. */
  16630. export abstract class Light extends Node {
  16631. /**
  16632. * Falloff Default: light is falling off following the material specification:
  16633. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16634. */
  16635. static readonly FALLOFF_DEFAULT: number;
  16636. /**
  16637. * Falloff Physical: light is falling off following the inverse squared distance law.
  16638. */
  16639. static readonly FALLOFF_PHYSICAL: number;
  16640. /**
  16641. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16642. * to enhance interoperability with other engines.
  16643. */
  16644. static readonly FALLOFF_GLTF: number;
  16645. /**
  16646. * Falloff Standard: light is falling off like in the standard material
  16647. * to enhance interoperability with other materials.
  16648. */
  16649. static readonly FALLOFF_STANDARD: number;
  16650. /**
  16651. * If every light affecting the material is in this lightmapMode,
  16652. * material.lightmapTexture adds or multiplies
  16653. * (depends on material.useLightmapAsShadowmap)
  16654. * after every other light calculations.
  16655. */
  16656. static readonly LIGHTMAP_DEFAULT: number;
  16657. /**
  16658. * material.lightmapTexture as only diffuse lighting from this light
  16659. * adds only specular lighting from this light
  16660. * adds dynamic shadows
  16661. */
  16662. static readonly LIGHTMAP_SPECULAR: number;
  16663. /**
  16664. * material.lightmapTexture as only lighting
  16665. * no light calculation from this light
  16666. * only adds dynamic shadows from this light
  16667. */
  16668. static readonly LIGHTMAP_SHADOWSONLY: number;
  16669. /**
  16670. * Each light type uses the default quantity according to its type:
  16671. * point/spot lights use luminous intensity
  16672. * directional lights use illuminance
  16673. */
  16674. static readonly INTENSITYMODE_AUTOMATIC: number;
  16675. /**
  16676. * lumen (lm)
  16677. */
  16678. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16679. /**
  16680. * candela (lm/sr)
  16681. */
  16682. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16683. /**
  16684. * lux (lm/m^2)
  16685. */
  16686. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16687. /**
  16688. * nit (cd/m^2)
  16689. */
  16690. static readonly INTENSITYMODE_LUMINANCE: number;
  16691. /**
  16692. * Light type const id of the point light.
  16693. */
  16694. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16695. /**
  16696. * Light type const id of the directional light.
  16697. */
  16698. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16699. /**
  16700. * Light type const id of the spot light.
  16701. */
  16702. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16703. /**
  16704. * Light type const id of the hemispheric light.
  16705. */
  16706. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16707. /**
  16708. * Diffuse gives the basic color to an object.
  16709. */
  16710. diffuse: Color3;
  16711. /**
  16712. * Specular produces a highlight color on an object.
  16713. * Note: This is note affecting PBR materials.
  16714. */
  16715. specular: Color3;
  16716. /**
  16717. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16718. * falling off base on range or angle.
  16719. * This can be set to any values in Light.FALLOFF_x.
  16720. *
  16721. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16722. * other types of materials.
  16723. */
  16724. falloffType: number;
  16725. /**
  16726. * Strength of the light.
  16727. * Note: By default it is define in the framework own unit.
  16728. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16729. */
  16730. intensity: number;
  16731. private _range;
  16732. protected _inverseSquaredRange: number;
  16733. /**
  16734. * Defines how far from the source the light is impacting in scene units.
  16735. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16736. */
  16737. get range(): number;
  16738. /**
  16739. * Defines how far from the source the light is impacting in scene units.
  16740. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16741. */
  16742. set range(value: number);
  16743. /**
  16744. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16745. * of light.
  16746. */
  16747. private _photometricScale;
  16748. private _intensityMode;
  16749. /**
  16750. * Gets the photometric scale used to interpret the intensity.
  16751. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16752. */
  16753. get intensityMode(): number;
  16754. /**
  16755. * Sets the photometric scale used to interpret the intensity.
  16756. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16757. */
  16758. set intensityMode(value: number);
  16759. private _radius;
  16760. /**
  16761. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16762. */
  16763. get radius(): number;
  16764. /**
  16765. * sets the light radius used by PBR Materials to simulate soft area lights.
  16766. */
  16767. set radius(value: number);
  16768. private _renderPriority;
  16769. /**
  16770. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16771. * exceeding the number allowed of the materials.
  16772. */
  16773. renderPriority: number;
  16774. private _shadowEnabled;
  16775. /**
  16776. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16777. * the current shadow generator.
  16778. */
  16779. get shadowEnabled(): boolean;
  16780. /**
  16781. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16782. * the current shadow generator.
  16783. */
  16784. set shadowEnabled(value: boolean);
  16785. private _includedOnlyMeshes;
  16786. /**
  16787. * Gets the only meshes impacted by this light.
  16788. */
  16789. get includedOnlyMeshes(): AbstractMesh[];
  16790. /**
  16791. * Sets the only meshes impacted by this light.
  16792. */
  16793. set includedOnlyMeshes(value: AbstractMesh[]);
  16794. private _excludedMeshes;
  16795. /**
  16796. * Gets the meshes not impacted by this light.
  16797. */
  16798. get excludedMeshes(): AbstractMesh[];
  16799. /**
  16800. * Sets the meshes not impacted by this light.
  16801. */
  16802. set excludedMeshes(value: AbstractMesh[]);
  16803. private _excludeWithLayerMask;
  16804. /**
  16805. * Gets the layer id use to find what meshes are not impacted by the light.
  16806. * Inactive if 0
  16807. */
  16808. get excludeWithLayerMask(): number;
  16809. /**
  16810. * Sets the layer id use to find what meshes are not impacted by the light.
  16811. * Inactive if 0
  16812. */
  16813. set excludeWithLayerMask(value: number);
  16814. private _includeOnlyWithLayerMask;
  16815. /**
  16816. * Gets the layer id use to find what meshes are impacted by the light.
  16817. * Inactive if 0
  16818. */
  16819. get includeOnlyWithLayerMask(): number;
  16820. /**
  16821. * Sets the layer id use to find what meshes are impacted by the light.
  16822. * Inactive if 0
  16823. */
  16824. set includeOnlyWithLayerMask(value: number);
  16825. private _lightmapMode;
  16826. /**
  16827. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16828. */
  16829. get lightmapMode(): number;
  16830. /**
  16831. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16832. */
  16833. set lightmapMode(value: number);
  16834. /**
  16835. * Shadow generator associted to the light.
  16836. * @hidden Internal use only.
  16837. */
  16838. _shadowGenerator: Nullable<IShadowGenerator>;
  16839. /**
  16840. * @hidden Internal use only.
  16841. */
  16842. _excludedMeshesIds: string[];
  16843. /**
  16844. * @hidden Internal use only.
  16845. */
  16846. _includedOnlyMeshesIds: string[];
  16847. /**
  16848. * The current light unifom buffer.
  16849. * @hidden Internal use only.
  16850. */
  16851. _uniformBuffer: UniformBuffer;
  16852. /** @hidden */
  16853. _renderId: number;
  16854. /**
  16855. * Creates a Light object in the scene.
  16856. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16857. * @param name The firendly name of the light
  16858. * @param scene The scene the light belongs too
  16859. */
  16860. constructor(name: string, scene: Scene);
  16861. protected abstract _buildUniformLayout(): void;
  16862. /**
  16863. * Sets the passed Effect "effect" with the Light information.
  16864. * @param effect The effect to update
  16865. * @param lightIndex The index of the light in the effect to update
  16866. * @returns The light
  16867. */
  16868. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16869. /**
  16870. * Sets the passed Effect "effect" with the Light textures.
  16871. * @param effect The effect to update
  16872. * @param lightIndex The index of the light in the effect to update
  16873. * @returns The light
  16874. */
  16875. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16876. /**
  16877. * Binds the lights information from the scene to the effect for the given mesh.
  16878. * @param lightIndex Light index
  16879. * @param scene The scene where the light belongs to
  16880. * @param effect The effect we are binding the data to
  16881. * @param useSpecular Defines if specular is supported
  16882. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16883. */
  16884. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16885. /**
  16886. * Sets the passed Effect "effect" with the Light information.
  16887. * @param effect The effect to update
  16888. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16889. * @returns The light
  16890. */
  16891. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16892. /**
  16893. * Returns the string "Light".
  16894. * @returns the class name
  16895. */
  16896. getClassName(): string;
  16897. /** @hidden */
  16898. readonly _isLight: boolean;
  16899. /**
  16900. * Converts the light information to a readable string for debug purpose.
  16901. * @param fullDetails Supports for multiple levels of logging within scene loading
  16902. * @returns the human readable light info
  16903. */
  16904. toString(fullDetails?: boolean): string;
  16905. /** @hidden */
  16906. protected _syncParentEnabledState(): void;
  16907. /**
  16908. * Set the enabled state of this node.
  16909. * @param value - the new enabled state
  16910. */
  16911. setEnabled(value: boolean): void;
  16912. /**
  16913. * Returns the Light associated shadow generator if any.
  16914. * @return the associated shadow generator.
  16915. */
  16916. getShadowGenerator(): Nullable<IShadowGenerator>;
  16917. /**
  16918. * Returns a Vector3, the absolute light position in the World.
  16919. * @returns the world space position of the light
  16920. */
  16921. getAbsolutePosition(): Vector3;
  16922. /**
  16923. * Specifies if the light will affect the passed mesh.
  16924. * @param mesh The mesh to test against the light
  16925. * @return true the mesh is affected otherwise, false.
  16926. */
  16927. canAffectMesh(mesh: AbstractMesh): boolean;
  16928. /**
  16929. * Sort function to order lights for rendering.
  16930. * @param a First Light object to compare to second.
  16931. * @param b Second Light object to compare first.
  16932. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16933. */
  16934. static CompareLightsPriority(a: Light, b: Light): number;
  16935. /**
  16936. * Releases resources associated with this node.
  16937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16939. */
  16940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16941. /**
  16942. * Returns the light type ID (integer).
  16943. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16944. */
  16945. getTypeID(): number;
  16946. /**
  16947. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16948. * @returns the scaled intensity in intensity mode unit
  16949. */
  16950. getScaledIntensity(): number;
  16951. /**
  16952. * Returns a new Light object, named "name", from the current one.
  16953. * @param name The name of the cloned light
  16954. * @returns the new created light
  16955. */
  16956. clone(name: string): Nullable<Light>;
  16957. /**
  16958. * Serializes the current light into a Serialization object.
  16959. * @returns the serialized object.
  16960. */
  16961. serialize(): any;
  16962. /**
  16963. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16964. * This new light is named "name" and added to the passed scene.
  16965. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16966. * @param name The friendly name of the light
  16967. * @param scene The scene the new light will belong to
  16968. * @returns the constructor function
  16969. */
  16970. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16971. /**
  16972. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16973. * @param parsedLight The JSON representation of the light
  16974. * @param scene The scene to create the parsed light in
  16975. * @returns the created light after parsing
  16976. */
  16977. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16978. private _hookArrayForExcluded;
  16979. private _hookArrayForIncludedOnly;
  16980. private _resyncMeshes;
  16981. /**
  16982. * Forces the meshes to update their light related information in their rendering used effects
  16983. * @hidden Internal Use Only
  16984. */
  16985. _markMeshesAsLightDirty(): void;
  16986. /**
  16987. * Recomputes the cached photometric scale if needed.
  16988. */
  16989. private _computePhotometricScale;
  16990. /**
  16991. * Returns the Photometric Scale according to the light type and intensity mode.
  16992. */
  16993. private _getPhotometricScale;
  16994. /**
  16995. * Reorder the light in the scene according to their defined priority.
  16996. * @hidden Internal Use Only
  16997. */
  16998. _reorderLightsInScene(): void;
  16999. /**
  17000. * Prepares the list of defines specific to the light type.
  17001. * @param defines the list of defines
  17002. * @param lightIndex defines the index of the light for the effect
  17003. */
  17004. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17005. }
  17006. }
  17007. declare module BABYLON {
  17008. /**
  17009. * Interface used to define Action
  17010. */
  17011. export interface IAction {
  17012. /**
  17013. * Trigger for the action
  17014. */
  17015. trigger: number;
  17016. /** Options of the trigger */
  17017. triggerOptions: any;
  17018. /**
  17019. * Gets the trigger parameters
  17020. * @returns the trigger parameters
  17021. */
  17022. getTriggerParameter(): any;
  17023. /**
  17024. * Internal only - executes current action event
  17025. * @hidden
  17026. */
  17027. _executeCurrent(evt?: ActionEvent): void;
  17028. /**
  17029. * Serialize placeholder for child classes
  17030. * @param parent of child
  17031. * @returns the serialized object
  17032. */
  17033. serialize(parent: any): any;
  17034. /**
  17035. * Internal only
  17036. * @hidden
  17037. */
  17038. _prepare(): void;
  17039. /**
  17040. * Internal only - manager for action
  17041. * @hidden
  17042. */
  17043. _actionManager: AbstractActionManager;
  17044. /**
  17045. * Adds action to chain of actions, may be a DoNothingAction
  17046. * @param action defines the next action to execute
  17047. * @returns The action passed in
  17048. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17049. */
  17050. then(action: IAction): IAction;
  17051. }
  17052. /**
  17053. * The action to be carried out following a trigger
  17054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17055. */
  17056. export class Action implements IAction {
  17057. /** the trigger, with or without parameters, for the action */
  17058. triggerOptions: any;
  17059. /**
  17060. * Trigger for the action
  17061. */
  17062. trigger: number;
  17063. /**
  17064. * Internal only - manager for action
  17065. * @hidden
  17066. */
  17067. _actionManager: ActionManager;
  17068. private _nextActiveAction;
  17069. private _child;
  17070. private _condition?;
  17071. private _triggerParameter;
  17072. /**
  17073. * An event triggered prior to action being executed.
  17074. */
  17075. onBeforeExecuteObservable: Observable<Action>;
  17076. /**
  17077. * Creates a new Action
  17078. * @param triggerOptions the trigger, with or without parameters, for the action
  17079. * @param condition an optional determinant of action
  17080. */
  17081. constructor(
  17082. /** the trigger, with or without parameters, for the action */
  17083. triggerOptions: any, condition?: Condition);
  17084. /**
  17085. * Internal only
  17086. * @hidden
  17087. */
  17088. _prepare(): void;
  17089. /**
  17090. * Gets the trigger parameters
  17091. * @returns the trigger parameters
  17092. */
  17093. getTriggerParameter(): any;
  17094. /**
  17095. * Internal only - executes current action event
  17096. * @hidden
  17097. */
  17098. _executeCurrent(evt?: ActionEvent): void;
  17099. /**
  17100. * Execute placeholder for child classes
  17101. * @param evt optional action event
  17102. */
  17103. execute(evt?: ActionEvent): void;
  17104. /**
  17105. * Skips to next active action
  17106. */
  17107. skipToNextActiveAction(): void;
  17108. /**
  17109. * Adds action to chain of actions, may be a DoNothingAction
  17110. * @param action defines the next action to execute
  17111. * @returns The action passed in
  17112. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17113. */
  17114. then(action: Action): Action;
  17115. /**
  17116. * Internal only
  17117. * @hidden
  17118. */
  17119. _getProperty(propertyPath: string): string;
  17120. /**
  17121. * Internal only
  17122. * @hidden
  17123. */
  17124. _getEffectiveTarget(target: any, propertyPath: string): any;
  17125. /**
  17126. * Serialize placeholder for child classes
  17127. * @param parent of child
  17128. * @returns the serialized object
  17129. */
  17130. serialize(parent: any): any;
  17131. /**
  17132. * Internal only called by serialize
  17133. * @hidden
  17134. */
  17135. protected _serialize(serializedAction: any, parent?: any): any;
  17136. /**
  17137. * Internal only
  17138. * @hidden
  17139. */
  17140. static _SerializeValueAsString: (value: any) => string;
  17141. /**
  17142. * Internal only
  17143. * @hidden
  17144. */
  17145. static _GetTargetProperty: (target: Node | Scene) => {
  17146. name: string;
  17147. targetType: string;
  17148. value: string;
  17149. };
  17150. }
  17151. }
  17152. declare module BABYLON {
  17153. /**
  17154. * A Condition applied to an Action
  17155. */
  17156. export class Condition {
  17157. /**
  17158. * Internal only - manager for action
  17159. * @hidden
  17160. */
  17161. _actionManager: ActionManager;
  17162. /**
  17163. * Internal only
  17164. * @hidden
  17165. */
  17166. _evaluationId: number;
  17167. /**
  17168. * Internal only
  17169. * @hidden
  17170. */
  17171. _currentResult: boolean;
  17172. /**
  17173. * Creates a new Condition
  17174. * @param actionManager the manager of the action the condition is applied to
  17175. */
  17176. constructor(actionManager: ActionManager);
  17177. /**
  17178. * Check if the current condition is valid
  17179. * @returns a boolean
  17180. */
  17181. isValid(): boolean;
  17182. /**
  17183. * Internal only
  17184. * @hidden
  17185. */
  17186. _getProperty(propertyPath: string): string;
  17187. /**
  17188. * Internal only
  17189. * @hidden
  17190. */
  17191. _getEffectiveTarget(target: any, propertyPath: string): any;
  17192. /**
  17193. * Serialize placeholder for child classes
  17194. * @returns the serialized object
  17195. */
  17196. serialize(): any;
  17197. /**
  17198. * Internal only
  17199. * @hidden
  17200. */
  17201. protected _serialize(serializedCondition: any): any;
  17202. }
  17203. /**
  17204. * Defines specific conditional operators as extensions of Condition
  17205. */
  17206. export class ValueCondition extends Condition {
  17207. /** path to specify the property of the target the conditional operator uses */
  17208. propertyPath: string;
  17209. /** the value compared by the conditional operator against the current value of the property */
  17210. value: any;
  17211. /** the conditional operator, default ValueCondition.IsEqual */
  17212. operator: number;
  17213. /**
  17214. * Internal only
  17215. * @hidden
  17216. */
  17217. private static _IsEqual;
  17218. /**
  17219. * Internal only
  17220. * @hidden
  17221. */
  17222. private static _IsDifferent;
  17223. /**
  17224. * Internal only
  17225. * @hidden
  17226. */
  17227. private static _IsGreater;
  17228. /**
  17229. * Internal only
  17230. * @hidden
  17231. */
  17232. private static _IsLesser;
  17233. /**
  17234. * returns the number for IsEqual
  17235. */
  17236. static get IsEqual(): number;
  17237. /**
  17238. * Returns the number for IsDifferent
  17239. */
  17240. static get IsDifferent(): number;
  17241. /**
  17242. * Returns the number for IsGreater
  17243. */
  17244. static get IsGreater(): number;
  17245. /**
  17246. * Returns the number for IsLesser
  17247. */
  17248. static get IsLesser(): number;
  17249. /**
  17250. * Internal only The action manager for the condition
  17251. * @hidden
  17252. */
  17253. _actionManager: ActionManager;
  17254. /**
  17255. * Internal only
  17256. * @hidden
  17257. */
  17258. private _target;
  17259. /**
  17260. * Internal only
  17261. * @hidden
  17262. */
  17263. private _effectiveTarget;
  17264. /**
  17265. * Internal only
  17266. * @hidden
  17267. */
  17268. private _property;
  17269. /**
  17270. * Creates a new ValueCondition
  17271. * @param actionManager manager for the action the condition applies to
  17272. * @param target for the action
  17273. * @param propertyPath path to specify the property of the target the conditional operator uses
  17274. * @param value the value compared by the conditional operator against the current value of the property
  17275. * @param operator the conditional operator, default ValueCondition.IsEqual
  17276. */
  17277. constructor(actionManager: ActionManager, target: any,
  17278. /** path to specify the property of the target the conditional operator uses */
  17279. propertyPath: string,
  17280. /** the value compared by the conditional operator against the current value of the property */
  17281. value: any,
  17282. /** the conditional operator, default ValueCondition.IsEqual */
  17283. operator?: number);
  17284. /**
  17285. * Compares the given value with the property value for the specified conditional operator
  17286. * @returns the result of the comparison
  17287. */
  17288. isValid(): boolean;
  17289. /**
  17290. * Serialize the ValueCondition into a JSON compatible object
  17291. * @returns serialization object
  17292. */
  17293. serialize(): any;
  17294. /**
  17295. * Gets the name of the conditional operator for the ValueCondition
  17296. * @param operator the conditional operator
  17297. * @returns the name
  17298. */
  17299. static GetOperatorName(operator: number): string;
  17300. }
  17301. /**
  17302. * Defines a predicate condition as an extension of Condition
  17303. */
  17304. export class PredicateCondition extends Condition {
  17305. /** defines the predicate function used to validate the condition */
  17306. predicate: () => boolean;
  17307. /**
  17308. * Internal only - manager for action
  17309. * @hidden
  17310. */
  17311. _actionManager: ActionManager;
  17312. /**
  17313. * Creates a new PredicateCondition
  17314. * @param actionManager manager for the action the condition applies to
  17315. * @param predicate defines the predicate function used to validate the condition
  17316. */
  17317. constructor(actionManager: ActionManager,
  17318. /** defines the predicate function used to validate the condition */
  17319. predicate: () => boolean);
  17320. /**
  17321. * @returns the validity of the predicate condition
  17322. */
  17323. isValid(): boolean;
  17324. }
  17325. /**
  17326. * Defines a state condition as an extension of Condition
  17327. */
  17328. export class StateCondition extends Condition {
  17329. /** Value to compare with target state */
  17330. value: string;
  17331. /**
  17332. * Internal only - manager for action
  17333. * @hidden
  17334. */
  17335. _actionManager: ActionManager;
  17336. /**
  17337. * Internal only
  17338. * @hidden
  17339. */
  17340. private _target;
  17341. /**
  17342. * Creates a new StateCondition
  17343. * @param actionManager manager for the action the condition applies to
  17344. * @param target of the condition
  17345. * @param value to compare with target state
  17346. */
  17347. constructor(actionManager: ActionManager, target: any,
  17348. /** Value to compare with target state */
  17349. value: string);
  17350. /**
  17351. * Gets a boolean indicating if the current condition is met
  17352. * @returns the validity of the state
  17353. */
  17354. isValid(): boolean;
  17355. /**
  17356. * Serialize the StateCondition into a JSON compatible object
  17357. * @returns serialization object
  17358. */
  17359. serialize(): any;
  17360. }
  17361. }
  17362. declare module BABYLON {
  17363. /**
  17364. * This defines an action responsible to toggle a boolean once triggered.
  17365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17366. */
  17367. export class SwitchBooleanAction extends Action {
  17368. /**
  17369. * The path to the boolean property in the target object
  17370. */
  17371. propertyPath: string;
  17372. private _target;
  17373. private _effectiveTarget;
  17374. private _property;
  17375. /**
  17376. * Instantiate the action
  17377. * @param triggerOptions defines the trigger options
  17378. * @param target defines the object containing the boolean
  17379. * @param propertyPath defines the path to the boolean property in the target object
  17380. * @param condition defines the trigger related conditions
  17381. */
  17382. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17383. /** @hidden */
  17384. _prepare(): void;
  17385. /**
  17386. * Execute the action toggle the boolean value.
  17387. */
  17388. execute(): void;
  17389. /**
  17390. * Serializes the actions and its related information.
  17391. * @param parent defines the object to serialize in
  17392. * @returns the serialized object
  17393. */
  17394. serialize(parent: any): any;
  17395. }
  17396. /**
  17397. * This defines an action responsible to set a the state field of the target
  17398. * to a desired value once triggered.
  17399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17400. */
  17401. export class SetStateAction extends Action {
  17402. /**
  17403. * The value to store in the state field.
  17404. */
  17405. value: string;
  17406. private _target;
  17407. /**
  17408. * Instantiate the action
  17409. * @param triggerOptions defines the trigger options
  17410. * @param target defines the object containing the state property
  17411. * @param value defines the value to store in the state field
  17412. * @param condition defines the trigger related conditions
  17413. */
  17414. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17415. /**
  17416. * Execute the action and store the value on the target state property.
  17417. */
  17418. execute(): void;
  17419. /**
  17420. * Serializes the actions and its related information.
  17421. * @param parent defines the object to serialize in
  17422. * @returns the serialized object
  17423. */
  17424. serialize(parent: any): any;
  17425. }
  17426. /**
  17427. * This defines an action responsible to set a property of the target
  17428. * to a desired value once triggered.
  17429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17430. */
  17431. export class SetValueAction extends Action {
  17432. /**
  17433. * The path of the property to set in the target.
  17434. */
  17435. propertyPath: string;
  17436. /**
  17437. * The value to set in the property
  17438. */
  17439. value: any;
  17440. private _target;
  17441. private _effectiveTarget;
  17442. private _property;
  17443. /**
  17444. * Instantiate the action
  17445. * @param triggerOptions defines the trigger options
  17446. * @param target defines the object containing the property
  17447. * @param propertyPath defines the path of the property to set in the target
  17448. * @param value defines the value to set in the property
  17449. * @param condition defines the trigger related conditions
  17450. */
  17451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17452. /** @hidden */
  17453. _prepare(): void;
  17454. /**
  17455. * Execute the action and set the targetted property to the desired value.
  17456. */
  17457. execute(): void;
  17458. /**
  17459. * Serializes the actions and its related information.
  17460. * @param parent defines the object to serialize in
  17461. * @returns the serialized object
  17462. */
  17463. serialize(parent: any): any;
  17464. }
  17465. /**
  17466. * This defines an action responsible to increment the target value
  17467. * to a desired value once triggered.
  17468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17469. */
  17470. export class IncrementValueAction extends Action {
  17471. /**
  17472. * The path of the property to increment in the target.
  17473. */
  17474. propertyPath: string;
  17475. /**
  17476. * The value we should increment the property by.
  17477. */
  17478. value: any;
  17479. private _target;
  17480. private _effectiveTarget;
  17481. private _property;
  17482. /**
  17483. * Instantiate the action
  17484. * @param triggerOptions defines the trigger options
  17485. * @param target defines the object containing the property
  17486. * @param propertyPath defines the path of the property to increment in the target
  17487. * @param value defines the value value we should increment the property by
  17488. * @param condition defines the trigger related conditions
  17489. */
  17490. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17491. /** @hidden */
  17492. _prepare(): void;
  17493. /**
  17494. * Execute the action and increment the target of the value amount.
  17495. */
  17496. execute(): void;
  17497. /**
  17498. * Serializes the actions and its related information.
  17499. * @param parent defines the object to serialize in
  17500. * @returns the serialized object
  17501. */
  17502. serialize(parent: any): any;
  17503. }
  17504. /**
  17505. * This defines an action responsible to start an animation once triggered.
  17506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17507. */
  17508. export class PlayAnimationAction extends Action {
  17509. /**
  17510. * Where the animation should start (animation frame)
  17511. */
  17512. from: number;
  17513. /**
  17514. * Where the animation should stop (animation frame)
  17515. */
  17516. to: number;
  17517. /**
  17518. * Define if the animation should loop or stop after the first play.
  17519. */
  17520. loop?: boolean;
  17521. private _target;
  17522. /**
  17523. * Instantiate the action
  17524. * @param triggerOptions defines the trigger options
  17525. * @param target defines the target animation or animation name
  17526. * @param from defines from where the animation should start (animation frame)
  17527. * @param end defines where the animation should stop (animation frame)
  17528. * @param loop defines if the animation should loop or stop after the first play
  17529. * @param condition defines the trigger related conditions
  17530. */
  17531. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17532. /** @hidden */
  17533. _prepare(): void;
  17534. /**
  17535. * Execute the action and play the animation.
  17536. */
  17537. execute(): void;
  17538. /**
  17539. * Serializes the actions and its related information.
  17540. * @param parent defines the object to serialize in
  17541. * @returns the serialized object
  17542. */
  17543. serialize(parent: any): any;
  17544. }
  17545. /**
  17546. * This defines an action responsible to stop an animation once triggered.
  17547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17548. */
  17549. export class StopAnimationAction extends Action {
  17550. private _target;
  17551. /**
  17552. * Instantiate the action
  17553. * @param triggerOptions defines the trigger options
  17554. * @param target defines the target animation or animation name
  17555. * @param condition defines the trigger related conditions
  17556. */
  17557. constructor(triggerOptions: any, target: any, condition?: Condition);
  17558. /** @hidden */
  17559. _prepare(): void;
  17560. /**
  17561. * Execute the action and stop the animation.
  17562. */
  17563. execute(): void;
  17564. /**
  17565. * Serializes the actions and its related information.
  17566. * @param parent defines the object to serialize in
  17567. * @returns the serialized object
  17568. */
  17569. serialize(parent: any): any;
  17570. }
  17571. /**
  17572. * This defines an action responsible that does nothing once triggered.
  17573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17574. */
  17575. export class DoNothingAction extends Action {
  17576. /**
  17577. * Instantiate the action
  17578. * @param triggerOptions defines the trigger options
  17579. * @param condition defines the trigger related conditions
  17580. */
  17581. constructor(triggerOptions?: any, condition?: Condition);
  17582. /**
  17583. * Execute the action and do nothing.
  17584. */
  17585. execute(): void;
  17586. /**
  17587. * Serializes the actions and its related information.
  17588. * @param parent defines the object to serialize in
  17589. * @returns the serialized object
  17590. */
  17591. serialize(parent: any): any;
  17592. }
  17593. /**
  17594. * This defines an action responsible to trigger several actions once triggered.
  17595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17596. */
  17597. export class CombineAction extends Action {
  17598. /**
  17599. * The list of aggregated animations to run.
  17600. */
  17601. children: Action[];
  17602. /**
  17603. * Instantiate the action
  17604. * @param triggerOptions defines the trigger options
  17605. * @param children defines the list of aggregated animations to run
  17606. * @param condition defines the trigger related conditions
  17607. */
  17608. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17609. /** @hidden */
  17610. _prepare(): void;
  17611. /**
  17612. * Execute the action and executes all the aggregated actions.
  17613. */
  17614. execute(evt: ActionEvent): void;
  17615. /**
  17616. * Serializes the actions and its related information.
  17617. * @param parent defines the object to serialize in
  17618. * @returns the serialized object
  17619. */
  17620. serialize(parent: any): any;
  17621. }
  17622. /**
  17623. * This defines an action responsible to run code (external event) once triggered.
  17624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17625. */
  17626. export class ExecuteCodeAction extends Action {
  17627. /**
  17628. * The callback function to run.
  17629. */
  17630. func: (evt: ActionEvent) => void;
  17631. /**
  17632. * Instantiate the action
  17633. * @param triggerOptions defines the trigger options
  17634. * @param func defines the callback function to run
  17635. * @param condition defines the trigger related conditions
  17636. */
  17637. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17638. /**
  17639. * Execute the action and run the attached code.
  17640. */
  17641. execute(evt: ActionEvent): void;
  17642. }
  17643. /**
  17644. * This defines an action responsible to set the parent property of the target once triggered.
  17645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17646. */
  17647. export class SetParentAction extends Action {
  17648. private _parent;
  17649. private _target;
  17650. /**
  17651. * Instantiate the action
  17652. * @param triggerOptions defines the trigger options
  17653. * @param target defines the target containing the parent property
  17654. * @param parent defines from where the animation should start (animation frame)
  17655. * @param condition defines the trigger related conditions
  17656. */
  17657. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17658. /** @hidden */
  17659. _prepare(): void;
  17660. /**
  17661. * Execute the action and set the parent property.
  17662. */
  17663. execute(): void;
  17664. /**
  17665. * Serializes the actions and its related information.
  17666. * @param parent defines the object to serialize in
  17667. * @returns the serialized object
  17668. */
  17669. serialize(parent: any): any;
  17670. }
  17671. }
  17672. declare module BABYLON {
  17673. /**
  17674. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17675. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17677. */
  17678. export class ActionManager extends AbstractActionManager {
  17679. /**
  17680. * Nothing
  17681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17682. */
  17683. static readonly NothingTrigger: number;
  17684. /**
  17685. * On pick
  17686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17687. */
  17688. static readonly OnPickTrigger: number;
  17689. /**
  17690. * On left pick
  17691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17692. */
  17693. static readonly OnLeftPickTrigger: number;
  17694. /**
  17695. * On right pick
  17696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17697. */
  17698. static readonly OnRightPickTrigger: number;
  17699. /**
  17700. * On center pick
  17701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17702. */
  17703. static readonly OnCenterPickTrigger: number;
  17704. /**
  17705. * On pick down
  17706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17707. */
  17708. static readonly OnPickDownTrigger: number;
  17709. /**
  17710. * On double pick
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17712. */
  17713. static readonly OnDoublePickTrigger: number;
  17714. /**
  17715. * On pick up
  17716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17717. */
  17718. static readonly OnPickUpTrigger: number;
  17719. /**
  17720. * On pick out.
  17721. * This trigger will only be raised if you also declared a OnPickDown
  17722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17723. */
  17724. static readonly OnPickOutTrigger: number;
  17725. /**
  17726. * On long press
  17727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17728. */
  17729. static readonly OnLongPressTrigger: number;
  17730. /**
  17731. * On pointer over
  17732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17733. */
  17734. static readonly OnPointerOverTrigger: number;
  17735. /**
  17736. * On pointer out
  17737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17738. */
  17739. static readonly OnPointerOutTrigger: number;
  17740. /**
  17741. * On every frame
  17742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17743. */
  17744. static readonly OnEveryFrameTrigger: number;
  17745. /**
  17746. * On intersection enter
  17747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17748. */
  17749. static readonly OnIntersectionEnterTrigger: number;
  17750. /**
  17751. * On intersection exit
  17752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17753. */
  17754. static readonly OnIntersectionExitTrigger: number;
  17755. /**
  17756. * On key down
  17757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17758. */
  17759. static readonly OnKeyDownTrigger: number;
  17760. /**
  17761. * On key up
  17762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17763. */
  17764. static readonly OnKeyUpTrigger: number;
  17765. private _scene;
  17766. /**
  17767. * Creates a new action manager
  17768. * @param scene defines the hosting scene
  17769. */
  17770. constructor(scene: Scene);
  17771. /**
  17772. * Releases all associated resources
  17773. */
  17774. dispose(): void;
  17775. /**
  17776. * Gets hosting scene
  17777. * @returns the hosting scene
  17778. */
  17779. getScene(): Scene;
  17780. /**
  17781. * Does this action manager handles actions of any of the given triggers
  17782. * @param triggers defines the triggers to be tested
  17783. * @return a boolean indicating whether one (or more) of the triggers is handled
  17784. */
  17785. hasSpecificTriggers(triggers: number[]): boolean;
  17786. /**
  17787. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17788. * speed.
  17789. * @param triggerA defines the trigger to be tested
  17790. * @param triggerB defines the trigger to be tested
  17791. * @return a boolean indicating whether one (or more) of the triggers is handled
  17792. */
  17793. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17794. /**
  17795. * Does this action manager handles actions of a given trigger
  17796. * @param trigger defines the trigger to be tested
  17797. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17798. * @return whether the trigger is handled
  17799. */
  17800. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17801. /**
  17802. * Does this action manager has pointer triggers
  17803. */
  17804. get hasPointerTriggers(): boolean;
  17805. /**
  17806. * Does this action manager has pick triggers
  17807. */
  17808. get hasPickTriggers(): boolean;
  17809. /**
  17810. * Registers an action to this action manager
  17811. * @param action defines the action to be registered
  17812. * @return the action amended (prepared) after registration
  17813. */
  17814. registerAction(action: IAction): Nullable<IAction>;
  17815. /**
  17816. * Unregisters an action to this action manager
  17817. * @param action defines the action to be unregistered
  17818. * @return a boolean indicating whether the action has been unregistered
  17819. */
  17820. unregisterAction(action: IAction): Boolean;
  17821. /**
  17822. * Process a specific trigger
  17823. * @param trigger defines the trigger to process
  17824. * @param evt defines the event details to be processed
  17825. */
  17826. processTrigger(trigger: number, evt?: IActionEvent): void;
  17827. /** @hidden */
  17828. _getEffectiveTarget(target: any, propertyPath: string): any;
  17829. /** @hidden */
  17830. _getProperty(propertyPath: string): string;
  17831. /**
  17832. * Serialize this manager to a JSON object
  17833. * @param name defines the property name to store this manager
  17834. * @returns a JSON representation of this manager
  17835. */
  17836. serialize(name: string): any;
  17837. /**
  17838. * Creates a new ActionManager from a JSON data
  17839. * @param parsedActions defines the JSON data to read from
  17840. * @param object defines the hosting mesh
  17841. * @param scene defines the hosting scene
  17842. */
  17843. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17844. /**
  17845. * Get a trigger name by index
  17846. * @param trigger defines the trigger index
  17847. * @returns a trigger name
  17848. */
  17849. static GetTriggerName(trigger: number): string;
  17850. }
  17851. }
  17852. declare module BABYLON {
  17853. /**
  17854. * Class used to represent a sprite
  17855. * @see http://doc.babylonjs.com/babylon101/sprites
  17856. */
  17857. export class Sprite {
  17858. /** defines the name */
  17859. name: string;
  17860. /** Gets or sets the current world position */
  17861. position: Vector3;
  17862. /** Gets or sets the main color */
  17863. color: Color4;
  17864. /** Gets or sets the width */
  17865. width: number;
  17866. /** Gets or sets the height */
  17867. height: number;
  17868. /** Gets or sets rotation angle */
  17869. angle: number;
  17870. /** Gets or sets the cell index in the sprite sheet */
  17871. cellIndex: number;
  17872. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17873. cellRef: string;
  17874. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17875. invertU: number;
  17876. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17877. invertV: number;
  17878. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17879. disposeWhenFinishedAnimating: boolean;
  17880. /** Gets the list of attached animations */
  17881. animations: Animation[];
  17882. /** Gets or sets a boolean indicating if the sprite can be picked */
  17883. isPickable: boolean;
  17884. /**
  17885. * Gets or sets the associated action manager
  17886. */
  17887. actionManager: Nullable<ActionManager>;
  17888. private _animationStarted;
  17889. private _loopAnimation;
  17890. private _fromIndex;
  17891. private _toIndex;
  17892. private _delay;
  17893. private _direction;
  17894. private _manager;
  17895. private _time;
  17896. private _onAnimationEnd;
  17897. /**
  17898. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17899. */
  17900. isVisible: boolean;
  17901. /**
  17902. * Gets or sets the sprite size
  17903. */
  17904. get size(): number;
  17905. set size(value: number);
  17906. /**
  17907. * Creates a new Sprite
  17908. * @param name defines the name
  17909. * @param manager defines the manager
  17910. */
  17911. constructor(
  17912. /** defines the name */
  17913. name: string, manager: ISpriteManager);
  17914. /**
  17915. * Starts an animation
  17916. * @param from defines the initial key
  17917. * @param to defines the end key
  17918. * @param loop defines if the animation must loop
  17919. * @param delay defines the start delay (in ms)
  17920. * @param onAnimationEnd defines a callback to call when animation ends
  17921. */
  17922. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17923. /** Stops current animation (if any) */
  17924. stopAnimation(): void;
  17925. /** @hidden */
  17926. _animate(deltaTime: number): void;
  17927. /** Release associated resources */
  17928. dispose(): void;
  17929. }
  17930. }
  17931. declare module BABYLON {
  17932. /**
  17933. * Information about the result of picking within a scene
  17934. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17935. */
  17936. export class PickingInfo {
  17937. /** @hidden */
  17938. _pickingUnavailable: boolean;
  17939. /**
  17940. * If the pick collided with an object
  17941. */
  17942. hit: boolean;
  17943. /**
  17944. * Distance away where the pick collided
  17945. */
  17946. distance: number;
  17947. /**
  17948. * The location of pick collision
  17949. */
  17950. pickedPoint: Nullable<Vector3>;
  17951. /**
  17952. * The mesh corresponding the the pick collision
  17953. */
  17954. pickedMesh: Nullable<AbstractMesh>;
  17955. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  17956. bu: number;
  17957. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  17958. bv: number;
  17959. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  17960. faceId: number;
  17961. /** Id of the the submesh that was picked */
  17962. subMeshId: number;
  17963. /** If a sprite was picked, this will be the sprite the pick collided with */
  17964. pickedSprite: Nullable<Sprite>;
  17965. /**
  17966. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  17967. */
  17968. originMesh: Nullable<AbstractMesh>;
  17969. /**
  17970. * The ray that was used to perform the picking.
  17971. */
  17972. ray: Nullable<Ray>;
  17973. /**
  17974. * Gets the normal correspodning to the face the pick collided with
  17975. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  17976. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  17977. * @returns The normal correspodning to the face the pick collided with
  17978. */
  17979. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  17980. /**
  17981. * Gets the texture coordinates of where the pick occured
  17982. * @returns the vector containing the coordnates of the texture
  17983. */
  17984. getTextureCoordinates(): Nullable<Vector2>;
  17985. }
  17986. }
  17987. declare module BABYLON {
  17988. /**
  17989. * Gather the list of pointer event types as constants.
  17990. */
  17991. export class PointerEventTypes {
  17992. /**
  17993. * 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.
  17994. */
  17995. static readonly POINTERDOWN: number;
  17996. /**
  17997. * The pointerup event is fired when a pointer is no longer active.
  17998. */
  17999. static readonly POINTERUP: number;
  18000. /**
  18001. * The pointermove event is fired when a pointer changes coordinates.
  18002. */
  18003. static readonly POINTERMOVE: number;
  18004. /**
  18005. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18006. */
  18007. static readonly POINTERWHEEL: number;
  18008. /**
  18009. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18010. */
  18011. static readonly POINTERPICK: number;
  18012. /**
  18013. * The pointertap event is fired when a the object has been touched and released without drag.
  18014. */
  18015. static readonly POINTERTAP: number;
  18016. /**
  18017. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18018. */
  18019. static readonly POINTERDOUBLETAP: number;
  18020. }
  18021. /**
  18022. * Base class of pointer info types.
  18023. */
  18024. export class PointerInfoBase {
  18025. /**
  18026. * Defines the type of event (PointerEventTypes)
  18027. */
  18028. type: number;
  18029. /**
  18030. * Defines the related dom event
  18031. */
  18032. event: PointerEvent | MouseWheelEvent;
  18033. /**
  18034. * Instantiates the base class of pointers info.
  18035. * @param type Defines the type of event (PointerEventTypes)
  18036. * @param event Defines the related dom event
  18037. */
  18038. constructor(
  18039. /**
  18040. * Defines the type of event (PointerEventTypes)
  18041. */
  18042. type: number,
  18043. /**
  18044. * Defines the related dom event
  18045. */
  18046. event: PointerEvent | MouseWheelEvent);
  18047. }
  18048. /**
  18049. * This class is used to store pointer related info for the onPrePointerObservable event.
  18050. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18051. */
  18052. export class PointerInfoPre extends PointerInfoBase {
  18053. /**
  18054. * Ray from a pointer if availible (eg. 6dof controller)
  18055. */
  18056. ray: Nullable<Ray>;
  18057. /**
  18058. * Defines the local position of the pointer on the canvas.
  18059. */
  18060. localPosition: Vector2;
  18061. /**
  18062. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18063. */
  18064. skipOnPointerObservable: boolean;
  18065. /**
  18066. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18067. * @param type Defines the type of event (PointerEventTypes)
  18068. * @param event Defines the related dom event
  18069. * @param localX Defines the local x coordinates of the pointer when the event occured
  18070. * @param localY Defines the local y coordinates of the pointer when the event occured
  18071. */
  18072. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18073. }
  18074. /**
  18075. * This type contains all the data related to a pointer event in Babylon.js.
  18076. * 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.
  18077. */
  18078. export class PointerInfo extends PointerInfoBase {
  18079. /**
  18080. * Defines the picking info associated to the info (if any)\
  18081. */
  18082. pickInfo: Nullable<PickingInfo>;
  18083. /**
  18084. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18085. * @param type Defines the type of event (PointerEventTypes)
  18086. * @param event Defines the related dom event
  18087. * @param pickInfo Defines the picking info associated to the info (if any)\
  18088. */
  18089. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18090. /**
  18091. * Defines the picking info associated to the info (if any)\
  18092. */
  18093. pickInfo: Nullable<PickingInfo>);
  18094. }
  18095. /**
  18096. * Data relating to a touch event on the screen.
  18097. */
  18098. export interface PointerTouch {
  18099. /**
  18100. * X coordinate of touch.
  18101. */
  18102. x: number;
  18103. /**
  18104. * Y coordinate of touch.
  18105. */
  18106. y: number;
  18107. /**
  18108. * Id of touch. Unique for each finger.
  18109. */
  18110. pointerId: number;
  18111. /**
  18112. * Event type passed from DOM.
  18113. */
  18114. type: any;
  18115. }
  18116. }
  18117. declare module BABYLON {
  18118. /**
  18119. * Manage the mouse inputs to control the movement of a free camera.
  18120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18121. */
  18122. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18123. /**
  18124. * Define if touch is enabled in the mouse input
  18125. */
  18126. touchEnabled: boolean;
  18127. /**
  18128. * Defines the camera the input is attached to.
  18129. */
  18130. camera: FreeCamera;
  18131. /**
  18132. * Defines the buttons associated with the input to handle camera move.
  18133. */
  18134. buttons: number[];
  18135. /**
  18136. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18137. */
  18138. angularSensibility: number;
  18139. private _pointerInput;
  18140. private _onMouseMove;
  18141. private _observer;
  18142. private previousPosition;
  18143. /**
  18144. * Observable for when a pointer move event occurs containing the move offset
  18145. */
  18146. onPointerMovedObservable: Observable<{
  18147. offsetX: number;
  18148. offsetY: number;
  18149. }>;
  18150. /**
  18151. * @hidden
  18152. * If the camera should be rotated automatically based on pointer movement
  18153. */
  18154. _allowCameraRotation: boolean;
  18155. /**
  18156. * Manage the mouse inputs to control the movement of a free camera.
  18157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18158. * @param touchEnabled Defines if touch is enabled or not
  18159. */
  18160. constructor(
  18161. /**
  18162. * Define if touch is enabled in the mouse input
  18163. */
  18164. touchEnabled?: boolean);
  18165. /**
  18166. * Attach the input controls to a specific dom element to get the input from.
  18167. * @param element Defines the element the controls should be listened from
  18168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18169. */
  18170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18171. /**
  18172. * Called on JS contextmenu event.
  18173. * Override this method to provide functionality.
  18174. */
  18175. protected onContextMenu(evt: PointerEvent): void;
  18176. /**
  18177. * Detach the current controls from the specified dom element.
  18178. * @param element Defines the element to stop listening the inputs from
  18179. */
  18180. detachControl(element: Nullable<HTMLElement>): void;
  18181. /**
  18182. * Gets the class name of the current intput.
  18183. * @returns the class name
  18184. */
  18185. getClassName(): string;
  18186. /**
  18187. * Get the friendly name associated with the input class.
  18188. * @returns the input friendly name
  18189. */
  18190. getSimpleName(): string;
  18191. }
  18192. }
  18193. declare module BABYLON {
  18194. /**
  18195. * Manage the touch inputs to control the movement of a free camera.
  18196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18197. */
  18198. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18199. /**
  18200. * Defines the camera the input is attached to.
  18201. */
  18202. camera: FreeCamera;
  18203. /**
  18204. * Defines the touch sensibility for rotation.
  18205. * The higher the faster.
  18206. */
  18207. touchAngularSensibility: number;
  18208. /**
  18209. * Defines the touch sensibility for move.
  18210. * The higher the faster.
  18211. */
  18212. touchMoveSensibility: number;
  18213. private _offsetX;
  18214. private _offsetY;
  18215. private _pointerPressed;
  18216. private _pointerInput;
  18217. private _observer;
  18218. private _onLostFocus;
  18219. /**
  18220. * Attach the input controls to a specific dom element to get the input from.
  18221. * @param element Defines the element the controls should be listened from
  18222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18223. */
  18224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18225. /**
  18226. * Detach the current controls from the specified dom element.
  18227. * @param element Defines the element to stop listening the inputs from
  18228. */
  18229. detachControl(element: Nullable<HTMLElement>): void;
  18230. /**
  18231. * Update the current camera state depending on the inputs that have been used this frame.
  18232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18233. */
  18234. checkInputs(): void;
  18235. /**
  18236. * Gets the class name of the current intput.
  18237. * @returns the class name
  18238. */
  18239. getClassName(): string;
  18240. /**
  18241. * Get the friendly name associated with the input class.
  18242. * @returns the input friendly name
  18243. */
  18244. getSimpleName(): string;
  18245. }
  18246. }
  18247. declare module BABYLON {
  18248. /**
  18249. * Default Inputs manager for the FreeCamera.
  18250. * It groups all the default supported inputs for ease of use.
  18251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18252. */
  18253. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18254. /**
  18255. * @hidden
  18256. */
  18257. _mouseInput: Nullable<FreeCameraMouseInput>;
  18258. /**
  18259. * Instantiates a new FreeCameraInputsManager.
  18260. * @param camera Defines the camera the inputs belong to
  18261. */
  18262. constructor(camera: FreeCamera);
  18263. /**
  18264. * Add keyboard input support to the input manager.
  18265. * @returns the current input manager
  18266. */
  18267. addKeyboard(): FreeCameraInputsManager;
  18268. /**
  18269. * Add mouse input support to the input manager.
  18270. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18271. * @returns the current input manager
  18272. */
  18273. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18274. /**
  18275. * Removes the mouse input support from the manager
  18276. * @returns the current input manager
  18277. */
  18278. removeMouse(): FreeCameraInputsManager;
  18279. /**
  18280. * Add touch input support to the input manager.
  18281. * @returns the current input manager
  18282. */
  18283. addTouch(): FreeCameraInputsManager;
  18284. /**
  18285. * Remove all attached input methods from a camera
  18286. */
  18287. clear(): void;
  18288. }
  18289. }
  18290. declare module BABYLON {
  18291. /**
  18292. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18293. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18295. */
  18296. export class FreeCamera extends TargetCamera {
  18297. /**
  18298. * Define the collision ellipsoid of the camera.
  18299. * This is helpful to simulate a camera body like the player body around the camera
  18300. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18301. */
  18302. ellipsoid: Vector3;
  18303. /**
  18304. * Define an offset for the position of the ellipsoid around the camera.
  18305. * This can be helpful to determine the center of the body near the gravity center of the body
  18306. * instead of its head.
  18307. */
  18308. ellipsoidOffset: Vector3;
  18309. /**
  18310. * Enable or disable collisions of the camera with the rest of the scene objects.
  18311. */
  18312. checkCollisions: boolean;
  18313. /**
  18314. * Enable or disable gravity on the camera.
  18315. */
  18316. applyGravity: boolean;
  18317. /**
  18318. * Define the input manager associated to the camera.
  18319. */
  18320. inputs: FreeCameraInputsManager;
  18321. /**
  18322. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18323. * Higher values reduce sensitivity.
  18324. */
  18325. get angularSensibility(): number;
  18326. /**
  18327. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18328. * Higher values reduce sensitivity.
  18329. */
  18330. set angularSensibility(value: number);
  18331. /**
  18332. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18333. */
  18334. get keysUp(): number[];
  18335. set keysUp(value: number[]);
  18336. /**
  18337. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18338. */
  18339. get keysDown(): number[];
  18340. set keysDown(value: number[]);
  18341. /**
  18342. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18343. */
  18344. get keysLeft(): number[];
  18345. set keysLeft(value: number[]);
  18346. /**
  18347. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18348. */
  18349. get keysRight(): number[];
  18350. set keysRight(value: number[]);
  18351. /**
  18352. * Event raised when the camera collide with a mesh in the scene.
  18353. */
  18354. onCollide: (collidedMesh: AbstractMesh) => void;
  18355. private _collider;
  18356. private _needMoveForGravity;
  18357. private _oldPosition;
  18358. private _diffPosition;
  18359. private _newPosition;
  18360. /** @hidden */
  18361. _localDirection: Vector3;
  18362. /** @hidden */
  18363. _transformedDirection: Vector3;
  18364. /**
  18365. * Instantiates a Free Camera.
  18366. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18367. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18368. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18369. * @param name Define the name of the camera in the scene
  18370. * @param position Define the start position of the camera in the scene
  18371. * @param scene Define the scene the camera belongs to
  18372. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18373. */
  18374. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18375. /**
  18376. * Attached controls to the current camera.
  18377. * @param element Defines the element the controls should be listened from
  18378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18379. */
  18380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18381. /**
  18382. * Detach the current controls from the camera.
  18383. * The camera will stop reacting to inputs.
  18384. * @param element Defines the element to stop listening the inputs from
  18385. */
  18386. detachControl(element: HTMLElement): void;
  18387. private _collisionMask;
  18388. /**
  18389. * Define a collision mask to limit the list of object the camera can collide with
  18390. */
  18391. get collisionMask(): number;
  18392. set collisionMask(mask: number);
  18393. /** @hidden */
  18394. _collideWithWorld(displacement: Vector3): void;
  18395. private _onCollisionPositionChange;
  18396. /** @hidden */
  18397. _checkInputs(): void;
  18398. /** @hidden */
  18399. _decideIfNeedsToMove(): boolean;
  18400. /** @hidden */
  18401. _updatePosition(): void;
  18402. /**
  18403. * Destroy the camera and release the current resources hold by it.
  18404. */
  18405. dispose(): void;
  18406. /**
  18407. * Gets the current object class name.
  18408. * @return the class name
  18409. */
  18410. getClassName(): string;
  18411. }
  18412. }
  18413. declare module BABYLON {
  18414. /**
  18415. * Represents a gamepad control stick position
  18416. */
  18417. export class StickValues {
  18418. /**
  18419. * The x component of the control stick
  18420. */
  18421. x: number;
  18422. /**
  18423. * The y component of the control stick
  18424. */
  18425. y: number;
  18426. /**
  18427. * Initializes the gamepad x and y control stick values
  18428. * @param x The x component of the gamepad control stick value
  18429. * @param y The y component of the gamepad control stick value
  18430. */
  18431. constructor(
  18432. /**
  18433. * The x component of the control stick
  18434. */
  18435. x: number,
  18436. /**
  18437. * The y component of the control stick
  18438. */
  18439. y: number);
  18440. }
  18441. /**
  18442. * An interface which manages callbacks for gamepad button changes
  18443. */
  18444. export interface GamepadButtonChanges {
  18445. /**
  18446. * Called when a gamepad has been changed
  18447. */
  18448. changed: boolean;
  18449. /**
  18450. * Called when a gamepad press event has been triggered
  18451. */
  18452. pressChanged: boolean;
  18453. /**
  18454. * Called when a touch event has been triggered
  18455. */
  18456. touchChanged: boolean;
  18457. /**
  18458. * Called when a value has changed
  18459. */
  18460. valueChanged: boolean;
  18461. }
  18462. /**
  18463. * Represents a gamepad
  18464. */
  18465. export class Gamepad {
  18466. /**
  18467. * The id of the gamepad
  18468. */
  18469. id: string;
  18470. /**
  18471. * The index of the gamepad
  18472. */
  18473. index: number;
  18474. /**
  18475. * The browser gamepad
  18476. */
  18477. browserGamepad: any;
  18478. /**
  18479. * Specifies what type of gamepad this represents
  18480. */
  18481. type: number;
  18482. private _leftStick;
  18483. private _rightStick;
  18484. /** @hidden */
  18485. _isConnected: boolean;
  18486. private _leftStickAxisX;
  18487. private _leftStickAxisY;
  18488. private _rightStickAxisX;
  18489. private _rightStickAxisY;
  18490. /**
  18491. * Triggered when the left control stick has been changed
  18492. */
  18493. private _onleftstickchanged;
  18494. /**
  18495. * Triggered when the right control stick has been changed
  18496. */
  18497. private _onrightstickchanged;
  18498. /**
  18499. * Represents a gamepad controller
  18500. */
  18501. static GAMEPAD: number;
  18502. /**
  18503. * Represents a generic controller
  18504. */
  18505. static GENERIC: number;
  18506. /**
  18507. * Represents an XBox controller
  18508. */
  18509. static XBOX: number;
  18510. /**
  18511. * Represents a pose-enabled controller
  18512. */
  18513. static POSE_ENABLED: number;
  18514. /**
  18515. * Represents an Dual Shock controller
  18516. */
  18517. static DUALSHOCK: number;
  18518. /**
  18519. * Specifies whether the left control stick should be Y-inverted
  18520. */
  18521. protected _invertLeftStickY: boolean;
  18522. /**
  18523. * Specifies if the gamepad has been connected
  18524. */
  18525. get isConnected(): boolean;
  18526. /**
  18527. * Initializes the gamepad
  18528. * @param id The id of the gamepad
  18529. * @param index The index of the gamepad
  18530. * @param browserGamepad The browser gamepad
  18531. * @param leftStickX The x component of the left joystick
  18532. * @param leftStickY The y component of the left joystick
  18533. * @param rightStickX The x component of the right joystick
  18534. * @param rightStickY The y component of the right joystick
  18535. */
  18536. constructor(
  18537. /**
  18538. * The id of the gamepad
  18539. */
  18540. id: string,
  18541. /**
  18542. * The index of the gamepad
  18543. */
  18544. index: number,
  18545. /**
  18546. * The browser gamepad
  18547. */
  18548. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18549. /**
  18550. * Callback triggered when the left joystick has changed
  18551. * @param callback
  18552. */
  18553. onleftstickchanged(callback: (values: StickValues) => void): void;
  18554. /**
  18555. * Callback triggered when the right joystick has changed
  18556. * @param callback
  18557. */
  18558. onrightstickchanged(callback: (values: StickValues) => void): void;
  18559. /**
  18560. * Gets the left joystick
  18561. */
  18562. get leftStick(): StickValues;
  18563. /**
  18564. * Sets the left joystick values
  18565. */
  18566. set leftStick(newValues: StickValues);
  18567. /**
  18568. * Gets the right joystick
  18569. */
  18570. get rightStick(): StickValues;
  18571. /**
  18572. * Sets the right joystick value
  18573. */
  18574. set rightStick(newValues: StickValues);
  18575. /**
  18576. * Updates the gamepad joystick positions
  18577. */
  18578. update(): void;
  18579. /**
  18580. * Disposes the gamepad
  18581. */
  18582. dispose(): void;
  18583. }
  18584. /**
  18585. * Represents a generic gamepad
  18586. */
  18587. export class GenericPad extends Gamepad {
  18588. private _buttons;
  18589. private _onbuttondown;
  18590. private _onbuttonup;
  18591. /**
  18592. * Observable triggered when a button has been pressed
  18593. */
  18594. onButtonDownObservable: Observable<number>;
  18595. /**
  18596. * Observable triggered when a button has been released
  18597. */
  18598. onButtonUpObservable: Observable<number>;
  18599. /**
  18600. * Callback triggered when a button has been pressed
  18601. * @param callback Called when a button has been pressed
  18602. */
  18603. onbuttondown(callback: (buttonPressed: number) => void): void;
  18604. /**
  18605. * Callback triggered when a button has been released
  18606. * @param callback Called when a button has been released
  18607. */
  18608. onbuttonup(callback: (buttonReleased: number) => void): void;
  18609. /**
  18610. * Initializes the generic gamepad
  18611. * @param id The id of the generic gamepad
  18612. * @param index The index of the generic gamepad
  18613. * @param browserGamepad The browser gamepad
  18614. */
  18615. constructor(id: string, index: number, browserGamepad: any);
  18616. private _setButtonValue;
  18617. /**
  18618. * Updates the generic gamepad
  18619. */
  18620. update(): void;
  18621. /**
  18622. * Disposes the generic gamepad
  18623. */
  18624. dispose(): void;
  18625. }
  18626. }
  18627. declare module BABYLON {
  18628. /**
  18629. * Defines the types of pose enabled controllers that are supported
  18630. */
  18631. export enum PoseEnabledControllerType {
  18632. /**
  18633. * HTC Vive
  18634. */
  18635. VIVE = 0,
  18636. /**
  18637. * Oculus Rift
  18638. */
  18639. OCULUS = 1,
  18640. /**
  18641. * Windows mixed reality
  18642. */
  18643. WINDOWS = 2,
  18644. /**
  18645. * Samsung gear VR
  18646. */
  18647. GEAR_VR = 3,
  18648. /**
  18649. * Google Daydream
  18650. */
  18651. DAYDREAM = 4,
  18652. /**
  18653. * Generic
  18654. */
  18655. GENERIC = 5
  18656. }
  18657. /**
  18658. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18659. */
  18660. export interface MutableGamepadButton {
  18661. /**
  18662. * Value of the button/trigger
  18663. */
  18664. value: number;
  18665. /**
  18666. * If the button/trigger is currently touched
  18667. */
  18668. touched: boolean;
  18669. /**
  18670. * If the button/trigger is currently pressed
  18671. */
  18672. pressed: boolean;
  18673. }
  18674. /**
  18675. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18676. * @hidden
  18677. */
  18678. export interface ExtendedGamepadButton extends GamepadButton {
  18679. /**
  18680. * If the button/trigger is currently pressed
  18681. */
  18682. readonly pressed: boolean;
  18683. /**
  18684. * If the button/trigger is currently touched
  18685. */
  18686. readonly touched: boolean;
  18687. /**
  18688. * Value of the button/trigger
  18689. */
  18690. readonly value: number;
  18691. }
  18692. /** @hidden */
  18693. export interface _GamePadFactory {
  18694. /**
  18695. * Returns whether or not the current gamepad can be created for this type of controller.
  18696. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18697. * @returns true if it can be created, otherwise false
  18698. */
  18699. canCreate(gamepadInfo: any): boolean;
  18700. /**
  18701. * Creates a new instance of the Gamepad.
  18702. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18703. * @returns the new gamepad instance
  18704. */
  18705. create(gamepadInfo: any): Gamepad;
  18706. }
  18707. /**
  18708. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18709. */
  18710. export class PoseEnabledControllerHelper {
  18711. /** @hidden */
  18712. static _ControllerFactories: _GamePadFactory[];
  18713. /** @hidden */
  18714. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18715. /**
  18716. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18717. * @param vrGamepad the gamepad to initialized
  18718. * @returns a vr controller of the type the gamepad identified as
  18719. */
  18720. static InitiateController(vrGamepad: any): Gamepad;
  18721. }
  18722. /**
  18723. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18724. */
  18725. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18726. /**
  18727. * If the controller is used in a webXR session
  18728. */
  18729. isXR: boolean;
  18730. private _deviceRoomPosition;
  18731. private _deviceRoomRotationQuaternion;
  18732. /**
  18733. * The device position in babylon space
  18734. */
  18735. devicePosition: Vector3;
  18736. /**
  18737. * The device rotation in babylon space
  18738. */
  18739. deviceRotationQuaternion: Quaternion;
  18740. /**
  18741. * The scale factor of the device in babylon space
  18742. */
  18743. deviceScaleFactor: number;
  18744. /**
  18745. * (Likely devicePosition should be used instead) The device position in its room space
  18746. */
  18747. position: Vector3;
  18748. /**
  18749. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18750. */
  18751. rotationQuaternion: Quaternion;
  18752. /**
  18753. * The type of controller (Eg. Windows mixed reality)
  18754. */
  18755. controllerType: PoseEnabledControllerType;
  18756. protected _calculatedPosition: Vector3;
  18757. private _calculatedRotation;
  18758. /**
  18759. * The raw pose from the device
  18760. */
  18761. rawPose: DevicePose;
  18762. private _trackPosition;
  18763. private _maxRotationDistFromHeadset;
  18764. private _draggedRoomRotation;
  18765. /**
  18766. * @hidden
  18767. */
  18768. _disableTrackPosition(fixedPosition: Vector3): void;
  18769. /**
  18770. * Internal, the mesh attached to the controller
  18771. * @hidden
  18772. */
  18773. _mesh: Nullable<AbstractMesh>;
  18774. private _poseControlledCamera;
  18775. private _leftHandSystemQuaternion;
  18776. /**
  18777. * Internal, matrix used to convert room space to babylon space
  18778. * @hidden
  18779. */
  18780. _deviceToWorld: Matrix;
  18781. /**
  18782. * Node to be used when casting a ray from the controller
  18783. * @hidden
  18784. */
  18785. _pointingPoseNode: Nullable<TransformNode>;
  18786. /**
  18787. * Name of the child mesh that can be used to cast a ray from the controller
  18788. */
  18789. static readonly POINTING_POSE: string;
  18790. /**
  18791. * Creates a new PoseEnabledController from a gamepad
  18792. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18793. */
  18794. constructor(browserGamepad: any);
  18795. private _workingMatrix;
  18796. /**
  18797. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18798. */
  18799. update(): void;
  18800. /**
  18801. * Updates only the pose device and mesh without doing any button event checking
  18802. */
  18803. protected _updatePoseAndMesh(): void;
  18804. /**
  18805. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18806. * @param poseData raw pose fromthe device
  18807. */
  18808. updateFromDevice(poseData: DevicePose): void;
  18809. /**
  18810. * @hidden
  18811. */
  18812. _meshAttachedObservable: Observable<AbstractMesh>;
  18813. /**
  18814. * Attaches a mesh to the controller
  18815. * @param mesh the mesh to be attached
  18816. */
  18817. attachToMesh(mesh: AbstractMesh): void;
  18818. /**
  18819. * Attaches the controllers mesh to a camera
  18820. * @param camera the camera the mesh should be attached to
  18821. */
  18822. attachToPoseControlledCamera(camera: TargetCamera): void;
  18823. /**
  18824. * Disposes of the controller
  18825. */
  18826. dispose(): void;
  18827. /**
  18828. * The mesh that is attached to the controller
  18829. */
  18830. get mesh(): Nullable<AbstractMesh>;
  18831. /**
  18832. * Gets the ray of the controller in the direction the controller is pointing
  18833. * @param length the length the resulting ray should be
  18834. * @returns a ray in the direction the controller is pointing
  18835. */
  18836. getForwardRay(length?: number): Ray;
  18837. }
  18838. }
  18839. declare module BABYLON {
  18840. /**
  18841. * Defines the WebVRController object that represents controllers tracked in 3D space
  18842. */
  18843. export abstract class WebVRController extends PoseEnabledController {
  18844. /**
  18845. * Internal, the default controller model for the controller
  18846. */
  18847. protected _defaultModel: Nullable<AbstractMesh>;
  18848. /**
  18849. * Fired when the trigger state has changed
  18850. */
  18851. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18852. /**
  18853. * Fired when the main button state has changed
  18854. */
  18855. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18856. /**
  18857. * Fired when the secondary button state has changed
  18858. */
  18859. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18860. /**
  18861. * Fired when the pad state has changed
  18862. */
  18863. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18864. /**
  18865. * Fired when controllers stick values have changed
  18866. */
  18867. onPadValuesChangedObservable: Observable<StickValues>;
  18868. /**
  18869. * Array of button availible on the controller
  18870. */
  18871. protected _buttons: Array<MutableGamepadButton>;
  18872. private _onButtonStateChange;
  18873. /**
  18874. * Fired when a controller button's state has changed
  18875. * @param callback the callback containing the button that was modified
  18876. */
  18877. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18878. /**
  18879. * X and Y axis corresponding to the controllers joystick
  18880. */
  18881. pad: StickValues;
  18882. /**
  18883. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18884. */
  18885. hand: string;
  18886. /**
  18887. * The default controller model for the controller
  18888. */
  18889. get defaultModel(): Nullable<AbstractMesh>;
  18890. /**
  18891. * Creates a new WebVRController from a gamepad
  18892. * @param vrGamepad the gamepad that the WebVRController should be created from
  18893. */
  18894. constructor(vrGamepad: any);
  18895. /**
  18896. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18897. */
  18898. update(): void;
  18899. /**
  18900. * Function to be called when a button is modified
  18901. */
  18902. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18903. /**
  18904. * Loads a mesh and attaches it to the controller
  18905. * @param scene the scene the mesh should be added to
  18906. * @param meshLoaded callback for when the mesh has been loaded
  18907. */
  18908. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18909. private _setButtonValue;
  18910. private _changes;
  18911. private _checkChanges;
  18912. /**
  18913. * Disposes of th webVRCOntroller
  18914. */
  18915. dispose(): void;
  18916. }
  18917. }
  18918. declare module BABYLON {
  18919. /**
  18920. * The HemisphericLight simulates the ambient environment light,
  18921. * so the passed direction is the light reflection direction, not the incoming direction.
  18922. */
  18923. export class HemisphericLight extends Light {
  18924. /**
  18925. * The groundColor is the light in the opposite direction to the one specified during creation.
  18926. * 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.
  18927. */
  18928. groundColor: Color3;
  18929. /**
  18930. * The light reflection direction, not the incoming direction.
  18931. */
  18932. direction: Vector3;
  18933. /**
  18934. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18935. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18936. * The HemisphericLight can't cast shadows.
  18937. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18938. * @param name The friendly name of the light
  18939. * @param direction The direction of the light reflection
  18940. * @param scene The scene the light belongs to
  18941. */
  18942. constructor(name: string, direction: Vector3, scene: Scene);
  18943. protected _buildUniformLayout(): void;
  18944. /**
  18945. * Returns the string "HemisphericLight".
  18946. * @return The class name
  18947. */
  18948. getClassName(): string;
  18949. /**
  18950. * Sets the HemisphericLight direction towards the passed target (Vector3).
  18951. * Returns the updated direction.
  18952. * @param target The target the direction should point to
  18953. * @return The computed direction
  18954. */
  18955. setDirectionToTarget(target: Vector3): Vector3;
  18956. /**
  18957. * Returns the shadow generator associated to the light.
  18958. * @returns Always null for hemispheric lights because it does not support shadows.
  18959. */
  18960. getShadowGenerator(): Nullable<IShadowGenerator>;
  18961. /**
  18962. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  18963. * @param effect The effect to update
  18964. * @param lightIndex The index of the light in the effect to update
  18965. * @returns The hemispheric light
  18966. */
  18967. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  18968. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  18969. /**
  18970. * Computes the world matrix of the node
  18971. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  18972. * @param useWasUpdatedFlag defines a reserved property
  18973. * @returns the world matrix
  18974. */
  18975. computeWorldMatrix(): Matrix;
  18976. /**
  18977. * Returns the integer 3.
  18978. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18979. */
  18980. getTypeID(): number;
  18981. /**
  18982. * Prepares the list of defines specific to the light type.
  18983. * @param defines the list of defines
  18984. * @param lightIndex defines the index of the light for the effect
  18985. */
  18986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18987. }
  18988. }
  18989. declare module BABYLON {
  18990. /** @hidden */
  18991. export var vrMultiviewToSingleviewPixelShader: {
  18992. name: string;
  18993. shader: string;
  18994. };
  18995. }
  18996. declare module BABYLON {
  18997. /**
  18998. * Renders to multiple views with a single draw call
  18999. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19000. */
  19001. export class MultiviewRenderTarget extends RenderTargetTexture {
  19002. /**
  19003. * Creates a multiview render target
  19004. * @param scene scene used with the render target
  19005. * @param size the size of the render target (used for each view)
  19006. */
  19007. constructor(scene: Scene, size?: number | {
  19008. width: number;
  19009. height: number;
  19010. } | {
  19011. ratio: number;
  19012. });
  19013. /**
  19014. * @hidden
  19015. * @param faceIndex the face index, if its a cube texture
  19016. */
  19017. _bindFrameBuffer(faceIndex?: number): void;
  19018. /**
  19019. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19020. * @returns the view count
  19021. */
  19022. getViewCount(): number;
  19023. }
  19024. }
  19025. declare module BABYLON {
  19026. /**
  19027. * Represents a camera frustum
  19028. */
  19029. export class Frustum {
  19030. /**
  19031. * Gets the planes representing the frustum
  19032. * @param transform matrix to be applied to the returned planes
  19033. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19034. */
  19035. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19036. /**
  19037. * Gets the near frustum plane transformed by the transform matrix
  19038. * @param transform transformation matrix to be applied to the resulting frustum plane
  19039. * @param frustumPlane the resuling frustum plane
  19040. */
  19041. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19042. /**
  19043. * Gets the far frustum plane transformed by the transform matrix
  19044. * @param transform transformation matrix to be applied to the resulting frustum plane
  19045. * @param frustumPlane the resuling frustum plane
  19046. */
  19047. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19048. /**
  19049. * Gets the left frustum plane transformed by the transform matrix
  19050. * @param transform transformation matrix to be applied to the resulting frustum plane
  19051. * @param frustumPlane the resuling frustum plane
  19052. */
  19053. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19054. /**
  19055. * Gets the right frustum plane transformed by the transform matrix
  19056. * @param transform transformation matrix to be applied to the resulting frustum plane
  19057. * @param frustumPlane the resuling frustum plane
  19058. */
  19059. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19060. /**
  19061. * Gets the top frustum plane transformed by the transform matrix
  19062. * @param transform transformation matrix to be applied to the resulting frustum plane
  19063. * @param frustumPlane the resuling frustum plane
  19064. */
  19065. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19066. /**
  19067. * Gets the bottom frustum plane transformed by the transform matrix
  19068. * @param transform transformation matrix to be applied to the resulting frustum plane
  19069. * @param frustumPlane the resuling frustum plane
  19070. */
  19071. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19072. /**
  19073. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19074. * @param transform transformation matrix to be applied to the resulting frustum planes
  19075. * @param frustumPlanes the resuling frustum planes
  19076. */
  19077. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19078. }
  19079. }
  19080. declare module BABYLON {
  19081. interface Engine {
  19082. /**
  19083. * Creates a new multiview render target
  19084. * @param width defines the width of the texture
  19085. * @param height defines the height of the texture
  19086. * @returns the created multiview texture
  19087. */
  19088. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19089. /**
  19090. * Binds a multiview framebuffer to be drawn to
  19091. * @param multiviewTexture texture to bind
  19092. */
  19093. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19094. }
  19095. interface Camera {
  19096. /**
  19097. * @hidden
  19098. * 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)
  19099. */
  19100. _useMultiviewToSingleView: boolean;
  19101. /**
  19102. * @hidden
  19103. * 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)
  19104. */
  19105. _multiviewTexture: Nullable<RenderTargetTexture>;
  19106. /**
  19107. * @hidden
  19108. * ensures the multiview texture of the camera exists and has the specified width/height
  19109. * @param width height to set on the multiview texture
  19110. * @param height width to set on the multiview texture
  19111. */
  19112. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19113. }
  19114. interface Scene {
  19115. /** @hidden */
  19116. _transformMatrixR: Matrix;
  19117. /** @hidden */
  19118. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19119. /** @hidden */
  19120. _createMultiviewUbo(): void;
  19121. /** @hidden */
  19122. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19123. /** @hidden */
  19124. _renderMultiviewToSingleView(camera: Camera): void;
  19125. }
  19126. }
  19127. declare module BABYLON {
  19128. /**
  19129. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19130. * This will not be used for webXR as it supports displaying texture arrays directly
  19131. */
  19132. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19133. /**
  19134. * Initializes a VRMultiviewToSingleview
  19135. * @param name name of the post process
  19136. * @param camera camera to be applied to
  19137. * @param scaleFactor scaling factor to the size of the output texture
  19138. */
  19139. constructor(name: string, camera: Camera, scaleFactor: number);
  19140. }
  19141. }
  19142. declare module BABYLON {
  19143. /**
  19144. * Interface used to define additional presentation attributes
  19145. */
  19146. export interface IVRPresentationAttributes {
  19147. /**
  19148. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19149. */
  19150. highRefreshRate: boolean;
  19151. /**
  19152. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19153. */
  19154. foveationLevel: number;
  19155. }
  19156. interface Engine {
  19157. /** @hidden */
  19158. _vrDisplay: any;
  19159. /** @hidden */
  19160. _vrSupported: boolean;
  19161. /** @hidden */
  19162. _oldSize: Size;
  19163. /** @hidden */
  19164. _oldHardwareScaleFactor: number;
  19165. /** @hidden */
  19166. _vrExclusivePointerMode: boolean;
  19167. /** @hidden */
  19168. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19169. /** @hidden */
  19170. _onVRDisplayPointerRestricted: () => void;
  19171. /** @hidden */
  19172. _onVRDisplayPointerUnrestricted: () => void;
  19173. /** @hidden */
  19174. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19175. /** @hidden */
  19176. _onVrDisplayDisconnect: Nullable<() => void>;
  19177. /** @hidden */
  19178. _onVrDisplayPresentChange: Nullable<() => void>;
  19179. /**
  19180. * Observable signaled when VR display mode changes
  19181. */
  19182. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19183. /**
  19184. * Observable signaled when VR request present is complete
  19185. */
  19186. onVRRequestPresentComplete: Observable<boolean>;
  19187. /**
  19188. * Observable signaled when VR request present starts
  19189. */
  19190. onVRRequestPresentStart: Observable<Engine>;
  19191. /**
  19192. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19193. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19194. */
  19195. isInVRExclusivePointerMode: boolean;
  19196. /**
  19197. * Gets a boolean indicating if a webVR device was detected
  19198. * @returns true if a webVR device was detected
  19199. */
  19200. isVRDevicePresent(): boolean;
  19201. /**
  19202. * Gets the current webVR device
  19203. * @returns the current webVR device (or null)
  19204. */
  19205. getVRDevice(): any;
  19206. /**
  19207. * Initializes a webVR display and starts listening to display change events
  19208. * The onVRDisplayChangedObservable will be notified upon these changes
  19209. * @returns A promise containing a VRDisplay and if vr is supported
  19210. */
  19211. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19212. /** @hidden */
  19213. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19214. /**
  19215. * Gets or sets the presentation attributes used to configure VR rendering
  19216. */
  19217. vrPresentationAttributes?: IVRPresentationAttributes;
  19218. /**
  19219. * Call this function to switch to webVR mode
  19220. * Will do nothing if webVR is not supported or if there is no webVR device
  19221. * @param options the webvr options provided to the camera. mainly used for multiview
  19222. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19223. */
  19224. enableVR(options: WebVROptions): void;
  19225. /** @hidden */
  19226. _onVRFullScreenTriggered(): void;
  19227. }
  19228. }
  19229. declare module BABYLON {
  19230. /**
  19231. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19232. * IMPORTANT!! The data is right-hand data.
  19233. * @export
  19234. * @interface DevicePose
  19235. */
  19236. export interface DevicePose {
  19237. /**
  19238. * The position of the device, values in array are [x,y,z].
  19239. */
  19240. readonly position: Nullable<Float32Array>;
  19241. /**
  19242. * The linearVelocity of the device, values in array are [x,y,z].
  19243. */
  19244. readonly linearVelocity: Nullable<Float32Array>;
  19245. /**
  19246. * The linearAcceleration of the device, values in array are [x,y,z].
  19247. */
  19248. readonly linearAcceleration: Nullable<Float32Array>;
  19249. /**
  19250. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19251. */
  19252. readonly orientation: Nullable<Float32Array>;
  19253. /**
  19254. * The angularVelocity of the device, values in array are [x,y,z].
  19255. */
  19256. readonly angularVelocity: Nullable<Float32Array>;
  19257. /**
  19258. * The angularAcceleration of the device, values in array are [x,y,z].
  19259. */
  19260. readonly angularAcceleration: Nullable<Float32Array>;
  19261. }
  19262. /**
  19263. * Interface representing a pose controlled object in Babylon.
  19264. * A pose controlled object has both regular pose values as well as pose values
  19265. * from an external device such as a VR head mounted display
  19266. */
  19267. export interface PoseControlled {
  19268. /**
  19269. * The position of the object in babylon space.
  19270. */
  19271. position: Vector3;
  19272. /**
  19273. * The rotation quaternion of the object in babylon space.
  19274. */
  19275. rotationQuaternion: Quaternion;
  19276. /**
  19277. * The position of the device in babylon space.
  19278. */
  19279. devicePosition?: Vector3;
  19280. /**
  19281. * The rotation quaternion of the device in babylon space.
  19282. */
  19283. deviceRotationQuaternion: Quaternion;
  19284. /**
  19285. * The raw pose coming from the device.
  19286. */
  19287. rawPose: Nullable<DevicePose>;
  19288. /**
  19289. * The scale of the device to be used when translating from device space to babylon space.
  19290. */
  19291. deviceScaleFactor: number;
  19292. /**
  19293. * Updates the poseControlled values based on the input device pose.
  19294. * @param poseData the pose data to update the object with
  19295. */
  19296. updateFromDevice(poseData: DevicePose): void;
  19297. }
  19298. /**
  19299. * Set of options to customize the webVRCamera
  19300. */
  19301. export interface WebVROptions {
  19302. /**
  19303. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19304. */
  19305. trackPosition?: boolean;
  19306. /**
  19307. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19308. */
  19309. positionScale?: number;
  19310. /**
  19311. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19312. */
  19313. displayName?: string;
  19314. /**
  19315. * Should the native controller meshes be initialized. (default: true)
  19316. */
  19317. controllerMeshes?: boolean;
  19318. /**
  19319. * Creating a default HemiLight only on controllers. (default: true)
  19320. */
  19321. defaultLightingOnControllers?: boolean;
  19322. /**
  19323. * If you don't want to use the default VR button of the helper. (default: false)
  19324. */
  19325. useCustomVRButton?: boolean;
  19326. /**
  19327. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19328. */
  19329. customVRButton?: HTMLButtonElement;
  19330. /**
  19331. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19332. */
  19333. rayLength?: number;
  19334. /**
  19335. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19336. */
  19337. defaultHeight?: number;
  19338. /**
  19339. * If multiview should be used if availible (default: false)
  19340. */
  19341. useMultiview?: boolean;
  19342. }
  19343. /**
  19344. * This represents a WebVR camera.
  19345. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19346. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19347. */
  19348. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19349. private webVROptions;
  19350. /**
  19351. * @hidden
  19352. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19353. */
  19354. _vrDevice: any;
  19355. /**
  19356. * The rawPose of the vrDevice.
  19357. */
  19358. rawPose: Nullable<DevicePose>;
  19359. private _onVREnabled;
  19360. private _specsVersion;
  19361. private _attached;
  19362. private _frameData;
  19363. protected _descendants: Array<Node>;
  19364. private _deviceRoomPosition;
  19365. /** @hidden */
  19366. _deviceRoomRotationQuaternion: Quaternion;
  19367. private _standingMatrix;
  19368. /**
  19369. * Represents device position in babylon space.
  19370. */
  19371. devicePosition: Vector3;
  19372. /**
  19373. * Represents device rotation in babylon space.
  19374. */
  19375. deviceRotationQuaternion: Quaternion;
  19376. /**
  19377. * The scale of the device to be used when translating from device space to babylon space.
  19378. */
  19379. deviceScaleFactor: number;
  19380. private _deviceToWorld;
  19381. private _worldToDevice;
  19382. /**
  19383. * References to the webVR controllers for the vrDevice.
  19384. */
  19385. controllers: Array<WebVRController>;
  19386. /**
  19387. * Emits an event when a controller is attached.
  19388. */
  19389. onControllersAttachedObservable: Observable<WebVRController[]>;
  19390. /**
  19391. * Emits an event when a controller's mesh has been loaded;
  19392. */
  19393. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19394. /**
  19395. * Emits an event when the HMD's pose has been updated.
  19396. */
  19397. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19398. private _poseSet;
  19399. /**
  19400. * If the rig cameras be used as parent instead of this camera.
  19401. */
  19402. rigParenting: boolean;
  19403. private _lightOnControllers;
  19404. private _defaultHeight?;
  19405. /**
  19406. * Instantiates a WebVRFreeCamera.
  19407. * @param name The name of the WebVRFreeCamera
  19408. * @param position The starting anchor position for the camera
  19409. * @param scene The scene the camera belongs to
  19410. * @param webVROptions a set of customizable options for the webVRCamera
  19411. */
  19412. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19413. /**
  19414. * Gets the device distance from the ground in meters.
  19415. * @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.
  19416. */
  19417. deviceDistanceToRoomGround(): number;
  19418. /**
  19419. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19420. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19421. */
  19422. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19423. /**
  19424. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19425. * @returns A promise with a boolean set to if the standing matrix is supported.
  19426. */
  19427. useStandingMatrixAsync(): Promise<boolean>;
  19428. /**
  19429. * Disposes the camera
  19430. */
  19431. dispose(): void;
  19432. /**
  19433. * Gets a vrController by name.
  19434. * @param name The name of the controller to retreive
  19435. * @returns the controller matching the name specified or null if not found
  19436. */
  19437. getControllerByName(name: string): Nullable<WebVRController>;
  19438. private _leftController;
  19439. /**
  19440. * The controller corresponding to the users left hand.
  19441. */
  19442. get leftController(): Nullable<WebVRController>;
  19443. private _rightController;
  19444. /**
  19445. * The controller corresponding to the users right hand.
  19446. */
  19447. get rightController(): Nullable<WebVRController>;
  19448. /**
  19449. * Casts a ray forward from the vrCamera's gaze.
  19450. * @param length Length of the ray (default: 100)
  19451. * @returns the ray corresponding to the gaze
  19452. */
  19453. getForwardRay(length?: number): Ray;
  19454. /**
  19455. * @hidden
  19456. * Updates the camera based on device's frame data
  19457. */
  19458. _checkInputs(): void;
  19459. /**
  19460. * Updates the poseControlled values based on the input device pose.
  19461. * @param poseData Pose coming from the device
  19462. */
  19463. updateFromDevice(poseData: DevicePose): void;
  19464. private _htmlElementAttached;
  19465. private _detachIfAttached;
  19466. /**
  19467. * WebVR's attach control will start broadcasting frames to the device.
  19468. * Note that in certain browsers (chrome for example) this function must be called
  19469. * within a user-interaction callback. Example:
  19470. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19471. *
  19472. * @param element html element to attach the vrDevice to
  19473. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19474. */
  19475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19476. /**
  19477. * Detaches the camera from the html element and disables VR
  19478. *
  19479. * @param element html element to detach from
  19480. */
  19481. detachControl(element: HTMLElement): void;
  19482. /**
  19483. * @returns the name of this class
  19484. */
  19485. getClassName(): string;
  19486. /**
  19487. * Calls resetPose on the vrDisplay
  19488. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19489. */
  19490. resetToCurrentRotation(): void;
  19491. /**
  19492. * @hidden
  19493. * Updates the rig cameras (left and right eye)
  19494. */
  19495. _updateRigCameras(): void;
  19496. private _workingVector;
  19497. private _oneVector;
  19498. private _workingMatrix;
  19499. private updateCacheCalled;
  19500. private _correctPositionIfNotTrackPosition;
  19501. /**
  19502. * @hidden
  19503. * Updates the cached values of the camera
  19504. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19505. */
  19506. _updateCache(ignoreParentClass?: boolean): void;
  19507. /**
  19508. * @hidden
  19509. * Get current device position in babylon world
  19510. */
  19511. _computeDevicePosition(): void;
  19512. /**
  19513. * Updates the current device position and rotation in the babylon world
  19514. */
  19515. update(): void;
  19516. /**
  19517. * @hidden
  19518. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19519. * @returns an identity matrix
  19520. */
  19521. _getViewMatrix(): Matrix;
  19522. private _tmpMatrix;
  19523. /**
  19524. * This function is called by the two RIG cameras.
  19525. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19526. * @hidden
  19527. */
  19528. _getWebVRViewMatrix(): Matrix;
  19529. /** @hidden */
  19530. _getWebVRProjectionMatrix(): Matrix;
  19531. private _onGamepadConnectedObserver;
  19532. private _onGamepadDisconnectedObserver;
  19533. private _updateCacheWhenTrackingDisabledObserver;
  19534. /**
  19535. * Initializes the controllers and their meshes
  19536. */
  19537. initControllers(): void;
  19538. }
  19539. }
  19540. declare module BABYLON {
  19541. /**
  19542. * Size options for a post process
  19543. */
  19544. export type PostProcessOptions = {
  19545. width: number;
  19546. height: number;
  19547. };
  19548. /**
  19549. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19550. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19551. */
  19552. export class PostProcess {
  19553. /** Name of the PostProcess. */
  19554. name: string;
  19555. /**
  19556. * Gets or sets the unique id of the post process
  19557. */
  19558. uniqueId: number;
  19559. /**
  19560. * Width of the texture to apply the post process on
  19561. */
  19562. width: number;
  19563. /**
  19564. * Height of the texture to apply the post process on
  19565. */
  19566. height: number;
  19567. /**
  19568. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19569. * @hidden
  19570. */
  19571. _outputTexture: Nullable<InternalTexture>;
  19572. /**
  19573. * Sampling mode used by the shader
  19574. * See https://doc.babylonjs.com/classes/3.1/texture
  19575. */
  19576. renderTargetSamplingMode: number;
  19577. /**
  19578. * Clear color to use when screen clearing
  19579. */
  19580. clearColor: Color4;
  19581. /**
  19582. * If the buffer needs to be cleared before applying the post process. (default: true)
  19583. * Should be set to false if shader will overwrite all previous pixels.
  19584. */
  19585. autoClear: boolean;
  19586. /**
  19587. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19588. */
  19589. alphaMode: number;
  19590. /**
  19591. * Sets the setAlphaBlendConstants of the babylon engine
  19592. */
  19593. alphaConstants: Color4;
  19594. /**
  19595. * Animations to be used for the post processing
  19596. */
  19597. animations: Animation[];
  19598. /**
  19599. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19600. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19601. */
  19602. enablePixelPerfectMode: boolean;
  19603. /**
  19604. * Force the postprocess to be applied without taking in account viewport
  19605. */
  19606. forceFullscreenViewport: boolean;
  19607. /**
  19608. * List of inspectable custom properties (used by the Inspector)
  19609. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19610. */
  19611. inspectableCustomProperties: IInspectable[];
  19612. /**
  19613. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19614. *
  19615. * | Value | Type | Description |
  19616. * | ----- | ----------------------------------- | ----------- |
  19617. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19618. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19619. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19620. *
  19621. */
  19622. scaleMode: number;
  19623. /**
  19624. * Force textures to be a power of two (default: false)
  19625. */
  19626. alwaysForcePOT: boolean;
  19627. private _samples;
  19628. /**
  19629. * Number of sample textures (default: 1)
  19630. */
  19631. get samples(): number;
  19632. set samples(n: number);
  19633. /**
  19634. * Modify the scale of the post process to be the same as the viewport (default: false)
  19635. */
  19636. adaptScaleToCurrentViewport: boolean;
  19637. private _camera;
  19638. private _scene;
  19639. private _engine;
  19640. private _options;
  19641. private _reusable;
  19642. private _textureType;
  19643. private _textureFormat;
  19644. /**
  19645. * Smart array of input and output textures for the post process.
  19646. * @hidden
  19647. */
  19648. _textures: SmartArray<InternalTexture>;
  19649. /**
  19650. * The index in _textures that corresponds to the output texture.
  19651. * @hidden
  19652. */
  19653. _currentRenderTextureInd: number;
  19654. private _effect;
  19655. private _samplers;
  19656. private _fragmentUrl;
  19657. private _vertexUrl;
  19658. private _parameters;
  19659. private _scaleRatio;
  19660. protected _indexParameters: any;
  19661. private _shareOutputWithPostProcess;
  19662. private _texelSize;
  19663. private _forcedOutputTexture;
  19664. /**
  19665. * Returns the fragment url or shader name used in the post process.
  19666. * @returns the fragment url or name in the shader store.
  19667. */
  19668. getEffectName(): string;
  19669. /**
  19670. * An event triggered when the postprocess is activated.
  19671. */
  19672. onActivateObservable: Observable<Camera>;
  19673. private _onActivateObserver;
  19674. /**
  19675. * A function that is added to the onActivateObservable
  19676. */
  19677. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19678. /**
  19679. * An event triggered when the postprocess changes its size.
  19680. */
  19681. onSizeChangedObservable: Observable<PostProcess>;
  19682. private _onSizeChangedObserver;
  19683. /**
  19684. * A function that is added to the onSizeChangedObservable
  19685. */
  19686. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19687. /**
  19688. * An event triggered when the postprocess applies its effect.
  19689. */
  19690. onApplyObservable: Observable<Effect>;
  19691. private _onApplyObserver;
  19692. /**
  19693. * A function that is added to the onApplyObservable
  19694. */
  19695. set onApply(callback: (effect: Effect) => void);
  19696. /**
  19697. * An event triggered before rendering the postprocess
  19698. */
  19699. onBeforeRenderObservable: Observable<Effect>;
  19700. private _onBeforeRenderObserver;
  19701. /**
  19702. * A function that is added to the onBeforeRenderObservable
  19703. */
  19704. set onBeforeRender(callback: (effect: Effect) => void);
  19705. /**
  19706. * An event triggered after rendering the postprocess
  19707. */
  19708. onAfterRenderObservable: Observable<Effect>;
  19709. private _onAfterRenderObserver;
  19710. /**
  19711. * A function that is added to the onAfterRenderObservable
  19712. */
  19713. set onAfterRender(callback: (efect: Effect) => void);
  19714. /**
  19715. * 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
  19716. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19717. */
  19718. get inputTexture(): InternalTexture;
  19719. set inputTexture(value: InternalTexture);
  19720. /**
  19721. * Gets the camera which post process is applied to.
  19722. * @returns The camera the post process is applied to.
  19723. */
  19724. getCamera(): Camera;
  19725. /**
  19726. * Gets the texel size of the postprocess.
  19727. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19728. */
  19729. get texelSize(): Vector2;
  19730. /**
  19731. * Creates a new instance PostProcess
  19732. * @param name The name of the PostProcess.
  19733. * @param fragmentUrl The url of the fragment shader to be used.
  19734. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19735. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19736. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19737. * @param camera The camera to apply the render pass to.
  19738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19739. * @param engine The engine which the post process will be applied. (default: current engine)
  19740. * @param reusable If the post process can be reused on the same frame. (default: false)
  19741. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19742. * @param textureType Type of textures used when performing the post process. (default: 0)
  19743. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19744. * @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
  19745. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19746. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19747. */
  19748. constructor(
  19749. /** Name of the PostProcess. */
  19750. 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);
  19751. /**
  19752. * Gets a string idenfifying the name of the class
  19753. * @returns "PostProcess" string
  19754. */
  19755. getClassName(): string;
  19756. /**
  19757. * Gets the engine which this post process belongs to.
  19758. * @returns The engine the post process was enabled with.
  19759. */
  19760. getEngine(): Engine;
  19761. /**
  19762. * The effect that is created when initializing the post process.
  19763. * @returns The created effect corresponding the the postprocess.
  19764. */
  19765. getEffect(): Effect;
  19766. /**
  19767. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19768. * @param postProcess The post process to share the output with.
  19769. * @returns This post process.
  19770. */
  19771. shareOutputWith(postProcess: PostProcess): PostProcess;
  19772. /**
  19773. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19774. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19775. */
  19776. useOwnOutput(): void;
  19777. /**
  19778. * Updates the effect with the current post process compile time values and recompiles the shader.
  19779. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19780. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19781. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19782. * @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
  19783. * @param onCompiled Called when the shader has been compiled.
  19784. * @param onError Called if there is an error when compiling a shader.
  19785. */
  19786. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19787. /**
  19788. * The post process is reusable if it can be used multiple times within one frame.
  19789. * @returns If the post process is reusable
  19790. */
  19791. isReusable(): boolean;
  19792. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19793. markTextureDirty(): void;
  19794. /**
  19795. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19796. * 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.
  19797. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19798. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19799. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19800. * @returns The target texture that was bound to be written to.
  19801. */
  19802. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19803. /**
  19804. * If the post process is supported.
  19805. */
  19806. get isSupported(): boolean;
  19807. /**
  19808. * The aspect ratio of the output texture.
  19809. */
  19810. get aspectRatio(): number;
  19811. /**
  19812. * Get a value indicating if the post-process is ready to be used
  19813. * @returns true if the post-process is ready (shader is compiled)
  19814. */
  19815. isReady(): boolean;
  19816. /**
  19817. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19818. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19819. */
  19820. apply(): Nullable<Effect>;
  19821. private _disposeTextures;
  19822. /**
  19823. * Disposes the post process.
  19824. * @param camera The camera to dispose the post process on.
  19825. */
  19826. dispose(camera?: Camera): void;
  19827. }
  19828. }
  19829. declare module BABYLON {
  19830. /** @hidden */
  19831. export var kernelBlurVaryingDeclaration: {
  19832. name: string;
  19833. shader: string;
  19834. };
  19835. }
  19836. declare module BABYLON {
  19837. /** @hidden */
  19838. export var kernelBlurFragment: {
  19839. name: string;
  19840. shader: string;
  19841. };
  19842. }
  19843. declare module BABYLON {
  19844. /** @hidden */
  19845. export var kernelBlurFragment2: {
  19846. name: string;
  19847. shader: string;
  19848. };
  19849. }
  19850. declare module BABYLON {
  19851. /** @hidden */
  19852. export var kernelBlurPixelShader: {
  19853. name: string;
  19854. shader: string;
  19855. };
  19856. }
  19857. declare module BABYLON {
  19858. /** @hidden */
  19859. export var kernelBlurVertex: {
  19860. name: string;
  19861. shader: string;
  19862. };
  19863. }
  19864. declare module BABYLON {
  19865. /** @hidden */
  19866. export var kernelBlurVertexShader: {
  19867. name: string;
  19868. shader: string;
  19869. };
  19870. }
  19871. declare module BABYLON {
  19872. /**
  19873. * The Blur Post Process which blurs an image based on a kernel and direction.
  19874. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19875. */
  19876. export class BlurPostProcess extends PostProcess {
  19877. /** The direction in which to blur the image. */
  19878. direction: Vector2;
  19879. private blockCompilation;
  19880. protected _kernel: number;
  19881. protected _idealKernel: number;
  19882. protected _packedFloat: boolean;
  19883. private _staticDefines;
  19884. /**
  19885. * Sets the length in pixels of the blur sample region
  19886. */
  19887. set kernel(v: number);
  19888. /**
  19889. * Gets the length in pixels of the blur sample region
  19890. */
  19891. get kernel(): number;
  19892. /**
  19893. * Sets wether or not the blur needs to unpack/repack floats
  19894. */
  19895. set packedFloat(v: boolean);
  19896. /**
  19897. * Gets wether or not the blur is unpacking/repacking floats
  19898. */
  19899. get packedFloat(): boolean;
  19900. /**
  19901. * Creates a new instance BlurPostProcess
  19902. * @param name The name of the effect.
  19903. * @param direction The direction in which to blur the image.
  19904. * @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.
  19905. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19906. * @param camera The camera to apply the render pass to.
  19907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19908. * @param engine The engine which the post process will be applied. (default: current engine)
  19909. * @param reusable If the post process can be reused on the same frame. (default: false)
  19910. * @param textureType Type of textures used when performing the post process. (default: 0)
  19911. * @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)
  19912. */
  19913. constructor(name: string,
  19914. /** The direction in which to blur the image. */
  19915. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19916. /**
  19917. * Updates the effect with the current post process compile time values and recompiles the shader.
  19918. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19919. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19920. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19921. * @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
  19922. * @param onCompiled Called when the shader has been compiled.
  19923. * @param onError Called if there is an error when compiling a shader.
  19924. */
  19925. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19926. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19927. /**
  19928. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19929. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19930. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19931. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19932. * The gaps between physical kernels are compensated for in the weighting of the samples
  19933. * @param idealKernel Ideal blur kernel.
  19934. * @return Nearest best kernel.
  19935. */
  19936. protected _nearestBestKernel(idealKernel: number): number;
  19937. /**
  19938. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19939. * @param x The point on the Gaussian distribution to sample.
  19940. * @return the value of the Gaussian function at x.
  19941. */
  19942. protected _gaussianWeight(x: number): number;
  19943. /**
  19944. * Generates a string that can be used as a floating point number in GLSL.
  19945. * @param x Value to print.
  19946. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19947. * @return GLSL float string.
  19948. */
  19949. protected _glslFloat(x: number, decimalFigures?: number): string;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * Mirror texture can be used to simulate the view from a mirror in a scene.
  19955. * It will dynamically be rendered every frame to adapt to the camera point of view.
  19956. * You can then easily use it as a reflectionTexture on a flat surface.
  19957. * In case the surface is not a plane, please consider relying on reflection probes.
  19958. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19959. */
  19960. export class MirrorTexture extends RenderTargetTexture {
  19961. private scene;
  19962. /**
  19963. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  19964. * 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.
  19965. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19966. */
  19967. mirrorPlane: Plane;
  19968. /**
  19969. * Define the blur ratio used to blur the reflection if needed.
  19970. */
  19971. set blurRatio(value: number);
  19972. get blurRatio(): number;
  19973. /**
  19974. * Define the adaptive blur kernel used to blur the reflection if needed.
  19975. * This will autocompute the closest best match for the `blurKernel`
  19976. */
  19977. set adaptiveBlurKernel(value: number);
  19978. /**
  19979. * Define the blur kernel used to blur the reflection if needed.
  19980. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19981. */
  19982. set blurKernel(value: number);
  19983. /**
  19984. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  19985. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19986. */
  19987. set blurKernelX(value: number);
  19988. get blurKernelX(): number;
  19989. /**
  19990. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  19991. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19992. */
  19993. set blurKernelY(value: number);
  19994. get blurKernelY(): number;
  19995. private _autoComputeBlurKernel;
  19996. protected _onRatioRescale(): void;
  19997. private _updateGammaSpace;
  19998. private _imageProcessingConfigChangeObserver;
  19999. private _transformMatrix;
  20000. private _mirrorMatrix;
  20001. private _savedViewMatrix;
  20002. private _blurX;
  20003. private _blurY;
  20004. private _adaptiveBlurKernel;
  20005. private _blurKernelX;
  20006. private _blurKernelY;
  20007. private _blurRatio;
  20008. /**
  20009. * Instantiates a Mirror Texture.
  20010. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20011. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20012. * You can then easily use it as a reflectionTexture on a flat surface.
  20013. * In case the surface is not a plane, please consider relying on reflection probes.
  20014. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20015. * @param name
  20016. * @param size
  20017. * @param scene
  20018. * @param generateMipMaps
  20019. * @param type
  20020. * @param samplingMode
  20021. * @param generateDepthBuffer
  20022. */
  20023. constructor(name: string, size: number | {
  20024. width: number;
  20025. height: number;
  20026. } | {
  20027. ratio: number;
  20028. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20029. private _preparePostProcesses;
  20030. /**
  20031. * Clone the mirror texture.
  20032. * @returns the cloned texture
  20033. */
  20034. clone(): MirrorTexture;
  20035. /**
  20036. * Serialize the texture to a JSON representation you could use in Parse later on
  20037. * @returns the serialized JSON representation
  20038. */
  20039. serialize(): any;
  20040. /**
  20041. * Dispose the texture and release its associated resources.
  20042. */
  20043. dispose(): void;
  20044. }
  20045. }
  20046. declare module BABYLON {
  20047. /**
  20048. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20049. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20050. */
  20051. export class Texture extends BaseTexture {
  20052. /**
  20053. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20054. */
  20055. static SerializeBuffers: boolean;
  20056. /** @hidden */
  20057. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20058. /** @hidden */
  20059. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20060. /** @hidden */
  20061. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20062. /** nearest is mag = nearest and min = nearest and mip = linear */
  20063. static readonly NEAREST_SAMPLINGMODE: number;
  20064. /** nearest is mag = nearest and min = nearest and mip = linear */
  20065. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20066. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20067. static readonly BILINEAR_SAMPLINGMODE: number;
  20068. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20069. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20070. /** Trilinear is mag = linear and min = linear and mip = linear */
  20071. static readonly TRILINEAR_SAMPLINGMODE: number;
  20072. /** Trilinear is mag = linear and min = linear and mip = linear */
  20073. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20074. /** mag = nearest and min = nearest and mip = nearest */
  20075. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20076. /** mag = nearest and min = linear and mip = nearest */
  20077. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20078. /** mag = nearest and min = linear and mip = linear */
  20079. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20080. /** mag = nearest and min = linear and mip = none */
  20081. static readonly NEAREST_LINEAR: number;
  20082. /** mag = nearest and min = nearest and mip = none */
  20083. static readonly NEAREST_NEAREST: number;
  20084. /** mag = linear and min = nearest and mip = nearest */
  20085. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20086. /** mag = linear and min = nearest and mip = linear */
  20087. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20088. /** mag = linear and min = linear and mip = none */
  20089. static readonly LINEAR_LINEAR: number;
  20090. /** mag = linear and min = nearest and mip = none */
  20091. static readonly LINEAR_NEAREST: number;
  20092. /** Explicit coordinates mode */
  20093. static readonly EXPLICIT_MODE: number;
  20094. /** Spherical coordinates mode */
  20095. static readonly SPHERICAL_MODE: number;
  20096. /** Planar coordinates mode */
  20097. static readonly PLANAR_MODE: number;
  20098. /** Cubic coordinates mode */
  20099. static readonly CUBIC_MODE: number;
  20100. /** Projection coordinates mode */
  20101. static readonly PROJECTION_MODE: number;
  20102. /** Inverse Cubic coordinates mode */
  20103. static readonly SKYBOX_MODE: number;
  20104. /** Inverse Cubic coordinates mode */
  20105. static readonly INVCUBIC_MODE: number;
  20106. /** Equirectangular coordinates mode */
  20107. static readonly EQUIRECTANGULAR_MODE: number;
  20108. /** Equirectangular Fixed coordinates mode */
  20109. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20110. /** Equirectangular Fixed Mirrored coordinates mode */
  20111. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20112. /** Texture is not repeating outside of 0..1 UVs */
  20113. static readonly CLAMP_ADDRESSMODE: number;
  20114. /** Texture is repeating outside of 0..1 UVs */
  20115. static readonly WRAP_ADDRESSMODE: number;
  20116. /** Texture is repeating and mirrored */
  20117. static readonly MIRROR_ADDRESSMODE: number;
  20118. /**
  20119. * 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
  20120. */
  20121. static UseSerializedUrlIfAny: boolean;
  20122. /**
  20123. * Define the url of the texture.
  20124. */
  20125. url: Nullable<string>;
  20126. /**
  20127. * Define an offset on the texture to offset the u coordinates of the UVs
  20128. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20129. */
  20130. uOffset: number;
  20131. /**
  20132. * Define an offset on the texture to offset the v coordinates of the UVs
  20133. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20134. */
  20135. vOffset: number;
  20136. /**
  20137. * Define an offset on the texture to scale the u coordinates of the UVs
  20138. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20139. */
  20140. uScale: number;
  20141. /**
  20142. * Define an offset on the texture to scale the v coordinates of the UVs
  20143. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20144. */
  20145. vScale: number;
  20146. /**
  20147. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20148. * @see http://doc.babylonjs.com/how_to/more_materials
  20149. */
  20150. uAng: number;
  20151. /**
  20152. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20153. * @see http://doc.babylonjs.com/how_to/more_materials
  20154. */
  20155. vAng: number;
  20156. /**
  20157. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20158. * @see http://doc.babylonjs.com/how_to/more_materials
  20159. */
  20160. wAng: number;
  20161. /**
  20162. * Defines the center of rotation (U)
  20163. */
  20164. uRotationCenter: number;
  20165. /**
  20166. * Defines the center of rotation (V)
  20167. */
  20168. vRotationCenter: number;
  20169. /**
  20170. * Defines the center of rotation (W)
  20171. */
  20172. wRotationCenter: number;
  20173. /**
  20174. * Are mip maps generated for this texture or not.
  20175. */
  20176. get noMipmap(): boolean;
  20177. /**
  20178. * List of inspectable custom properties (used by the Inspector)
  20179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20180. */
  20181. inspectableCustomProperties: Nullable<IInspectable[]>;
  20182. private _noMipmap;
  20183. /** @hidden */
  20184. _invertY: boolean;
  20185. private _rowGenerationMatrix;
  20186. private _cachedTextureMatrix;
  20187. private _projectionModeMatrix;
  20188. private _t0;
  20189. private _t1;
  20190. private _t2;
  20191. private _cachedUOffset;
  20192. private _cachedVOffset;
  20193. private _cachedUScale;
  20194. private _cachedVScale;
  20195. private _cachedUAng;
  20196. private _cachedVAng;
  20197. private _cachedWAng;
  20198. private _cachedProjectionMatrixId;
  20199. private _cachedCoordinatesMode;
  20200. /** @hidden */
  20201. protected _initialSamplingMode: number;
  20202. /** @hidden */
  20203. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20204. private _deleteBuffer;
  20205. protected _format: Nullable<number>;
  20206. private _delayedOnLoad;
  20207. private _delayedOnError;
  20208. private _mimeType?;
  20209. /**
  20210. * Observable triggered once the texture has been loaded.
  20211. */
  20212. onLoadObservable: Observable<Texture>;
  20213. protected _isBlocking: boolean;
  20214. /**
  20215. * Is the texture preventing material to render while loading.
  20216. * If false, a default texture will be used instead of the loading one during the preparation step.
  20217. */
  20218. set isBlocking(value: boolean);
  20219. get isBlocking(): boolean;
  20220. /**
  20221. * Get the current sampling mode associated with the texture.
  20222. */
  20223. get samplingMode(): number;
  20224. /**
  20225. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20226. */
  20227. get invertY(): boolean;
  20228. /**
  20229. * Instantiates a new texture.
  20230. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20231. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20232. * @param url defines the url of the picture to load as a texture
  20233. * @param scene defines the scene or engine the texture will belong to
  20234. * @param noMipmap defines if the texture will require mip maps or not
  20235. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20236. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20237. * @param onLoad defines a callback triggered when the texture has been loaded
  20238. * @param onError defines a callback triggered when an error occurred during the loading session
  20239. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20240. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20241. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20242. * @param mimeType defines an optional mime type information
  20243. */
  20244. 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);
  20245. /**
  20246. * Update the url (and optional buffer) of this texture if url was null during construction.
  20247. * @param url the url of the texture
  20248. * @param buffer the buffer of the texture (defaults to null)
  20249. * @param onLoad callback called when the texture is loaded (defaults to null)
  20250. */
  20251. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20252. /**
  20253. * Finish the loading sequence of a texture flagged as delayed load.
  20254. * @hidden
  20255. */
  20256. delayLoad(): void;
  20257. private _prepareRowForTextureGeneration;
  20258. /**
  20259. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20260. * @returns the transform matrix of the texture.
  20261. */
  20262. getTextureMatrix(uBase?: number): Matrix;
  20263. /**
  20264. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20265. * @returns The reflection texture transform
  20266. */
  20267. getReflectionTextureMatrix(): Matrix;
  20268. /**
  20269. * Clones the texture.
  20270. * @returns the cloned texture
  20271. */
  20272. clone(): Texture;
  20273. /**
  20274. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20275. * @returns The JSON representation of the texture
  20276. */
  20277. serialize(): any;
  20278. /**
  20279. * Get the current class name of the texture useful for serialization or dynamic coding.
  20280. * @returns "Texture"
  20281. */
  20282. getClassName(): string;
  20283. /**
  20284. * Dispose the texture and release its associated resources.
  20285. */
  20286. dispose(): void;
  20287. /**
  20288. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20289. * @param parsedTexture Define the JSON representation of the texture
  20290. * @param scene Define the scene the parsed texture should be instantiated in
  20291. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20292. * @returns The parsed texture if successful
  20293. */
  20294. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20295. /**
  20296. * Creates a texture from its base 64 representation.
  20297. * @param data Define the base64 payload without the data: prefix
  20298. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20299. * @param scene Define the scene the texture should belong to
  20300. * @param noMipmap Forces the texture to not create mip map information if true
  20301. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20302. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20303. * @param onLoad define a callback triggered when the texture has been loaded
  20304. * @param onError define a callback triggered when an error occurred during the loading session
  20305. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20306. * @returns the created texture
  20307. */
  20308. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20309. /**
  20310. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20311. * @param data Define the base64 payload without the data: prefix
  20312. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20313. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20314. * @param scene Define the scene the texture should belong to
  20315. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20316. * @param noMipmap Forces the texture to not create mip map information if true
  20317. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20318. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20319. * @param onLoad define a callback triggered when the texture has been loaded
  20320. * @param onError define a callback triggered when an error occurred during the loading session
  20321. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20322. * @returns the created texture
  20323. */
  20324. 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;
  20325. }
  20326. }
  20327. declare module BABYLON {
  20328. /**
  20329. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20330. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20331. */
  20332. export class PostProcessManager {
  20333. private _scene;
  20334. private _indexBuffer;
  20335. private _vertexBuffers;
  20336. /**
  20337. * Creates a new instance PostProcess
  20338. * @param scene The scene that the post process is associated with.
  20339. */
  20340. constructor(scene: Scene);
  20341. private _prepareBuffers;
  20342. private _buildIndexBuffer;
  20343. /**
  20344. * Rebuilds the vertex buffers of the manager.
  20345. * @hidden
  20346. */
  20347. _rebuild(): void;
  20348. /**
  20349. * Prepares a frame to be run through a post process.
  20350. * @param sourceTexture The input texture to the post procesess. (default: null)
  20351. * @param postProcesses An array of post processes to be run. (default: null)
  20352. * @returns True if the post processes were able to be run.
  20353. * @hidden
  20354. */
  20355. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20356. /**
  20357. * Manually render a set of post processes to a texture.
  20358. * @param postProcesses An array of post processes to be run.
  20359. * @param targetTexture The target texture to render to.
  20360. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20361. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20362. * @param lodLevel defines which lod of the texture to render to
  20363. */
  20364. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20365. /**
  20366. * Finalize the result of the output of the postprocesses.
  20367. * @param doNotPresent If true the result will not be displayed to the screen.
  20368. * @param targetTexture The target texture to render to.
  20369. * @param faceIndex The index of the face to bind the target texture to.
  20370. * @param postProcesses The array of post processes to render.
  20371. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20372. * @hidden
  20373. */
  20374. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20375. /**
  20376. * Disposes of the post process manager.
  20377. */
  20378. dispose(): void;
  20379. }
  20380. }
  20381. declare module BABYLON {
  20382. /**
  20383. * This Helps creating a texture that will be created from a camera in your scene.
  20384. * It is basically a dynamic texture that could be used to create special effects for instance.
  20385. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20386. */
  20387. export class RenderTargetTexture extends Texture {
  20388. isCube: boolean;
  20389. /**
  20390. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20391. */
  20392. static readonly REFRESHRATE_RENDER_ONCE: number;
  20393. /**
  20394. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20395. */
  20396. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20397. /**
  20398. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20399. * the central point of your effect and can save a lot of performances.
  20400. */
  20401. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20402. /**
  20403. * Use this predicate to dynamically define the list of mesh you want to render.
  20404. * If set, the renderList property will be overwritten.
  20405. */
  20406. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20407. private _renderList;
  20408. /**
  20409. * Use this list to define the list of mesh you want to render.
  20410. */
  20411. get renderList(): Nullable<Array<AbstractMesh>>;
  20412. set renderList(value: Nullable<Array<AbstractMesh>>);
  20413. /**
  20414. * Use this function to overload the renderList array at rendering time.
  20415. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20416. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20417. * the cube (if the RTT is a cube, else layerOrFace=0).
  20418. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20419. */
  20420. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20421. private _hookArray;
  20422. /**
  20423. * Define if particles should be rendered in your texture.
  20424. */
  20425. renderParticles: boolean;
  20426. /**
  20427. * Define if sprites should be rendered in your texture.
  20428. */
  20429. renderSprites: boolean;
  20430. /**
  20431. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20432. */
  20433. coordinatesMode: number;
  20434. /**
  20435. * Define the camera used to render the texture.
  20436. */
  20437. activeCamera: Nullable<Camera>;
  20438. /**
  20439. * Override the render function of the texture with your own one.
  20440. */
  20441. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20442. /**
  20443. * Define if camera post processes should be use while rendering the texture.
  20444. */
  20445. useCameraPostProcesses: boolean;
  20446. /**
  20447. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20448. */
  20449. ignoreCameraViewport: boolean;
  20450. private _postProcessManager;
  20451. private _postProcesses;
  20452. private _resizeObserver;
  20453. /**
  20454. * An event triggered when the texture is unbind.
  20455. */
  20456. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20457. /**
  20458. * An event triggered when the texture is unbind.
  20459. */
  20460. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20461. private _onAfterUnbindObserver;
  20462. /**
  20463. * Set a after unbind callback in the texture.
  20464. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20465. */
  20466. set onAfterUnbind(callback: () => void);
  20467. /**
  20468. * An event triggered before rendering the texture
  20469. */
  20470. onBeforeRenderObservable: Observable<number>;
  20471. private _onBeforeRenderObserver;
  20472. /**
  20473. * Set a before render callback in the texture.
  20474. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20475. */
  20476. set onBeforeRender(callback: (faceIndex: number) => void);
  20477. /**
  20478. * An event triggered after rendering the texture
  20479. */
  20480. onAfterRenderObservable: Observable<number>;
  20481. private _onAfterRenderObserver;
  20482. /**
  20483. * Set a after render callback in the texture.
  20484. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20485. */
  20486. set onAfterRender(callback: (faceIndex: number) => void);
  20487. /**
  20488. * An event triggered after the texture clear
  20489. */
  20490. onClearObservable: Observable<Engine>;
  20491. private _onClearObserver;
  20492. /**
  20493. * Set a clear callback in the texture.
  20494. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20495. */
  20496. set onClear(callback: (Engine: Engine) => void);
  20497. /**
  20498. * An event triggered when the texture is resized.
  20499. */
  20500. onResizeObservable: Observable<RenderTargetTexture>;
  20501. /**
  20502. * Define the clear color of the Render Target if it should be different from the scene.
  20503. */
  20504. clearColor: Color4;
  20505. protected _size: number | {
  20506. width: number;
  20507. height: number;
  20508. layers?: number;
  20509. };
  20510. protected _initialSizeParameter: number | {
  20511. width: number;
  20512. height: number;
  20513. } | {
  20514. ratio: number;
  20515. };
  20516. protected _sizeRatio: Nullable<number>;
  20517. /** @hidden */
  20518. _generateMipMaps: boolean;
  20519. protected _renderingManager: RenderingManager;
  20520. /** @hidden */
  20521. _waitingRenderList: string[];
  20522. protected _doNotChangeAspectRatio: boolean;
  20523. protected _currentRefreshId: number;
  20524. protected _refreshRate: number;
  20525. protected _textureMatrix: Matrix;
  20526. protected _samples: number;
  20527. protected _renderTargetOptions: RenderTargetCreationOptions;
  20528. /**
  20529. * Gets render target creation options that were used.
  20530. */
  20531. get renderTargetOptions(): RenderTargetCreationOptions;
  20532. protected _engine: Engine;
  20533. protected _onRatioRescale(): void;
  20534. /**
  20535. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20536. * It must define where the camera used to render the texture is set
  20537. */
  20538. boundingBoxPosition: Vector3;
  20539. private _boundingBoxSize;
  20540. /**
  20541. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20542. * When defined, the cubemap will switch to local mode
  20543. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20544. * @example https://www.babylonjs-playground.com/#RNASML
  20545. */
  20546. set boundingBoxSize(value: Vector3);
  20547. get boundingBoxSize(): Vector3;
  20548. /**
  20549. * In case the RTT has been created with a depth texture, get the associated
  20550. * depth texture.
  20551. * Otherwise, return null.
  20552. */
  20553. get depthStencilTexture(): Nullable<InternalTexture>;
  20554. /**
  20555. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20556. * or used a shadow, depth texture...
  20557. * @param name The friendly name of the texture
  20558. * @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)
  20559. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20560. * @param generateMipMaps True if mip maps need to be generated after render.
  20561. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20562. * @param type The type of the buffer in the RTT (int, half float, float...)
  20563. * @param isCube True if a cube texture needs to be created
  20564. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20565. * @param generateDepthBuffer True to generate a depth buffer
  20566. * @param generateStencilBuffer True to generate a stencil buffer
  20567. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20568. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20569. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20570. */
  20571. constructor(name: string, size: number | {
  20572. width: number;
  20573. height: number;
  20574. layers?: number;
  20575. } | {
  20576. ratio: number;
  20577. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20578. /**
  20579. * Creates a depth stencil texture.
  20580. * This is only available in WebGL 2 or with the depth texture extension available.
  20581. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20582. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20583. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20584. */
  20585. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20586. private _processSizeParameter;
  20587. /**
  20588. * Define the number of samples to use in case of MSAA.
  20589. * It defaults to one meaning no MSAA has been enabled.
  20590. */
  20591. get samples(): number;
  20592. set samples(value: number);
  20593. /**
  20594. * Resets the refresh counter of the texture and start bak from scratch.
  20595. * Could be useful to regenerate the texture if it is setup to render only once.
  20596. */
  20597. resetRefreshCounter(): void;
  20598. /**
  20599. * Define the refresh rate of the texture or the rendering frequency.
  20600. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20601. */
  20602. get refreshRate(): number;
  20603. set refreshRate(value: number);
  20604. /**
  20605. * Adds a post process to the render target rendering passes.
  20606. * @param postProcess define the post process to add
  20607. */
  20608. addPostProcess(postProcess: PostProcess): void;
  20609. /**
  20610. * Clear all the post processes attached to the render target
  20611. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20612. */
  20613. clearPostProcesses(dispose?: boolean): void;
  20614. /**
  20615. * Remove one of the post process from the list of attached post processes to the texture
  20616. * @param postProcess define the post process to remove from the list
  20617. */
  20618. removePostProcess(postProcess: PostProcess): void;
  20619. /** @hidden */
  20620. _shouldRender(): boolean;
  20621. /**
  20622. * Gets the actual render size of the texture.
  20623. * @returns the width of the render size
  20624. */
  20625. getRenderSize(): number;
  20626. /**
  20627. * Gets the actual render width of the texture.
  20628. * @returns the width of the render size
  20629. */
  20630. getRenderWidth(): number;
  20631. /**
  20632. * Gets the actual render height of the texture.
  20633. * @returns the height of the render size
  20634. */
  20635. getRenderHeight(): number;
  20636. /**
  20637. * Gets the actual number of layers of the texture.
  20638. * @returns the number of layers
  20639. */
  20640. getRenderLayers(): number;
  20641. /**
  20642. * Get if the texture can be rescaled or not.
  20643. */
  20644. get canRescale(): boolean;
  20645. /**
  20646. * Resize the texture using a ratio.
  20647. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20648. */
  20649. scale(ratio: number): void;
  20650. /**
  20651. * Get the texture reflection matrix used to rotate/transform the reflection.
  20652. * @returns the reflection matrix
  20653. */
  20654. getReflectionTextureMatrix(): Matrix;
  20655. /**
  20656. * Resize the texture to a new desired size.
  20657. * Be carrefull as it will recreate all the data in the new texture.
  20658. * @param size Define the new size. It can be:
  20659. * - a number for squared texture,
  20660. * - an object containing { width: number, height: number }
  20661. * - or an object containing a ratio { ratio: number }
  20662. */
  20663. resize(size: number | {
  20664. width: number;
  20665. height: number;
  20666. } | {
  20667. ratio: number;
  20668. }): void;
  20669. private _defaultRenderListPrepared;
  20670. /**
  20671. * Renders all the objects from the render list into the texture.
  20672. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20673. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20674. */
  20675. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20676. private _bestReflectionRenderTargetDimension;
  20677. private _prepareRenderingManager;
  20678. /**
  20679. * @hidden
  20680. * @param faceIndex face index to bind to if this is a cubetexture
  20681. * @param layer defines the index of the texture to bind in the array
  20682. */
  20683. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20684. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20685. private renderToTarget;
  20686. /**
  20687. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20688. * This allowed control for front to back rendering or reversly depending of the special needs.
  20689. *
  20690. * @param renderingGroupId The rendering group id corresponding to its index
  20691. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20692. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20693. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20694. */
  20695. 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;
  20696. /**
  20697. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20698. *
  20699. * @param renderingGroupId The rendering group id corresponding to its index
  20700. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20701. */
  20702. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20703. /**
  20704. * Clones the texture.
  20705. * @returns the cloned texture
  20706. */
  20707. clone(): RenderTargetTexture;
  20708. /**
  20709. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20710. * @returns The JSON representation of the texture
  20711. */
  20712. serialize(): any;
  20713. /**
  20714. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20715. */
  20716. disposeFramebufferObjects(): void;
  20717. /**
  20718. * Dispose the texture and release its associated resources.
  20719. */
  20720. dispose(): void;
  20721. /** @hidden */
  20722. _rebuild(): void;
  20723. /**
  20724. * Clear the info related to rendering groups preventing retention point in material dispose.
  20725. */
  20726. freeRenderingGroups(): void;
  20727. /**
  20728. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20729. * @returns the view count
  20730. */
  20731. getViewCount(): number;
  20732. }
  20733. }
  20734. declare module BABYLON {
  20735. /**
  20736. * Options for compiling materials.
  20737. */
  20738. export interface IMaterialCompilationOptions {
  20739. /**
  20740. * Defines whether clip planes are enabled.
  20741. */
  20742. clipPlane: boolean;
  20743. /**
  20744. * Defines whether instances are enabled.
  20745. */
  20746. useInstances: boolean;
  20747. }
  20748. /**
  20749. * Base class for the main features of a material in Babylon.js
  20750. */
  20751. export class Material implements IAnimatable {
  20752. /**
  20753. * Returns the triangle fill mode
  20754. */
  20755. static readonly TriangleFillMode: number;
  20756. /**
  20757. * Returns the wireframe mode
  20758. */
  20759. static readonly WireFrameFillMode: number;
  20760. /**
  20761. * Returns the point fill mode
  20762. */
  20763. static readonly PointFillMode: number;
  20764. /**
  20765. * Returns the point list draw mode
  20766. */
  20767. static readonly PointListDrawMode: number;
  20768. /**
  20769. * Returns the line list draw mode
  20770. */
  20771. static readonly LineListDrawMode: number;
  20772. /**
  20773. * Returns the line loop draw mode
  20774. */
  20775. static readonly LineLoopDrawMode: number;
  20776. /**
  20777. * Returns the line strip draw mode
  20778. */
  20779. static readonly LineStripDrawMode: number;
  20780. /**
  20781. * Returns the triangle strip draw mode
  20782. */
  20783. static readonly TriangleStripDrawMode: number;
  20784. /**
  20785. * Returns the triangle fan draw mode
  20786. */
  20787. static readonly TriangleFanDrawMode: number;
  20788. /**
  20789. * Stores the clock-wise side orientation
  20790. */
  20791. static readonly ClockWiseSideOrientation: number;
  20792. /**
  20793. * Stores the counter clock-wise side orientation
  20794. */
  20795. static readonly CounterClockWiseSideOrientation: number;
  20796. /**
  20797. * The dirty texture flag value
  20798. */
  20799. static readonly TextureDirtyFlag: number;
  20800. /**
  20801. * The dirty light flag value
  20802. */
  20803. static readonly LightDirtyFlag: number;
  20804. /**
  20805. * The dirty fresnel flag value
  20806. */
  20807. static readonly FresnelDirtyFlag: number;
  20808. /**
  20809. * The dirty attribute flag value
  20810. */
  20811. static readonly AttributesDirtyFlag: number;
  20812. /**
  20813. * The dirty misc flag value
  20814. */
  20815. static readonly MiscDirtyFlag: number;
  20816. /**
  20817. * The all dirty flag value
  20818. */
  20819. static readonly AllDirtyFlag: number;
  20820. /**
  20821. * The ID of the material
  20822. */
  20823. id: string;
  20824. /**
  20825. * Gets or sets the unique id of the material
  20826. */
  20827. uniqueId: number;
  20828. /**
  20829. * The name of the material
  20830. */
  20831. name: string;
  20832. /**
  20833. * Gets or sets user defined metadata
  20834. */
  20835. metadata: any;
  20836. /**
  20837. * For internal use only. Please do not use.
  20838. */
  20839. reservedDataStore: any;
  20840. /**
  20841. * Specifies if the ready state should be checked on each call
  20842. */
  20843. checkReadyOnEveryCall: boolean;
  20844. /**
  20845. * Specifies if the ready state should be checked once
  20846. */
  20847. checkReadyOnlyOnce: boolean;
  20848. /**
  20849. * The state of the material
  20850. */
  20851. state: string;
  20852. /**
  20853. * The alpha value of the material
  20854. */
  20855. protected _alpha: number;
  20856. /**
  20857. * List of inspectable custom properties (used by the Inspector)
  20858. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20859. */
  20860. inspectableCustomProperties: IInspectable[];
  20861. /**
  20862. * Sets the alpha value of the material
  20863. */
  20864. set alpha(value: number);
  20865. /**
  20866. * Gets the alpha value of the material
  20867. */
  20868. get alpha(): number;
  20869. /**
  20870. * Specifies if back face culling is enabled
  20871. */
  20872. protected _backFaceCulling: boolean;
  20873. /**
  20874. * Sets the back-face culling state
  20875. */
  20876. set backFaceCulling(value: boolean);
  20877. /**
  20878. * Gets the back-face culling state
  20879. */
  20880. get backFaceCulling(): boolean;
  20881. /**
  20882. * Stores the value for side orientation
  20883. */
  20884. sideOrientation: number;
  20885. /**
  20886. * Callback triggered when the material is compiled
  20887. */
  20888. onCompiled: Nullable<(effect: Effect) => void>;
  20889. /**
  20890. * Callback triggered when an error occurs
  20891. */
  20892. onError: Nullable<(effect: Effect, errors: string) => void>;
  20893. /**
  20894. * Callback triggered to get the render target textures
  20895. */
  20896. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20897. /**
  20898. * Gets a boolean indicating that current material needs to register RTT
  20899. */
  20900. get hasRenderTargetTextures(): boolean;
  20901. /**
  20902. * Specifies if the material should be serialized
  20903. */
  20904. doNotSerialize: boolean;
  20905. /**
  20906. * @hidden
  20907. */
  20908. _storeEffectOnSubMeshes: boolean;
  20909. /**
  20910. * Stores the animations for the material
  20911. */
  20912. animations: Nullable<Array<Animation>>;
  20913. /**
  20914. * An event triggered when the material is disposed
  20915. */
  20916. onDisposeObservable: Observable<Material>;
  20917. /**
  20918. * An observer which watches for dispose events
  20919. */
  20920. private _onDisposeObserver;
  20921. private _onUnBindObservable;
  20922. /**
  20923. * Called during a dispose event
  20924. */
  20925. set onDispose(callback: () => void);
  20926. private _onBindObservable;
  20927. /**
  20928. * An event triggered when the material is bound
  20929. */
  20930. get onBindObservable(): Observable<AbstractMesh>;
  20931. /**
  20932. * An observer which watches for bind events
  20933. */
  20934. private _onBindObserver;
  20935. /**
  20936. * Called during a bind event
  20937. */
  20938. set onBind(callback: (Mesh: AbstractMesh) => void);
  20939. /**
  20940. * An event triggered when the material is unbound
  20941. */
  20942. get onUnBindObservable(): Observable<Material>;
  20943. /**
  20944. * Stores the value of the alpha mode
  20945. */
  20946. private _alphaMode;
  20947. /**
  20948. * Sets the value of the alpha mode.
  20949. *
  20950. * | Value | Type | Description |
  20951. * | --- | --- | --- |
  20952. * | 0 | ALPHA_DISABLE | |
  20953. * | 1 | ALPHA_ADD | |
  20954. * | 2 | ALPHA_COMBINE | |
  20955. * | 3 | ALPHA_SUBTRACT | |
  20956. * | 4 | ALPHA_MULTIPLY | |
  20957. * | 5 | ALPHA_MAXIMIZED | |
  20958. * | 6 | ALPHA_ONEONE | |
  20959. * | 7 | ALPHA_PREMULTIPLIED | |
  20960. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20961. * | 9 | ALPHA_INTERPOLATE | |
  20962. * | 10 | ALPHA_SCREENMODE | |
  20963. *
  20964. */
  20965. set alphaMode(value: number);
  20966. /**
  20967. * Gets the value of the alpha mode
  20968. */
  20969. get alphaMode(): number;
  20970. /**
  20971. * Stores the state of the need depth pre-pass value
  20972. */
  20973. private _needDepthPrePass;
  20974. /**
  20975. * Sets the need depth pre-pass value
  20976. */
  20977. set needDepthPrePass(value: boolean);
  20978. /**
  20979. * Gets the depth pre-pass value
  20980. */
  20981. get needDepthPrePass(): boolean;
  20982. /**
  20983. * Specifies if depth writing should be disabled
  20984. */
  20985. disableDepthWrite: boolean;
  20986. /**
  20987. * Specifies if depth writing should be forced
  20988. */
  20989. forceDepthWrite: boolean;
  20990. /**
  20991. * Specifies the depth function that should be used. 0 means the default engine function
  20992. */
  20993. depthFunction: number;
  20994. /**
  20995. * Specifies if there should be a separate pass for culling
  20996. */
  20997. separateCullingPass: boolean;
  20998. /**
  20999. * Stores the state specifing if fog should be enabled
  21000. */
  21001. private _fogEnabled;
  21002. /**
  21003. * Sets the state for enabling fog
  21004. */
  21005. set fogEnabled(value: boolean);
  21006. /**
  21007. * Gets the value of the fog enabled state
  21008. */
  21009. get fogEnabled(): boolean;
  21010. /**
  21011. * Stores the size of points
  21012. */
  21013. pointSize: number;
  21014. /**
  21015. * Stores the z offset value
  21016. */
  21017. zOffset: number;
  21018. /**
  21019. * Gets a value specifying if wireframe mode is enabled
  21020. */
  21021. get wireframe(): boolean;
  21022. /**
  21023. * Sets the state of wireframe mode
  21024. */
  21025. set wireframe(value: boolean);
  21026. /**
  21027. * Gets the value specifying if point clouds are enabled
  21028. */
  21029. get pointsCloud(): boolean;
  21030. /**
  21031. * Sets the state of point cloud mode
  21032. */
  21033. set pointsCloud(value: boolean);
  21034. /**
  21035. * Gets the material fill mode
  21036. */
  21037. get fillMode(): number;
  21038. /**
  21039. * Sets the material fill mode
  21040. */
  21041. set fillMode(value: number);
  21042. /**
  21043. * @hidden
  21044. * Stores the effects for the material
  21045. */
  21046. _effect: Nullable<Effect>;
  21047. /**
  21048. * Specifies if uniform buffers should be used
  21049. */
  21050. private _useUBO;
  21051. /**
  21052. * Stores a reference to the scene
  21053. */
  21054. private _scene;
  21055. /**
  21056. * Stores the fill mode state
  21057. */
  21058. private _fillMode;
  21059. /**
  21060. * Specifies if the depth write state should be cached
  21061. */
  21062. private _cachedDepthWriteState;
  21063. /**
  21064. * Specifies if the depth function state should be cached
  21065. */
  21066. private _cachedDepthFunctionState;
  21067. /**
  21068. * Stores the uniform buffer
  21069. */
  21070. protected _uniformBuffer: UniformBuffer;
  21071. /** @hidden */
  21072. _indexInSceneMaterialArray: number;
  21073. /** @hidden */
  21074. meshMap: Nullable<{
  21075. [id: string]: AbstractMesh | undefined;
  21076. }>;
  21077. /**
  21078. * Creates a material instance
  21079. * @param name defines the name of the material
  21080. * @param scene defines the scene to reference
  21081. * @param doNotAdd specifies if the material should be added to the scene
  21082. */
  21083. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21084. /**
  21085. * Returns a string representation of the current material
  21086. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21087. * @returns a string with material information
  21088. */
  21089. toString(fullDetails?: boolean): string;
  21090. /**
  21091. * Gets the class name of the material
  21092. * @returns a string with the class name of the material
  21093. */
  21094. getClassName(): string;
  21095. /**
  21096. * Specifies if updates for the material been locked
  21097. */
  21098. get isFrozen(): boolean;
  21099. /**
  21100. * Locks updates for the material
  21101. */
  21102. freeze(): void;
  21103. /**
  21104. * Unlocks updates for the material
  21105. */
  21106. unfreeze(): void;
  21107. /**
  21108. * Specifies if the material is ready to be used
  21109. * @param mesh defines the mesh to check
  21110. * @param useInstances specifies if instances should be used
  21111. * @returns a boolean indicating if the material is ready to be used
  21112. */
  21113. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21114. /**
  21115. * Specifies that the submesh is ready to be used
  21116. * @param mesh defines the mesh to check
  21117. * @param subMesh defines which submesh to check
  21118. * @param useInstances specifies that instances should be used
  21119. * @returns a boolean indicating that the submesh is ready or not
  21120. */
  21121. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21122. /**
  21123. * Returns the material effect
  21124. * @returns the effect associated with the material
  21125. */
  21126. getEffect(): Nullable<Effect>;
  21127. /**
  21128. * Returns the current scene
  21129. * @returns a Scene
  21130. */
  21131. getScene(): Scene;
  21132. /**
  21133. * Specifies if the material will require alpha blending
  21134. * @returns a boolean specifying if alpha blending is needed
  21135. */
  21136. needAlphaBlending(): boolean;
  21137. /**
  21138. * Specifies if the mesh will require alpha blending
  21139. * @param mesh defines the mesh to check
  21140. * @returns a boolean specifying if alpha blending is needed for the mesh
  21141. */
  21142. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21143. /**
  21144. * Specifies if this material should be rendered in alpha test mode
  21145. * @returns a boolean specifying if an alpha test is needed.
  21146. */
  21147. needAlphaTesting(): boolean;
  21148. /**
  21149. * Gets the texture used for the alpha test
  21150. * @returns the texture to use for alpha testing
  21151. */
  21152. getAlphaTestTexture(): Nullable<BaseTexture>;
  21153. /**
  21154. * Marks the material to indicate that it needs to be re-calculated
  21155. */
  21156. markDirty(): void;
  21157. /** @hidden */
  21158. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21159. /**
  21160. * Binds the material to the mesh
  21161. * @param world defines the world transformation matrix
  21162. * @param mesh defines the mesh to bind the material to
  21163. */
  21164. bind(world: Matrix, mesh?: Mesh): void;
  21165. /**
  21166. * Binds the submesh to the material
  21167. * @param world defines the world transformation matrix
  21168. * @param mesh defines the mesh containing the submesh
  21169. * @param subMesh defines the submesh to bind the material to
  21170. */
  21171. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21172. /**
  21173. * Binds the world matrix to the material
  21174. * @param world defines the world transformation matrix
  21175. */
  21176. bindOnlyWorldMatrix(world: Matrix): void;
  21177. /**
  21178. * Binds the scene's uniform buffer to the effect.
  21179. * @param effect defines the effect to bind to the scene uniform buffer
  21180. * @param sceneUbo defines the uniform buffer storing scene data
  21181. */
  21182. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21183. /**
  21184. * Binds the view matrix to the effect
  21185. * @param effect defines the effect to bind the view matrix to
  21186. */
  21187. bindView(effect: Effect): void;
  21188. /**
  21189. * Binds the view projection matrix to the effect
  21190. * @param effect defines the effect to bind the view projection matrix to
  21191. */
  21192. bindViewProjection(effect: Effect): void;
  21193. /**
  21194. * Specifies if material alpha testing should be turned on for the mesh
  21195. * @param mesh defines the mesh to check
  21196. */
  21197. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21198. /**
  21199. * Processes to execute after binding the material to a mesh
  21200. * @param mesh defines the rendered mesh
  21201. */
  21202. protected _afterBind(mesh?: Mesh): void;
  21203. /**
  21204. * Unbinds the material from the mesh
  21205. */
  21206. unbind(): void;
  21207. /**
  21208. * Gets the active textures from the material
  21209. * @returns an array of textures
  21210. */
  21211. getActiveTextures(): BaseTexture[];
  21212. /**
  21213. * Specifies if the material uses a texture
  21214. * @param texture defines the texture to check against the material
  21215. * @returns a boolean specifying if the material uses the texture
  21216. */
  21217. hasTexture(texture: BaseTexture): boolean;
  21218. /**
  21219. * Makes a duplicate of the material, and gives it a new name
  21220. * @param name defines the new name for the duplicated material
  21221. * @returns the cloned material
  21222. */
  21223. clone(name: string): Nullable<Material>;
  21224. /**
  21225. * Gets the meshes bound to the material
  21226. * @returns an array of meshes bound to the material
  21227. */
  21228. getBindedMeshes(): AbstractMesh[];
  21229. /**
  21230. * Force shader compilation
  21231. * @param mesh defines the mesh associated with this material
  21232. * @param onCompiled defines a function to execute once the material is compiled
  21233. * @param options defines the options to configure the compilation
  21234. * @param onError defines a function to execute if the material fails compiling
  21235. */
  21236. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21237. /**
  21238. * Force shader compilation
  21239. * @param mesh defines the mesh that will use this material
  21240. * @param options defines additional options for compiling the shaders
  21241. * @returns a promise that resolves when the compilation completes
  21242. */
  21243. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21244. private static readonly _AllDirtyCallBack;
  21245. private static readonly _ImageProcessingDirtyCallBack;
  21246. private static readonly _TextureDirtyCallBack;
  21247. private static readonly _FresnelDirtyCallBack;
  21248. private static readonly _MiscDirtyCallBack;
  21249. private static readonly _LightsDirtyCallBack;
  21250. private static readonly _AttributeDirtyCallBack;
  21251. private static _FresnelAndMiscDirtyCallBack;
  21252. private static _TextureAndMiscDirtyCallBack;
  21253. private static readonly _DirtyCallbackArray;
  21254. private static readonly _RunDirtyCallBacks;
  21255. /**
  21256. * Marks a define in the material to indicate that it needs to be re-computed
  21257. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21258. */
  21259. markAsDirty(flag: number): void;
  21260. /**
  21261. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21262. * @param func defines a function which checks material defines against the submeshes
  21263. */
  21264. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21265. /**
  21266. * Indicates that we need to re-calculated for all submeshes
  21267. */
  21268. protected _markAllSubMeshesAsAllDirty(): void;
  21269. /**
  21270. * Indicates that image processing needs to be re-calculated for all submeshes
  21271. */
  21272. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21273. /**
  21274. * Indicates that textures need to be re-calculated for all submeshes
  21275. */
  21276. protected _markAllSubMeshesAsTexturesDirty(): void;
  21277. /**
  21278. * Indicates that fresnel needs to be re-calculated for all submeshes
  21279. */
  21280. protected _markAllSubMeshesAsFresnelDirty(): void;
  21281. /**
  21282. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21283. */
  21284. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21285. /**
  21286. * Indicates that lights need to be re-calculated for all submeshes
  21287. */
  21288. protected _markAllSubMeshesAsLightsDirty(): void;
  21289. /**
  21290. * Indicates that attributes need to be re-calculated for all submeshes
  21291. */
  21292. protected _markAllSubMeshesAsAttributesDirty(): void;
  21293. /**
  21294. * Indicates that misc needs to be re-calculated for all submeshes
  21295. */
  21296. protected _markAllSubMeshesAsMiscDirty(): void;
  21297. /**
  21298. * Indicates that textures and misc need to be re-calculated for all submeshes
  21299. */
  21300. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21301. /**
  21302. * Disposes the material
  21303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21304. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21305. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21306. */
  21307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21308. /** @hidden */
  21309. private releaseVertexArrayObject;
  21310. /**
  21311. * Serializes this material
  21312. * @returns the serialized material object
  21313. */
  21314. serialize(): any;
  21315. /**
  21316. * Creates a material from parsed material data
  21317. * @param parsedMaterial defines parsed material data
  21318. * @param scene defines the hosting scene
  21319. * @param rootUrl defines the root URL to use to load textures
  21320. * @returns a new material
  21321. */
  21322. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21323. }
  21324. }
  21325. declare module BABYLON {
  21326. /**
  21327. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21328. * separate meshes. This can be use to improve performances.
  21329. * @see http://doc.babylonjs.com/how_to/multi_materials
  21330. */
  21331. export class MultiMaterial extends Material {
  21332. private _subMaterials;
  21333. /**
  21334. * Gets or Sets the list of Materials used within the multi material.
  21335. * They need to be ordered according to the submeshes order in the associated mesh
  21336. */
  21337. get subMaterials(): Nullable<Material>[];
  21338. set subMaterials(value: Nullable<Material>[]);
  21339. /**
  21340. * Function used to align with Node.getChildren()
  21341. * @returns the list of Materials used within the multi material
  21342. */
  21343. getChildren(): Nullable<Material>[];
  21344. /**
  21345. * Instantiates a new Multi Material
  21346. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21347. * separate meshes. This can be use to improve performances.
  21348. * @see http://doc.babylonjs.com/how_to/multi_materials
  21349. * @param name Define the name in the scene
  21350. * @param scene Define the scene the material belongs to
  21351. */
  21352. constructor(name: string, scene: Scene);
  21353. private _hookArray;
  21354. /**
  21355. * Get one of the submaterial by its index in the submaterials array
  21356. * @param index The index to look the sub material at
  21357. * @returns The Material if the index has been defined
  21358. */
  21359. getSubMaterial(index: number): Nullable<Material>;
  21360. /**
  21361. * Get the list of active textures for the whole sub materials list.
  21362. * @returns All the textures that will be used during the rendering
  21363. */
  21364. getActiveTextures(): BaseTexture[];
  21365. /**
  21366. * Gets the current class name of the material e.g. "MultiMaterial"
  21367. * Mainly use in serialization.
  21368. * @returns the class name
  21369. */
  21370. getClassName(): string;
  21371. /**
  21372. * Checks if the material is ready to render the requested sub mesh
  21373. * @param mesh Define the mesh the submesh belongs to
  21374. * @param subMesh Define the sub mesh to look readyness for
  21375. * @param useInstances Define whether or not the material is used with instances
  21376. * @returns true if ready, otherwise false
  21377. */
  21378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21379. /**
  21380. * Clones the current material and its related sub materials
  21381. * @param name Define the name of the newly cloned material
  21382. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21383. * @returns the cloned material
  21384. */
  21385. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21386. /**
  21387. * Serializes the materials into a JSON representation.
  21388. * @returns the JSON representation
  21389. */
  21390. serialize(): any;
  21391. /**
  21392. * Dispose the material and release its associated resources
  21393. * @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)
  21394. * @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)
  21395. * @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)
  21396. */
  21397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21398. /**
  21399. * Creates a MultiMaterial from parsed MultiMaterial data.
  21400. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21401. * @param scene defines the hosting scene
  21402. * @returns a new MultiMaterial
  21403. */
  21404. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21405. }
  21406. }
  21407. declare module BABYLON {
  21408. /**
  21409. * Base class for submeshes
  21410. */
  21411. export class BaseSubMesh {
  21412. /** @hidden */
  21413. _materialDefines: Nullable<MaterialDefines>;
  21414. /** @hidden */
  21415. _materialEffect: Nullable<Effect>;
  21416. /**
  21417. * Gets material defines used by the effect associated to the sub mesh
  21418. */
  21419. get materialDefines(): Nullable<MaterialDefines>;
  21420. /**
  21421. * Sets material defines used by the effect associated to the sub mesh
  21422. */
  21423. set materialDefines(defines: Nullable<MaterialDefines>);
  21424. /**
  21425. * Gets associated effect
  21426. */
  21427. get effect(): Nullable<Effect>;
  21428. /**
  21429. * Sets associated effect (effect used to render this submesh)
  21430. * @param effect defines the effect to associate with
  21431. * @param defines defines the set of defines used to compile this effect
  21432. */
  21433. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21434. }
  21435. /**
  21436. * Defines a subdivision inside a mesh
  21437. */
  21438. export class SubMesh extends BaseSubMesh implements ICullable {
  21439. /** the material index to use */
  21440. materialIndex: number;
  21441. /** vertex index start */
  21442. verticesStart: number;
  21443. /** vertices count */
  21444. verticesCount: number;
  21445. /** index start */
  21446. indexStart: number;
  21447. /** indices count */
  21448. indexCount: number;
  21449. /** @hidden */
  21450. _linesIndexCount: number;
  21451. private _mesh;
  21452. private _renderingMesh;
  21453. private _boundingInfo;
  21454. private _linesIndexBuffer;
  21455. /** @hidden */
  21456. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21457. /** @hidden */
  21458. _trianglePlanes: Plane[];
  21459. /** @hidden */
  21460. _lastColliderTransformMatrix: Nullable<Matrix>;
  21461. /** @hidden */
  21462. _renderId: number;
  21463. /** @hidden */
  21464. _alphaIndex: number;
  21465. /** @hidden */
  21466. _distanceToCamera: number;
  21467. /** @hidden */
  21468. _id: number;
  21469. private _currentMaterial;
  21470. /**
  21471. * Add a new submesh to a mesh
  21472. * @param materialIndex defines the material index to use
  21473. * @param verticesStart defines vertex index start
  21474. * @param verticesCount defines vertices count
  21475. * @param indexStart defines index start
  21476. * @param indexCount defines indices count
  21477. * @param mesh defines the parent mesh
  21478. * @param renderingMesh defines an optional rendering mesh
  21479. * @param createBoundingBox defines if bounding box should be created for this submesh
  21480. * @returns the new submesh
  21481. */
  21482. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21483. /**
  21484. * Creates a new submesh
  21485. * @param materialIndex defines the material index to use
  21486. * @param verticesStart defines vertex index start
  21487. * @param verticesCount defines vertices count
  21488. * @param indexStart defines index start
  21489. * @param indexCount defines indices count
  21490. * @param mesh defines the parent mesh
  21491. * @param renderingMesh defines an optional rendering mesh
  21492. * @param createBoundingBox defines if bounding box should be created for this submesh
  21493. */
  21494. constructor(
  21495. /** the material index to use */
  21496. materialIndex: number,
  21497. /** vertex index start */
  21498. verticesStart: number,
  21499. /** vertices count */
  21500. verticesCount: number,
  21501. /** index start */
  21502. indexStart: number,
  21503. /** indices count */
  21504. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21505. /**
  21506. * Returns true if this submesh covers the entire parent mesh
  21507. * @ignorenaming
  21508. */
  21509. get IsGlobal(): boolean;
  21510. /**
  21511. * Returns the submesh BoudingInfo object
  21512. * @returns current bounding info (or mesh's one if the submesh is global)
  21513. */
  21514. getBoundingInfo(): BoundingInfo;
  21515. /**
  21516. * Sets the submesh BoundingInfo
  21517. * @param boundingInfo defines the new bounding info to use
  21518. * @returns the SubMesh
  21519. */
  21520. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21521. /**
  21522. * Returns the mesh of the current submesh
  21523. * @return the parent mesh
  21524. */
  21525. getMesh(): AbstractMesh;
  21526. /**
  21527. * Returns the rendering mesh of the submesh
  21528. * @returns the rendering mesh (could be different from parent mesh)
  21529. */
  21530. getRenderingMesh(): Mesh;
  21531. /**
  21532. * Returns the submesh material
  21533. * @returns null or the current material
  21534. */
  21535. getMaterial(): Nullable<Material>;
  21536. /**
  21537. * Sets a new updated BoundingInfo object to the submesh
  21538. * @param data defines an optional position array to use to determine the bounding info
  21539. * @returns the SubMesh
  21540. */
  21541. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21542. /** @hidden */
  21543. _checkCollision(collider: Collider): boolean;
  21544. /**
  21545. * Updates the submesh BoundingInfo
  21546. * @param world defines the world matrix to use to update the bounding info
  21547. * @returns the submesh
  21548. */
  21549. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21550. /**
  21551. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21552. * @param frustumPlanes defines the frustum planes
  21553. * @returns true if the submesh is intersecting with the frustum
  21554. */
  21555. isInFrustum(frustumPlanes: Plane[]): boolean;
  21556. /**
  21557. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21558. * @param frustumPlanes defines the frustum planes
  21559. * @returns true if the submesh is inside the frustum
  21560. */
  21561. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21562. /**
  21563. * Renders the submesh
  21564. * @param enableAlphaMode defines if alpha needs to be used
  21565. * @returns the submesh
  21566. */
  21567. render(enableAlphaMode: boolean): SubMesh;
  21568. /**
  21569. * @hidden
  21570. */
  21571. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21572. /**
  21573. * Checks if the submesh intersects with a ray
  21574. * @param ray defines the ray to test
  21575. * @returns true is the passed ray intersects the submesh bounding box
  21576. */
  21577. canIntersects(ray: Ray): boolean;
  21578. /**
  21579. * Intersects current submesh with a ray
  21580. * @param ray defines the ray to test
  21581. * @param positions defines mesh's positions array
  21582. * @param indices defines mesh's indices array
  21583. * @param fastCheck defines if only bounding info should be used
  21584. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21585. * @returns intersection info or null if no intersection
  21586. */
  21587. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21588. /** @hidden */
  21589. private _intersectLines;
  21590. /** @hidden */
  21591. private _intersectUnIndexedLines;
  21592. /** @hidden */
  21593. private _intersectTriangles;
  21594. /** @hidden */
  21595. private _intersectUnIndexedTriangles;
  21596. /** @hidden */
  21597. _rebuild(): void;
  21598. /**
  21599. * Creates a new submesh from the passed mesh
  21600. * @param newMesh defines the new hosting mesh
  21601. * @param newRenderingMesh defines an optional rendering mesh
  21602. * @returns the new submesh
  21603. */
  21604. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21605. /**
  21606. * Release associated resources
  21607. */
  21608. dispose(): void;
  21609. /**
  21610. * Gets the class name
  21611. * @returns the string "SubMesh".
  21612. */
  21613. getClassName(): string;
  21614. /**
  21615. * Creates a new submesh from indices data
  21616. * @param materialIndex the index of the main mesh material
  21617. * @param startIndex the index where to start the copy in the mesh indices array
  21618. * @param indexCount the number of indices to copy then from the startIndex
  21619. * @param mesh the main mesh to create the submesh from
  21620. * @param renderingMesh the optional rendering mesh
  21621. * @returns a new submesh
  21622. */
  21623. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21624. }
  21625. }
  21626. declare module BABYLON {
  21627. /**
  21628. * Class used to represent data loading progression
  21629. */
  21630. export class SceneLoaderFlags {
  21631. private static _ForceFullSceneLoadingForIncremental;
  21632. private static _ShowLoadingScreen;
  21633. private static _CleanBoneMatrixWeights;
  21634. private static _loggingLevel;
  21635. /**
  21636. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21637. */
  21638. static get ForceFullSceneLoadingForIncremental(): boolean;
  21639. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21640. /**
  21641. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21642. */
  21643. static get ShowLoadingScreen(): boolean;
  21644. static set ShowLoadingScreen(value: boolean);
  21645. /**
  21646. * Defines the current logging level (while loading the scene)
  21647. * @ignorenaming
  21648. */
  21649. static get loggingLevel(): number;
  21650. static set loggingLevel(value: number);
  21651. /**
  21652. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21653. */
  21654. static get CleanBoneMatrixWeights(): boolean;
  21655. static set CleanBoneMatrixWeights(value: boolean);
  21656. }
  21657. }
  21658. declare module BABYLON {
  21659. /**
  21660. * Class used to store geometry data (vertex buffers + index buffer)
  21661. */
  21662. export class Geometry implements IGetSetVerticesData {
  21663. /**
  21664. * Gets or sets the ID of the geometry
  21665. */
  21666. id: string;
  21667. /**
  21668. * Gets or sets the unique ID of the geometry
  21669. */
  21670. uniqueId: number;
  21671. /**
  21672. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21673. */
  21674. delayLoadState: number;
  21675. /**
  21676. * Gets the file containing the data to load when running in delay load state
  21677. */
  21678. delayLoadingFile: Nullable<string>;
  21679. /**
  21680. * Callback called when the geometry is updated
  21681. */
  21682. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21683. private _scene;
  21684. private _engine;
  21685. private _meshes;
  21686. private _totalVertices;
  21687. /** @hidden */
  21688. _indices: IndicesArray;
  21689. /** @hidden */
  21690. _vertexBuffers: {
  21691. [key: string]: VertexBuffer;
  21692. };
  21693. private _isDisposed;
  21694. private _extend;
  21695. private _boundingBias;
  21696. /** @hidden */
  21697. _delayInfo: Array<string>;
  21698. private _indexBuffer;
  21699. private _indexBufferIsUpdatable;
  21700. /** @hidden */
  21701. _boundingInfo: Nullable<BoundingInfo>;
  21702. /** @hidden */
  21703. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21704. /** @hidden */
  21705. _softwareSkinningFrameId: number;
  21706. private _vertexArrayObjects;
  21707. private _updatable;
  21708. /** @hidden */
  21709. _positions: Nullable<Vector3[]>;
  21710. /**
  21711. * 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
  21712. */
  21713. get boundingBias(): Vector2;
  21714. /**
  21715. * 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
  21716. */
  21717. set boundingBias(value: Vector2);
  21718. /**
  21719. * Static function used to attach a new empty geometry to a mesh
  21720. * @param mesh defines the mesh to attach the geometry to
  21721. * @returns the new Geometry
  21722. */
  21723. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21724. /**
  21725. * Creates a new geometry
  21726. * @param id defines the unique ID
  21727. * @param scene defines the hosting scene
  21728. * @param vertexData defines the VertexData used to get geometry data
  21729. * @param updatable defines if geometry must be updatable (false by default)
  21730. * @param mesh defines the mesh that will be associated with the geometry
  21731. */
  21732. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21733. /**
  21734. * Gets the current extend of the geometry
  21735. */
  21736. get extend(): {
  21737. minimum: Vector3;
  21738. maximum: Vector3;
  21739. };
  21740. /**
  21741. * Gets the hosting scene
  21742. * @returns the hosting Scene
  21743. */
  21744. getScene(): Scene;
  21745. /**
  21746. * Gets the hosting engine
  21747. * @returns the hosting Engine
  21748. */
  21749. getEngine(): Engine;
  21750. /**
  21751. * Defines if the geometry is ready to use
  21752. * @returns true if the geometry is ready to be used
  21753. */
  21754. isReady(): boolean;
  21755. /**
  21756. * Gets a value indicating that the geometry should not be serialized
  21757. */
  21758. get doNotSerialize(): boolean;
  21759. /** @hidden */
  21760. _rebuild(): void;
  21761. /**
  21762. * Affects all geometry data in one call
  21763. * @param vertexData defines the geometry data
  21764. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21765. */
  21766. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21767. /**
  21768. * Set specific vertex data
  21769. * @param kind defines the data kind (Position, normal, etc...)
  21770. * @param data defines the vertex data to use
  21771. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21772. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21773. */
  21774. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21775. /**
  21776. * Removes a specific vertex data
  21777. * @param kind defines the data kind (Position, normal, etc...)
  21778. */
  21779. removeVerticesData(kind: string): void;
  21780. /**
  21781. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21782. * @param buffer defines the vertex buffer to use
  21783. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21784. */
  21785. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21786. /**
  21787. * Update a specific vertex buffer
  21788. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21789. * It will do nothing if the buffer is not updatable
  21790. * @param kind defines the data kind (Position, normal, etc...)
  21791. * @param data defines the data to use
  21792. * @param offset defines the offset in the target buffer where to store the data
  21793. * @param useBytes set to true if the offset is in bytes
  21794. */
  21795. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21796. /**
  21797. * Update a specific vertex buffer
  21798. * This function will create a new buffer if the current one is not updatable
  21799. * @param kind defines the data kind (Position, normal, etc...)
  21800. * @param data defines the data to use
  21801. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21802. */
  21803. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21804. private _updateBoundingInfo;
  21805. /** @hidden */
  21806. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21807. /**
  21808. * Gets total number of vertices
  21809. * @returns the total number of vertices
  21810. */
  21811. getTotalVertices(): number;
  21812. /**
  21813. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21814. * @param kind defines the data kind (Position, normal, etc...)
  21815. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21816. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21817. * @returns a float array containing vertex data
  21818. */
  21819. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21820. /**
  21821. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21822. * @param kind defines the data kind (Position, normal, etc...)
  21823. * @returns true if the vertex buffer with the specified kind is updatable
  21824. */
  21825. isVertexBufferUpdatable(kind: string): boolean;
  21826. /**
  21827. * Gets a specific vertex buffer
  21828. * @param kind defines the data kind (Position, normal, etc...)
  21829. * @returns a VertexBuffer
  21830. */
  21831. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21832. /**
  21833. * Returns all vertex buffers
  21834. * @return an object holding all vertex buffers indexed by kind
  21835. */
  21836. getVertexBuffers(): Nullable<{
  21837. [key: string]: VertexBuffer;
  21838. }>;
  21839. /**
  21840. * Gets a boolean indicating if specific vertex buffer is present
  21841. * @param kind defines the data kind (Position, normal, etc...)
  21842. * @returns true if data is present
  21843. */
  21844. isVerticesDataPresent(kind: string): boolean;
  21845. /**
  21846. * Gets a list of all attached data kinds (Position, normal, etc...)
  21847. * @returns a list of string containing all kinds
  21848. */
  21849. getVerticesDataKinds(): string[];
  21850. /**
  21851. * Update index buffer
  21852. * @param indices defines the indices to store in the index buffer
  21853. * @param offset defines the offset in the target buffer where to store the data
  21854. * @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)
  21855. */
  21856. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21857. /**
  21858. * Creates a new index buffer
  21859. * @param indices defines the indices to store in the index buffer
  21860. * @param totalVertices defines the total number of vertices (could be null)
  21861. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21862. */
  21863. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21864. /**
  21865. * Return the total number of indices
  21866. * @returns the total number of indices
  21867. */
  21868. getTotalIndices(): number;
  21869. /**
  21870. * Gets the index buffer array
  21871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21873. * @returns the index buffer array
  21874. */
  21875. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21876. /**
  21877. * Gets the index buffer
  21878. * @return the index buffer
  21879. */
  21880. getIndexBuffer(): Nullable<DataBuffer>;
  21881. /** @hidden */
  21882. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21883. /**
  21884. * Release the associated resources for a specific mesh
  21885. * @param mesh defines the source mesh
  21886. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21887. */
  21888. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21889. /**
  21890. * Apply current geometry to a given mesh
  21891. * @param mesh defines the mesh to apply geometry to
  21892. */
  21893. applyToMesh(mesh: Mesh): void;
  21894. private _updateExtend;
  21895. private _applyToMesh;
  21896. private notifyUpdate;
  21897. /**
  21898. * Load the geometry if it was flagged as delay loaded
  21899. * @param scene defines the hosting scene
  21900. * @param onLoaded defines a callback called when the geometry is loaded
  21901. */
  21902. load(scene: Scene, onLoaded?: () => void): void;
  21903. private _queueLoad;
  21904. /**
  21905. * Invert the geometry to move from a right handed system to a left handed one.
  21906. */
  21907. toLeftHanded(): void;
  21908. /** @hidden */
  21909. _resetPointsArrayCache(): void;
  21910. /** @hidden */
  21911. _generatePointsArray(): boolean;
  21912. /**
  21913. * Gets a value indicating if the geometry is disposed
  21914. * @returns true if the geometry was disposed
  21915. */
  21916. isDisposed(): boolean;
  21917. private _disposeVertexArrayObjects;
  21918. /**
  21919. * Free all associated resources
  21920. */
  21921. dispose(): void;
  21922. /**
  21923. * Clone the current geometry into a new geometry
  21924. * @param id defines the unique ID of the new geometry
  21925. * @returns a new geometry object
  21926. */
  21927. copy(id: string): Geometry;
  21928. /**
  21929. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21930. * @return a JSON representation of the current geometry data (without the vertices data)
  21931. */
  21932. serialize(): any;
  21933. private toNumberArray;
  21934. /**
  21935. * Serialize all vertices data into a JSON oject
  21936. * @returns a JSON representation of the current geometry data
  21937. */
  21938. serializeVerticeData(): any;
  21939. /**
  21940. * Extracts a clone of a mesh geometry
  21941. * @param mesh defines the source mesh
  21942. * @param id defines the unique ID of the new geometry object
  21943. * @returns the new geometry object
  21944. */
  21945. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21946. /**
  21947. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21948. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21949. * Be aware Math.random() could cause collisions, but:
  21950. * "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"
  21951. * @returns a string containing a new GUID
  21952. */
  21953. static RandomId(): string;
  21954. /** @hidden */
  21955. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21956. private static _CleanMatricesWeights;
  21957. /**
  21958. * Create a new geometry from persisted data (Using .babylon file format)
  21959. * @param parsedVertexData defines the persisted data
  21960. * @param scene defines the hosting scene
  21961. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21962. * @returns the new geometry object
  21963. */
  21964. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21965. }
  21966. }
  21967. declare module BABYLON {
  21968. /**
  21969. * Define an interface for all classes that will get and set the data on vertices
  21970. */
  21971. export interface IGetSetVerticesData {
  21972. /**
  21973. * Gets a boolean indicating if specific vertex data is present
  21974. * @param kind defines the vertex data kind to use
  21975. * @returns true is data kind is present
  21976. */
  21977. isVerticesDataPresent(kind: string): boolean;
  21978. /**
  21979. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21980. * @param kind defines the data kind (Position, normal, etc...)
  21981. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21982. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21983. * @returns a float array containing vertex data
  21984. */
  21985. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21986. /**
  21987. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21988. * @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.
  21989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21990. * @returns the indices array or an empty array if the mesh has no geometry
  21991. */
  21992. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21993. /**
  21994. * Set specific vertex data
  21995. * @param kind defines the data kind (Position, normal, etc...)
  21996. * @param data defines the vertex data to use
  21997. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21998. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21999. */
  22000. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22001. /**
  22002. * Update a specific associated vertex buffer
  22003. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22004. * - VertexBuffer.PositionKind
  22005. * - VertexBuffer.UVKind
  22006. * - VertexBuffer.UV2Kind
  22007. * - VertexBuffer.UV3Kind
  22008. * - VertexBuffer.UV4Kind
  22009. * - VertexBuffer.UV5Kind
  22010. * - VertexBuffer.UV6Kind
  22011. * - VertexBuffer.ColorKind
  22012. * - VertexBuffer.MatricesIndicesKind
  22013. * - VertexBuffer.MatricesIndicesExtraKind
  22014. * - VertexBuffer.MatricesWeightsKind
  22015. * - VertexBuffer.MatricesWeightsExtraKind
  22016. * @param data defines the data source
  22017. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22018. * @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)
  22019. */
  22020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22021. /**
  22022. * Creates a new index buffer
  22023. * @param indices defines the indices to store in the index buffer
  22024. * @param totalVertices defines the total number of vertices (could be null)
  22025. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22026. */
  22027. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22028. }
  22029. /**
  22030. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22031. */
  22032. export class VertexData {
  22033. /**
  22034. * Mesh side orientation : usually the external or front surface
  22035. */
  22036. static readonly FRONTSIDE: number;
  22037. /**
  22038. * Mesh side orientation : usually the internal or back surface
  22039. */
  22040. static readonly BACKSIDE: number;
  22041. /**
  22042. * Mesh side orientation : both internal and external or front and back surfaces
  22043. */
  22044. static readonly DOUBLESIDE: number;
  22045. /**
  22046. * Mesh side orientation : by default, `FRONTSIDE`
  22047. */
  22048. static readonly DEFAULTSIDE: number;
  22049. /**
  22050. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22051. */
  22052. positions: Nullable<FloatArray>;
  22053. /**
  22054. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22055. */
  22056. normals: Nullable<FloatArray>;
  22057. /**
  22058. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22059. */
  22060. tangents: Nullable<FloatArray>;
  22061. /**
  22062. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22063. */
  22064. uvs: Nullable<FloatArray>;
  22065. /**
  22066. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22067. */
  22068. uvs2: Nullable<FloatArray>;
  22069. /**
  22070. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22071. */
  22072. uvs3: Nullable<FloatArray>;
  22073. /**
  22074. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22075. */
  22076. uvs4: Nullable<FloatArray>;
  22077. /**
  22078. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22079. */
  22080. uvs5: Nullable<FloatArray>;
  22081. /**
  22082. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22083. */
  22084. uvs6: Nullable<FloatArray>;
  22085. /**
  22086. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22087. */
  22088. colors: Nullable<FloatArray>;
  22089. /**
  22090. * 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).
  22091. */
  22092. matricesIndices: Nullable<FloatArray>;
  22093. /**
  22094. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22095. */
  22096. matricesWeights: Nullable<FloatArray>;
  22097. /**
  22098. * An array extending the number of possible indices
  22099. */
  22100. matricesIndicesExtra: Nullable<FloatArray>;
  22101. /**
  22102. * An array extending the number of possible weights when the number of indices is extended
  22103. */
  22104. matricesWeightsExtra: Nullable<FloatArray>;
  22105. /**
  22106. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22107. */
  22108. indices: Nullable<IndicesArray>;
  22109. /**
  22110. * Uses the passed data array to set the set the values for the specified kind of data
  22111. * @param data a linear array of floating numbers
  22112. * @param kind the type of data that is being set, eg positions, colors etc
  22113. */
  22114. set(data: FloatArray, kind: string): void;
  22115. /**
  22116. * Associates the vertexData to the passed Mesh.
  22117. * Sets it as updatable or not (default `false`)
  22118. * @param mesh the mesh the vertexData is applied to
  22119. * @param updatable when used and having the value true allows new data to update the vertexData
  22120. * @returns the VertexData
  22121. */
  22122. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22123. /**
  22124. * Associates the vertexData to the passed Geometry.
  22125. * Sets it as updatable or not (default `false`)
  22126. * @param geometry the geometry the vertexData is applied to
  22127. * @param updatable when used and having the value true allows new data to update the vertexData
  22128. * @returns VertexData
  22129. */
  22130. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22131. /**
  22132. * Updates the associated mesh
  22133. * @param mesh the mesh to be updated
  22134. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22135. * @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
  22136. * @returns VertexData
  22137. */
  22138. updateMesh(mesh: Mesh): VertexData;
  22139. /**
  22140. * Updates the associated geometry
  22141. * @param geometry the geometry to be updated
  22142. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22143. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22144. * @returns VertexData.
  22145. */
  22146. updateGeometry(geometry: Geometry): VertexData;
  22147. private _applyTo;
  22148. private _update;
  22149. /**
  22150. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22151. * @param matrix the transforming matrix
  22152. * @returns the VertexData
  22153. */
  22154. transform(matrix: Matrix): VertexData;
  22155. /**
  22156. * Merges the passed VertexData into the current one
  22157. * @param other the VertexData to be merged into the current one
  22158. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22159. * @returns the modified VertexData
  22160. */
  22161. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22162. private _mergeElement;
  22163. private _validate;
  22164. /**
  22165. * Serializes the VertexData
  22166. * @returns a serialized object
  22167. */
  22168. serialize(): any;
  22169. /**
  22170. * Extracts the vertexData from a mesh
  22171. * @param mesh the mesh from which to extract the VertexData
  22172. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22173. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22174. * @returns the object VertexData associated to the passed mesh
  22175. */
  22176. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22177. /**
  22178. * Extracts the vertexData from the geometry
  22179. * @param geometry the geometry from which to extract the VertexData
  22180. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22181. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22182. * @returns the object VertexData associated to the passed mesh
  22183. */
  22184. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22185. private static _ExtractFrom;
  22186. /**
  22187. * Creates the VertexData for a Ribbon
  22188. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22189. * * pathArray array of paths, each of which an array of successive Vector3
  22190. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22191. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22192. * * 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
  22193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22194. * * 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)
  22195. * * 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)
  22196. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22197. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22198. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22199. * @returns the VertexData of the ribbon
  22200. */
  22201. static CreateRibbon(options: {
  22202. pathArray: Vector3[][];
  22203. closeArray?: boolean;
  22204. closePath?: boolean;
  22205. offset?: number;
  22206. sideOrientation?: number;
  22207. frontUVs?: Vector4;
  22208. backUVs?: Vector4;
  22209. invertUV?: boolean;
  22210. uvs?: Vector2[];
  22211. colors?: Color4[];
  22212. }): VertexData;
  22213. /**
  22214. * Creates the VertexData for a box
  22215. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22216. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22217. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22218. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22219. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22220. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22221. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22223. * * 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)
  22224. * * 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)
  22225. * @returns the VertexData of the box
  22226. */
  22227. static CreateBox(options: {
  22228. size?: number;
  22229. width?: number;
  22230. height?: number;
  22231. depth?: number;
  22232. faceUV?: Vector4[];
  22233. faceColors?: Color4[];
  22234. sideOrientation?: number;
  22235. frontUVs?: Vector4;
  22236. backUVs?: Vector4;
  22237. }): VertexData;
  22238. /**
  22239. * Creates the VertexData for a tiled box
  22240. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22241. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22242. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22243. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22245. * @returns the VertexData of the box
  22246. */
  22247. static CreateTiledBox(options: {
  22248. pattern?: number;
  22249. width?: number;
  22250. height?: number;
  22251. depth?: number;
  22252. tileSize?: number;
  22253. tileWidth?: number;
  22254. tileHeight?: number;
  22255. alignHorizontal?: number;
  22256. alignVertical?: number;
  22257. faceUV?: Vector4[];
  22258. faceColors?: Color4[];
  22259. sideOrientation?: number;
  22260. }): VertexData;
  22261. /**
  22262. * Creates the VertexData for a tiled plane
  22263. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22264. * * pattern a limited pattern arrangement depending on the number
  22265. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22266. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22267. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22269. * * 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)
  22270. * * 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)
  22271. * @returns the VertexData of the tiled plane
  22272. */
  22273. static CreateTiledPlane(options: {
  22274. pattern?: number;
  22275. tileSize?: number;
  22276. tileWidth?: number;
  22277. tileHeight?: number;
  22278. size?: number;
  22279. width?: number;
  22280. height?: number;
  22281. alignHorizontal?: number;
  22282. alignVertical?: number;
  22283. sideOrientation?: number;
  22284. frontUVs?: Vector4;
  22285. backUVs?: Vector4;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22290. * * segments sets the number of horizontal strips optional, default 32
  22291. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22292. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22293. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22294. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22295. * * 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
  22296. * * 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
  22297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22298. * * 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)
  22299. * * 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)
  22300. * @returns the VertexData of the ellipsoid
  22301. */
  22302. static CreateSphere(options: {
  22303. segments?: number;
  22304. diameter?: number;
  22305. diameterX?: number;
  22306. diameterY?: number;
  22307. diameterZ?: number;
  22308. arc?: number;
  22309. slice?: number;
  22310. sideOrientation?: number;
  22311. frontUVs?: Vector4;
  22312. backUVs?: Vector4;
  22313. }): VertexData;
  22314. /**
  22315. * Creates the VertexData for a cylinder, cone or prism
  22316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22317. * * height sets the height (y direction) of the cylinder, optional, default 2
  22318. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22319. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22320. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22321. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22322. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22323. * * 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
  22324. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22325. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22326. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22327. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22329. * * 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)
  22330. * * 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)
  22331. * @returns the VertexData of the cylinder, cone or prism
  22332. */
  22333. static CreateCylinder(options: {
  22334. height?: number;
  22335. diameterTop?: number;
  22336. diameterBottom?: number;
  22337. diameter?: number;
  22338. tessellation?: number;
  22339. subdivisions?: number;
  22340. arc?: number;
  22341. faceColors?: Color4[];
  22342. faceUV?: Vector4[];
  22343. hasRings?: boolean;
  22344. enclose?: boolean;
  22345. sideOrientation?: number;
  22346. frontUVs?: Vector4;
  22347. backUVs?: Vector4;
  22348. }): VertexData;
  22349. /**
  22350. * Creates the VertexData for a torus
  22351. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22352. * * diameter the diameter of the torus, optional default 1
  22353. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22354. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22356. * * 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)
  22357. * * 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)
  22358. * @returns the VertexData of the torus
  22359. */
  22360. static CreateTorus(options: {
  22361. diameter?: number;
  22362. thickness?: number;
  22363. tessellation?: number;
  22364. sideOrientation?: number;
  22365. frontUVs?: Vector4;
  22366. backUVs?: Vector4;
  22367. }): VertexData;
  22368. /**
  22369. * Creates the VertexData of the LineSystem
  22370. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22371. * - lines an array of lines, each line being an array of successive Vector3
  22372. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22373. * @returns the VertexData of the LineSystem
  22374. */
  22375. static CreateLineSystem(options: {
  22376. lines: Vector3[][];
  22377. colors?: Nullable<Color4[][]>;
  22378. }): VertexData;
  22379. /**
  22380. * Create the VertexData for a DashedLines
  22381. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22382. * - points an array successive Vector3
  22383. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22384. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22385. * - dashNb the intended total number of dashes, optional, default 200
  22386. * @returns the VertexData for the DashedLines
  22387. */
  22388. static CreateDashedLines(options: {
  22389. points: Vector3[];
  22390. dashSize?: number;
  22391. gapSize?: number;
  22392. dashNb?: number;
  22393. }): VertexData;
  22394. /**
  22395. * Creates the VertexData for a Ground
  22396. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22397. * - width the width (x direction) of the ground, optional, default 1
  22398. * - height the height (z direction) of the ground, optional, default 1
  22399. * - subdivisions the number of subdivisions per side, optional, default 1
  22400. * @returns the VertexData of the Ground
  22401. */
  22402. static CreateGround(options: {
  22403. width?: number;
  22404. height?: number;
  22405. subdivisions?: number;
  22406. subdivisionsX?: number;
  22407. subdivisionsY?: number;
  22408. }): VertexData;
  22409. /**
  22410. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22411. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22412. * * xmin the ground minimum X coordinate, optional, default -1
  22413. * * zmin the ground minimum Z coordinate, optional, default -1
  22414. * * xmax the ground maximum X coordinate, optional, default 1
  22415. * * zmax the ground maximum Z coordinate, optional, default 1
  22416. * * 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}
  22417. * * 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}
  22418. * @returns the VertexData of the TiledGround
  22419. */
  22420. static CreateTiledGround(options: {
  22421. xmin: number;
  22422. zmin: number;
  22423. xmax: number;
  22424. zmax: number;
  22425. subdivisions?: {
  22426. w: number;
  22427. h: number;
  22428. };
  22429. precision?: {
  22430. w: number;
  22431. h: number;
  22432. };
  22433. }): VertexData;
  22434. /**
  22435. * Creates the VertexData of the Ground designed from a heightmap
  22436. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22437. * * width the width (x direction) of the ground
  22438. * * height the height (z direction) of the ground
  22439. * * subdivisions the number of subdivisions per side
  22440. * * minHeight the minimum altitude on the ground, optional, default 0
  22441. * * maxHeight the maximum altitude on the ground, optional default 1
  22442. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22443. * * buffer the array holding the image color data
  22444. * * bufferWidth the width of image
  22445. * * bufferHeight the height of image
  22446. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22447. * @returns the VertexData of the Ground designed from a heightmap
  22448. */
  22449. static CreateGroundFromHeightMap(options: {
  22450. width: number;
  22451. height: number;
  22452. subdivisions: number;
  22453. minHeight: number;
  22454. maxHeight: number;
  22455. colorFilter: Color3;
  22456. buffer: Uint8Array;
  22457. bufferWidth: number;
  22458. bufferHeight: number;
  22459. alphaFilter: number;
  22460. }): VertexData;
  22461. /**
  22462. * Creates the VertexData for a Plane
  22463. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22464. * * size sets the width and height of the plane to the value of size, optional default 1
  22465. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22466. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22468. * * 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)
  22469. * * 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)
  22470. * @returns the VertexData of the box
  22471. */
  22472. static CreatePlane(options: {
  22473. size?: number;
  22474. width?: number;
  22475. height?: number;
  22476. sideOrientation?: number;
  22477. frontUVs?: Vector4;
  22478. backUVs?: Vector4;
  22479. }): VertexData;
  22480. /**
  22481. * Creates the VertexData of the Disc or regular Polygon
  22482. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22483. * * radius the radius of the disc, optional default 0.5
  22484. * * tessellation the number of polygon sides, optional, default 64
  22485. * * 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
  22486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22487. * * 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)
  22488. * * 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)
  22489. * @returns the VertexData of the box
  22490. */
  22491. static CreateDisc(options: {
  22492. radius?: number;
  22493. tessellation?: number;
  22494. arc?: number;
  22495. sideOrientation?: number;
  22496. frontUVs?: Vector4;
  22497. backUVs?: Vector4;
  22498. }): VertexData;
  22499. /**
  22500. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22501. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22502. * @param polygon a mesh built from polygonTriangulation.build()
  22503. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22505. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22506. * @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)
  22507. * @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)
  22508. * @returns the VertexData of the Polygon
  22509. */
  22510. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22511. /**
  22512. * Creates the VertexData of the IcoSphere
  22513. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22514. * * radius the radius of the IcoSphere, optional default 1
  22515. * * radiusX allows stretching in the x direction, optional, default radius
  22516. * * radiusY allows stretching in the y direction, optional, default radius
  22517. * * radiusZ allows stretching in the z direction, optional, default radius
  22518. * * flat when true creates a flat shaded mesh, optional, default true
  22519. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22521. * * 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)
  22522. * * 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)
  22523. * @returns the VertexData of the IcoSphere
  22524. */
  22525. static CreateIcoSphere(options: {
  22526. radius?: number;
  22527. radiusX?: number;
  22528. radiusY?: number;
  22529. radiusZ?: number;
  22530. flat?: boolean;
  22531. subdivisions?: number;
  22532. sideOrientation?: number;
  22533. frontUVs?: Vector4;
  22534. backUVs?: Vector4;
  22535. }): VertexData;
  22536. /**
  22537. * Creates the VertexData for a Polyhedron
  22538. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22539. * * type provided types are:
  22540. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22541. * * 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)
  22542. * * size the size of the IcoSphere, optional default 1
  22543. * * sizeX allows stretching in the x direction, optional, default size
  22544. * * sizeY allows stretching in the y direction, optional, default size
  22545. * * sizeZ allows stretching in the z direction, optional, default size
  22546. * * 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
  22547. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22548. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22549. * * flat when true creates a flat shaded mesh, optional, default true
  22550. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22552. * * 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)
  22553. * * 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)
  22554. * @returns the VertexData of the Polyhedron
  22555. */
  22556. static CreatePolyhedron(options: {
  22557. type?: number;
  22558. size?: number;
  22559. sizeX?: number;
  22560. sizeY?: number;
  22561. sizeZ?: number;
  22562. custom?: any;
  22563. faceUV?: Vector4[];
  22564. faceColors?: Color4[];
  22565. flat?: boolean;
  22566. sideOrientation?: number;
  22567. frontUVs?: Vector4;
  22568. backUVs?: Vector4;
  22569. }): VertexData;
  22570. /**
  22571. * Creates the VertexData for a TorusKnot
  22572. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22573. * * radius the radius of the torus knot, optional, default 2
  22574. * * tube the thickness of the tube, optional, default 0.5
  22575. * * radialSegments the number of sides on each tube segments, optional, default 32
  22576. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22577. * * p the number of windings around the z axis, optional, default 2
  22578. * * q the number of windings around the x axis, optional, default 3
  22579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22580. * * 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)
  22581. * * 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)
  22582. * @returns the VertexData of the Torus Knot
  22583. */
  22584. static CreateTorusKnot(options: {
  22585. radius?: number;
  22586. tube?: number;
  22587. radialSegments?: number;
  22588. tubularSegments?: number;
  22589. p?: number;
  22590. q?: number;
  22591. sideOrientation?: number;
  22592. frontUVs?: Vector4;
  22593. backUVs?: Vector4;
  22594. }): VertexData;
  22595. /**
  22596. * Compute normals for given positions and indices
  22597. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22598. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22599. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22600. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22601. * * facetNormals : optional array of facet normals (vector3)
  22602. * * facetPositions : optional array of facet positions (vector3)
  22603. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22604. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22605. * * bInfo : optional bounding info, required for facetPartitioning computation
  22606. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22607. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22608. * * useRightHandedSystem: optional boolean to for right handed system computation
  22609. * * depthSort : optional boolean to enable the facet depth sort computation
  22610. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22611. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22612. */
  22613. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22614. facetNormals?: any;
  22615. facetPositions?: any;
  22616. facetPartitioning?: any;
  22617. ratio?: number;
  22618. bInfo?: any;
  22619. bbSize?: Vector3;
  22620. subDiv?: any;
  22621. useRightHandedSystem?: boolean;
  22622. depthSort?: boolean;
  22623. distanceTo?: Vector3;
  22624. depthSortedFacets?: any;
  22625. }): void;
  22626. /** @hidden */
  22627. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22628. /**
  22629. * Applies VertexData created from the imported parameters to the geometry
  22630. * @param parsedVertexData the parsed data from an imported file
  22631. * @param geometry the geometry to apply the VertexData to
  22632. */
  22633. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22634. }
  22635. }
  22636. declare module BABYLON {
  22637. /**
  22638. * Defines a target to use with MorphTargetManager
  22639. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22640. */
  22641. export class MorphTarget implements IAnimatable {
  22642. /** defines the name of the target */
  22643. name: string;
  22644. /**
  22645. * Gets or sets the list of animations
  22646. */
  22647. animations: Animation[];
  22648. private _scene;
  22649. private _positions;
  22650. private _normals;
  22651. private _tangents;
  22652. private _uvs;
  22653. private _influence;
  22654. private _uniqueId;
  22655. /**
  22656. * Observable raised when the influence changes
  22657. */
  22658. onInfluenceChanged: Observable<boolean>;
  22659. /** @hidden */
  22660. _onDataLayoutChanged: Observable<void>;
  22661. /**
  22662. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22663. */
  22664. get influence(): number;
  22665. set influence(influence: number);
  22666. /**
  22667. * Gets or sets the id of the morph Target
  22668. */
  22669. id: string;
  22670. private _animationPropertiesOverride;
  22671. /**
  22672. * Gets or sets the animation properties override
  22673. */
  22674. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22675. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22676. /**
  22677. * Creates a new MorphTarget
  22678. * @param name defines the name of the target
  22679. * @param influence defines the influence to use
  22680. * @param scene defines the scene the morphtarget belongs to
  22681. */
  22682. constructor(
  22683. /** defines the name of the target */
  22684. name: string, influence?: number, scene?: Nullable<Scene>);
  22685. /**
  22686. * Gets the unique ID of this manager
  22687. */
  22688. get uniqueId(): number;
  22689. /**
  22690. * Gets a boolean defining if the target contains position data
  22691. */
  22692. get hasPositions(): boolean;
  22693. /**
  22694. * Gets a boolean defining if the target contains normal data
  22695. */
  22696. get hasNormals(): boolean;
  22697. /**
  22698. * Gets a boolean defining if the target contains tangent data
  22699. */
  22700. get hasTangents(): boolean;
  22701. /**
  22702. * Gets a boolean defining if the target contains texture coordinates data
  22703. */
  22704. get hasUVs(): boolean;
  22705. /**
  22706. * Affects position data to this target
  22707. * @param data defines the position data to use
  22708. */
  22709. setPositions(data: Nullable<FloatArray>): void;
  22710. /**
  22711. * Gets the position data stored in this target
  22712. * @returns a FloatArray containing the position data (or null if not present)
  22713. */
  22714. getPositions(): Nullable<FloatArray>;
  22715. /**
  22716. * Affects normal data to this target
  22717. * @param data defines the normal data to use
  22718. */
  22719. setNormals(data: Nullable<FloatArray>): void;
  22720. /**
  22721. * Gets the normal data stored in this target
  22722. * @returns a FloatArray containing the normal data (or null if not present)
  22723. */
  22724. getNormals(): Nullable<FloatArray>;
  22725. /**
  22726. * Affects tangent data to this target
  22727. * @param data defines the tangent data to use
  22728. */
  22729. setTangents(data: Nullable<FloatArray>): void;
  22730. /**
  22731. * Gets the tangent data stored in this target
  22732. * @returns a FloatArray containing the tangent data (or null if not present)
  22733. */
  22734. getTangents(): Nullable<FloatArray>;
  22735. /**
  22736. * Affects texture coordinates data to this target
  22737. * @param data defines the texture coordinates data to use
  22738. */
  22739. setUVs(data: Nullable<FloatArray>): void;
  22740. /**
  22741. * Gets the texture coordinates data stored in this target
  22742. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22743. */
  22744. getUVs(): Nullable<FloatArray>;
  22745. /**
  22746. * Clone the current target
  22747. * @returns a new MorphTarget
  22748. */
  22749. clone(): MorphTarget;
  22750. /**
  22751. * Serializes the current target into a Serialization object
  22752. * @returns the serialized object
  22753. */
  22754. serialize(): any;
  22755. /**
  22756. * Returns the string "MorphTarget"
  22757. * @returns "MorphTarget"
  22758. */
  22759. getClassName(): string;
  22760. /**
  22761. * Creates a new target from serialized data
  22762. * @param serializationObject defines the serialized data to use
  22763. * @returns a new MorphTarget
  22764. */
  22765. static Parse(serializationObject: any): MorphTarget;
  22766. /**
  22767. * Creates a MorphTarget from mesh data
  22768. * @param mesh defines the source mesh
  22769. * @param name defines the name to use for the new target
  22770. * @param influence defines the influence to attach to the target
  22771. * @returns a new MorphTarget
  22772. */
  22773. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22774. }
  22775. }
  22776. declare module BABYLON {
  22777. /**
  22778. * This class is used to deform meshes using morphing between different targets
  22779. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22780. */
  22781. export class MorphTargetManager {
  22782. private _targets;
  22783. private _targetInfluenceChangedObservers;
  22784. private _targetDataLayoutChangedObservers;
  22785. private _activeTargets;
  22786. private _scene;
  22787. private _influences;
  22788. private _supportsNormals;
  22789. private _supportsTangents;
  22790. private _supportsUVs;
  22791. private _vertexCount;
  22792. private _uniqueId;
  22793. private _tempInfluences;
  22794. /**
  22795. * Gets or sets a boolean indicating if normals must be morphed
  22796. */
  22797. enableNormalMorphing: boolean;
  22798. /**
  22799. * Gets or sets a boolean indicating if tangents must be morphed
  22800. */
  22801. enableTangentMorphing: boolean;
  22802. /**
  22803. * Gets or sets a boolean indicating if UV must be morphed
  22804. */
  22805. enableUVMorphing: boolean;
  22806. /**
  22807. * Creates a new MorphTargetManager
  22808. * @param scene defines the current scene
  22809. */
  22810. constructor(scene?: Nullable<Scene>);
  22811. /**
  22812. * Gets the unique ID of this manager
  22813. */
  22814. get uniqueId(): number;
  22815. /**
  22816. * Gets the number of vertices handled by this manager
  22817. */
  22818. get vertexCount(): number;
  22819. /**
  22820. * Gets a boolean indicating if this manager supports morphing of normals
  22821. */
  22822. get supportsNormals(): boolean;
  22823. /**
  22824. * Gets a boolean indicating if this manager supports morphing of tangents
  22825. */
  22826. get supportsTangents(): boolean;
  22827. /**
  22828. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22829. */
  22830. get supportsUVs(): boolean;
  22831. /**
  22832. * Gets the number of targets stored in this manager
  22833. */
  22834. get numTargets(): number;
  22835. /**
  22836. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22837. */
  22838. get numInfluencers(): number;
  22839. /**
  22840. * Gets the list of influences (one per target)
  22841. */
  22842. get influences(): Float32Array;
  22843. /**
  22844. * Gets the active target at specified index. An active target is a target with an influence > 0
  22845. * @param index defines the index to check
  22846. * @returns the requested target
  22847. */
  22848. getActiveTarget(index: number): MorphTarget;
  22849. /**
  22850. * Gets the target at specified index
  22851. * @param index defines the index to check
  22852. * @returns the requested target
  22853. */
  22854. getTarget(index: number): MorphTarget;
  22855. /**
  22856. * Add a new target to this manager
  22857. * @param target defines the target to add
  22858. */
  22859. addTarget(target: MorphTarget): void;
  22860. /**
  22861. * Removes a target from the manager
  22862. * @param target defines the target to remove
  22863. */
  22864. removeTarget(target: MorphTarget): void;
  22865. /**
  22866. * Clone the current manager
  22867. * @returns a new MorphTargetManager
  22868. */
  22869. clone(): MorphTargetManager;
  22870. /**
  22871. * Serializes the current manager into a Serialization object
  22872. * @returns the serialized object
  22873. */
  22874. serialize(): any;
  22875. private _syncActiveTargets;
  22876. /**
  22877. * Syncrhonize the targets with all the meshes using this morph target manager
  22878. */
  22879. synchronize(): void;
  22880. /**
  22881. * Creates a new MorphTargetManager from serialized data
  22882. * @param serializationObject defines the serialized data
  22883. * @param scene defines the hosting scene
  22884. * @returns the new MorphTargetManager
  22885. */
  22886. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22887. }
  22888. }
  22889. declare module BABYLON {
  22890. /**
  22891. * Class used to represent a specific level of detail of a mesh
  22892. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22893. */
  22894. export class MeshLODLevel {
  22895. /** Defines the distance where this level should start being displayed */
  22896. distance: number;
  22897. /** Defines the mesh to use to render this level */
  22898. mesh: Nullable<Mesh>;
  22899. /**
  22900. * Creates a new LOD level
  22901. * @param distance defines the distance where this level should star being displayed
  22902. * @param mesh defines the mesh to use to render this level
  22903. */
  22904. constructor(
  22905. /** Defines the distance where this level should start being displayed */
  22906. distance: number,
  22907. /** Defines the mesh to use to render this level */
  22908. mesh: Nullable<Mesh>);
  22909. }
  22910. }
  22911. declare module BABYLON {
  22912. /**
  22913. * Mesh representing the gorund
  22914. */
  22915. export class GroundMesh extends Mesh {
  22916. /** If octree should be generated */
  22917. generateOctree: boolean;
  22918. private _heightQuads;
  22919. /** @hidden */
  22920. _subdivisionsX: number;
  22921. /** @hidden */
  22922. _subdivisionsY: number;
  22923. /** @hidden */
  22924. _width: number;
  22925. /** @hidden */
  22926. _height: number;
  22927. /** @hidden */
  22928. _minX: number;
  22929. /** @hidden */
  22930. _maxX: number;
  22931. /** @hidden */
  22932. _minZ: number;
  22933. /** @hidden */
  22934. _maxZ: number;
  22935. constructor(name: string, scene: Scene);
  22936. /**
  22937. * "GroundMesh"
  22938. * @returns "GroundMesh"
  22939. */
  22940. getClassName(): string;
  22941. /**
  22942. * The minimum of x and y subdivisions
  22943. */
  22944. get subdivisions(): number;
  22945. /**
  22946. * X subdivisions
  22947. */
  22948. get subdivisionsX(): number;
  22949. /**
  22950. * Y subdivisions
  22951. */
  22952. get subdivisionsY(): number;
  22953. /**
  22954. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22955. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22956. * @param chunksCount the number of subdivisions for x and y
  22957. * @param octreeBlocksSize (Default: 32)
  22958. */
  22959. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22960. /**
  22961. * Returns a height (y) value in the Worl system :
  22962. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22963. * @param x x coordinate
  22964. * @param z z coordinate
  22965. * @returns the ground y position if (x, z) are outside the ground surface.
  22966. */
  22967. getHeightAtCoordinates(x: number, z: number): number;
  22968. /**
  22969. * Returns a normalized vector (Vector3) orthogonal to the ground
  22970. * at the ground coordinates (x, z) expressed in the World system.
  22971. * @param x x coordinate
  22972. * @param z z coordinate
  22973. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22974. */
  22975. getNormalAtCoordinates(x: number, z: number): Vector3;
  22976. /**
  22977. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22978. * at the ground coordinates (x, z) expressed in the World system.
  22979. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22980. * @param x x coordinate
  22981. * @param z z coordinate
  22982. * @param ref vector to store the result
  22983. * @returns the GroundMesh.
  22984. */
  22985. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22986. /**
  22987. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22988. * if the ground has been updated.
  22989. * This can be used in the render loop.
  22990. * @returns the GroundMesh.
  22991. */
  22992. updateCoordinateHeights(): GroundMesh;
  22993. private _getFacetAt;
  22994. private _initHeightQuads;
  22995. private _computeHeightQuads;
  22996. /**
  22997. * Serializes this ground mesh
  22998. * @param serializationObject object to write serialization to
  22999. */
  23000. serialize(serializationObject: any): void;
  23001. /**
  23002. * Parses a serialized ground mesh
  23003. * @param parsedMesh the serialized mesh
  23004. * @param scene the scene to create the ground mesh in
  23005. * @returns the created ground mesh
  23006. */
  23007. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23008. }
  23009. }
  23010. declare module BABYLON {
  23011. /**
  23012. * Interface for Physics-Joint data
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export interface PhysicsJointData {
  23016. /**
  23017. * The main pivot of the joint
  23018. */
  23019. mainPivot?: Vector3;
  23020. /**
  23021. * The connected pivot of the joint
  23022. */
  23023. connectedPivot?: Vector3;
  23024. /**
  23025. * The main axis of the joint
  23026. */
  23027. mainAxis?: Vector3;
  23028. /**
  23029. * The connected axis of the joint
  23030. */
  23031. connectedAxis?: Vector3;
  23032. /**
  23033. * The collision of the joint
  23034. */
  23035. collision?: boolean;
  23036. /**
  23037. * Native Oimo/Cannon/Energy data
  23038. */
  23039. nativeParams?: any;
  23040. }
  23041. /**
  23042. * This is a holder class for the physics joint created by the physics plugin
  23043. * It holds a set of functions to control the underlying joint
  23044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23045. */
  23046. export class PhysicsJoint {
  23047. /**
  23048. * The type of the physics joint
  23049. */
  23050. type: number;
  23051. /**
  23052. * The data for the physics joint
  23053. */
  23054. jointData: PhysicsJointData;
  23055. private _physicsJoint;
  23056. protected _physicsPlugin: IPhysicsEnginePlugin;
  23057. /**
  23058. * Initializes the physics joint
  23059. * @param type The type of the physics joint
  23060. * @param jointData The data for the physics joint
  23061. */
  23062. constructor(
  23063. /**
  23064. * The type of the physics joint
  23065. */
  23066. type: number,
  23067. /**
  23068. * The data for the physics joint
  23069. */
  23070. jointData: PhysicsJointData);
  23071. /**
  23072. * Gets the physics joint
  23073. */
  23074. get physicsJoint(): any;
  23075. /**
  23076. * Sets the physics joint
  23077. */
  23078. set physicsJoint(newJoint: any);
  23079. /**
  23080. * Sets the physics plugin
  23081. */
  23082. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23083. /**
  23084. * Execute a function that is physics-plugin specific.
  23085. * @param {Function} func the function that will be executed.
  23086. * It accepts two parameters: the physics world and the physics joint
  23087. */
  23088. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23089. /**
  23090. * Distance-Joint type
  23091. */
  23092. static DistanceJoint: number;
  23093. /**
  23094. * Hinge-Joint type
  23095. */
  23096. static HingeJoint: number;
  23097. /**
  23098. * Ball-and-Socket joint type
  23099. */
  23100. static BallAndSocketJoint: number;
  23101. /**
  23102. * Wheel-Joint type
  23103. */
  23104. static WheelJoint: number;
  23105. /**
  23106. * Slider-Joint type
  23107. */
  23108. static SliderJoint: number;
  23109. /**
  23110. * Prismatic-Joint type
  23111. */
  23112. static PrismaticJoint: number;
  23113. /**
  23114. * Universal-Joint type
  23115. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23116. */
  23117. static UniversalJoint: number;
  23118. /**
  23119. * Hinge-Joint 2 type
  23120. */
  23121. static Hinge2Joint: number;
  23122. /**
  23123. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23124. */
  23125. static PointToPointJoint: number;
  23126. /**
  23127. * Spring-Joint type
  23128. */
  23129. static SpringJoint: number;
  23130. /**
  23131. * Lock-Joint type
  23132. */
  23133. static LockJoint: number;
  23134. }
  23135. /**
  23136. * A class representing a physics distance joint
  23137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23138. */
  23139. export class DistanceJoint extends PhysicsJoint {
  23140. /**
  23141. *
  23142. * @param jointData The data for the Distance-Joint
  23143. */
  23144. constructor(jointData: DistanceJointData);
  23145. /**
  23146. * Update the predefined distance.
  23147. * @param maxDistance The maximum preferred distance
  23148. * @param minDistance The minimum preferred distance
  23149. */
  23150. updateDistance(maxDistance: number, minDistance?: number): void;
  23151. }
  23152. /**
  23153. * Represents a Motor-Enabled Joint
  23154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23155. */
  23156. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23157. /**
  23158. * Initializes the Motor-Enabled Joint
  23159. * @param type The type of the joint
  23160. * @param jointData The physica joint data for the joint
  23161. */
  23162. constructor(type: number, jointData: PhysicsJointData);
  23163. /**
  23164. * Set the motor values.
  23165. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23166. * @param force the force to apply
  23167. * @param maxForce max force for this motor.
  23168. */
  23169. setMotor(force?: number, maxForce?: number): void;
  23170. /**
  23171. * Set the motor's limits.
  23172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23173. * @param upperLimit The upper limit of the motor
  23174. * @param lowerLimit The lower limit of the motor
  23175. */
  23176. setLimit(upperLimit: number, lowerLimit?: number): void;
  23177. }
  23178. /**
  23179. * This class represents a single physics Hinge-Joint
  23180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23181. */
  23182. export class HingeJoint extends MotorEnabledJoint {
  23183. /**
  23184. * Initializes the Hinge-Joint
  23185. * @param jointData The joint data for the Hinge-Joint
  23186. */
  23187. constructor(jointData: PhysicsJointData);
  23188. /**
  23189. * Set the motor values.
  23190. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23191. * @param {number} force the force to apply
  23192. * @param {number} maxForce max force for this motor.
  23193. */
  23194. setMotor(force?: number, maxForce?: number): void;
  23195. /**
  23196. * Set the motor's limits.
  23197. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23198. * @param upperLimit The upper limit of the motor
  23199. * @param lowerLimit The lower limit of the motor
  23200. */
  23201. setLimit(upperLimit: number, lowerLimit?: number): void;
  23202. }
  23203. /**
  23204. * This class represents a dual hinge physics joint (same as wheel joint)
  23205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23206. */
  23207. export class Hinge2Joint extends MotorEnabledJoint {
  23208. /**
  23209. * Initializes the Hinge2-Joint
  23210. * @param jointData The joint data for the Hinge2-Joint
  23211. */
  23212. constructor(jointData: PhysicsJointData);
  23213. /**
  23214. * Set the motor values.
  23215. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23216. * @param {number} targetSpeed the speed the motor is to reach
  23217. * @param {number} maxForce max force for this motor.
  23218. * @param {motorIndex} the motor's index, 0 or 1.
  23219. */
  23220. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23221. /**
  23222. * Set the motor limits.
  23223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23224. * @param {number} upperLimit the upper limit
  23225. * @param {number} lowerLimit lower limit
  23226. * @param {motorIndex} the motor's index, 0 or 1.
  23227. */
  23228. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23229. }
  23230. /**
  23231. * Interface for a motor enabled joint
  23232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23233. */
  23234. export interface IMotorEnabledJoint {
  23235. /**
  23236. * Physics joint
  23237. */
  23238. physicsJoint: any;
  23239. /**
  23240. * Sets the motor of the motor-enabled joint
  23241. * @param force The force of the motor
  23242. * @param maxForce The maximum force of the motor
  23243. * @param motorIndex The index of the motor
  23244. */
  23245. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23246. /**
  23247. * Sets the limit of the motor
  23248. * @param upperLimit The upper limit of the motor
  23249. * @param lowerLimit The lower limit of the motor
  23250. * @param motorIndex The index of the motor
  23251. */
  23252. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23253. }
  23254. /**
  23255. * Joint data for a Distance-Joint
  23256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23257. */
  23258. export interface DistanceJointData extends PhysicsJointData {
  23259. /**
  23260. * Max distance the 2 joint objects can be apart
  23261. */
  23262. maxDistance: number;
  23263. }
  23264. /**
  23265. * Joint data from a spring joint
  23266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23267. */
  23268. export interface SpringJointData extends PhysicsJointData {
  23269. /**
  23270. * Length of the spring
  23271. */
  23272. length: number;
  23273. /**
  23274. * Stiffness of the spring
  23275. */
  23276. stiffness: number;
  23277. /**
  23278. * Damping of the spring
  23279. */
  23280. damping: number;
  23281. /** this callback will be called when applying the force to the impostors. */
  23282. forceApplicationCallback: () => void;
  23283. }
  23284. }
  23285. declare module BABYLON {
  23286. /**
  23287. * Holds the data for the raycast result
  23288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23289. */
  23290. export class PhysicsRaycastResult {
  23291. private _hasHit;
  23292. private _hitDistance;
  23293. private _hitNormalWorld;
  23294. private _hitPointWorld;
  23295. private _rayFromWorld;
  23296. private _rayToWorld;
  23297. /**
  23298. * Gets if there was a hit
  23299. */
  23300. get hasHit(): boolean;
  23301. /**
  23302. * Gets the distance from the hit
  23303. */
  23304. get hitDistance(): number;
  23305. /**
  23306. * Gets the hit normal/direction in the world
  23307. */
  23308. get hitNormalWorld(): Vector3;
  23309. /**
  23310. * Gets the hit point in the world
  23311. */
  23312. get hitPointWorld(): Vector3;
  23313. /**
  23314. * Gets the ray "start point" of the ray in the world
  23315. */
  23316. get rayFromWorld(): Vector3;
  23317. /**
  23318. * Gets the ray "end point" of the ray in the world
  23319. */
  23320. get rayToWorld(): Vector3;
  23321. /**
  23322. * Sets the hit data (normal & point in world space)
  23323. * @param hitNormalWorld defines the normal in world space
  23324. * @param hitPointWorld defines the point in world space
  23325. */
  23326. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23327. /**
  23328. * Sets the distance from the start point to the hit point
  23329. * @param distance
  23330. */
  23331. setHitDistance(distance: number): void;
  23332. /**
  23333. * Calculates the distance manually
  23334. */
  23335. calculateHitDistance(): void;
  23336. /**
  23337. * Resets all the values to default
  23338. * @param from The from point on world space
  23339. * @param to The to point on world space
  23340. */
  23341. reset(from?: Vector3, to?: Vector3): void;
  23342. }
  23343. /**
  23344. * Interface for the size containing width and height
  23345. */
  23346. interface IXYZ {
  23347. /**
  23348. * X
  23349. */
  23350. x: number;
  23351. /**
  23352. * Y
  23353. */
  23354. y: number;
  23355. /**
  23356. * Z
  23357. */
  23358. z: number;
  23359. }
  23360. }
  23361. declare module BABYLON {
  23362. /**
  23363. * Interface used to describe a physics joint
  23364. */
  23365. export interface PhysicsImpostorJoint {
  23366. /** Defines the main impostor to which the joint is linked */
  23367. mainImpostor: PhysicsImpostor;
  23368. /** Defines the impostor that is connected to the main impostor using this joint */
  23369. connectedImpostor: PhysicsImpostor;
  23370. /** Defines the joint itself */
  23371. joint: PhysicsJoint;
  23372. }
  23373. /** @hidden */
  23374. export interface IPhysicsEnginePlugin {
  23375. world: any;
  23376. name: string;
  23377. setGravity(gravity: Vector3): void;
  23378. setTimeStep(timeStep: number): void;
  23379. getTimeStep(): number;
  23380. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23381. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23382. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23383. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23384. removePhysicsBody(impostor: PhysicsImpostor): void;
  23385. generateJoint(joint: PhysicsImpostorJoint): void;
  23386. removeJoint(joint: PhysicsImpostorJoint): void;
  23387. isSupported(): boolean;
  23388. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23389. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23390. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23391. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23392. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23393. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23394. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23395. getBodyMass(impostor: PhysicsImpostor): number;
  23396. getBodyFriction(impostor: PhysicsImpostor): number;
  23397. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23398. getBodyRestitution(impostor: PhysicsImpostor): number;
  23399. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23400. getBodyPressure?(impostor: PhysicsImpostor): number;
  23401. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23402. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23403. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23404. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23405. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23406. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23407. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23408. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23409. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23410. sleepBody(impostor: PhysicsImpostor): void;
  23411. wakeUpBody(impostor: PhysicsImpostor): void;
  23412. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23413. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23414. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23415. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23416. getRadius(impostor: PhysicsImpostor): number;
  23417. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23419. dispose(): void;
  23420. }
  23421. /**
  23422. * Interface used to define a physics engine
  23423. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23424. */
  23425. export interface IPhysicsEngine {
  23426. /**
  23427. * Gets the gravity vector used by the simulation
  23428. */
  23429. gravity: Vector3;
  23430. /**
  23431. * Sets the gravity vector used by the simulation
  23432. * @param gravity defines the gravity vector to use
  23433. */
  23434. setGravity(gravity: Vector3): void;
  23435. /**
  23436. * Set the time step of the physics engine.
  23437. * Default is 1/60.
  23438. * To slow it down, enter 1/600 for example.
  23439. * To speed it up, 1/30
  23440. * @param newTimeStep the new timestep to apply to this world.
  23441. */
  23442. setTimeStep(newTimeStep: number): void;
  23443. /**
  23444. * Get the time step of the physics engine.
  23445. * @returns the current time step
  23446. */
  23447. getTimeStep(): number;
  23448. /**
  23449. * Set the sub time step of the physics engine.
  23450. * Default is 0 meaning there is no sub steps
  23451. * To increase physics resolution precision, set a small value (like 1 ms)
  23452. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23453. */
  23454. setSubTimeStep(subTimeStep: number): void;
  23455. /**
  23456. * Get the sub time step of the physics engine.
  23457. * @returns the current sub time step
  23458. */
  23459. getSubTimeStep(): number;
  23460. /**
  23461. * Release all resources
  23462. */
  23463. dispose(): void;
  23464. /**
  23465. * Gets the name of the current physics plugin
  23466. * @returns the name of the plugin
  23467. */
  23468. getPhysicsPluginName(): string;
  23469. /**
  23470. * Adding a new impostor for the impostor tracking.
  23471. * This will be done by the impostor itself.
  23472. * @param impostor the impostor to add
  23473. */
  23474. addImpostor(impostor: PhysicsImpostor): void;
  23475. /**
  23476. * Remove an impostor from the engine.
  23477. * This impostor and its mesh will not longer be updated by the physics engine.
  23478. * @param impostor the impostor to remove
  23479. */
  23480. removeImpostor(impostor: PhysicsImpostor): void;
  23481. /**
  23482. * Add a joint to the physics engine
  23483. * @param mainImpostor defines the main impostor to which the joint is added.
  23484. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23485. * @param joint defines the joint that will connect both impostors.
  23486. */
  23487. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23488. /**
  23489. * Removes a joint from the simulation
  23490. * @param mainImpostor defines the impostor used with the joint
  23491. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23492. * @param joint defines the joint to remove
  23493. */
  23494. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23495. /**
  23496. * Gets the current plugin used to run the simulation
  23497. * @returns current plugin
  23498. */
  23499. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23500. /**
  23501. * Gets the list of physic impostors
  23502. * @returns an array of PhysicsImpostor
  23503. */
  23504. getImpostors(): Array<PhysicsImpostor>;
  23505. /**
  23506. * Gets the impostor for a physics enabled object
  23507. * @param object defines the object impersonated by the impostor
  23508. * @returns the PhysicsImpostor or null if not found
  23509. */
  23510. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23511. /**
  23512. * Gets the impostor for a physics body object
  23513. * @param body defines physics body used by the impostor
  23514. * @returns the PhysicsImpostor or null if not found
  23515. */
  23516. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23517. /**
  23518. * Does a raycast in the physics world
  23519. * @param from when should the ray start?
  23520. * @param to when should the ray end?
  23521. * @returns PhysicsRaycastResult
  23522. */
  23523. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23524. /**
  23525. * Called by the scene. No need to call it.
  23526. * @param delta defines the timespam between frames
  23527. */
  23528. _step(delta: number): void;
  23529. }
  23530. }
  23531. declare module BABYLON {
  23532. /**
  23533. * The interface for the physics imposter parameters
  23534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23535. */
  23536. export interface PhysicsImpostorParameters {
  23537. /**
  23538. * The mass of the physics imposter
  23539. */
  23540. mass: number;
  23541. /**
  23542. * The friction of the physics imposter
  23543. */
  23544. friction?: number;
  23545. /**
  23546. * The coefficient of restitution of the physics imposter
  23547. */
  23548. restitution?: number;
  23549. /**
  23550. * The native options of the physics imposter
  23551. */
  23552. nativeOptions?: any;
  23553. /**
  23554. * Specifies if the parent should be ignored
  23555. */
  23556. ignoreParent?: boolean;
  23557. /**
  23558. * Specifies if bi-directional transformations should be disabled
  23559. */
  23560. disableBidirectionalTransformation?: boolean;
  23561. /**
  23562. * The pressure inside the physics imposter, soft object only
  23563. */
  23564. pressure?: number;
  23565. /**
  23566. * The stiffness the physics imposter, soft object only
  23567. */
  23568. stiffness?: number;
  23569. /**
  23570. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23571. */
  23572. velocityIterations?: number;
  23573. /**
  23574. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23575. */
  23576. positionIterations?: number;
  23577. /**
  23578. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23579. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23580. * Add to fix multiple points
  23581. */
  23582. fixedPoints?: number;
  23583. /**
  23584. * The collision margin around a soft object
  23585. */
  23586. margin?: number;
  23587. /**
  23588. * The collision margin around a soft object
  23589. */
  23590. damping?: number;
  23591. /**
  23592. * The path for a rope based on an extrusion
  23593. */
  23594. path?: any;
  23595. /**
  23596. * The shape of an extrusion used for a rope based on an extrusion
  23597. */
  23598. shape?: any;
  23599. }
  23600. /**
  23601. * Interface for a physics-enabled object
  23602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23603. */
  23604. export interface IPhysicsEnabledObject {
  23605. /**
  23606. * The position of the physics-enabled object
  23607. */
  23608. position: Vector3;
  23609. /**
  23610. * The rotation of the physics-enabled object
  23611. */
  23612. rotationQuaternion: Nullable<Quaternion>;
  23613. /**
  23614. * The scale of the physics-enabled object
  23615. */
  23616. scaling: Vector3;
  23617. /**
  23618. * The rotation of the physics-enabled object
  23619. */
  23620. rotation?: Vector3;
  23621. /**
  23622. * The parent of the physics-enabled object
  23623. */
  23624. parent?: any;
  23625. /**
  23626. * The bounding info of the physics-enabled object
  23627. * @returns The bounding info of the physics-enabled object
  23628. */
  23629. getBoundingInfo(): BoundingInfo;
  23630. /**
  23631. * Computes the world matrix
  23632. * @param force Specifies if the world matrix should be computed by force
  23633. * @returns A world matrix
  23634. */
  23635. computeWorldMatrix(force: boolean): Matrix;
  23636. /**
  23637. * Gets the world matrix
  23638. * @returns A world matrix
  23639. */
  23640. getWorldMatrix?(): Matrix;
  23641. /**
  23642. * Gets the child meshes
  23643. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23644. * @returns An array of abstract meshes
  23645. */
  23646. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23647. /**
  23648. * Gets the vertex data
  23649. * @param kind The type of vertex data
  23650. * @returns A nullable array of numbers, or a float32 array
  23651. */
  23652. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23653. /**
  23654. * Gets the indices from the mesh
  23655. * @returns A nullable array of index arrays
  23656. */
  23657. getIndices?(): Nullable<IndicesArray>;
  23658. /**
  23659. * Gets the scene from the mesh
  23660. * @returns the indices array or null
  23661. */
  23662. getScene?(): Scene;
  23663. /**
  23664. * Gets the absolute position from the mesh
  23665. * @returns the absolute position
  23666. */
  23667. getAbsolutePosition(): Vector3;
  23668. /**
  23669. * Gets the absolute pivot point from the mesh
  23670. * @returns the absolute pivot point
  23671. */
  23672. getAbsolutePivotPoint(): Vector3;
  23673. /**
  23674. * Rotates the mesh
  23675. * @param axis The axis of rotation
  23676. * @param amount The amount of rotation
  23677. * @param space The space of the rotation
  23678. * @returns The rotation transform node
  23679. */
  23680. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23681. /**
  23682. * Translates the mesh
  23683. * @param axis The axis of translation
  23684. * @param distance The distance of translation
  23685. * @param space The space of the translation
  23686. * @returns The transform node
  23687. */
  23688. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23689. /**
  23690. * Sets the absolute position of the mesh
  23691. * @param absolutePosition The absolute position of the mesh
  23692. * @returns The transform node
  23693. */
  23694. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23695. /**
  23696. * Gets the class name of the mesh
  23697. * @returns The class name
  23698. */
  23699. getClassName(): string;
  23700. }
  23701. /**
  23702. * Represents a physics imposter
  23703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23704. */
  23705. export class PhysicsImpostor {
  23706. /**
  23707. * The physics-enabled object used as the physics imposter
  23708. */
  23709. object: IPhysicsEnabledObject;
  23710. /**
  23711. * The type of the physics imposter
  23712. */
  23713. type: number;
  23714. private _options;
  23715. private _scene?;
  23716. /**
  23717. * The default object size of the imposter
  23718. */
  23719. static DEFAULT_OBJECT_SIZE: Vector3;
  23720. /**
  23721. * The identity quaternion of the imposter
  23722. */
  23723. static IDENTITY_QUATERNION: Quaternion;
  23724. /** @hidden */
  23725. _pluginData: any;
  23726. private _physicsEngine;
  23727. private _physicsBody;
  23728. private _bodyUpdateRequired;
  23729. private _onBeforePhysicsStepCallbacks;
  23730. private _onAfterPhysicsStepCallbacks;
  23731. /** @hidden */
  23732. _onPhysicsCollideCallbacks: Array<{
  23733. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23734. otherImpostors: Array<PhysicsImpostor>;
  23735. }>;
  23736. private _deltaPosition;
  23737. private _deltaRotation;
  23738. private _deltaRotationConjugated;
  23739. /** @hidden */
  23740. _isFromLine: boolean;
  23741. private _parent;
  23742. private _isDisposed;
  23743. private static _tmpVecs;
  23744. private static _tmpQuat;
  23745. /**
  23746. * Specifies if the physics imposter is disposed
  23747. */
  23748. get isDisposed(): boolean;
  23749. /**
  23750. * Gets the mass of the physics imposter
  23751. */
  23752. get mass(): number;
  23753. set mass(value: number);
  23754. /**
  23755. * Gets the coefficient of friction
  23756. */
  23757. get friction(): number;
  23758. /**
  23759. * Sets the coefficient of friction
  23760. */
  23761. set friction(value: number);
  23762. /**
  23763. * Gets the coefficient of restitution
  23764. */
  23765. get restitution(): number;
  23766. /**
  23767. * Sets the coefficient of restitution
  23768. */
  23769. set restitution(value: number);
  23770. /**
  23771. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23772. */
  23773. get pressure(): number;
  23774. /**
  23775. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23776. */
  23777. set pressure(value: number);
  23778. /**
  23779. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23780. */
  23781. get stiffness(): number;
  23782. /**
  23783. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23784. */
  23785. set stiffness(value: number);
  23786. /**
  23787. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23788. */
  23789. get velocityIterations(): number;
  23790. /**
  23791. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23792. */
  23793. set velocityIterations(value: number);
  23794. /**
  23795. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23796. */
  23797. get positionIterations(): number;
  23798. /**
  23799. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23800. */
  23801. set positionIterations(value: number);
  23802. /**
  23803. * The unique id of the physics imposter
  23804. * set by the physics engine when adding this impostor to the array
  23805. */
  23806. uniqueId: number;
  23807. /**
  23808. * @hidden
  23809. */
  23810. soft: boolean;
  23811. /**
  23812. * @hidden
  23813. */
  23814. segments: number;
  23815. private _joints;
  23816. /**
  23817. * Initializes the physics imposter
  23818. * @param object The physics-enabled object used as the physics imposter
  23819. * @param type The type of the physics imposter
  23820. * @param _options The options for the physics imposter
  23821. * @param _scene The Babylon scene
  23822. */
  23823. constructor(
  23824. /**
  23825. * The physics-enabled object used as the physics imposter
  23826. */
  23827. object: IPhysicsEnabledObject,
  23828. /**
  23829. * The type of the physics imposter
  23830. */
  23831. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23832. /**
  23833. * This function will completly initialize this impostor.
  23834. * It will create a new body - but only if this mesh has no parent.
  23835. * If it has, this impostor will not be used other than to define the impostor
  23836. * of the child mesh.
  23837. * @hidden
  23838. */
  23839. _init(): void;
  23840. private _getPhysicsParent;
  23841. /**
  23842. * Should a new body be generated.
  23843. * @returns boolean specifying if body initialization is required
  23844. */
  23845. isBodyInitRequired(): boolean;
  23846. /**
  23847. * Sets the updated scaling
  23848. * @param updated Specifies if the scaling is updated
  23849. */
  23850. setScalingUpdated(): void;
  23851. /**
  23852. * Force a regeneration of this or the parent's impostor's body.
  23853. * Use under cautious - This will remove all joints already implemented.
  23854. */
  23855. forceUpdate(): void;
  23856. /**
  23857. * Gets the body that holds this impostor. Either its own, or its parent.
  23858. */
  23859. get physicsBody(): any;
  23860. /**
  23861. * Get the parent of the physics imposter
  23862. * @returns Physics imposter or null
  23863. */
  23864. get parent(): Nullable<PhysicsImpostor>;
  23865. /**
  23866. * Sets the parent of the physics imposter
  23867. */
  23868. set parent(value: Nullable<PhysicsImpostor>);
  23869. /**
  23870. * Set the physics body. Used mainly by the physics engine/plugin
  23871. */
  23872. set physicsBody(physicsBody: any);
  23873. /**
  23874. * Resets the update flags
  23875. */
  23876. resetUpdateFlags(): void;
  23877. /**
  23878. * Gets the object extend size
  23879. * @returns the object extend size
  23880. */
  23881. getObjectExtendSize(): Vector3;
  23882. /**
  23883. * Gets the object center
  23884. * @returns The object center
  23885. */
  23886. getObjectCenter(): Vector3;
  23887. /**
  23888. * Get a specific parameter from the options parameters
  23889. * @param paramName The object parameter name
  23890. * @returns The object parameter
  23891. */
  23892. getParam(paramName: string): any;
  23893. /**
  23894. * Sets a specific parameter in the options given to the physics plugin
  23895. * @param paramName The parameter name
  23896. * @param value The value of the parameter
  23897. */
  23898. setParam(paramName: string, value: number): void;
  23899. /**
  23900. * Specifically change the body's mass option. Won't recreate the physics body object
  23901. * @param mass The mass of the physics imposter
  23902. */
  23903. setMass(mass: number): void;
  23904. /**
  23905. * Gets the linear velocity
  23906. * @returns linear velocity or null
  23907. */
  23908. getLinearVelocity(): Nullable<Vector3>;
  23909. /**
  23910. * Sets the linear velocity
  23911. * @param velocity linear velocity or null
  23912. */
  23913. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23914. /**
  23915. * Gets the angular velocity
  23916. * @returns angular velocity or null
  23917. */
  23918. getAngularVelocity(): Nullable<Vector3>;
  23919. /**
  23920. * Sets the angular velocity
  23921. * @param velocity The velocity or null
  23922. */
  23923. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23924. /**
  23925. * Execute a function with the physics plugin native code
  23926. * Provide a function the will have two variables - the world object and the physics body object
  23927. * @param func The function to execute with the physics plugin native code
  23928. */
  23929. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23930. /**
  23931. * Register a function that will be executed before the physics world is stepping forward
  23932. * @param func The function to execute before the physics world is stepped forward
  23933. */
  23934. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23935. /**
  23936. * Unregister a function that will be executed before the physics world is stepping forward
  23937. * @param func The function to execute before the physics world is stepped forward
  23938. */
  23939. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23940. /**
  23941. * Register a function that will be executed after the physics step
  23942. * @param func The function to execute after physics step
  23943. */
  23944. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23945. /**
  23946. * Unregisters a function that will be executed after the physics step
  23947. * @param func The function to execute after physics step
  23948. */
  23949. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23950. /**
  23951. * register a function that will be executed when this impostor collides against a different body
  23952. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23953. * @param func Callback that is executed on collision
  23954. */
  23955. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23956. /**
  23957. * Unregisters the physics imposter on contact
  23958. * @param collideAgainst The physics object to collide against
  23959. * @param func Callback to execute on collision
  23960. */
  23961. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23962. private _tmpQuat;
  23963. private _tmpQuat2;
  23964. /**
  23965. * Get the parent rotation
  23966. * @returns The parent rotation
  23967. */
  23968. getParentsRotation(): Quaternion;
  23969. /**
  23970. * this function is executed by the physics engine.
  23971. */
  23972. beforeStep: () => void;
  23973. /**
  23974. * this function is executed by the physics engine
  23975. */
  23976. afterStep: () => void;
  23977. /**
  23978. * Legacy collision detection event support
  23979. */
  23980. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23981. /**
  23982. * event and body object due to cannon's event-based architecture.
  23983. */
  23984. onCollide: (e: {
  23985. body: any;
  23986. }) => void;
  23987. /**
  23988. * Apply a force
  23989. * @param force The force to apply
  23990. * @param contactPoint The contact point for the force
  23991. * @returns The physics imposter
  23992. */
  23993. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23994. /**
  23995. * Apply an impulse
  23996. * @param force The impulse force
  23997. * @param contactPoint The contact point for the impulse force
  23998. * @returns The physics imposter
  23999. */
  24000. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24001. /**
  24002. * A help function to create a joint
  24003. * @param otherImpostor A physics imposter used to create a joint
  24004. * @param jointType The type of joint
  24005. * @param jointData The data for the joint
  24006. * @returns The physics imposter
  24007. */
  24008. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24009. /**
  24010. * Add a joint to this impostor with a different impostor
  24011. * @param otherImpostor A physics imposter used to add a joint
  24012. * @param joint The joint to add
  24013. * @returns The physics imposter
  24014. */
  24015. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24016. /**
  24017. * Add an anchor to a cloth impostor
  24018. * @param otherImpostor rigid impostor to anchor to
  24019. * @param width ratio across width from 0 to 1
  24020. * @param height ratio up height from 0 to 1
  24021. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24022. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24023. * @returns impostor the soft imposter
  24024. */
  24025. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24026. /**
  24027. * Add a hook to a rope impostor
  24028. * @param otherImpostor rigid impostor to anchor to
  24029. * @param length ratio across rope from 0 to 1
  24030. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24031. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24032. * @returns impostor the rope imposter
  24033. */
  24034. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24035. /**
  24036. * Will keep this body still, in a sleep mode.
  24037. * @returns the physics imposter
  24038. */
  24039. sleep(): PhysicsImpostor;
  24040. /**
  24041. * Wake the body up.
  24042. * @returns The physics imposter
  24043. */
  24044. wakeUp(): PhysicsImpostor;
  24045. /**
  24046. * Clones the physics imposter
  24047. * @param newObject The physics imposter clones to this physics-enabled object
  24048. * @returns A nullable physics imposter
  24049. */
  24050. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24051. /**
  24052. * Disposes the physics imposter
  24053. */
  24054. dispose(): void;
  24055. /**
  24056. * Sets the delta position
  24057. * @param position The delta position amount
  24058. */
  24059. setDeltaPosition(position: Vector3): void;
  24060. /**
  24061. * Sets the delta rotation
  24062. * @param rotation The delta rotation amount
  24063. */
  24064. setDeltaRotation(rotation: Quaternion): void;
  24065. /**
  24066. * Gets the box size of the physics imposter and stores the result in the input parameter
  24067. * @param result Stores the box size
  24068. * @returns The physics imposter
  24069. */
  24070. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24071. /**
  24072. * Gets the radius of the physics imposter
  24073. * @returns Radius of the physics imposter
  24074. */
  24075. getRadius(): number;
  24076. /**
  24077. * Sync a bone with this impostor
  24078. * @param bone The bone to sync to the impostor.
  24079. * @param boneMesh The mesh that the bone is influencing.
  24080. * @param jointPivot The pivot of the joint / bone in local space.
  24081. * @param distToJoint Optional distance from the impostor to the joint.
  24082. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24083. */
  24084. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24085. /**
  24086. * Sync impostor to a bone
  24087. * @param bone The bone that the impostor will be synced to.
  24088. * @param boneMesh The mesh that the bone is influencing.
  24089. * @param jointPivot The pivot of the joint / bone in local space.
  24090. * @param distToJoint Optional distance from the impostor to the joint.
  24091. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24092. * @param boneAxis Optional vector3 axis the bone is aligned with
  24093. */
  24094. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24095. /**
  24096. * No-Imposter type
  24097. */
  24098. static NoImpostor: number;
  24099. /**
  24100. * Sphere-Imposter type
  24101. */
  24102. static SphereImpostor: number;
  24103. /**
  24104. * Box-Imposter type
  24105. */
  24106. static BoxImpostor: number;
  24107. /**
  24108. * Plane-Imposter type
  24109. */
  24110. static PlaneImpostor: number;
  24111. /**
  24112. * Mesh-imposter type
  24113. */
  24114. static MeshImpostor: number;
  24115. /**
  24116. * Capsule-Impostor type (Ammo.js plugin only)
  24117. */
  24118. static CapsuleImpostor: number;
  24119. /**
  24120. * Cylinder-Imposter type
  24121. */
  24122. static CylinderImpostor: number;
  24123. /**
  24124. * Particle-Imposter type
  24125. */
  24126. static ParticleImpostor: number;
  24127. /**
  24128. * Heightmap-Imposter type
  24129. */
  24130. static HeightmapImpostor: number;
  24131. /**
  24132. * ConvexHull-Impostor type (Ammo.js plugin only)
  24133. */
  24134. static ConvexHullImpostor: number;
  24135. /**
  24136. * Custom-Imposter type (Ammo.js plugin only)
  24137. */
  24138. static CustomImpostor: number;
  24139. /**
  24140. * Rope-Imposter type
  24141. */
  24142. static RopeImpostor: number;
  24143. /**
  24144. * Cloth-Imposter type
  24145. */
  24146. static ClothImpostor: number;
  24147. /**
  24148. * Softbody-Imposter type
  24149. */
  24150. static SoftbodyImpostor: number;
  24151. }
  24152. }
  24153. declare module BABYLON {
  24154. /**
  24155. * @hidden
  24156. **/
  24157. export class _CreationDataStorage {
  24158. closePath?: boolean;
  24159. closeArray?: boolean;
  24160. idx: number[];
  24161. dashSize: number;
  24162. gapSize: number;
  24163. path3D: Path3D;
  24164. pathArray: Vector3[][];
  24165. arc: number;
  24166. radius: number;
  24167. cap: number;
  24168. tessellation: number;
  24169. }
  24170. /**
  24171. * @hidden
  24172. **/
  24173. class _InstanceDataStorage {
  24174. visibleInstances: any;
  24175. batchCache: _InstancesBatch;
  24176. instancesBufferSize: number;
  24177. instancesBuffer: Nullable<Buffer>;
  24178. instancesData: Float32Array;
  24179. overridenInstanceCount: number;
  24180. isFrozen: boolean;
  24181. previousBatch: Nullable<_InstancesBatch>;
  24182. hardwareInstancedRendering: boolean;
  24183. sideOrientation: number;
  24184. manualUpdate: boolean;
  24185. }
  24186. /**
  24187. * @hidden
  24188. **/
  24189. export class _InstancesBatch {
  24190. mustReturn: boolean;
  24191. visibleInstances: Nullable<InstancedMesh[]>[];
  24192. renderSelf: boolean[];
  24193. hardwareInstancedRendering: boolean[];
  24194. }
  24195. /**
  24196. * Class used to represent renderable models
  24197. */
  24198. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24199. /**
  24200. * Mesh side orientation : usually the external or front surface
  24201. */
  24202. static readonly FRONTSIDE: number;
  24203. /**
  24204. * Mesh side orientation : usually the internal or back surface
  24205. */
  24206. static readonly BACKSIDE: number;
  24207. /**
  24208. * Mesh side orientation : both internal and external or front and back surfaces
  24209. */
  24210. static readonly DOUBLESIDE: number;
  24211. /**
  24212. * Mesh side orientation : by default, `FRONTSIDE`
  24213. */
  24214. static readonly DEFAULTSIDE: number;
  24215. /**
  24216. * Mesh cap setting : no cap
  24217. */
  24218. static readonly NO_CAP: number;
  24219. /**
  24220. * Mesh cap setting : one cap at the beginning of the mesh
  24221. */
  24222. static readonly CAP_START: number;
  24223. /**
  24224. * Mesh cap setting : one cap at the end of the mesh
  24225. */
  24226. static readonly CAP_END: number;
  24227. /**
  24228. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24229. */
  24230. static readonly CAP_ALL: number;
  24231. /**
  24232. * Mesh pattern setting : no flip or rotate
  24233. */
  24234. static readonly NO_FLIP: number;
  24235. /**
  24236. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24237. */
  24238. static readonly FLIP_TILE: number;
  24239. /**
  24240. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24241. */
  24242. static readonly ROTATE_TILE: number;
  24243. /**
  24244. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24245. */
  24246. static readonly FLIP_ROW: number;
  24247. /**
  24248. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24249. */
  24250. static readonly ROTATE_ROW: number;
  24251. /**
  24252. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24253. */
  24254. static readonly FLIP_N_ROTATE_TILE: number;
  24255. /**
  24256. * Mesh pattern setting : rotate pattern and rotate
  24257. */
  24258. static readonly FLIP_N_ROTATE_ROW: number;
  24259. /**
  24260. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24261. */
  24262. static readonly CENTER: number;
  24263. /**
  24264. * Mesh tile positioning : part tiles on left
  24265. */
  24266. static readonly LEFT: number;
  24267. /**
  24268. * Mesh tile positioning : part tiles on right
  24269. */
  24270. static readonly RIGHT: number;
  24271. /**
  24272. * Mesh tile positioning : part tiles on top
  24273. */
  24274. static readonly TOP: number;
  24275. /**
  24276. * Mesh tile positioning : part tiles on bottom
  24277. */
  24278. static readonly BOTTOM: number;
  24279. /**
  24280. * Gets the default side orientation.
  24281. * @param orientation the orientation to value to attempt to get
  24282. * @returns the default orientation
  24283. * @hidden
  24284. */
  24285. static _GetDefaultSideOrientation(orientation?: number): number;
  24286. private _internalMeshDataInfo;
  24287. /**
  24288. * An event triggered before rendering the mesh
  24289. */
  24290. get onBeforeRenderObservable(): Observable<Mesh>;
  24291. /**
  24292. * An event triggered before binding the mesh
  24293. */
  24294. get onBeforeBindObservable(): Observable<Mesh>;
  24295. /**
  24296. * An event triggered after rendering the mesh
  24297. */
  24298. get onAfterRenderObservable(): Observable<Mesh>;
  24299. /**
  24300. * An event triggered before drawing the mesh
  24301. */
  24302. get onBeforeDrawObservable(): Observable<Mesh>;
  24303. private _onBeforeDrawObserver;
  24304. /**
  24305. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24306. */
  24307. set onBeforeDraw(callback: () => void);
  24308. get hasInstances(): boolean;
  24309. /**
  24310. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24311. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24312. */
  24313. delayLoadState: number;
  24314. /**
  24315. * Gets the list of instances created from this mesh
  24316. * it is not supposed to be modified manually.
  24317. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24318. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24319. */
  24320. instances: InstancedMesh[];
  24321. /**
  24322. * Gets the file containing delay loading data for this mesh
  24323. */
  24324. delayLoadingFile: string;
  24325. /** @hidden */
  24326. _binaryInfo: any;
  24327. /**
  24328. * User defined function used to change how LOD level selection is done
  24329. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24330. */
  24331. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24332. /**
  24333. * Gets or sets the morph target manager
  24334. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24335. */
  24336. get morphTargetManager(): Nullable<MorphTargetManager>;
  24337. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24338. /** @hidden */
  24339. _creationDataStorage: Nullable<_CreationDataStorage>;
  24340. /** @hidden */
  24341. _geometry: Nullable<Geometry>;
  24342. /** @hidden */
  24343. _delayInfo: Array<string>;
  24344. /** @hidden */
  24345. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24346. /** @hidden */
  24347. _instanceDataStorage: _InstanceDataStorage;
  24348. private _effectiveMaterial;
  24349. /** @hidden */
  24350. _shouldGenerateFlatShading: boolean;
  24351. /** @hidden */
  24352. _originalBuilderSideOrientation: number;
  24353. /**
  24354. * Use this property to change the original side orientation defined at construction time
  24355. */
  24356. overrideMaterialSideOrientation: Nullable<number>;
  24357. /**
  24358. * Gets the source mesh (the one used to clone this one from)
  24359. */
  24360. get source(): Nullable<Mesh>;
  24361. /**
  24362. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24363. */
  24364. get isUnIndexed(): boolean;
  24365. set isUnIndexed(value: boolean);
  24366. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24367. get worldMatrixInstancedBuffer(): Float32Array;
  24368. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24369. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24370. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24371. /**
  24372. * @constructor
  24373. * @param name The value used by scene.getMeshByName() to do a lookup.
  24374. * @param scene The scene to add this mesh to.
  24375. * @param parent The parent of this mesh, if it has one
  24376. * @param source An optional Mesh from which geometry is shared, cloned.
  24377. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24378. * When false, achieved by calling a clone(), also passing False.
  24379. * This will make creation of children, recursive.
  24380. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24381. */
  24382. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24383. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24384. doNotInstantiate: boolean;
  24385. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24386. /**
  24387. * Gets the class name
  24388. * @returns the string "Mesh".
  24389. */
  24390. getClassName(): string;
  24391. /** @hidden */
  24392. get _isMesh(): boolean;
  24393. /**
  24394. * Returns a description of this mesh
  24395. * @param fullDetails define if full details about this mesh must be used
  24396. * @returns a descriptive string representing this mesh
  24397. */
  24398. toString(fullDetails?: boolean): string;
  24399. /** @hidden */
  24400. _unBindEffect(): void;
  24401. /**
  24402. * Gets a boolean indicating if this mesh has LOD
  24403. */
  24404. get hasLODLevels(): boolean;
  24405. /**
  24406. * Gets the list of MeshLODLevel associated with the current mesh
  24407. * @returns an array of MeshLODLevel
  24408. */
  24409. getLODLevels(): MeshLODLevel[];
  24410. private _sortLODLevels;
  24411. /**
  24412. * Add a mesh as LOD level triggered at the given distance.
  24413. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24414. * @param distance The distance from the center of the object to show this level
  24415. * @param mesh The mesh to be added as LOD level (can be null)
  24416. * @return This mesh (for chaining)
  24417. */
  24418. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24419. /**
  24420. * Returns the LOD level mesh at the passed distance or null if not found.
  24421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24422. * @param distance The distance from the center of the object to show this level
  24423. * @returns a Mesh or `null`
  24424. */
  24425. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24426. /**
  24427. * Remove a mesh from the LOD array
  24428. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24429. * @param mesh defines the mesh to be removed
  24430. * @return This mesh (for chaining)
  24431. */
  24432. removeLODLevel(mesh: Mesh): Mesh;
  24433. /**
  24434. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24435. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24436. * @param camera defines the camera to use to compute distance
  24437. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24438. * @return This mesh (for chaining)
  24439. */
  24440. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24441. /**
  24442. * Gets the mesh internal Geometry object
  24443. */
  24444. get geometry(): Nullable<Geometry>;
  24445. /**
  24446. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24447. * @returns the total number of vertices
  24448. */
  24449. getTotalVertices(): number;
  24450. /**
  24451. * Returns the content of an associated vertex buffer
  24452. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24453. * - VertexBuffer.PositionKind
  24454. * - VertexBuffer.UVKind
  24455. * - VertexBuffer.UV2Kind
  24456. * - VertexBuffer.UV3Kind
  24457. * - VertexBuffer.UV4Kind
  24458. * - VertexBuffer.UV5Kind
  24459. * - VertexBuffer.UV6Kind
  24460. * - VertexBuffer.ColorKind
  24461. * - VertexBuffer.MatricesIndicesKind
  24462. * - VertexBuffer.MatricesIndicesExtraKind
  24463. * - VertexBuffer.MatricesWeightsKind
  24464. * - VertexBuffer.MatricesWeightsExtraKind
  24465. * @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
  24466. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24467. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24468. */
  24469. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24470. /**
  24471. * Returns the mesh VertexBuffer object from the requested `kind`
  24472. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24473. * - VertexBuffer.PositionKind
  24474. * - VertexBuffer.NormalKind
  24475. * - VertexBuffer.UVKind
  24476. * - VertexBuffer.UV2Kind
  24477. * - VertexBuffer.UV3Kind
  24478. * - VertexBuffer.UV4Kind
  24479. * - VertexBuffer.UV5Kind
  24480. * - VertexBuffer.UV6Kind
  24481. * - VertexBuffer.ColorKind
  24482. * - VertexBuffer.MatricesIndicesKind
  24483. * - VertexBuffer.MatricesIndicesExtraKind
  24484. * - VertexBuffer.MatricesWeightsKind
  24485. * - VertexBuffer.MatricesWeightsExtraKind
  24486. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24487. */
  24488. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24489. /**
  24490. * Tests if a specific vertex buffer is associated with this mesh
  24491. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24492. * - VertexBuffer.PositionKind
  24493. * - VertexBuffer.NormalKind
  24494. * - VertexBuffer.UVKind
  24495. * - VertexBuffer.UV2Kind
  24496. * - VertexBuffer.UV3Kind
  24497. * - VertexBuffer.UV4Kind
  24498. * - VertexBuffer.UV5Kind
  24499. * - VertexBuffer.UV6Kind
  24500. * - VertexBuffer.ColorKind
  24501. * - VertexBuffer.MatricesIndicesKind
  24502. * - VertexBuffer.MatricesIndicesExtraKind
  24503. * - VertexBuffer.MatricesWeightsKind
  24504. * - VertexBuffer.MatricesWeightsExtraKind
  24505. * @returns a boolean
  24506. */
  24507. isVerticesDataPresent(kind: string): boolean;
  24508. /**
  24509. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24510. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24511. * - VertexBuffer.PositionKind
  24512. * - VertexBuffer.UVKind
  24513. * - VertexBuffer.UV2Kind
  24514. * - VertexBuffer.UV3Kind
  24515. * - VertexBuffer.UV4Kind
  24516. * - VertexBuffer.UV5Kind
  24517. * - VertexBuffer.UV6Kind
  24518. * - VertexBuffer.ColorKind
  24519. * - VertexBuffer.MatricesIndicesKind
  24520. * - VertexBuffer.MatricesIndicesExtraKind
  24521. * - VertexBuffer.MatricesWeightsKind
  24522. * - VertexBuffer.MatricesWeightsExtraKind
  24523. * @returns a boolean
  24524. */
  24525. isVertexBufferUpdatable(kind: string): boolean;
  24526. /**
  24527. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24528. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24529. * - VertexBuffer.PositionKind
  24530. * - VertexBuffer.NormalKind
  24531. * - VertexBuffer.UVKind
  24532. * - VertexBuffer.UV2Kind
  24533. * - VertexBuffer.UV3Kind
  24534. * - VertexBuffer.UV4Kind
  24535. * - VertexBuffer.UV5Kind
  24536. * - VertexBuffer.UV6Kind
  24537. * - VertexBuffer.ColorKind
  24538. * - VertexBuffer.MatricesIndicesKind
  24539. * - VertexBuffer.MatricesIndicesExtraKind
  24540. * - VertexBuffer.MatricesWeightsKind
  24541. * - VertexBuffer.MatricesWeightsExtraKind
  24542. * @returns an array of strings
  24543. */
  24544. getVerticesDataKinds(): string[];
  24545. /**
  24546. * Returns a positive integer : the total number of indices in this mesh geometry.
  24547. * @returns the numner of indices or zero if the mesh has no geometry.
  24548. */
  24549. getTotalIndices(): number;
  24550. /**
  24551. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24552. * @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.
  24553. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24554. * @returns the indices array or an empty array if the mesh has no geometry
  24555. */
  24556. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24557. get isBlocked(): boolean;
  24558. /**
  24559. * Determine if the current mesh is ready to be rendered
  24560. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24561. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24562. * @returns true if all associated assets are ready (material, textures, shaders)
  24563. */
  24564. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24565. /**
  24566. * 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.
  24567. */
  24568. get areNormalsFrozen(): boolean;
  24569. /**
  24570. * 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.
  24571. * @returns the current mesh
  24572. */
  24573. freezeNormals(): Mesh;
  24574. /**
  24575. * 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
  24576. * @returns the current mesh
  24577. */
  24578. unfreezeNormals(): Mesh;
  24579. /**
  24580. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24581. */
  24582. set overridenInstanceCount(count: number);
  24583. /** @hidden */
  24584. _preActivate(): Mesh;
  24585. /** @hidden */
  24586. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24587. /** @hidden */
  24588. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24589. /**
  24590. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24591. * This means the mesh underlying bounding box and sphere are recomputed.
  24592. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24593. * @returns the current mesh
  24594. */
  24595. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24596. /** @hidden */
  24597. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24598. /**
  24599. * This function will subdivide the mesh into multiple submeshes
  24600. * @param count defines the expected number of submeshes
  24601. */
  24602. subdivide(count: number): void;
  24603. /**
  24604. * Copy a FloatArray into a specific associated vertex buffer
  24605. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24606. * - VertexBuffer.PositionKind
  24607. * - VertexBuffer.UVKind
  24608. * - VertexBuffer.UV2Kind
  24609. * - VertexBuffer.UV3Kind
  24610. * - VertexBuffer.UV4Kind
  24611. * - VertexBuffer.UV5Kind
  24612. * - VertexBuffer.UV6Kind
  24613. * - VertexBuffer.ColorKind
  24614. * - VertexBuffer.MatricesIndicesKind
  24615. * - VertexBuffer.MatricesIndicesExtraKind
  24616. * - VertexBuffer.MatricesWeightsKind
  24617. * - VertexBuffer.MatricesWeightsExtraKind
  24618. * @param data defines the data source
  24619. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24620. * @param stride defines the data stride size (can be null)
  24621. * @returns the current mesh
  24622. */
  24623. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24624. /**
  24625. * Delete a vertex buffer associated with this mesh
  24626. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24627. * - VertexBuffer.PositionKind
  24628. * - VertexBuffer.UVKind
  24629. * - VertexBuffer.UV2Kind
  24630. * - VertexBuffer.UV3Kind
  24631. * - VertexBuffer.UV4Kind
  24632. * - VertexBuffer.UV5Kind
  24633. * - VertexBuffer.UV6Kind
  24634. * - VertexBuffer.ColorKind
  24635. * - VertexBuffer.MatricesIndicesKind
  24636. * - VertexBuffer.MatricesIndicesExtraKind
  24637. * - VertexBuffer.MatricesWeightsKind
  24638. * - VertexBuffer.MatricesWeightsExtraKind
  24639. */
  24640. removeVerticesData(kind: string): void;
  24641. /**
  24642. * Flags an associated vertex buffer as updatable
  24643. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24644. * - VertexBuffer.PositionKind
  24645. * - VertexBuffer.UVKind
  24646. * - VertexBuffer.UV2Kind
  24647. * - VertexBuffer.UV3Kind
  24648. * - VertexBuffer.UV4Kind
  24649. * - VertexBuffer.UV5Kind
  24650. * - VertexBuffer.UV6Kind
  24651. * - VertexBuffer.ColorKind
  24652. * - VertexBuffer.MatricesIndicesKind
  24653. * - VertexBuffer.MatricesIndicesExtraKind
  24654. * - VertexBuffer.MatricesWeightsKind
  24655. * - VertexBuffer.MatricesWeightsExtraKind
  24656. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24657. */
  24658. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24659. /**
  24660. * Sets the mesh global Vertex Buffer
  24661. * @param buffer defines the buffer to use
  24662. * @returns the current mesh
  24663. */
  24664. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24665. /**
  24666. * Update a specific associated vertex buffer
  24667. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24668. * - VertexBuffer.PositionKind
  24669. * - VertexBuffer.UVKind
  24670. * - VertexBuffer.UV2Kind
  24671. * - VertexBuffer.UV3Kind
  24672. * - VertexBuffer.UV4Kind
  24673. * - VertexBuffer.UV5Kind
  24674. * - VertexBuffer.UV6Kind
  24675. * - VertexBuffer.ColorKind
  24676. * - VertexBuffer.MatricesIndicesKind
  24677. * - VertexBuffer.MatricesIndicesExtraKind
  24678. * - VertexBuffer.MatricesWeightsKind
  24679. * - VertexBuffer.MatricesWeightsExtraKind
  24680. * @param data defines the data source
  24681. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24682. * @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)
  24683. * @returns the current mesh
  24684. */
  24685. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24686. /**
  24687. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24688. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24689. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24690. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24691. * @returns the current mesh
  24692. */
  24693. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24694. /**
  24695. * Creates a un-shared specific occurence of the geometry for the mesh.
  24696. * @returns the current mesh
  24697. */
  24698. makeGeometryUnique(): Mesh;
  24699. /**
  24700. * Set the index buffer of this mesh
  24701. * @param indices defines the source data
  24702. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24703. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24704. * @returns the current mesh
  24705. */
  24706. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24707. /**
  24708. * Update the current index buffer
  24709. * @param indices defines the source data
  24710. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24711. * @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)
  24712. * @returns the current mesh
  24713. */
  24714. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24715. /**
  24716. * Invert the geometry to move from a right handed system to a left handed one.
  24717. * @returns the current mesh
  24718. */
  24719. toLeftHanded(): Mesh;
  24720. /** @hidden */
  24721. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24722. /** @hidden */
  24723. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24724. /**
  24725. * Registers for this mesh a javascript function called just before the rendering process
  24726. * @param func defines the function to call before rendering this mesh
  24727. * @returns the current mesh
  24728. */
  24729. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24730. /**
  24731. * Disposes a previously registered javascript function called before the rendering
  24732. * @param func defines the function to remove
  24733. * @returns the current mesh
  24734. */
  24735. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24736. /**
  24737. * Registers for this mesh a javascript function called just after the rendering is complete
  24738. * @param func defines the function to call after rendering this mesh
  24739. * @returns the current mesh
  24740. */
  24741. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24742. /**
  24743. * Disposes a previously registered javascript function called after the rendering.
  24744. * @param func defines the function to remove
  24745. * @returns the current mesh
  24746. */
  24747. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24748. /** @hidden */
  24749. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24750. /** @hidden */
  24751. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24752. /** @hidden */
  24753. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24754. /** @hidden */
  24755. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24756. /** @hidden */
  24757. _rebuild(): void;
  24758. /** @hidden */
  24759. _freeze(): void;
  24760. /** @hidden */
  24761. _unFreeze(): void;
  24762. /**
  24763. * 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
  24764. * @param subMesh defines the subMesh to render
  24765. * @param enableAlphaMode defines if alpha mode can be changed
  24766. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24767. * @returns the current mesh
  24768. */
  24769. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24770. private _onBeforeDraw;
  24771. /**
  24772. * Renormalize the mesh and patch it up if there are no weights
  24773. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24774. * However in the case of zero weights then we set just a single influence to 1.
  24775. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24776. */
  24777. cleanMatrixWeights(): void;
  24778. private normalizeSkinFourWeights;
  24779. private normalizeSkinWeightsAndExtra;
  24780. /**
  24781. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24782. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24783. * the user know there was an issue with importing the mesh
  24784. * @returns a validation object with skinned, valid and report string
  24785. */
  24786. validateSkinning(): {
  24787. skinned: boolean;
  24788. valid: boolean;
  24789. report: string;
  24790. };
  24791. /** @hidden */
  24792. _checkDelayState(): Mesh;
  24793. private _queueLoad;
  24794. /**
  24795. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24796. * A mesh is in the frustum if its bounding box intersects the frustum
  24797. * @param frustumPlanes defines the frustum to test
  24798. * @returns true if the mesh is in the frustum planes
  24799. */
  24800. isInFrustum(frustumPlanes: Plane[]): boolean;
  24801. /**
  24802. * Sets the mesh material by the material or multiMaterial `id` property
  24803. * @param id is a string identifying the material or the multiMaterial
  24804. * @returns the current mesh
  24805. */
  24806. setMaterialByID(id: string): Mesh;
  24807. /**
  24808. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24809. * @returns an array of IAnimatable
  24810. */
  24811. getAnimatables(): IAnimatable[];
  24812. /**
  24813. * Modifies the mesh geometry according to the passed transformation matrix.
  24814. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24815. * The mesh normals are modified using the same transformation.
  24816. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24817. * @param transform defines the transform matrix to use
  24818. * @see http://doc.babylonjs.com/resources/baking_transformations
  24819. * @returns the current mesh
  24820. */
  24821. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24822. /**
  24823. * Modifies the mesh geometry according to its own current World Matrix.
  24824. * The mesh World Matrix is then reset.
  24825. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24826. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24827. * @see http://doc.babylonjs.com/resources/baking_transformations
  24828. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24829. * @returns the current mesh
  24830. */
  24831. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24832. /** @hidden */
  24833. get _positions(): Nullable<Vector3[]>;
  24834. /** @hidden */
  24835. _resetPointsArrayCache(): Mesh;
  24836. /** @hidden */
  24837. _generatePointsArray(): boolean;
  24838. /**
  24839. * Returns a new Mesh object generated from the current mesh properties.
  24840. * This method must not get confused with createInstance()
  24841. * @param name is a string, the name given to the new mesh
  24842. * @param newParent can be any Node object (default `null`)
  24843. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24844. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24845. * @returns a new mesh
  24846. */
  24847. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24848. /**
  24849. * Releases resources associated with this mesh.
  24850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24852. */
  24853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24854. /** @hidden */
  24855. _disposeInstanceSpecificData(): void;
  24856. /**
  24857. * Modifies the mesh geometry according to a displacement map.
  24858. * 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.
  24859. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24860. * @param url is a string, the URL from the image file is to be downloaded.
  24861. * @param minHeight is the lower limit of the displacement.
  24862. * @param maxHeight is the upper limit of the displacement.
  24863. * @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.
  24864. * @param uvOffset is an optional vector2 used to offset UV.
  24865. * @param uvScale is an optional vector2 used to scale UV.
  24866. * @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.
  24867. * @returns the Mesh.
  24868. */
  24869. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24870. /**
  24871. * Modifies the mesh geometry according to a displacementMap buffer.
  24872. * 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.
  24873. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24874. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24875. * @param heightMapWidth is the width of the buffer image.
  24876. * @param heightMapHeight is the height of the buffer image.
  24877. * @param minHeight is the lower limit of the displacement.
  24878. * @param maxHeight is the upper limit of the displacement.
  24879. * @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.
  24880. * @param uvOffset is an optional vector2 used to offset UV.
  24881. * @param uvScale is an optional vector2 used to scale UV.
  24882. * @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.
  24883. * @returns the Mesh.
  24884. */
  24885. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24886. /**
  24887. * Modify the mesh to get a flat shading rendering.
  24888. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24889. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24890. * @returns current mesh
  24891. */
  24892. convertToFlatShadedMesh(): Mesh;
  24893. /**
  24894. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24895. * In other words, more vertices, no more indices and a single bigger VBO.
  24896. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24897. * @returns current mesh
  24898. */
  24899. convertToUnIndexedMesh(): Mesh;
  24900. /**
  24901. * Inverses facet orientations.
  24902. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24903. * @param flipNormals will also inverts the normals
  24904. * @returns current mesh
  24905. */
  24906. flipFaces(flipNormals?: boolean): Mesh;
  24907. /**
  24908. * Increase the number of facets and hence vertices in a mesh
  24909. * Vertex normals are interpolated from existing vertex normals
  24910. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24911. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24912. */
  24913. increaseVertices(numberPerEdge: number): void;
  24914. /**
  24915. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24916. * This will undo any application of covertToFlatShadedMesh
  24917. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24918. */
  24919. forceSharedVertices(): void;
  24920. /** @hidden */
  24921. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24922. /** @hidden */
  24923. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24924. /**
  24925. * Creates a new InstancedMesh object from the mesh model.
  24926. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24927. * @param name defines the name of the new instance
  24928. * @returns a new InstancedMesh
  24929. */
  24930. createInstance(name: string): InstancedMesh;
  24931. /**
  24932. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24933. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24934. * @returns the current mesh
  24935. */
  24936. synchronizeInstances(): Mesh;
  24937. /**
  24938. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24939. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24940. * This should be used together with the simplification to avoid disappearing triangles.
  24941. * @param successCallback an optional success callback to be called after the optimization finished.
  24942. * @returns the current mesh
  24943. */
  24944. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24945. /**
  24946. * Serialize current mesh
  24947. * @param serializationObject defines the object which will receive the serialization data
  24948. */
  24949. serialize(serializationObject: any): void;
  24950. /** @hidden */
  24951. _syncGeometryWithMorphTargetManager(): void;
  24952. /** @hidden */
  24953. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24954. /**
  24955. * Returns a new Mesh object parsed from the source provided.
  24956. * @param parsedMesh is the source
  24957. * @param scene defines the hosting scene
  24958. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24959. * @returns a new Mesh
  24960. */
  24961. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24962. /**
  24963. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24964. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24965. * @param name defines the name of the mesh to create
  24966. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24967. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24968. * @param closePath creates a seam between the first and the last points of each path of the path array
  24969. * @param offset is taken in account only if the `pathArray` is containing a single path
  24970. * @param scene defines the hosting scene
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @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)
  24974. * @returns a new Mesh
  24975. */
  24976. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24977. /**
  24978. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24979. * @param name defines the name of the mesh to create
  24980. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24981. * @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
  24982. * @param scene defines the hosting scene
  24983. * @param updatable defines if the mesh must be flagged as updatable
  24984. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24985. * @returns a new Mesh
  24986. */
  24987. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24988. /**
  24989. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24990. * @param name defines the name of the mesh to create
  24991. * @param size sets the size (float) of each box side (default 1)
  24992. * @param scene defines the hosting scene
  24993. * @param updatable defines if the mesh must be flagged as updatable
  24994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24995. * @returns a new Mesh
  24996. */
  24997. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24998. /**
  24999. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25000. * @param name defines the name of the mesh to create
  25001. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25002. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25003. * @param scene defines the hosting scene
  25004. * @param updatable defines if the mesh must be flagged as updatable
  25005. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25006. * @returns a new Mesh
  25007. */
  25008. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25009. /**
  25010. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25011. * @param name defines the name of the mesh to create
  25012. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25013. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25014. * @param scene defines the hosting scene
  25015. * @returns a new Mesh
  25016. */
  25017. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25018. /**
  25019. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25020. * @param name defines the name of the mesh to create
  25021. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25022. * @param diameterTop set the top cap diameter (floats, default 1)
  25023. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25024. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25025. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25026. * @param scene defines the hosting scene
  25027. * @param updatable defines if the mesh must be flagged as updatable
  25028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25029. * @returns a new Mesh
  25030. */
  25031. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25032. /**
  25033. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25034. * @param name defines the name of the mesh to create
  25035. * @param diameter sets the diameter size (float) of the torus (default 1)
  25036. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25037. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25038. * @param scene defines the hosting scene
  25039. * @param updatable defines if the mesh must be flagged as updatable
  25040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25041. * @returns a new Mesh
  25042. */
  25043. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25044. /**
  25045. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25046. * @param name defines the name of the mesh to create
  25047. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25048. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25049. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25050. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25051. * @param p the number of windings on X axis (positive integers, default 2)
  25052. * @param q the number of windings on Y axis (positive integers, default 3)
  25053. * @param scene defines the hosting scene
  25054. * @param updatable defines if the mesh must be flagged as updatable
  25055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25056. * @returns a new Mesh
  25057. */
  25058. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25059. /**
  25060. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25061. * @param name defines the name of the mesh to create
  25062. * @param points is an array successive Vector3
  25063. * @param scene defines the hosting scene
  25064. * @param updatable defines if the mesh must be flagged as updatable
  25065. * @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).
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25069. /**
  25070. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param points is an array successive Vector3
  25073. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25074. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25075. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25076. * @param scene defines the hosting scene
  25077. * @param updatable defines if the mesh must be flagged as updatable
  25078. * @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)
  25079. * @returns a new Mesh
  25080. */
  25081. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25082. /**
  25083. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25084. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25085. * 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.
  25086. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25087. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25088. * Remember you can only change the shape positions, not their number when updating a polygon.
  25089. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25090. * @param name defines the name of the mesh to create
  25091. * @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
  25092. * @param scene defines the hosting scene
  25093. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25094. * @param updatable defines if the mesh must be flagged as updatable
  25095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25096. * @param earcutInjection can be used to inject your own earcut reference
  25097. * @returns a new Mesh
  25098. */
  25099. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25100. /**
  25101. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25102. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25103. * @param name defines the name of the mesh to create
  25104. * @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
  25105. * @param depth defines the height of extrusion
  25106. * @param scene defines the hosting scene
  25107. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25108. * @param updatable defines if the mesh must be flagged as updatable
  25109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25110. * @param earcutInjection can be used to inject your own earcut reference
  25111. * @returns a new Mesh
  25112. */
  25113. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25114. /**
  25115. * Creates an extruded shape mesh.
  25116. * 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
  25117. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25118. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25119. * @param name defines the name of the mesh to create
  25120. * @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
  25121. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25122. * @param scale is the value to scale the shape
  25123. * @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
  25124. * @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
  25125. * @param scene defines the hosting scene
  25126. * @param updatable defines if the mesh must be flagged as updatable
  25127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25128. * @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)
  25129. * @returns a new Mesh
  25130. */
  25131. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25132. /**
  25133. * Creates an custom extruded shape mesh.
  25134. * The custom extrusion is a parametric shape.
  25135. * It has no predefined shape. Its final shape will depend on the input parameters.
  25136. * Please consider using the same method from the MeshBuilder class instead
  25137. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25138. * @param name defines the name of the mesh to create
  25139. * @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
  25140. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25141. * @param scaleFunction is a custom Javascript function called on each path point
  25142. * @param rotationFunction is a custom Javascript function called on each path point
  25143. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25144. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25145. * @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
  25146. * @param scene defines the hosting scene
  25147. * @param updatable defines if the mesh must be flagged as updatable
  25148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25149. * @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)
  25150. * @returns a new Mesh
  25151. */
  25152. 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;
  25153. /**
  25154. * Creates lathe mesh.
  25155. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25156. * Please consider using the same method from the MeshBuilder class instead
  25157. * @param name defines the name of the mesh to create
  25158. * @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
  25159. * @param radius is the radius value of the lathe
  25160. * @param tessellation is the side number of the lathe.
  25161. * @param scene defines the hosting scene
  25162. * @param updatable defines if the mesh must be flagged as updatable
  25163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25164. * @returns a new Mesh
  25165. */
  25166. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25167. /**
  25168. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25169. * @param name defines the name of the mesh to create
  25170. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25171. * @param scene defines the hosting scene
  25172. * @param updatable defines if the mesh must be flagged as updatable
  25173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25174. * @returns a new Mesh
  25175. */
  25176. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25177. /**
  25178. * Creates a ground mesh.
  25179. * Please consider using the same method from the MeshBuilder class instead
  25180. * @param name defines the name of the mesh to create
  25181. * @param width set the width of the ground
  25182. * @param height set the height of the ground
  25183. * @param subdivisions sets the number of subdivisions per side
  25184. * @param scene defines the hosting scene
  25185. * @param updatable defines if the mesh must be flagged as updatable
  25186. * @returns a new Mesh
  25187. */
  25188. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25189. /**
  25190. * Creates a tiled ground mesh.
  25191. * Please consider using the same method from the MeshBuilder class instead
  25192. * @param name defines the name of the mesh to create
  25193. * @param xmin set the ground minimum X coordinate
  25194. * @param zmin set the ground minimum Y coordinate
  25195. * @param xmax set the ground maximum X coordinate
  25196. * @param zmax set the ground maximum Z coordinate
  25197. * @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
  25198. * @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
  25199. * @param scene defines the hosting scene
  25200. * @param updatable defines if the mesh must be flagged as updatable
  25201. * @returns a new Mesh
  25202. */
  25203. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25204. w: number;
  25205. h: number;
  25206. }, precision: {
  25207. w: number;
  25208. h: number;
  25209. }, scene: Scene, updatable?: boolean): Mesh;
  25210. /**
  25211. * Creates a ground mesh from a height map.
  25212. * Please consider using the same method from the MeshBuilder class instead
  25213. * @see http://doc.babylonjs.com/babylon101/height_map
  25214. * @param name defines the name of the mesh to create
  25215. * @param url sets the URL of the height map image resource
  25216. * @param width set the ground width size
  25217. * @param height set the ground height size
  25218. * @param subdivisions sets the number of subdivision per side
  25219. * @param minHeight is the minimum altitude on the ground
  25220. * @param maxHeight is the maximum altitude on the ground
  25221. * @param scene defines the hosting scene
  25222. * @param updatable defines if the mesh must be flagged as updatable
  25223. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25224. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25225. * @returns a new Mesh
  25226. */
  25227. 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;
  25228. /**
  25229. * Creates a tube mesh.
  25230. * The tube is a parametric shape.
  25231. * It has no predefined shape. Its final shape will depend on the input parameters.
  25232. * Please consider using the same method from the MeshBuilder class instead
  25233. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25234. * @param name defines the name of the mesh to create
  25235. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25236. * @param radius sets the tube radius size
  25237. * @param tessellation is the number of sides on the tubular surface
  25238. * @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
  25239. * @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
  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. * @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)
  25244. * @returns a new Mesh
  25245. */
  25246. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25247. (i: number, distance: number): number;
  25248. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25249. /**
  25250. * Creates a polyhedron mesh.
  25251. * Please consider using the same method from the MeshBuilder class instead.
  25252. * * 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
  25253. * * The parameter `size` (positive float, default 1) sets the polygon size
  25254. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25255. * * 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`
  25256. * * 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
  25257. * * 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)`)
  25258. * * 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
  25259. * * 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
  25260. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25261. * * 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
  25262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25263. * @param name defines the name of the mesh to create
  25264. * @param options defines the options used to create the mesh
  25265. * @param scene defines the hosting scene
  25266. * @returns a new Mesh
  25267. */
  25268. static CreatePolyhedron(name: string, options: {
  25269. type?: number;
  25270. size?: number;
  25271. sizeX?: number;
  25272. sizeY?: number;
  25273. sizeZ?: number;
  25274. custom?: any;
  25275. faceUV?: Vector4[];
  25276. faceColors?: Color4[];
  25277. updatable?: boolean;
  25278. sideOrientation?: number;
  25279. }, scene: Scene): Mesh;
  25280. /**
  25281. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25282. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25283. * * 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`)
  25284. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25285. * * 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
  25286. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25287. * * 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
  25288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25289. * @param name defines the name of the mesh
  25290. * @param options defines the options used to create the mesh
  25291. * @param scene defines the hosting scene
  25292. * @returns a new Mesh
  25293. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25294. */
  25295. static CreateIcoSphere(name: string, options: {
  25296. radius?: number;
  25297. flat?: boolean;
  25298. subdivisions?: number;
  25299. sideOrientation?: number;
  25300. updatable?: boolean;
  25301. }, scene: Scene): Mesh;
  25302. /**
  25303. * Creates a decal mesh.
  25304. * Please consider using the same method from the MeshBuilder class instead.
  25305. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25306. * @param name defines the name of the mesh
  25307. * @param sourceMesh defines the mesh receiving the decal
  25308. * @param position sets the position of the decal in world coordinates
  25309. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25310. * @param size sets the decal scaling
  25311. * @param angle sets the angle to rotate the decal
  25312. * @returns a new Mesh
  25313. */
  25314. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25315. /**
  25316. * Prepare internal position array for software CPU skinning
  25317. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25318. */
  25319. setPositionsForCPUSkinning(): Float32Array;
  25320. /**
  25321. * Prepare internal normal array for software CPU skinning
  25322. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25323. */
  25324. setNormalsForCPUSkinning(): Float32Array;
  25325. /**
  25326. * Updates the vertex buffer by applying transformation from the bones
  25327. * @param skeleton defines the skeleton to apply to current mesh
  25328. * @returns the current mesh
  25329. */
  25330. applySkeleton(skeleton: Skeleton): Mesh;
  25331. /**
  25332. * 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
  25333. * @param meshes defines the list of meshes to scan
  25334. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25335. */
  25336. static MinMax(meshes: AbstractMesh[]): {
  25337. min: Vector3;
  25338. max: Vector3;
  25339. };
  25340. /**
  25341. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25342. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25343. * @returns a vector3
  25344. */
  25345. static Center(meshesOrMinMaxVector: {
  25346. min: Vector3;
  25347. max: Vector3;
  25348. } | AbstractMesh[]): Vector3;
  25349. /**
  25350. * Merge the array of meshes into a single mesh for performance reasons.
  25351. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25352. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25353. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25354. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25355. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25356. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25357. * @returns a new mesh
  25358. */
  25359. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25360. /** @hidden */
  25361. addInstance(instance: InstancedMesh): void;
  25362. /** @hidden */
  25363. removeInstance(instance: InstancedMesh): void;
  25364. }
  25365. }
  25366. declare module BABYLON {
  25367. /**
  25368. * This is the base class of all the camera used in the application.
  25369. * @see http://doc.babylonjs.com/features/cameras
  25370. */
  25371. export class Camera extends Node {
  25372. /** @hidden */
  25373. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25374. /**
  25375. * This is the default projection mode used by the cameras.
  25376. * It helps recreating a feeling of perspective and better appreciate depth.
  25377. * This is the best way to simulate real life cameras.
  25378. */
  25379. static readonly PERSPECTIVE_CAMERA: number;
  25380. /**
  25381. * This helps creating camera with an orthographic mode.
  25382. * 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.
  25383. */
  25384. static readonly ORTHOGRAPHIC_CAMERA: number;
  25385. /**
  25386. * This is the default FOV mode for perspective cameras.
  25387. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25388. */
  25389. static readonly FOVMODE_VERTICAL_FIXED: number;
  25390. /**
  25391. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25392. */
  25393. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25394. /**
  25395. * This specifies ther is no need for a camera rig.
  25396. * Basically only one eye is rendered corresponding to the camera.
  25397. */
  25398. static readonly RIG_MODE_NONE: number;
  25399. /**
  25400. * Simulates a camera Rig with one blue eye and one red eye.
  25401. * This can be use with 3d blue and red glasses.
  25402. */
  25403. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25404. /**
  25405. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25406. */
  25407. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25408. /**
  25409. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25410. */
  25411. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25412. /**
  25413. * Defines that both eyes of the camera will be rendered over under each other.
  25414. */
  25415. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25416. /**
  25417. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25418. */
  25419. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25420. /**
  25421. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25422. */
  25423. static readonly RIG_MODE_VR: number;
  25424. /**
  25425. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25426. */
  25427. static readonly RIG_MODE_WEBVR: number;
  25428. /**
  25429. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25430. */
  25431. static readonly RIG_MODE_CUSTOM: number;
  25432. /**
  25433. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25434. */
  25435. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25436. /**
  25437. * Define the input manager associated with the camera.
  25438. */
  25439. inputs: CameraInputsManager<Camera>;
  25440. /** @hidden */
  25441. _position: Vector3;
  25442. /**
  25443. * Define the current local position of the camera in the scene
  25444. */
  25445. get position(): Vector3;
  25446. set position(newPosition: Vector3);
  25447. /**
  25448. * The vector the camera should consider as up.
  25449. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25450. */
  25451. upVector: Vector3;
  25452. /**
  25453. * Define the current limit on the left side for an orthographic camera
  25454. * In scene unit
  25455. */
  25456. orthoLeft: Nullable<number>;
  25457. /**
  25458. * Define the current limit on the right side for an orthographic camera
  25459. * In scene unit
  25460. */
  25461. orthoRight: Nullable<number>;
  25462. /**
  25463. * Define the current limit on the bottom side for an orthographic camera
  25464. * In scene unit
  25465. */
  25466. orthoBottom: Nullable<number>;
  25467. /**
  25468. * Define the current limit on the top side for an orthographic camera
  25469. * In scene unit
  25470. */
  25471. orthoTop: Nullable<number>;
  25472. /**
  25473. * Field Of View is set in Radians. (default is 0.8)
  25474. */
  25475. fov: number;
  25476. /**
  25477. * Define the minimum distance the camera can see from.
  25478. * This is important to note that the depth buffer are not infinite and the closer it starts
  25479. * the more your scene might encounter depth fighting issue.
  25480. */
  25481. minZ: number;
  25482. /**
  25483. * Define the maximum distance the camera can see to.
  25484. * This is important to note that the depth buffer are not infinite and the further it end
  25485. * the more your scene might encounter depth fighting issue.
  25486. */
  25487. maxZ: number;
  25488. /**
  25489. * Define the default inertia of the camera.
  25490. * This helps giving a smooth feeling to the camera movement.
  25491. */
  25492. inertia: number;
  25493. /**
  25494. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25495. */
  25496. mode: number;
  25497. /**
  25498. * Define whether the camera is intermediate.
  25499. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25500. */
  25501. isIntermediate: boolean;
  25502. /**
  25503. * Define the viewport of the camera.
  25504. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25505. */
  25506. viewport: Viewport;
  25507. /**
  25508. * Restricts the camera to viewing objects with the same layerMask.
  25509. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25510. */
  25511. layerMask: number;
  25512. /**
  25513. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25514. */
  25515. fovMode: number;
  25516. /**
  25517. * Rig mode of the camera.
  25518. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25519. * This is normally controlled byt the camera themselves as internal use.
  25520. */
  25521. cameraRigMode: number;
  25522. /**
  25523. * Defines the distance between both "eyes" in case of a RIG
  25524. */
  25525. interaxialDistance: number;
  25526. /**
  25527. * Defines if stereoscopic rendering is done side by side or over under.
  25528. */
  25529. isStereoscopicSideBySide: boolean;
  25530. /**
  25531. * 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
  25532. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25533. * else in the scene. (Eg. security camera)
  25534. *
  25535. * 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)
  25536. */
  25537. customRenderTargets: RenderTargetTexture[];
  25538. /**
  25539. * When set, the camera will render to this render target instead of the default canvas
  25540. *
  25541. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25542. */
  25543. outputRenderTarget: Nullable<RenderTargetTexture>;
  25544. /**
  25545. * Observable triggered when the camera view matrix has changed.
  25546. */
  25547. onViewMatrixChangedObservable: Observable<Camera>;
  25548. /**
  25549. * Observable triggered when the camera Projection matrix has changed.
  25550. */
  25551. onProjectionMatrixChangedObservable: Observable<Camera>;
  25552. /**
  25553. * Observable triggered when the inputs have been processed.
  25554. */
  25555. onAfterCheckInputsObservable: Observable<Camera>;
  25556. /**
  25557. * Observable triggered when reset has been called and applied to the camera.
  25558. */
  25559. onRestoreStateObservable: Observable<Camera>;
  25560. /**
  25561. * Is this camera a part of a rig system?
  25562. */
  25563. isRigCamera: boolean;
  25564. /**
  25565. * If isRigCamera set to true this will be set with the parent camera.
  25566. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25567. */
  25568. rigParent?: Camera;
  25569. /** @hidden */
  25570. _cameraRigParams: any;
  25571. /** @hidden */
  25572. _rigCameras: Camera[];
  25573. /** @hidden */
  25574. _rigPostProcess: Nullable<PostProcess>;
  25575. protected _webvrViewMatrix: Matrix;
  25576. /** @hidden */
  25577. _skipRendering: boolean;
  25578. /** @hidden */
  25579. _projectionMatrix: Matrix;
  25580. /** @hidden */
  25581. _postProcesses: Nullable<PostProcess>[];
  25582. /** @hidden */
  25583. _activeMeshes: SmartArray<AbstractMesh>;
  25584. protected _globalPosition: Vector3;
  25585. /** @hidden */
  25586. _computedViewMatrix: Matrix;
  25587. private _doNotComputeProjectionMatrix;
  25588. private _transformMatrix;
  25589. private _frustumPlanes;
  25590. private _refreshFrustumPlanes;
  25591. private _storedFov;
  25592. private _stateStored;
  25593. /**
  25594. * Instantiates a new camera object.
  25595. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25596. * @see http://doc.babylonjs.com/features/cameras
  25597. * @param name Defines the name of the camera in the scene
  25598. * @param position Defines the position of the camera
  25599. * @param scene Defines the scene the camera belongs too
  25600. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25601. */
  25602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25603. /**
  25604. * Store current camera state (fov, position, etc..)
  25605. * @returns the camera
  25606. */
  25607. storeState(): Camera;
  25608. /**
  25609. * Restores the camera state values if it has been stored. You must call storeState() first
  25610. */
  25611. protected _restoreStateValues(): boolean;
  25612. /**
  25613. * Restored camera state. You must call storeState() first.
  25614. * @returns true if restored and false otherwise
  25615. */
  25616. restoreState(): boolean;
  25617. /**
  25618. * Gets the class name of the camera.
  25619. * @returns the class name
  25620. */
  25621. getClassName(): string;
  25622. /** @hidden */
  25623. readonly _isCamera: boolean;
  25624. /**
  25625. * Gets a string representation of the camera useful for debug purpose.
  25626. * @param fullDetails Defines that a more verboe level of logging is required
  25627. * @returns the string representation
  25628. */
  25629. toString(fullDetails?: boolean): string;
  25630. /**
  25631. * Gets the current world space position of the camera.
  25632. */
  25633. get globalPosition(): Vector3;
  25634. /**
  25635. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25636. * @returns the active meshe list
  25637. */
  25638. getActiveMeshes(): SmartArray<AbstractMesh>;
  25639. /**
  25640. * Check whether a mesh is part of the current active mesh list of the camera
  25641. * @param mesh Defines the mesh to check
  25642. * @returns true if active, false otherwise
  25643. */
  25644. isActiveMesh(mesh: Mesh): boolean;
  25645. /**
  25646. * Is this camera ready to be used/rendered
  25647. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25648. * @return true if the camera is ready
  25649. */
  25650. isReady(completeCheck?: boolean): boolean;
  25651. /** @hidden */
  25652. _initCache(): void;
  25653. /** @hidden */
  25654. _updateCache(ignoreParentClass?: boolean): void;
  25655. /** @hidden */
  25656. _isSynchronized(): boolean;
  25657. /** @hidden */
  25658. _isSynchronizedViewMatrix(): boolean;
  25659. /** @hidden */
  25660. _isSynchronizedProjectionMatrix(): boolean;
  25661. /**
  25662. * Attach the input controls to a specific dom element to get the input from.
  25663. * @param element Defines the element the controls should be listened from
  25664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25665. */
  25666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25667. /**
  25668. * Detach the current controls from the specified dom element.
  25669. * @param element Defines the element to stop listening the inputs from
  25670. */
  25671. detachControl(element: HTMLElement): void;
  25672. /**
  25673. * Update the camera state according to the different inputs gathered during the frame.
  25674. */
  25675. update(): void;
  25676. /** @hidden */
  25677. _checkInputs(): void;
  25678. /** @hidden */
  25679. get rigCameras(): Camera[];
  25680. /**
  25681. * Gets the post process used by the rig cameras
  25682. */
  25683. get rigPostProcess(): Nullable<PostProcess>;
  25684. /**
  25685. * Internal, gets the first post proces.
  25686. * @returns the first post process to be run on this camera.
  25687. */
  25688. _getFirstPostProcess(): Nullable<PostProcess>;
  25689. private _cascadePostProcessesToRigCams;
  25690. /**
  25691. * Attach a post process to the camera.
  25692. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25693. * @param postProcess The post process to attach to the camera
  25694. * @param insertAt The position of the post process in case several of them are in use in the scene
  25695. * @returns the position the post process has been inserted at
  25696. */
  25697. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25698. /**
  25699. * Detach a post process to the camera.
  25700. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25701. * @param postProcess The post process to detach from the camera
  25702. */
  25703. detachPostProcess(postProcess: PostProcess): void;
  25704. /**
  25705. * Gets the current world matrix of the camera
  25706. */
  25707. getWorldMatrix(): Matrix;
  25708. /** @hidden */
  25709. _getViewMatrix(): Matrix;
  25710. /**
  25711. * Gets the current view matrix of the camera.
  25712. * @param force forces the camera to recompute the matrix without looking at the cached state
  25713. * @returns the view matrix
  25714. */
  25715. getViewMatrix(force?: boolean): Matrix;
  25716. /**
  25717. * Freeze the projection matrix.
  25718. * It will prevent the cache check of the camera projection compute and can speed up perf
  25719. * if no parameter of the camera are meant to change
  25720. * @param projection Defines manually a projection if necessary
  25721. */
  25722. freezeProjectionMatrix(projection?: Matrix): void;
  25723. /**
  25724. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25725. */
  25726. unfreezeProjectionMatrix(): void;
  25727. /**
  25728. * Gets the current projection matrix of the camera.
  25729. * @param force forces the camera to recompute the matrix without looking at the cached state
  25730. * @returns the projection matrix
  25731. */
  25732. getProjectionMatrix(force?: boolean): Matrix;
  25733. /**
  25734. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25735. * @returns a Matrix
  25736. */
  25737. getTransformationMatrix(): Matrix;
  25738. private _updateFrustumPlanes;
  25739. /**
  25740. * Checks if a cullable object (mesh...) is in the camera frustum
  25741. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25742. * @param target The object to check
  25743. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25744. * @returns true if the object is in frustum otherwise false
  25745. */
  25746. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25747. /**
  25748. * Checks if a cullable object (mesh...) is in the camera frustum
  25749. * Unlike isInFrustum this cheks the full bounding box
  25750. * @param target The object to check
  25751. * @returns true if the object is in frustum otherwise false
  25752. */
  25753. isCompletelyInFrustum(target: ICullable): boolean;
  25754. /**
  25755. * Gets a ray in the forward direction from the camera.
  25756. * @param length Defines the length of the ray to create
  25757. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25758. * @param origin Defines the start point of the ray which defaults to the camera position
  25759. * @returns the forward ray
  25760. */
  25761. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25762. /**
  25763. * Releases resources associated with this node.
  25764. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25765. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25766. */
  25767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25768. /** @hidden */
  25769. _isLeftCamera: boolean;
  25770. /**
  25771. * Gets the left camera of a rig setup in case of Rigged Camera
  25772. */
  25773. get isLeftCamera(): boolean;
  25774. /** @hidden */
  25775. _isRightCamera: boolean;
  25776. /**
  25777. * Gets the right camera of a rig setup in case of Rigged Camera
  25778. */
  25779. get isRightCamera(): boolean;
  25780. /**
  25781. * Gets the left camera of a rig setup in case of Rigged Camera
  25782. */
  25783. get leftCamera(): Nullable<FreeCamera>;
  25784. /**
  25785. * Gets the right camera of a rig setup in case of Rigged Camera
  25786. */
  25787. get rightCamera(): Nullable<FreeCamera>;
  25788. /**
  25789. * Gets the left camera target of a rig setup in case of Rigged Camera
  25790. * @returns the target position
  25791. */
  25792. getLeftTarget(): Nullable<Vector3>;
  25793. /**
  25794. * Gets the right camera target of a rig setup in case of Rigged Camera
  25795. * @returns the target position
  25796. */
  25797. getRightTarget(): Nullable<Vector3>;
  25798. /**
  25799. * @hidden
  25800. */
  25801. setCameraRigMode(mode: number, rigParams: any): void;
  25802. /** @hidden */
  25803. static _setStereoscopicRigMode(camera: Camera): void;
  25804. /** @hidden */
  25805. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25806. /** @hidden */
  25807. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25808. /** @hidden */
  25809. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25810. /** @hidden */
  25811. _getVRProjectionMatrix(): Matrix;
  25812. protected _updateCameraRotationMatrix(): void;
  25813. protected _updateWebVRCameraRotationMatrix(): void;
  25814. /**
  25815. * This function MUST be overwritten by the different WebVR cameras available.
  25816. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25817. * @hidden
  25818. */
  25819. _getWebVRProjectionMatrix(): Matrix;
  25820. /**
  25821. * This function MUST be overwritten by the different WebVR cameras available.
  25822. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25823. * @hidden
  25824. */
  25825. _getWebVRViewMatrix(): Matrix;
  25826. /** @hidden */
  25827. setCameraRigParameter(name: string, value: any): void;
  25828. /**
  25829. * needs to be overridden by children so sub has required properties to be copied
  25830. * @hidden
  25831. */
  25832. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25833. /**
  25834. * May need to be overridden by children
  25835. * @hidden
  25836. */
  25837. _updateRigCameras(): void;
  25838. /** @hidden */
  25839. _setupInputs(): void;
  25840. /**
  25841. * Serialiaze the camera setup to a json represention
  25842. * @returns the JSON representation
  25843. */
  25844. serialize(): any;
  25845. /**
  25846. * Clones the current camera.
  25847. * @param name The cloned camera name
  25848. * @returns the cloned camera
  25849. */
  25850. clone(name: string): Camera;
  25851. /**
  25852. * Gets the direction of the camera relative to a given local axis.
  25853. * @param localAxis Defines the reference axis to provide a relative direction.
  25854. * @return the direction
  25855. */
  25856. getDirection(localAxis: Vector3): Vector3;
  25857. /**
  25858. * Returns the current camera absolute rotation
  25859. */
  25860. get absoluteRotation(): Quaternion;
  25861. /**
  25862. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25863. * @param localAxis Defines the reference axis to provide a relative direction.
  25864. * @param result Defines the vector to store the result in
  25865. */
  25866. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25867. /**
  25868. * Gets a camera constructor for a given camera type
  25869. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25870. * @param name The name of the camera the result will be able to instantiate
  25871. * @param scene The scene the result will construct the camera in
  25872. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25873. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25874. * @returns a factory method to construc the camera
  25875. */
  25876. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25877. /**
  25878. * Compute the world matrix of the camera.
  25879. * @returns the camera world matrix
  25880. */
  25881. computeWorldMatrix(): Matrix;
  25882. /**
  25883. * Parse a JSON and creates the camera from the parsed information
  25884. * @param parsedCamera The JSON to parse
  25885. * @param scene The scene to instantiate the camera in
  25886. * @returns the newly constructed camera
  25887. */
  25888. static Parse(parsedCamera: any, scene: Scene): Camera;
  25889. }
  25890. }
  25891. declare module BABYLON {
  25892. /**
  25893. * Class containing static functions to help procedurally build meshes
  25894. */
  25895. export class DiscBuilder {
  25896. /**
  25897. * Creates a plane polygonal mesh. By default, this is a disc
  25898. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25899. * * 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
  25900. * * 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
  25901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25902. * * 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
  25903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25904. * @param name defines the name of the mesh
  25905. * @param options defines the options used to create the mesh
  25906. * @param scene defines the hosting scene
  25907. * @returns the plane polygonal mesh
  25908. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25909. */
  25910. static CreateDisc(name: string, options: {
  25911. radius?: number;
  25912. tessellation?: number;
  25913. arc?: number;
  25914. updatable?: boolean;
  25915. sideOrientation?: number;
  25916. frontUVs?: Vector4;
  25917. backUVs?: Vector4;
  25918. }, scene?: Nullable<Scene>): Mesh;
  25919. }
  25920. }
  25921. declare module BABYLON {
  25922. /**
  25923. * This represents all the required information to add a fresnel effect on a material:
  25924. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25925. */
  25926. export class FresnelParameters {
  25927. private _isEnabled;
  25928. /**
  25929. * Define if the fresnel effect is enable or not.
  25930. */
  25931. get isEnabled(): boolean;
  25932. set isEnabled(value: boolean);
  25933. /**
  25934. * Define the color used on edges (grazing angle)
  25935. */
  25936. leftColor: Color3;
  25937. /**
  25938. * Define the color used on center
  25939. */
  25940. rightColor: Color3;
  25941. /**
  25942. * Define bias applied to computed fresnel term
  25943. */
  25944. bias: number;
  25945. /**
  25946. * Defined the power exponent applied to fresnel term
  25947. */
  25948. power: number;
  25949. /**
  25950. * Clones the current fresnel and its valuues
  25951. * @returns a clone fresnel configuration
  25952. */
  25953. clone(): FresnelParameters;
  25954. /**
  25955. * Serializes the current fresnel parameters to a JSON representation.
  25956. * @return the JSON serialization
  25957. */
  25958. serialize(): any;
  25959. /**
  25960. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25961. * @param parsedFresnelParameters Define the JSON representation
  25962. * @returns the parsed parameters
  25963. */
  25964. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25965. }
  25966. }
  25967. declare module BABYLON {
  25968. /**
  25969. * Base class of materials working in push mode in babylon JS
  25970. * @hidden
  25971. */
  25972. export class PushMaterial extends Material {
  25973. protected _activeEffect: Effect;
  25974. protected _normalMatrix: Matrix;
  25975. /**
  25976. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25977. * This means that the material can keep using a previous shader while a new one is being compiled.
  25978. * This is mostly used when shader parallel compilation is supported (true by default)
  25979. */
  25980. allowShaderHotSwapping: boolean;
  25981. constructor(name: string, scene: Scene);
  25982. getEffect(): Effect;
  25983. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25984. /**
  25985. * Binds the given world matrix to the active effect
  25986. *
  25987. * @param world the matrix to bind
  25988. */
  25989. bindOnlyWorldMatrix(world: Matrix): void;
  25990. /**
  25991. * Binds the given normal matrix to the active effect
  25992. *
  25993. * @param normalMatrix the matrix to bind
  25994. */
  25995. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25996. bind(world: Matrix, mesh?: Mesh): void;
  25997. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25998. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25999. }
  26000. }
  26001. declare module BABYLON {
  26002. /**
  26003. * This groups all the flags used to control the materials channel.
  26004. */
  26005. export class MaterialFlags {
  26006. private static _DiffuseTextureEnabled;
  26007. /**
  26008. * Are diffuse textures enabled in the application.
  26009. */
  26010. static get DiffuseTextureEnabled(): boolean;
  26011. static set DiffuseTextureEnabled(value: boolean);
  26012. private static _AmbientTextureEnabled;
  26013. /**
  26014. * Are ambient textures enabled in the application.
  26015. */
  26016. static get AmbientTextureEnabled(): boolean;
  26017. static set AmbientTextureEnabled(value: boolean);
  26018. private static _OpacityTextureEnabled;
  26019. /**
  26020. * Are opacity textures enabled in the application.
  26021. */
  26022. static get OpacityTextureEnabled(): boolean;
  26023. static set OpacityTextureEnabled(value: boolean);
  26024. private static _ReflectionTextureEnabled;
  26025. /**
  26026. * Are reflection textures enabled in the application.
  26027. */
  26028. static get ReflectionTextureEnabled(): boolean;
  26029. static set ReflectionTextureEnabled(value: boolean);
  26030. private static _EmissiveTextureEnabled;
  26031. /**
  26032. * Are emissive textures enabled in the application.
  26033. */
  26034. static get EmissiveTextureEnabled(): boolean;
  26035. static set EmissiveTextureEnabled(value: boolean);
  26036. private static _SpecularTextureEnabled;
  26037. /**
  26038. * Are specular textures enabled in the application.
  26039. */
  26040. static get SpecularTextureEnabled(): boolean;
  26041. static set SpecularTextureEnabled(value: boolean);
  26042. private static _BumpTextureEnabled;
  26043. /**
  26044. * Are bump textures enabled in the application.
  26045. */
  26046. static get BumpTextureEnabled(): boolean;
  26047. static set BumpTextureEnabled(value: boolean);
  26048. private static _LightmapTextureEnabled;
  26049. /**
  26050. * Are lightmap textures enabled in the application.
  26051. */
  26052. static get LightmapTextureEnabled(): boolean;
  26053. static set LightmapTextureEnabled(value: boolean);
  26054. private static _RefractionTextureEnabled;
  26055. /**
  26056. * Are refraction textures enabled in the application.
  26057. */
  26058. static get RefractionTextureEnabled(): boolean;
  26059. static set RefractionTextureEnabled(value: boolean);
  26060. private static _ColorGradingTextureEnabled;
  26061. /**
  26062. * Are color grading textures enabled in the application.
  26063. */
  26064. static get ColorGradingTextureEnabled(): boolean;
  26065. static set ColorGradingTextureEnabled(value: boolean);
  26066. private static _FresnelEnabled;
  26067. /**
  26068. * Are fresnels enabled in the application.
  26069. */
  26070. static get FresnelEnabled(): boolean;
  26071. static set FresnelEnabled(value: boolean);
  26072. private static _ClearCoatTextureEnabled;
  26073. /**
  26074. * Are clear coat textures enabled in the application.
  26075. */
  26076. static get ClearCoatTextureEnabled(): boolean;
  26077. static set ClearCoatTextureEnabled(value: boolean);
  26078. private static _ClearCoatBumpTextureEnabled;
  26079. /**
  26080. * Are clear coat bump textures enabled in the application.
  26081. */
  26082. static get ClearCoatBumpTextureEnabled(): boolean;
  26083. static set ClearCoatBumpTextureEnabled(value: boolean);
  26084. private static _ClearCoatTintTextureEnabled;
  26085. /**
  26086. * Are clear coat tint textures enabled in the application.
  26087. */
  26088. static get ClearCoatTintTextureEnabled(): boolean;
  26089. static set ClearCoatTintTextureEnabled(value: boolean);
  26090. private static _SheenTextureEnabled;
  26091. /**
  26092. * Are sheen textures enabled in the application.
  26093. */
  26094. static get SheenTextureEnabled(): boolean;
  26095. static set SheenTextureEnabled(value: boolean);
  26096. private static _AnisotropicTextureEnabled;
  26097. /**
  26098. * Are anisotropic textures enabled in the application.
  26099. */
  26100. static get AnisotropicTextureEnabled(): boolean;
  26101. static set AnisotropicTextureEnabled(value: boolean);
  26102. private static _ThicknessTextureEnabled;
  26103. /**
  26104. * Are thickness textures enabled in the application.
  26105. */
  26106. static get ThicknessTextureEnabled(): boolean;
  26107. static set ThicknessTextureEnabled(value: boolean);
  26108. }
  26109. }
  26110. declare module BABYLON {
  26111. /** @hidden */
  26112. export var defaultFragmentDeclaration: {
  26113. name: string;
  26114. shader: string;
  26115. };
  26116. }
  26117. declare module BABYLON {
  26118. /** @hidden */
  26119. export var defaultUboDeclaration: {
  26120. name: string;
  26121. shader: string;
  26122. };
  26123. }
  26124. declare module BABYLON {
  26125. /** @hidden */
  26126. export var lightFragmentDeclaration: {
  26127. name: string;
  26128. shader: string;
  26129. };
  26130. }
  26131. declare module BABYLON {
  26132. /** @hidden */
  26133. export var lightUboDeclaration: {
  26134. name: string;
  26135. shader: string;
  26136. };
  26137. }
  26138. declare module BABYLON {
  26139. /** @hidden */
  26140. export var lightsFragmentFunctions: {
  26141. name: string;
  26142. shader: string;
  26143. };
  26144. }
  26145. declare module BABYLON {
  26146. /** @hidden */
  26147. export var shadowsFragmentFunctions: {
  26148. name: string;
  26149. shader: string;
  26150. };
  26151. }
  26152. declare module BABYLON {
  26153. /** @hidden */
  26154. export var fresnelFunction: {
  26155. name: string;
  26156. shader: string;
  26157. };
  26158. }
  26159. declare module BABYLON {
  26160. /** @hidden */
  26161. export var reflectionFunction: {
  26162. name: string;
  26163. shader: string;
  26164. };
  26165. }
  26166. declare module BABYLON {
  26167. /** @hidden */
  26168. export var bumpFragmentFunctions: {
  26169. name: string;
  26170. shader: string;
  26171. };
  26172. }
  26173. declare module BABYLON {
  26174. /** @hidden */
  26175. export var logDepthDeclaration: {
  26176. name: string;
  26177. shader: string;
  26178. };
  26179. }
  26180. declare module BABYLON {
  26181. /** @hidden */
  26182. export var bumpFragment: {
  26183. name: string;
  26184. shader: string;
  26185. };
  26186. }
  26187. declare module BABYLON {
  26188. /** @hidden */
  26189. export var depthPrePass: {
  26190. name: string;
  26191. shader: string;
  26192. };
  26193. }
  26194. declare module BABYLON {
  26195. /** @hidden */
  26196. export var lightFragment: {
  26197. name: string;
  26198. shader: string;
  26199. };
  26200. }
  26201. declare module BABYLON {
  26202. /** @hidden */
  26203. export var logDepthFragment: {
  26204. name: string;
  26205. shader: string;
  26206. };
  26207. }
  26208. declare module BABYLON {
  26209. /** @hidden */
  26210. export var defaultPixelShader: {
  26211. name: string;
  26212. shader: string;
  26213. };
  26214. }
  26215. declare module BABYLON {
  26216. /** @hidden */
  26217. export var defaultVertexDeclaration: {
  26218. name: string;
  26219. shader: string;
  26220. };
  26221. }
  26222. declare module BABYLON {
  26223. /** @hidden */
  26224. export var bumpVertexDeclaration: {
  26225. name: string;
  26226. shader: string;
  26227. };
  26228. }
  26229. declare module BABYLON {
  26230. /** @hidden */
  26231. export var bumpVertex: {
  26232. name: string;
  26233. shader: string;
  26234. };
  26235. }
  26236. declare module BABYLON {
  26237. /** @hidden */
  26238. export var fogVertex: {
  26239. name: string;
  26240. shader: string;
  26241. };
  26242. }
  26243. declare module BABYLON {
  26244. /** @hidden */
  26245. export var shadowsVertex: {
  26246. name: string;
  26247. shader: string;
  26248. };
  26249. }
  26250. declare module BABYLON {
  26251. /** @hidden */
  26252. export var pointCloudVertex: {
  26253. name: string;
  26254. shader: string;
  26255. };
  26256. }
  26257. declare module BABYLON {
  26258. /** @hidden */
  26259. export var logDepthVertex: {
  26260. name: string;
  26261. shader: string;
  26262. };
  26263. }
  26264. declare module BABYLON {
  26265. /** @hidden */
  26266. export var defaultVertexShader: {
  26267. name: string;
  26268. shader: string;
  26269. };
  26270. }
  26271. declare module BABYLON {
  26272. /** @hidden */
  26273. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26274. MAINUV1: boolean;
  26275. MAINUV2: boolean;
  26276. DIFFUSE: boolean;
  26277. DIFFUSEDIRECTUV: number;
  26278. AMBIENT: boolean;
  26279. AMBIENTDIRECTUV: number;
  26280. OPACITY: boolean;
  26281. OPACITYDIRECTUV: number;
  26282. OPACITYRGB: boolean;
  26283. REFLECTION: boolean;
  26284. EMISSIVE: boolean;
  26285. EMISSIVEDIRECTUV: number;
  26286. SPECULAR: boolean;
  26287. SPECULARDIRECTUV: number;
  26288. BUMP: boolean;
  26289. BUMPDIRECTUV: number;
  26290. PARALLAX: boolean;
  26291. PARALLAXOCCLUSION: boolean;
  26292. SPECULAROVERALPHA: boolean;
  26293. CLIPPLANE: boolean;
  26294. CLIPPLANE2: boolean;
  26295. CLIPPLANE3: boolean;
  26296. CLIPPLANE4: boolean;
  26297. CLIPPLANE5: boolean;
  26298. CLIPPLANE6: boolean;
  26299. ALPHATEST: boolean;
  26300. DEPTHPREPASS: boolean;
  26301. ALPHAFROMDIFFUSE: boolean;
  26302. POINTSIZE: boolean;
  26303. FOG: boolean;
  26304. SPECULARTERM: boolean;
  26305. DIFFUSEFRESNEL: boolean;
  26306. OPACITYFRESNEL: boolean;
  26307. REFLECTIONFRESNEL: boolean;
  26308. REFRACTIONFRESNEL: boolean;
  26309. EMISSIVEFRESNEL: boolean;
  26310. FRESNEL: boolean;
  26311. NORMAL: boolean;
  26312. UV1: boolean;
  26313. UV2: boolean;
  26314. VERTEXCOLOR: boolean;
  26315. VERTEXALPHA: boolean;
  26316. NUM_BONE_INFLUENCERS: number;
  26317. BonesPerMesh: number;
  26318. BONETEXTURE: boolean;
  26319. INSTANCES: boolean;
  26320. GLOSSINESS: boolean;
  26321. ROUGHNESS: boolean;
  26322. EMISSIVEASILLUMINATION: boolean;
  26323. LINKEMISSIVEWITHDIFFUSE: boolean;
  26324. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26325. LIGHTMAP: boolean;
  26326. LIGHTMAPDIRECTUV: number;
  26327. OBJECTSPACE_NORMALMAP: boolean;
  26328. USELIGHTMAPASSHADOWMAP: boolean;
  26329. REFLECTIONMAP_3D: boolean;
  26330. REFLECTIONMAP_SPHERICAL: boolean;
  26331. REFLECTIONMAP_PLANAR: boolean;
  26332. REFLECTIONMAP_CUBIC: boolean;
  26333. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26334. REFLECTIONMAP_PROJECTION: boolean;
  26335. REFLECTIONMAP_SKYBOX: boolean;
  26336. REFLECTIONMAP_EXPLICIT: boolean;
  26337. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26338. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26339. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26340. INVERTCUBICMAP: boolean;
  26341. LOGARITHMICDEPTH: boolean;
  26342. REFRACTION: boolean;
  26343. REFRACTIONMAP_3D: boolean;
  26344. REFLECTIONOVERALPHA: boolean;
  26345. TWOSIDEDLIGHTING: boolean;
  26346. SHADOWFLOAT: boolean;
  26347. MORPHTARGETS: boolean;
  26348. MORPHTARGETS_NORMAL: boolean;
  26349. MORPHTARGETS_TANGENT: boolean;
  26350. MORPHTARGETS_UV: boolean;
  26351. NUM_MORPH_INFLUENCERS: number;
  26352. NONUNIFORMSCALING: boolean;
  26353. PREMULTIPLYALPHA: boolean;
  26354. IMAGEPROCESSING: boolean;
  26355. VIGNETTE: boolean;
  26356. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26357. VIGNETTEBLENDMODEOPAQUE: boolean;
  26358. TONEMAPPING: boolean;
  26359. TONEMAPPING_ACES: boolean;
  26360. CONTRAST: boolean;
  26361. COLORCURVES: boolean;
  26362. COLORGRADING: boolean;
  26363. COLORGRADING3D: boolean;
  26364. SAMPLER3DGREENDEPTH: boolean;
  26365. SAMPLER3DBGRMAP: boolean;
  26366. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26367. MULTIVIEW: boolean;
  26368. /**
  26369. * If the reflection texture on this material is in linear color space
  26370. * @hidden
  26371. */
  26372. IS_REFLECTION_LINEAR: boolean;
  26373. /**
  26374. * If the refraction texture on this material is in linear color space
  26375. * @hidden
  26376. */
  26377. IS_REFRACTION_LINEAR: boolean;
  26378. EXPOSURE: boolean;
  26379. constructor();
  26380. setReflectionMode(modeToEnable: string): void;
  26381. }
  26382. /**
  26383. * This is the default material used in Babylon. It is the best trade off between quality
  26384. * and performances.
  26385. * @see http://doc.babylonjs.com/babylon101/materials
  26386. */
  26387. export class StandardMaterial extends PushMaterial {
  26388. private _diffuseTexture;
  26389. /**
  26390. * The basic texture of the material as viewed under a light.
  26391. */
  26392. diffuseTexture: Nullable<BaseTexture>;
  26393. private _ambientTexture;
  26394. /**
  26395. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26396. */
  26397. ambientTexture: Nullable<BaseTexture>;
  26398. private _opacityTexture;
  26399. /**
  26400. * Define the transparency of the material from a texture.
  26401. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26402. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26403. */
  26404. opacityTexture: Nullable<BaseTexture>;
  26405. private _reflectionTexture;
  26406. /**
  26407. * Define the texture used to display the reflection.
  26408. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26409. */
  26410. reflectionTexture: Nullable<BaseTexture>;
  26411. private _emissiveTexture;
  26412. /**
  26413. * Define texture of the material as if self lit.
  26414. * This will be mixed in the final result even in the absence of light.
  26415. */
  26416. emissiveTexture: Nullable<BaseTexture>;
  26417. private _specularTexture;
  26418. /**
  26419. * Define how the color and intensity of the highlight given by the light in the material.
  26420. */
  26421. specularTexture: Nullable<BaseTexture>;
  26422. private _bumpTexture;
  26423. /**
  26424. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26425. * 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.
  26426. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26427. */
  26428. bumpTexture: Nullable<BaseTexture>;
  26429. private _lightmapTexture;
  26430. /**
  26431. * Complex lighting can be computationally expensive to compute at runtime.
  26432. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26433. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26434. */
  26435. lightmapTexture: Nullable<BaseTexture>;
  26436. private _refractionTexture;
  26437. /**
  26438. * Define the texture used to display the refraction.
  26439. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26440. */
  26441. refractionTexture: Nullable<BaseTexture>;
  26442. /**
  26443. * The color of the material lit by the environmental background lighting.
  26444. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26445. */
  26446. ambientColor: Color3;
  26447. /**
  26448. * The basic color of the material as viewed under a light.
  26449. */
  26450. diffuseColor: Color3;
  26451. /**
  26452. * Define how the color and intensity of the highlight given by the light in the material.
  26453. */
  26454. specularColor: Color3;
  26455. /**
  26456. * Define the color of the material as if self lit.
  26457. * This will be mixed in the final result even in the absence of light.
  26458. */
  26459. emissiveColor: Color3;
  26460. /**
  26461. * Defines how sharp are the highlights in the material.
  26462. * The bigger the value the sharper giving a more glossy feeling to the result.
  26463. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26464. */
  26465. specularPower: number;
  26466. private _useAlphaFromDiffuseTexture;
  26467. /**
  26468. * Does the transparency come from the diffuse texture alpha channel.
  26469. */
  26470. useAlphaFromDiffuseTexture: boolean;
  26471. private _useEmissiveAsIllumination;
  26472. /**
  26473. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26474. */
  26475. useEmissiveAsIllumination: boolean;
  26476. private _linkEmissiveWithDiffuse;
  26477. /**
  26478. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26479. * the emissive level when the final color is close to one.
  26480. */
  26481. linkEmissiveWithDiffuse: boolean;
  26482. private _useSpecularOverAlpha;
  26483. /**
  26484. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26485. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26486. */
  26487. useSpecularOverAlpha: boolean;
  26488. private _useReflectionOverAlpha;
  26489. /**
  26490. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26491. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26492. */
  26493. useReflectionOverAlpha: boolean;
  26494. private _disableLighting;
  26495. /**
  26496. * Does lights from the scene impacts this material.
  26497. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26498. */
  26499. disableLighting: boolean;
  26500. private _useObjectSpaceNormalMap;
  26501. /**
  26502. * Allows using an object space normal map (instead of tangent space).
  26503. */
  26504. useObjectSpaceNormalMap: boolean;
  26505. private _useParallax;
  26506. /**
  26507. * Is parallax enabled or not.
  26508. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26509. */
  26510. useParallax: boolean;
  26511. private _useParallaxOcclusion;
  26512. /**
  26513. * Is parallax occlusion enabled or not.
  26514. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26515. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26516. */
  26517. useParallaxOcclusion: boolean;
  26518. /**
  26519. * 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.
  26520. */
  26521. parallaxScaleBias: number;
  26522. private _roughness;
  26523. /**
  26524. * Helps to define how blurry the reflections should appears in the material.
  26525. */
  26526. roughness: number;
  26527. /**
  26528. * In case of refraction, define the value of the index of refraction.
  26529. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26530. */
  26531. indexOfRefraction: number;
  26532. /**
  26533. * Invert the refraction texture alongside the y axis.
  26534. * It can be useful with procedural textures or probe for instance.
  26535. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26536. */
  26537. invertRefractionY: boolean;
  26538. /**
  26539. * Defines the alpha limits in alpha test mode.
  26540. */
  26541. alphaCutOff: number;
  26542. private _useLightmapAsShadowmap;
  26543. /**
  26544. * In case of light mapping, define whether the map contains light or shadow informations.
  26545. */
  26546. useLightmapAsShadowmap: boolean;
  26547. private _diffuseFresnelParameters;
  26548. /**
  26549. * Define the diffuse fresnel parameters of the material.
  26550. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26551. */
  26552. diffuseFresnelParameters: FresnelParameters;
  26553. private _opacityFresnelParameters;
  26554. /**
  26555. * Define the opacity fresnel parameters of the material.
  26556. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26557. */
  26558. opacityFresnelParameters: FresnelParameters;
  26559. private _reflectionFresnelParameters;
  26560. /**
  26561. * Define the reflection fresnel parameters of the material.
  26562. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26563. */
  26564. reflectionFresnelParameters: FresnelParameters;
  26565. private _refractionFresnelParameters;
  26566. /**
  26567. * Define the refraction fresnel parameters of the material.
  26568. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26569. */
  26570. refractionFresnelParameters: FresnelParameters;
  26571. private _emissiveFresnelParameters;
  26572. /**
  26573. * Define the emissive fresnel parameters of the material.
  26574. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26575. */
  26576. emissiveFresnelParameters: FresnelParameters;
  26577. private _useReflectionFresnelFromSpecular;
  26578. /**
  26579. * If true automatically deducts the fresnels values from the material specularity.
  26580. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26581. */
  26582. useReflectionFresnelFromSpecular: boolean;
  26583. private _useGlossinessFromSpecularMapAlpha;
  26584. /**
  26585. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26586. */
  26587. useGlossinessFromSpecularMapAlpha: boolean;
  26588. private _maxSimultaneousLights;
  26589. /**
  26590. * Defines the maximum number of lights that can be used in the material
  26591. */
  26592. maxSimultaneousLights: number;
  26593. private _invertNormalMapX;
  26594. /**
  26595. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26596. */
  26597. invertNormalMapX: boolean;
  26598. private _invertNormalMapY;
  26599. /**
  26600. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26601. */
  26602. invertNormalMapY: boolean;
  26603. private _twoSidedLighting;
  26604. /**
  26605. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26606. */
  26607. twoSidedLighting: boolean;
  26608. /**
  26609. * Default configuration related to image processing available in the standard Material.
  26610. */
  26611. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26612. /**
  26613. * Gets the image processing configuration used either in this material.
  26614. */
  26615. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26616. /**
  26617. * Sets the Default image processing configuration used either in the this material.
  26618. *
  26619. * If sets to null, the scene one is in use.
  26620. */
  26621. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26622. /**
  26623. * Keep track of the image processing observer to allow dispose and replace.
  26624. */
  26625. private _imageProcessingObserver;
  26626. /**
  26627. * Attaches a new image processing configuration to the Standard Material.
  26628. * @param configuration
  26629. */
  26630. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26631. /**
  26632. * Gets wether the color curves effect is enabled.
  26633. */
  26634. get cameraColorCurvesEnabled(): boolean;
  26635. /**
  26636. * Sets wether the color curves effect is enabled.
  26637. */
  26638. set cameraColorCurvesEnabled(value: boolean);
  26639. /**
  26640. * Gets wether the color grading effect is enabled.
  26641. */
  26642. get cameraColorGradingEnabled(): boolean;
  26643. /**
  26644. * Gets wether the color grading effect is enabled.
  26645. */
  26646. set cameraColorGradingEnabled(value: boolean);
  26647. /**
  26648. * Gets wether tonemapping is enabled or not.
  26649. */
  26650. get cameraToneMappingEnabled(): boolean;
  26651. /**
  26652. * Sets wether tonemapping is enabled or not
  26653. */
  26654. set cameraToneMappingEnabled(value: boolean);
  26655. /**
  26656. * The camera exposure used on this material.
  26657. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26658. * This corresponds to a photographic exposure.
  26659. */
  26660. get cameraExposure(): number;
  26661. /**
  26662. * The camera exposure used on this material.
  26663. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26664. * This corresponds to a photographic exposure.
  26665. */
  26666. set cameraExposure(value: number);
  26667. /**
  26668. * Gets The camera contrast used on this material.
  26669. */
  26670. get cameraContrast(): number;
  26671. /**
  26672. * Sets The camera contrast used on this material.
  26673. */
  26674. set cameraContrast(value: number);
  26675. /**
  26676. * Gets the Color Grading 2D Lookup Texture.
  26677. */
  26678. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26679. /**
  26680. * Sets the Color Grading 2D Lookup Texture.
  26681. */
  26682. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26683. /**
  26684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26686. * 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;
  26687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26688. */
  26689. get cameraColorCurves(): Nullable<ColorCurves>;
  26690. /**
  26691. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26692. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26693. * 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;
  26694. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26695. */
  26696. set cameraColorCurves(value: Nullable<ColorCurves>);
  26697. /**
  26698. * Custom callback helping to override the default shader used in the material.
  26699. */
  26700. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26701. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26702. protected _worldViewProjectionMatrix: Matrix;
  26703. protected _globalAmbientColor: Color3;
  26704. protected _useLogarithmicDepth: boolean;
  26705. protected _rebuildInParallel: boolean;
  26706. /**
  26707. * Instantiates a new standard material.
  26708. * This is the default material used in Babylon. It is the best trade off between quality
  26709. * and performances.
  26710. * @see http://doc.babylonjs.com/babylon101/materials
  26711. * @param name Define the name of the material in the scene
  26712. * @param scene Define the scene the material belong to
  26713. */
  26714. constructor(name: string, scene: Scene);
  26715. /**
  26716. * Gets a boolean indicating that current material needs to register RTT
  26717. */
  26718. get hasRenderTargetTextures(): boolean;
  26719. /**
  26720. * Gets the current class name of the material e.g. "StandardMaterial"
  26721. * Mainly use in serialization.
  26722. * @returns the class name
  26723. */
  26724. getClassName(): string;
  26725. /**
  26726. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26727. * You can try switching to logarithmic depth.
  26728. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26729. */
  26730. get useLogarithmicDepth(): boolean;
  26731. set useLogarithmicDepth(value: boolean);
  26732. /**
  26733. * Specifies if the material will require alpha blending
  26734. * @returns a boolean specifying if alpha blending is needed
  26735. */
  26736. needAlphaBlending(): boolean;
  26737. /**
  26738. * Specifies if this material should be rendered in alpha test mode
  26739. * @returns a boolean specifying if an alpha test is needed.
  26740. */
  26741. needAlphaTesting(): boolean;
  26742. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26743. /**
  26744. * Get the texture used for alpha test purpose.
  26745. * @returns the diffuse texture in case of the standard material.
  26746. */
  26747. getAlphaTestTexture(): Nullable<BaseTexture>;
  26748. /**
  26749. * Get if the submesh is ready to be used and all its information available.
  26750. * Child classes can use it to update shaders
  26751. * @param mesh defines the mesh to check
  26752. * @param subMesh defines which submesh to check
  26753. * @param useInstances specifies that instances should be used
  26754. * @returns a boolean indicating that the submesh is ready or not
  26755. */
  26756. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26757. /**
  26758. * Builds the material UBO layouts.
  26759. * Used internally during the effect preparation.
  26760. */
  26761. buildUniformLayout(): void;
  26762. /**
  26763. * Unbinds the material from the mesh
  26764. */
  26765. unbind(): void;
  26766. /**
  26767. * Binds the submesh to this material by preparing the effect and shader to draw
  26768. * @param world defines the world transformation matrix
  26769. * @param mesh defines the mesh containing the submesh
  26770. * @param subMesh defines the submesh to bind the material to
  26771. */
  26772. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26773. /**
  26774. * Get the list of animatables in the material.
  26775. * @returns the list of animatables object used in the material
  26776. */
  26777. getAnimatables(): IAnimatable[];
  26778. /**
  26779. * Gets the active textures from the material
  26780. * @returns an array of textures
  26781. */
  26782. getActiveTextures(): BaseTexture[];
  26783. /**
  26784. * Specifies if the material uses a texture
  26785. * @param texture defines the texture to check against the material
  26786. * @returns a boolean specifying if the material uses the texture
  26787. */
  26788. hasTexture(texture: BaseTexture): boolean;
  26789. /**
  26790. * Disposes the material
  26791. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26792. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26793. */
  26794. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26795. /**
  26796. * Makes a duplicate of the material, and gives it a new name
  26797. * @param name defines the new name for the duplicated material
  26798. * @returns the cloned material
  26799. */
  26800. clone(name: string): StandardMaterial;
  26801. /**
  26802. * Serializes this material in a JSON representation
  26803. * @returns the serialized material object
  26804. */
  26805. serialize(): any;
  26806. /**
  26807. * Creates a standard material from parsed material data
  26808. * @param source defines the JSON representation of the material
  26809. * @param scene defines the hosting scene
  26810. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26811. * @returns a new standard material
  26812. */
  26813. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26814. /**
  26815. * Are diffuse textures enabled in the application.
  26816. */
  26817. static get DiffuseTextureEnabled(): boolean;
  26818. static set DiffuseTextureEnabled(value: boolean);
  26819. /**
  26820. * Are ambient textures enabled in the application.
  26821. */
  26822. static get AmbientTextureEnabled(): boolean;
  26823. static set AmbientTextureEnabled(value: boolean);
  26824. /**
  26825. * Are opacity textures enabled in the application.
  26826. */
  26827. static get OpacityTextureEnabled(): boolean;
  26828. static set OpacityTextureEnabled(value: boolean);
  26829. /**
  26830. * Are reflection textures enabled in the application.
  26831. */
  26832. static get ReflectionTextureEnabled(): boolean;
  26833. static set ReflectionTextureEnabled(value: boolean);
  26834. /**
  26835. * Are emissive textures enabled in the application.
  26836. */
  26837. static get EmissiveTextureEnabled(): boolean;
  26838. static set EmissiveTextureEnabled(value: boolean);
  26839. /**
  26840. * Are specular textures enabled in the application.
  26841. */
  26842. static get SpecularTextureEnabled(): boolean;
  26843. static set SpecularTextureEnabled(value: boolean);
  26844. /**
  26845. * Are bump textures enabled in the application.
  26846. */
  26847. static get BumpTextureEnabled(): boolean;
  26848. static set BumpTextureEnabled(value: boolean);
  26849. /**
  26850. * Are lightmap textures enabled in the application.
  26851. */
  26852. static get LightmapTextureEnabled(): boolean;
  26853. static set LightmapTextureEnabled(value: boolean);
  26854. /**
  26855. * Are refraction textures enabled in the application.
  26856. */
  26857. static get RefractionTextureEnabled(): boolean;
  26858. static set RefractionTextureEnabled(value: boolean);
  26859. /**
  26860. * Are color grading textures enabled in the application.
  26861. */
  26862. static get ColorGradingTextureEnabled(): boolean;
  26863. static set ColorGradingTextureEnabled(value: boolean);
  26864. /**
  26865. * Are fresnels enabled in the application.
  26866. */
  26867. static get FresnelEnabled(): boolean;
  26868. static set FresnelEnabled(value: boolean);
  26869. }
  26870. }
  26871. declare module BABYLON {
  26872. /**
  26873. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26874. *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.
  26875. * The SPS is also a particle system. It provides some methods to manage the particles.
  26876. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26877. *
  26878. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26879. */
  26880. export class SolidParticleSystem implements IDisposable {
  26881. /**
  26882. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26883. * Example : var p = SPS.particles[i];
  26884. */
  26885. particles: SolidParticle[];
  26886. /**
  26887. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26888. */
  26889. nbParticles: number;
  26890. /**
  26891. * If the particles must ever face the camera (default false). Useful for planar particles.
  26892. */
  26893. billboard: boolean;
  26894. /**
  26895. * Recompute normals when adding a shape
  26896. */
  26897. recomputeNormals: boolean;
  26898. /**
  26899. * This a counter ofr your own usage. It's not set by any SPS functions.
  26900. */
  26901. counter: number;
  26902. /**
  26903. * The SPS name. This name is also given to the underlying mesh.
  26904. */
  26905. name: string;
  26906. /**
  26907. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26908. */
  26909. mesh: Mesh;
  26910. /**
  26911. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26912. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26913. */
  26914. vars: any;
  26915. /**
  26916. * This array is populated when the SPS is set as 'pickable'.
  26917. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26918. * Each element of this array is an object `{idx: int, faceId: int}`.
  26919. * `idx` is the picked particle index in the `SPS.particles` array
  26920. * `faceId` is the picked face index counted within this particle.
  26921. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26922. */
  26923. pickedParticles: {
  26924. idx: number;
  26925. faceId: number;
  26926. }[];
  26927. /**
  26928. * This array is populated when `enableDepthSort` is set to true.
  26929. * Each element of this array is an instance of the class DepthSortedParticle.
  26930. */
  26931. depthSortedParticles: DepthSortedParticle[];
  26932. /**
  26933. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26934. * @hidden
  26935. */
  26936. _bSphereOnly: boolean;
  26937. /**
  26938. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26939. * @hidden
  26940. */
  26941. _bSphereRadiusFactor: number;
  26942. private _scene;
  26943. private _positions;
  26944. private _indices;
  26945. private _normals;
  26946. private _colors;
  26947. private _uvs;
  26948. private _indices32;
  26949. private _positions32;
  26950. private _normals32;
  26951. private _fixedNormal32;
  26952. private _colors32;
  26953. private _uvs32;
  26954. private _index;
  26955. private _updatable;
  26956. private _pickable;
  26957. private _isVisibilityBoxLocked;
  26958. private _alwaysVisible;
  26959. private _depthSort;
  26960. private _expandable;
  26961. private _shapeCounter;
  26962. private _copy;
  26963. private _color;
  26964. private _computeParticleColor;
  26965. private _computeParticleTexture;
  26966. private _computeParticleRotation;
  26967. private _computeParticleVertex;
  26968. private _computeBoundingBox;
  26969. private _depthSortParticles;
  26970. private _camera;
  26971. private _mustUnrotateFixedNormals;
  26972. private _particlesIntersect;
  26973. private _needs32Bits;
  26974. private _isNotBuilt;
  26975. private _lastParticleId;
  26976. private _idxOfId;
  26977. private _multimaterialEnabled;
  26978. private _useModelMaterial;
  26979. private _indicesByMaterial;
  26980. private _materialIndexes;
  26981. private _depthSortFunction;
  26982. private _materialSortFunction;
  26983. private _materials;
  26984. private _multimaterial;
  26985. private _materialIndexesById;
  26986. private _defaultMaterial;
  26987. private _autoUpdateSubMeshes;
  26988. /**
  26989. * Creates a SPS (Solid Particle System) object.
  26990. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26991. * @param scene (Scene) is the scene in which the SPS is added.
  26992. * @param options defines the options of the sps e.g.
  26993. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26994. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26995. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26996. * * 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.
  26997. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26998. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26999. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27000. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27001. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27002. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27003. */
  27004. constructor(name: string, scene: Scene, options?: {
  27005. updatable?: boolean;
  27006. isPickable?: boolean;
  27007. enableDepthSort?: boolean;
  27008. particleIntersection?: boolean;
  27009. boundingSphereOnly?: boolean;
  27010. bSphereRadiusFactor?: number;
  27011. expandable?: boolean;
  27012. useModelMaterial?: boolean;
  27013. enableMultiMaterial?: boolean;
  27014. });
  27015. /**
  27016. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27017. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27018. * @returns the created mesh
  27019. */
  27020. buildMesh(): Mesh;
  27021. /**
  27022. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27023. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27024. * Thus the particles generated from `digest()` have their property `position` set yet.
  27025. * @param mesh ( Mesh ) is the mesh to be digested
  27026. * @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
  27027. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27028. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27029. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27030. * @returns the current SPS
  27031. */
  27032. digest(mesh: Mesh, options?: {
  27033. facetNb?: number;
  27034. number?: number;
  27035. delta?: number;
  27036. storage?: [];
  27037. }): SolidParticleSystem;
  27038. /**
  27039. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27040. * @hidden
  27041. */
  27042. private _unrotateFixedNormals;
  27043. /**
  27044. * Resets the temporary working copy particle
  27045. * @hidden
  27046. */
  27047. private _resetCopy;
  27048. /**
  27049. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27050. * @param p the current index in the positions array to be updated
  27051. * @param ind the current index in the indices array
  27052. * @param shape a Vector3 array, the shape geometry
  27053. * @param positions the positions array to be updated
  27054. * @param meshInd the shape indices array
  27055. * @param indices the indices array to be updated
  27056. * @param meshUV the shape uv array
  27057. * @param uvs the uv array to be updated
  27058. * @param meshCol the shape color array
  27059. * @param colors the color array to be updated
  27060. * @param meshNor the shape normals array
  27061. * @param normals the normals array to be updated
  27062. * @param idx the particle index
  27063. * @param idxInShape the particle index in its shape
  27064. * @param options the addShape() method passed options
  27065. * @model the particle model
  27066. * @hidden
  27067. */
  27068. private _meshBuilder;
  27069. /**
  27070. * Returns a shape Vector3 array from positions float array
  27071. * @param positions float array
  27072. * @returns a vector3 array
  27073. * @hidden
  27074. */
  27075. private _posToShape;
  27076. /**
  27077. * Returns a shapeUV array from a float uvs (array deep copy)
  27078. * @param uvs as a float array
  27079. * @returns a shapeUV array
  27080. * @hidden
  27081. */
  27082. private _uvsToShapeUV;
  27083. /**
  27084. * Adds a new particle object in the particles array
  27085. * @param idx particle index in particles array
  27086. * @param id particle id
  27087. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27088. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27089. * @param model particle ModelShape object
  27090. * @param shapeId model shape identifier
  27091. * @param idxInShape index of the particle in the current model
  27092. * @param bInfo model bounding info object
  27093. * @param storage target storage array, if any
  27094. * @hidden
  27095. */
  27096. private _addParticle;
  27097. /**
  27098. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27099. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27100. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27101. * @param nb (positive integer) the number of particles to be created from this model
  27102. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27103. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27104. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27105. * @returns the number of shapes in the system
  27106. */
  27107. addShape(mesh: Mesh, nb: number, options?: {
  27108. positionFunction?: any;
  27109. vertexFunction?: any;
  27110. storage?: [];
  27111. }): number;
  27112. /**
  27113. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27114. * @hidden
  27115. */
  27116. private _rebuildParticle;
  27117. /**
  27118. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27119. * @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.
  27120. * @returns the SPS.
  27121. */
  27122. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27123. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27124. * Returns an array with the removed particles.
  27125. * 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.
  27126. * The SPS can't be empty so at least one particle needs to remain in place.
  27127. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27128. * @param start index of the first particle to remove
  27129. * @param end index of the last particle to remove (included)
  27130. * @returns an array populated with the removed particles
  27131. */
  27132. removeParticles(start: number, end: number): SolidParticle[];
  27133. /**
  27134. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27135. * @param solidParticleArray an array populated with Solid Particles objects
  27136. * @returns the SPS
  27137. */
  27138. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27139. /**
  27140. * Creates a new particle and modifies the SPS mesh geometry :
  27141. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27142. * - calls _addParticle() to populate the particle array
  27143. * factorized code from addShape() and insertParticlesFromArray()
  27144. * @param idx particle index in the particles array
  27145. * @param i particle index in its shape
  27146. * @param modelShape particle ModelShape object
  27147. * @param shape shape vertex array
  27148. * @param meshInd shape indices array
  27149. * @param meshUV shape uv array
  27150. * @param meshCol shape color array
  27151. * @param meshNor shape normals array
  27152. * @param bbInfo shape bounding info
  27153. * @param storage target particle storage
  27154. * @options addShape() passed options
  27155. * @hidden
  27156. */
  27157. private _insertNewParticle;
  27158. /**
  27159. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27160. * This method calls `updateParticle()` for each particle of the SPS.
  27161. * For an animated SPS, it is usually called within the render loop.
  27162. * 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.
  27163. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27164. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27165. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27166. * @returns the SPS.
  27167. */
  27168. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27169. /**
  27170. * Disposes the SPS.
  27171. */
  27172. dispose(): void;
  27173. /**
  27174. * Returns a SolidParticle object from its identifier : particle.id
  27175. * @param id (integer) the particle Id
  27176. * @returns the searched particle or null if not found in the SPS.
  27177. */
  27178. getParticleById(id: number): Nullable<SolidParticle>;
  27179. /**
  27180. * Returns a new array populated with the particles having the passed shapeId.
  27181. * @param shapeId (integer) the shape identifier
  27182. * @returns a new solid particle array
  27183. */
  27184. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27185. /**
  27186. * Populates the passed array "ref" with the particles having the passed shapeId.
  27187. * @param shapeId the shape identifier
  27188. * @returns the SPS
  27189. * @param ref
  27190. */
  27191. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27192. /**
  27193. * Computes the required SubMeshes according the materials assigned to the particles.
  27194. * @returns the solid particle system.
  27195. * Does nothing if called before the SPS mesh is built.
  27196. */
  27197. computeSubMeshes(): SolidParticleSystem;
  27198. /**
  27199. * Sorts the solid particles by material when MultiMaterial is enabled.
  27200. * Updates the indices32 array.
  27201. * Updates the indicesByMaterial array.
  27202. * Updates the mesh indices array.
  27203. * @returns the SPS
  27204. * @hidden
  27205. */
  27206. private _sortParticlesByMaterial;
  27207. /**
  27208. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27209. * @hidden
  27210. */
  27211. private _setMaterialIndexesById;
  27212. /**
  27213. * Returns an array with unique values of Materials from the passed array
  27214. * @param array the material array to be checked and filtered
  27215. * @hidden
  27216. */
  27217. private _filterUniqueMaterialId;
  27218. /**
  27219. * Sets a new Standard Material as _defaultMaterial if not already set.
  27220. * @hidden
  27221. */
  27222. private _setDefaultMaterial;
  27223. /**
  27224. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27225. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27226. * @returns the SPS.
  27227. */
  27228. refreshVisibleSize(): SolidParticleSystem;
  27229. /**
  27230. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27231. * @param size the size (float) of the visibility box
  27232. * note : this doesn't lock the SPS mesh bounding box.
  27233. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27234. */
  27235. setVisibilityBox(size: number): void;
  27236. /**
  27237. * Gets whether the SPS as always visible or not
  27238. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27239. */
  27240. get isAlwaysVisible(): boolean;
  27241. /**
  27242. * Sets the SPS as always visible or not
  27243. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27244. */
  27245. set isAlwaysVisible(val: boolean);
  27246. /**
  27247. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27248. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27249. */
  27250. set isVisibilityBoxLocked(val: boolean);
  27251. /**
  27252. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27253. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27254. */
  27255. get isVisibilityBoxLocked(): boolean;
  27256. /**
  27257. * Tells to `setParticles()` to compute the particle rotations or not.
  27258. * Default value : true. The SPS is faster when it's set to false.
  27259. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27260. */
  27261. set computeParticleRotation(val: boolean);
  27262. /**
  27263. * Tells to `setParticles()` to compute the particle colors or not.
  27264. * Default value : true. The SPS is faster when it's set to false.
  27265. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27266. */
  27267. set computeParticleColor(val: boolean);
  27268. set computeParticleTexture(val: boolean);
  27269. /**
  27270. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27271. * Default value : false. The SPS is faster when it's set to false.
  27272. * Note : the particle custom vertex positions aren't stored values.
  27273. */
  27274. set computeParticleVertex(val: boolean);
  27275. /**
  27276. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27277. */
  27278. set computeBoundingBox(val: boolean);
  27279. /**
  27280. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27281. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27282. * Default : `true`
  27283. */
  27284. set depthSortParticles(val: boolean);
  27285. /**
  27286. * Gets if `setParticles()` computes the particle rotations or not.
  27287. * Default value : true. The SPS is faster when it's set to false.
  27288. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27289. */
  27290. get computeParticleRotation(): boolean;
  27291. /**
  27292. * Gets if `setParticles()` computes the particle colors or not.
  27293. * Default value : true. The SPS is faster when it's set to false.
  27294. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27295. */
  27296. get computeParticleColor(): boolean;
  27297. /**
  27298. * Gets if `setParticles()` computes the particle textures or not.
  27299. * Default value : true. The SPS is faster when it's set to false.
  27300. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27301. */
  27302. get computeParticleTexture(): boolean;
  27303. /**
  27304. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27305. * Default value : false. The SPS is faster when it's set to false.
  27306. * Note : the particle custom vertex positions aren't stored values.
  27307. */
  27308. get computeParticleVertex(): boolean;
  27309. /**
  27310. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27311. */
  27312. get computeBoundingBox(): boolean;
  27313. /**
  27314. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27315. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27316. * Default : `true`
  27317. */
  27318. get depthSortParticles(): boolean;
  27319. /**
  27320. * Gets if the SPS is created as expandable at construction time.
  27321. * Default : `false`
  27322. */
  27323. get expandable(): boolean;
  27324. /**
  27325. * Gets if the SPS supports the Multi Materials
  27326. */
  27327. get multimaterialEnabled(): boolean;
  27328. /**
  27329. * Gets if the SPS uses the model materials for its own multimaterial.
  27330. */
  27331. get useModelMaterial(): boolean;
  27332. /**
  27333. * The SPS used material array.
  27334. */
  27335. get materials(): Material[];
  27336. /**
  27337. * Sets the SPS MultiMaterial from the passed materials.
  27338. * Note : the passed array is internally copied and not used then by reference.
  27339. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27340. */
  27341. setMultiMaterial(materials: Material[]): void;
  27342. /**
  27343. * The SPS computed multimaterial object
  27344. */
  27345. get multimaterial(): MultiMaterial;
  27346. set multimaterial(mm: MultiMaterial);
  27347. /**
  27348. * If the subMeshes must be updated on the next call to setParticles()
  27349. */
  27350. get autoUpdateSubMeshes(): boolean;
  27351. set autoUpdateSubMeshes(val: boolean);
  27352. /**
  27353. * This function does nothing. It may be overwritten to set all the particle first values.
  27354. * The SPS doesn't call this function, you may have to call it by your own.
  27355. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27356. */
  27357. initParticles(): void;
  27358. /**
  27359. * This function does nothing. It may be overwritten to recycle a particle.
  27360. * The SPS doesn't call this function, you may have to call it by your own.
  27361. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27362. * @param particle The particle to recycle
  27363. * @returns the recycled particle
  27364. */
  27365. recycleParticle(particle: SolidParticle): SolidParticle;
  27366. /**
  27367. * Updates a particle : this function should be overwritten by the user.
  27368. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27369. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27370. * @example : just set a particle position or velocity and recycle conditions
  27371. * @param particle The particle to update
  27372. * @returns the updated particle
  27373. */
  27374. updateParticle(particle: SolidParticle): SolidParticle;
  27375. /**
  27376. * Updates a vertex of a particle : it can be overwritten by the user.
  27377. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27378. * @param particle the current particle
  27379. * @param vertex the current index of the current particle
  27380. * @param pt the index of the current vertex in the particle shape
  27381. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27382. * @example : just set a vertex particle position
  27383. * @returns the updated vertex
  27384. */
  27385. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27386. /**
  27387. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27388. * This does nothing and may be overwritten by the user.
  27389. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27390. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27391. * @param update the boolean update value actually passed to setParticles()
  27392. */
  27393. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27394. /**
  27395. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27396. * This will be passed three parameters.
  27397. * This does nothing and may be overwritten by the user.
  27398. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27399. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27400. * @param update the boolean update value actually passed to setParticles()
  27401. */
  27402. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27403. }
  27404. }
  27405. declare module BABYLON {
  27406. /**
  27407. * Represents one particle of a solid particle system.
  27408. */
  27409. export class SolidParticle {
  27410. /**
  27411. * particle global index
  27412. */
  27413. idx: number;
  27414. /**
  27415. * particle identifier
  27416. */
  27417. id: number;
  27418. /**
  27419. * The color of the particle
  27420. */
  27421. color: Nullable<Color4>;
  27422. /**
  27423. * The world space position of the particle.
  27424. */
  27425. position: Vector3;
  27426. /**
  27427. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27428. */
  27429. rotation: Vector3;
  27430. /**
  27431. * The world space rotation quaternion of the particle.
  27432. */
  27433. rotationQuaternion: Nullable<Quaternion>;
  27434. /**
  27435. * The scaling of the particle.
  27436. */
  27437. scaling: Vector3;
  27438. /**
  27439. * The uvs of the particle.
  27440. */
  27441. uvs: Vector4;
  27442. /**
  27443. * The current speed of the particle.
  27444. */
  27445. velocity: Vector3;
  27446. /**
  27447. * The pivot point in the particle local space.
  27448. */
  27449. pivot: Vector3;
  27450. /**
  27451. * Must the particle be translated from its pivot point in its local space ?
  27452. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27453. * Default : false
  27454. */
  27455. translateFromPivot: boolean;
  27456. /**
  27457. * Is the particle active or not ?
  27458. */
  27459. alive: boolean;
  27460. /**
  27461. * Is the particle visible or not ?
  27462. */
  27463. isVisible: boolean;
  27464. /**
  27465. * Index of this particle in the global "positions" array (Internal use)
  27466. * @hidden
  27467. */
  27468. _pos: number;
  27469. /**
  27470. * @hidden Index of this particle in the global "indices" array (Internal use)
  27471. */
  27472. _ind: number;
  27473. /**
  27474. * @hidden ModelShape of this particle (Internal use)
  27475. */
  27476. _model: ModelShape;
  27477. /**
  27478. * ModelShape id of this particle
  27479. */
  27480. shapeId: number;
  27481. /**
  27482. * Index of the particle in its shape id
  27483. */
  27484. idxInShape: number;
  27485. /**
  27486. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27487. */
  27488. _modelBoundingInfo: BoundingInfo;
  27489. /**
  27490. * @hidden Particle BoundingInfo object (Internal use)
  27491. */
  27492. _boundingInfo: BoundingInfo;
  27493. /**
  27494. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27495. */
  27496. _sps: SolidParticleSystem;
  27497. /**
  27498. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27499. */
  27500. _stillInvisible: boolean;
  27501. /**
  27502. * @hidden Last computed particle rotation matrix
  27503. */
  27504. _rotationMatrix: number[];
  27505. /**
  27506. * Parent particle Id, if any.
  27507. * Default null.
  27508. */
  27509. parentId: Nullable<number>;
  27510. /**
  27511. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27512. */
  27513. materialIndex: Nullable<number>;
  27514. /**
  27515. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27516. * The possible values are :
  27517. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27518. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27519. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27520. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27521. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27522. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27523. * */
  27524. cullingStrategy: number;
  27525. /**
  27526. * @hidden Internal global position in the SPS.
  27527. */
  27528. _globalPosition: Vector3;
  27529. /**
  27530. * Creates a Solid Particle object.
  27531. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27532. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27533. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27534. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27535. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27536. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27537. * @param shapeId (integer) is the model shape identifier in the SPS.
  27538. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27539. * @param sps defines the sps it is associated to
  27540. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27541. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27542. */
  27543. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27544. /**
  27545. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27546. * @param target the particle target
  27547. * @returns the current particle
  27548. */
  27549. copyToRef(target: SolidParticle): SolidParticle;
  27550. /**
  27551. * Legacy support, changed scale to scaling
  27552. */
  27553. get scale(): Vector3;
  27554. /**
  27555. * Legacy support, changed scale to scaling
  27556. */
  27557. set scale(scale: Vector3);
  27558. /**
  27559. * Legacy support, changed quaternion to rotationQuaternion
  27560. */
  27561. get quaternion(): Nullable<Quaternion>;
  27562. /**
  27563. * Legacy support, changed quaternion to rotationQuaternion
  27564. */
  27565. set quaternion(q: Nullable<Quaternion>);
  27566. /**
  27567. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27568. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27569. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27570. * @returns true if it intersects
  27571. */
  27572. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27573. /**
  27574. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27575. * A particle is in the frustum if its bounding box intersects the frustum
  27576. * @param frustumPlanes defines the frustum to test
  27577. * @returns true if the particle is in the frustum planes
  27578. */
  27579. isInFrustum(frustumPlanes: Plane[]): boolean;
  27580. /**
  27581. * get the rotation matrix of the particle
  27582. * @hidden
  27583. */
  27584. getRotationMatrix(m: Matrix): void;
  27585. }
  27586. /**
  27587. * Represents the shape of the model used by one particle of a solid particle system.
  27588. * SPS internal tool, don't use it manually.
  27589. */
  27590. export class ModelShape {
  27591. /**
  27592. * The shape id
  27593. * @hidden
  27594. */
  27595. shapeID: number;
  27596. /**
  27597. * flat array of model positions (internal use)
  27598. * @hidden
  27599. */
  27600. _shape: Vector3[];
  27601. /**
  27602. * flat array of model UVs (internal use)
  27603. * @hidden
  27604. */
  27605. _shapeUV: number[];
  27606. /**
  27607. * color array of the model
  27608. * @hidden
  27609. */
  27610. _shapeColors: number[];
  27611. /**
  27612. * indices array of the model
  27613. * @hidden
  27614. */
  27615. _indices: number[];
  27616. /**
  27617. * normals array of the model
  27618. * @hidden
  27619. */
  27620. _normals: number[];
  27621. /**
  27622. * length of the shape in the model indices array (internal use)
  27623. * @hidden
  27624. */
  27625. _indicesLength: number;
  27626. /**
  27627. * Custom position function (internal use)
  27628. * @hidden
  27629. */
  27630. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27631. /**
  27632. * Custom vertex function (internal use)
  27633. * @hidden
  27634. */
  27635. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27636. /**
  27637. * Model material (internal use)
  27638. * @hidden
  27639. */
  27640. _material: Nullable<Material>;
  27641. /**
  27642. * 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.
  27643. * SPS internal tool, don't use it manually.
  27644. * @hidden
  27645. */
  27646. 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>);
  27647. }
  27648. /**
  27649. * Represents a Depth Sorted Particle in the solid particle system.
  27650. * @hidden
  27651. */
  27652. export class DepthSortedParticle {
  27653. /**
  27654. * Index of the particle in the "indices" array
  27655. */
  27656. ind: number;
  27657. /**
  27658. * Length of the particle shape in the "indices" array
  27659. */
  27660. indicesLength: number;
  27661. /**
  27662. * Squared distance from the particle to the camera
  27663. */
  27664. sqDistance: number;
  27665. /**
  27666. * Material index when used with MultiMaterials
  27667. */
  27668. materialIndex: number;
  27669. /**
  27670. * Creates a new sorted particle
  27671. * @param materialIndex
  27672. */
  27673. constructor(ind: number, indLength: number, materialIndex: number);
  27674. }
  27675. }
  27676. declare module BABYLON {
  27677. /**
  27678. * @hidden
  27679. */
  27680. export class _MeshCollisionData {
  27681. _checkCollisions: boolean;
  27682. _collisionMask: number;
  27683. _collisionGroup: number;
  27684. _collider: Nullable<Collider>;
  27685. _oldPositionForCollisions: Vector3;
  27686. _diffPositionForCollisions: Vector3;
  27687. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27688. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27689. }
  27690. }
  27691. declare module BABYLON {
  27692. /** @hidden */
  27693. class _FacetDataStorage {
  27694. facetPositions: Vector3[];
  27695. facetNormals: Vector3[];
  27696. facetPartitioning: number[][];
  27697. facetNb: number;
  27698. partitioningSubdivisions: number;
  27699. partitioningBBoxRatio: number;
  27700. facetDataEnabled: boolean;
  27701. facetParameters: any;
  27702. bbSize: Vector3;
  27703. subDiv: {
  27704. max: number;
  27705. X: number;
  27706. Y: number;
  27707. Z: number;
  27708. };
  27709. facetDepthSort: boolean;
  27710. facetDepthSortEnabled: boolean;
  27711. depthSortedIndices: IndicesArray;
  27712. depthSortedFacets: {
  27713. ind: number;
  27714. sqDistance: number;
  27715. }[];
  27716. facetDepthSortFunction: (f1: {
  27717. ind: number;
  27718. sqDistance: number;
  27719. }, f2: {
  27720. ind: number;
  27721. sqDistance: number;
  27722. }) => number;
  27723. facetDepthSortFrom: Vector3;
  27724. facetDepthSortOrigin: Vector3;
  27725. invertedMatrix: Matrix;
  27726. }
  27727. /**
  27728. * @hidden
  27729. **/
  27730. class _InternalAbstractMeshDataInfo {
  27731. _hasVertexAlpha: boolean;
  27732. _useVertexColors: boolean;
  27733. _numBoneInfluencers: number;
  27734. _applyFog: boolean;
  27735. _receiveShadows: boolean;
  27736. _facetData: _FacetDataStorage;
  27737. _visibility: number;
  27738. _skeleton: Nullable<Skeleton>;
  27739. _layerMask: number;
  27740. _computeBonesUsingShaders: boolean;
  27741. _isActive: boolean;
  27742. _onlyForInstances: boolean;
  27743. _isActiveIntermediate: boolean;
  27744. _onlyForInstancesIntermediate: boolean;
  27745. _actAsRegularMesh: boolean;
  27746. }
  27747. /**
  27748. * Class used to store all common mesh properties
  27749. */
  27750. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27751. /** No occlusion */
  27752. static OCCLUSION_TYPE_NONE: number;
  27753. /** Occlusion set to optimisitic */
  27754. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27755. /** Occlusion set to strict */
  27756. static OCCLUSION_TYPE_STRICT: number;
  27757. /** Use an accurante occlusion algorithm */
  27758. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27759. /** Use a conservative occlusion algorithm */
  27760. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27761. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27762. * Test order :
  27763. * Is the bounding sphere outside the frustum ?
  27764. * If not, are the bounding box vertices outside the frustum ?
  27765. * It not, then the cullable object is in the frustum.
  27766. */
  27767. static readonly CULLINGSTRATEGY_STANDARD: number;
  27768. /** Culling strategy : Bounding Sphere Only.
  27769. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27770. * It's also less accurate than the standard because some not visible objects can still be selected.
  27771. * Test : is the bounding sphere outside the frustum ?
  27772. * If not, then the cullable object is in the frustum.
  27773. */
  27774. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27775. /** Culling strategy : Optimistic Inclusion.
  27776. * This in an inclusion test first, then the standard exclusion test.
  27777. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27778. * 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.
  27779. * Anyway, it's as accurate as the standard strategy.
  27780. * Test :
  27781. * Is the cullable object bounding sphere center in the frustum ?
  27782. * If not, apply the default culling strategy.
  27783. */
  27784. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27785. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27786. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27787. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27788. * 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.
  27789. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27790. * Test :
  27791. * Is the cullable object bounding sphere center in the frustum ?
  27792. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27793. */
  27794. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27795. /**
  27796. * No billboard
  27797. */
  27798. static get BILLBOARDMODE_NONE(): number;
  27799. /** Billboard on X axis */
  27800. static get BILLBOARDMODE_X(): number;
  27801. /** Billboard on Y axis */
  27802. static get BILLBOARDMODE_Y(): number;
  27803. /** Billboard on Z axis */
  27804. static get BILLBOARDMODE_Z(): number;
  27805. /** Billboard on all axes */
  27806. static get BILLBOARDMODE_ALL(): number;
  27807. /** Billboard on using position instead of orientation */
  27808. static get BILLBOARDMODE_USE_POSITION(): number;
  27809. /** @hidden */
  27810. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27811. /**
  27812. * The culling strategy to use to check whether the mesh must be rendered or not.
  27813. * This value can be changed at any time and will be used on the next render mesh selection.
  27814. * The possible values are :
  27815. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27816. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27817. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27818. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27819. * Please read each static variable documentation to get details about the culling process.
  27820. * */
  27821. cullingStrategy: number;
  27822. /**
  27823. * Gets the number of facets in the mesh
  27824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27825. */
  27826. get facetNb(): number;
  27827. /**
  27828. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27830. */
  27831. get partitioningSubdivisions(): number;
  27832. set partitioningSubdivisions(nb: number);
  27833. /**
  27834. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27835. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27837. */
  27838. get partitioningBBoxRatio(): number;
  27839. set partitioningBBoxRatio(ratio: number);
  27840. /**
  27841. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27842. * Works only for updatable meshes.
  27843. * Doesn't work with multi-materials
  27844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27845. */
  27846. get mustDepthSortFacets(): boolean;
  27847. set mustDepthSortFacets(sort: boolean);
  27848. /**
  27849. * The location (Vector3) where the facet depth sort must be computed from.
  27850. * By default, the active camera position.
  27851. * Used only when facet depth sort is enabled
  27852. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27853. */
  27854. get facetDepthSortFrom(): Vector3;
  27855. set facetDepthSortFrom(location: Vector3);
  27856. /**
  27857. * gets a boolean indicating if facetData is enabled
  27858. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27859. */
  27860. get isFacetDataEnabled(): boolean;
  27861. /** @hidden */
  27862. _updateNonUniformScalingState(value: boolean): boolean;
  27863. /**
  27864. * An event triggered when this mesh collides with another one
  27865. */
  27866. onCollideObservable: Observable<AbstractMesh>;
  27867. /** Set a function to call when this mesh collides with another one */
  27868. set onCollide(callback: () => void);
  27869. /**
  27870. * An event triggered when the collision's position changes
  27871. */
  27872. onCollisionPositionChangeObservable: Observable<Vector3>;
  27873. /** Set a function to call when the collision's position changes */
  27874. set onCollisionPositionChange(callback: () => void);
  27875. /**
  27876. * An event triggered when material is changed
  27877. */
  27878. onMaterialChangedObservable: Observable<AbstractMesh>;
  27879. /**
  27880. * Gets or sets the orientation for POV movement & rotation
  27881. */
  27882. definedFacingForward: boolean;
  27883. /** @hidden */
  27884. _occlusionQuery: Nullable<WebGLQuery>;
  27885. /** @hidden */
  27886. _renderingGroup: Nullable<RenderingGroup>;
  27887. /**
  27888. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27889. */
  27890. get visibility(): number;
  27891. /**
  27892. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27893. */
  27894. set visibility(value: number);
  27895. /** Gets or sets the alpha index used to sort transparent meshes
  27896. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27897. */
  27898. alphaIndex: number;
  27899. /**
  27900. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27901. */
  27902. isVisible: boolean;
  27903. /**
  27904. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27905. */
  27906. isPickable: boolean;
  27907. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27908. showSubMeshesBoundingBox: boolean;
  27909. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27910. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27911. */
  27912. isBlocker: boolean;
  27913. /**
  27914. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27915. */
  27916. enablePointerMoveEvents: boolean;
  27917. /**
  27918. * Specifies the rendering group id for this mesh (0 by default)
  27919. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27920. */
  27921. renderingGroupId: number;
  27922. private _material;
  27923. /** Gets or sets current material */
  27924. get material(): Nullable<Material>;
  27925. set material(value: Nullable<Material>);
  27926. /**
  27927. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27928. * @see http://doc.babylonjs.com/babylon101/shadows
  27929. */
  27930. get receiveShadows(): boolean;
  27931. set receiveShadows(value: boolean);
  27932. /** Defines color to use when rendering outline */
  27933. outlineColor: Color3;
  27934. /** Define width to use when rendering outline */
  27935. outlineWidth: number;
  27936. /** Defines color to use when rendering overlay */
  27937. overlayColor: Color3;
  27938. /** Defines alpha to use when rendering overlay */
  27939. overlayAlpha: number;
  27940. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27941. get hasVertexAlpha(): boolean;
  27942. set hasVertexAlpha(value: boolean);
  27943. /** 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) */
  27944. get useVertexColors(): boolean;
  27945. set useVertexColors(value: boolean);
  27946. /**
  27947. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27948. */
  27949. get computeBonesUsingShaders(): boolean;
  27950. set computeBonesUsingShaders(value: boolean);
  27951. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27952. get numBoneInfluencers(): number;
  27953. set numBoneInfluencers(value: number);
  27954. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27955. get applyFog(): boolean;
  27956. set applyFog(value: boolean);
  27957. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27958. useOctreeForRenderingSelection: boolean;
  27959. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27960. useOctreeForPicking: boolean;
  27961. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27962. useOctreeForCollisions: boolean;
  27963. /**
  27964. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27965. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27966. */
  27967. get layerMask(): number;
  27968. set layerMask(value: number);
  27969. /**
  27970. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27971. */
  27972. alwaysSelectAsActiveMesh: boolean;
  27973. /**
  27974. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27975. */
  27976. doNotSyncBoundingInfo: boolean;
  27977. /**
  27978. * Gets or sets the current action manager
  27979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27980. */
  27981. actionManager: Nullable<AbstractActionManager>;
  27982. private _meshCollisionData;
  27983. /**
  27984. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27986. */
  27987. ellipsoid: Vector3;
  27988. /**
  27989. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27991. */
  27992. ellipsoidOffset: Vector3;
  27993. /**
  27994. * Gets or sets a collision mask used to mask collisions (default is -1).
  27995. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27996. */
  27997. get collisionMask(): number;
  27998. set collisionMask(mask: number);
  27999. /**
  28000. * Gets or sets the current collision group mask (-1 by default).
  28001. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28002. */
  28003. get collisionGroup(): number;
  28004. set collisionGroup(mask: number);
  28005. /**
  28006. * Defines edge width used when edgesRenderer is enabled
  28007. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28008. */
  28009. edgesWidth: number;
  28010. /**
  28011. * Defines edge color used when edgesRenderer is enabled
  28012. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28013. */
  28014. edgesColor: Color4;
  28015. /** @hidden */
  28016. _edgesRenderer: Nullable<IEdgesRenderer>;
  28017. /** @hidden */
  28018. _masterMesh: Nullable<AbstractMesh>;
  28019. /** @hidden */
  28020. _boundingInfo: Nullable<BoundingInfo>;
  28021. /** @hidden */
  28022. _renderId: number;
  28023. /**
  28024. * Gets or sets the list of subMeshes
  28025. * @see http://doc.babylonjs.com/how_to/multi_materials
  28026. */
  28027. subMeshes: SubMesh[];
  28028. /** @hidden */
  28029. _intersectionsInProgress: AbstractMesh[];
  28030. /** @hidden */
  28031. _unIndexed: boolean;
  28032. /** @hidden */
  28033. _lightSources: Light[];
  28034. /** Gets the list of lights affecting that mesh */
  28035. get lightSources(): Light[];
  28036. /** @hidden */
  28037. get _positions(): Nullable<Vector3[]>;
  28038. /** @hidden */
  28039. _waitingData: {
  28040. lods: Nullable<any>;
  28041. actions: Nullable<any>;
  28042. freezeWorldMatrix: Nullable<boolean>;
  28043. };
  28044. /** @hidden */
  28045. _bonesTransformMatrices: Nullable<Float32Array>;
  28046. /** @hidden */
  28047. _transformMatrixTexture: Nullable<RawTexture>;
  28048. /**
  28049. * Gets or sets a skeleton to apply skining transformations
  28050. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28051. */
  28052. set skeleton(value: Nullable<Skeleton>);
  28053. get skeleton(): Nullable<Skeleton>;
  28054. /**
  28055. * An event triggered when the mesh is rebuilt.
  28056. */
  28057. onRebuildObservable: Observable<AbstractMesh>;
  28058. /**
  28059. * Creates a new AbstractMesh
  28060. * @param name defines the name of the mesh
  28061. * @param scene defines the hosting scene
  28062. */
  28063. constructor(name: string, scene?: Nullable<Scene>);
  28064. /**
  28065. * Returns the string "AbstractMesh"
  28066. * @returns "AbstractMesh"
  28067. */
  28068. getClassName(): string;
  28069. /**
  28070. * Gets a string representation of the current mesh
  28071. * @param fullDetails defines a boolean indicating if full details must be included
  28072. * @returns a string representation of the current mesh
  28073. */
  28074. toString(fullDetails?: boolean): string;
  28075. /**
  28076. * @hidden
  28077. */
  28078. protected _getEffectiveParent(): Nullable<Node>;
  28079. /** @hidden */
  28080. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28081. /** @hidden */
  28082. _rebuild(): void;
  28083. /** @hidden */
  28084. _resyncLightSources(): void;
  28085. /** @hidden */
  28086. _resyncLightSource(light: Light): void;
  28087. /** @hidden */
  28088. _unBindEffect(): void;
  28089. /** @hidden */
  28090. _removeLightSource(light: Light, dispose: boolean): void;
  28091. private _markSubMeshesAsDirty;
  28092. /** @hidden */
  28093. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28094. /** @hidden */
  28095. _markSubMeshesAsAttributesDirty(): void;
  28096. /** @hidden */
  28097. _markSubMeshesAsMiscDirty(): void;
  28098. /**
  28099. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28100. */
  28101. get scaling(): Vector3;
  28102. set scaling(newScaling: Vector3);
  28103. /**
  28104. * Returns true if the mesh is blocked. Implemented by child classes
  28105. */
  28106. get isBlocked(): boolean;
  28107. /**
  28108. * Returns the mesh itself by default. Implemented by child classes
  28109. * @param camera defines the camera to use to pick the right LOD level
  28110. * @returns the currentAbstractMesh
  28111. */
  28112. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28113. /**
  28114. * Returns 0 by default. Implemented by child classes
  28115. * @returns an integer
  28116. */
  28117. getTotalVertices(): number;
  28118. /**
  28119. * Returns a positive integer : the total number of indices in this mesh geometry.
  28120. * @returns the numner of indices or zero if the mesh has no geometry.
  28121. */
  28122. getTotalIndices(): number;
  28123. /**
  28124. * Returns null by default. Implemented by child classes
  28125. * @returns null
  28126. */
  28127. getIndices(): Nullable<IndicesArray>;
  28128. /**
  28129. * Returns the array of the requested vertex data kind. Implemented by child classes
  28130. * @param kind defines the vertex data kind to use
  28131. * @returns null
  28132. */
  28133. getVerticesData(kind: string): Nullable<FloatArray>;
  28134. /**
  28135. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28136. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28137. * Note that a new underlying VertexBuffer object is created each call.
  28138. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28139. * @param kind defines vertex data kind:
  28140. * * VertexBuffer.PositionKind
  28141. * * VertexBuffer.UVKind
  28142. * * VertexBuffer.UV2Kind
  28143. * * VertexBuffer.UV3Kind
  28144. * * VertexBuffer.UV4Kind
  28145. * * VertexBuffer.UV5Kind
  28146. * * VertexBuffer.UV6Kind
  28147. * * VertexBuffer.ColorKind
  28148. * * VertexBuffer.MatricesIndicesKind
  28149. * * VertexBuffer.MatricesIndicesExtraKind
  28150. * * VertexBuffer.MatricesWeightsKind
  28151. * * VertexBuffer.MatricesWeightsExtraKind
  28152. * @param data defines the data source
  28153. * @param updatable defines if the data must be flagged as updatable (or static)
  28154. * @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
  28155. * @returns the current mesh
  28156. */
  28157. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28158. /**
  28159. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28160. * If the mesh has no geometry, it is simply returned as it is.
  28161. * @param kind defines vertex data kind:
  28162. * * VertexBuffer.PositionKind
  28163. * * VertexBuffer.UVKind
  28164. * * VertexBuffer.UV2Kind
  28165. * * VertexBuffer.UV3Kind
  28166. * * VertexBuffer.UV4Kind
  28167. * * VertexBuffer.UV5Kind
  28168. * * VertexBuffer.UV6Kind
  28169. * * VertexBuffer.ColorKind
  28170. * * VertexBuffer.MatricesIndicesKind
  28171. * * VertexBuffer.MatricesIndicesExtraKind
  28172. * * VertexBuffer.MatricesWeightsKind
  28173. * * VertexBuffer.MatricesWeightsExtraKind
  28174. * @param data defines the data source
  28175. * @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
  28176. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28177. * @returns the current mesh
  28178. */
  28179. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28180. /**
  28181. * Sets the mesh indices,
  28182. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28183. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28184. * @param totalVertices Defines the total number of vertices
  28185. * @returns the current mesh
  28186. */
  28187. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28188. /**
  28189. * Gets a boolean indicating if specific vertex data is present
  28190. * @param kind defines the vertex data kind to use
  28191. * @returns true is data kind is present
  28192. */
  28193. isVerticesDataPresent(kind: string): boolean;
  28194. /**
  28195. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28196. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28197. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28198. * @returns a BoundingInfo
  28199. */
  28200. getBoundingInfo(): BoundingInfo;
  28201. /**
  28202. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28203. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28204. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28205. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28206. * @returns the current mesh
  28207. */
  28208. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28209. /**
  28210. * Overwrite the current bounding info
  28211. * @param boundingInfo defines the new bounding info
  28212. * @returns the current mesh
  28213. */
  28214. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28215. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28216. get useBones(): boolean;
  28217. /** @hidden */
  28218. _preActivate(): void;
  28219. /** @hidden */
  28220. _preActivateForIntermediateRendering(renderId: number): void;
  28221. /** @hidden */
  28222. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28223. /** @hidden */
  28224. _postActivate(): void;
  28225. /** @hidden */
  28226. _freeze(): void;
  28227. /** @hidden */
  28228. _unFreeze(): void;
  28229. /**
  28230. * Gets the current world matrix
  28231. * @returns a Matrix
  28232. */
  28233. getWorldMatrix(): Matrix;
  28234. /** @hidden */
  28235. _getWorldMatrixDeterminant(): number;
  28236. /**
  28237. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28238. */
  28239. get isAnInstance(): boolean;
  28240. /**
  28241. * Gets a boolean indicating if this mesh has instances
  28242. */
  28243. get hasInstances(): boolean;
  28244. /**
  28245. * Perform relative position change from the point of view of behind the front of the mesh.
  28246. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28247. * Supports definition of mesh facing forward or backward
  28248. * @param amountRight defines the distance on the right axis
  28249. * @param amountUp defines the distance on the up axis
  28250. * @param amountForward defines the distance on the forward axis
  28251. * @returns the current mesh
  28252. */
  28253. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28254. /**
  28255. * Calculate relative position change from the point of view of behind the front of the mesh.
  28256. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28257. * Supports definition of mesh facing forward or backward
  28258. * @param amountRight defines the distance on the right axis
  28259. * @param amountUp defines the distance on the up axis
  28260. * @param amountForward defines the distance on the forward axis
  28261. * @returns the new displacement vector
  28262. */
  28263. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28264. /**
  28265. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28266. * Supports definition of mesh facing forward or backward
  28267. * @param flipBack defines the flip
  28268. * @param twirlClockwise defines the twirl
  28269. * @param tiltRight defines the tilt
  28270. * @returns the current mesh
  28271. */
  28272. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28273. /**
  28274. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28275. * Supports definition of mesh facing forward or backward.
  28276. * @param flipBack defines the flip
  28277. * @param twirlClockwise defines the twirl
  28278. * @param tiltRight defines the tilt
  28279. * @returns the new rotation vector
  28280. */
  28281. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28282. /**
  28283. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28284. * This means the mesh underlying bounding box and sphere are recomputed.
  28285. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28286. * @returns the current mesh
  28287. */
  28288. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28289. /** @hidden */
  28290. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28291. /** @hidden */
  28292. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28293. /** @hidden */
  28294. _updateBoundingInfo(): AbstractMesh;
  28295. /** @hidden */
  28296. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28297. /** @hidden */
  28298. protected _afterComputeWorldMatrix(): void;
  28299. /** @hidden */
  28300. get _effectiveMesh(): AbstractMesh;
  28301. /**
  28302. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28303. * A mesh is in the frustum if its bounding box intersects the frustum
  28304. * @param frustumPlanes defines the frustum to test
  28305. * @returns true if the mesh is in the frustum planes
  28306. */
  28307. isInFrustum(frustumPlanes: Plane[]): boolean;
  28308. /**
  28309. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28310. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28311. * @param frustumPlanes defines the frustum to test
  28312. * @returns true if the mesh is completely in the frustum planes
  28313. */
  28314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28315. /**
  28316. * True if the mesh intersects another mesh or a SolidParticle object
  28317. * @param mesh defines a target mesh or SolidParticle to test
  28318. * @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)
  28319. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28320. * @returns true if there is an intersection
  28321. */
  28322. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28323. /**
  28324. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28325. * @param point defines the point to test
  28326. * @returns true if there is an intersection
  28327. */
  28328. intersectsPoint(point: Vector3): boolean;
  28329. /**
  28330. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28332. */
  28333. get checkCollisions(): boolean;
  28334. set checkCollisions(collisionEnabled: boolean);
  28335. /**
  28336. * Gets Collider object used to compute collisions (not physics)
  28337. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28338. */
  28339. get collider(): Nullable<Collider>;
  28340. /**
  28341. * Move the mesh using collision engine
  28342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28343. * @param displacement defines the requested displacement vector
  28344. * @returns the current mesh
  28345. */
  28346. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28347. private _onCollisionPositionChange;
  28348. /** @hidden */
  28349. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28350. /** @hidden */
  28351. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28352. /** @hidden */
  28353. _checkCollision(collider: Collider): AbstractMesh;
  28354. /** @hidden */
  28355. _generatePointsArray(): boolean;
  28356. /**
  28357. * Checks if the passed Ray intersects with the mesh
  28358. * @param ray defines the ray to use
  28359. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28360. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28361. * @returns the picking info
  28362. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28363. */
  28364. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28365. /**
  28366. * Clones the current mesh
  28367. * @param name defines the mesh name
  28368. * @param newParent defines the new mesh parent
  28369. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28370. * @returns the new mesh
  28371. */
  28372. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28373. /**
  28374. * Disposes all the submeshes of the current meshnp
  28375. * @returns the current mesh
  28376. */
  28377. releaseSubMeshes(): AbstractMesh;
  28378. /**
  28379. * Releases resources associated with this abstract mesh.
  28380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28382. */
  28383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28384. /**
  28385. * Adds the passed mesh as a child to the current mesh
  28386. * @param mesh defines the child mesh
  28387. * @returns the current mesh
  28388. */
  28389. addChild(mesh: AbstractMesh): AbstractMesh;
  28390. /**
  28391. * Removes the passed mesh from the current mesh children list
  28392. * @param mesh defines the child mesh
  28393. * @returns the current mesh
  28394. */
  28395. removeChild(mesh: AbstractMesh): AbstractMesh;
  28396. /** @hidden */
  28397. private _initFacetData;
  28398. /**
  28399. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28400. * This method can be called within the render loop.
  28401. * 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
  28402. * @returns the current mesh
  28403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28404. */
  28405. updateFacetData(): AbstractMesh;
  28406. /**
  28407. * Returns the facetLocalNormals array.
  28408. * The normals are expressed in the mesh local spac
  28409. * @returns an array of Vector3
  28410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28411. */
  28412. getFacetLocalNormals(): Vector3[];
  28413. /**
  28414. * Returns the facetLocalPositions array.
  28415. * The facet positions are expressed in the mesh local space
  28416. * @returns an array of Vector3
  28417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28418. */
  28419. getFacetLocalPositions(): Vector3[];
  28420. /**
  28421. * Returns the facetLocalPartioning array
  28422. * @returns an array of array of numbers
  28423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28424. */
  28425. getFacetLocalPartitioning(): number[][];
  28426. /**
  28427. * Returns the i-th facet position in the world system.
  28428. * This method allocates a new Vector3 per call
  28429. * @param i defines the facet index
  28430. * @returns a new Vector3
  28431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28432. */
  28433. getFacetPosition(i: number): Vector3;
  28434. /**
  28435. * Sets the reference Vector3 with the i-th facet position in the world system
  28436. * @param i defines the facet index
  28437. * @param ref defines the target vector
  28438. * @returns the current mesh
  28439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28440. */
  28441. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28442. /**
  28443. * Returns the i-th facet normal in the world system.
  28444. * This method allocates a new Vector3 per call
  28445. * @param i defines the facet index
  28446. * @returns a new Vector3
  28447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28448. */
  28449. getFacetNormal(i: number): Vector3;
  28450. /**
  28451. * Sets the reference Vector3 with the i-th facet normal in the world system
  28452. * @param i defines the facet index
  28453. * @param ref defines the target vector
  28454. * @returns the current mesh
  28455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28456. */
  28457. getFacetNormalToRef(i: number, ref: Vector3): this;
  28458. /**
  28459. * 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)
  28460. * @param x defines x coordinate
  28461. * @param y defines y coordinate
  28462. * @param z defines z coordinate
  28463. * @returns the array of facet indexes
  28464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28465. */
  28466. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28467. /**
  28468. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28469. * @param projected sets as the (x,y,z) world projection on the facet
  28470. * @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
  28471. * @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
  28472. * @param x defines x coordinate
  28473. * @param y defines y coordinate
  28474. * @param z defines z coordinate
  28475. * @returns the face index if found (or null instead)
  28476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28477. */
  28478. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28479. /**
  28480. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28481. * @param projected sets as the (x,y,z) local projection on the facet
  28482. * @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
  28483. * @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
  28484. * @param x defines x coordinate
  28485. * @param y defines y coordinate
  28486. * @param z defines z coordinate
  28487. * @returns the face index if found (or null instead)
  28488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28489. */
  28490. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28491. /**
  28492. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28493. * @returns the parameters
  28494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28495. */
  28496. getFacetDataParameters(): any;
  28497. /**
  28498. * Disables the feature FacetData and frees the related memory
  28499. * @returns the current mesh
  28500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28501. */
  28502. disableFacetData(): AbstractMesh;
  28503. /**
  28504. * Updates the AbstractMesh indices array
  28505. * @param indices defines the data source
  28506. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28507. * @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)
  28508. * @returns the current mesh
  28509. */
  28510. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28511. /**
  28512. * Creates new normals data for the mesh
  28513. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28514. * @returns the current mesh
  28515. */
  28516. createNormals(updatable: boolean): AbstractMesh;
  28517. /**
  28518. * Align the mesh with a normal
  28519. * @param normal defines the normal to use
  28520. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28521. * @returns the current mesh
  28522. */
  28523. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28524. /** @hidden */
  28525. _checkOcclusionQuery(): boolean;
  28526. /**
  28527. * Disables the mesh edge rendering mode
  28528. * @returns the currentAbstractMesh
  28529. */
  28530. disableEdgesRendering(): AbstractMesh;
  28531. /**
  28532. * Enables the edge rendering mode on the mesh.
  28533. * This mode makes the mesh edges visible
  28534. * @param epsilon defines the maximal distance between two angles to detect a face
  28535. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28536. * @returns the currentAbstractMesh
  28537. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28538. */
  28539. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28540. }
  28541. }
  28542. declare module BABYLON {
  28543. /**
  28544. * Interface used to define ActionEvent
  28545. */
  28546. export interface IActionEvent {
  28547. /** The mesh or sprite that triggered the action */
  28548. source: any;
  28549. /** The X mouse cursor position at the time of the event */
  28550. pointerX: number;
  28551. /** The Y mouse cursor position at the time of the event */
  28552. pointerY: number;
  28553. /** The mesh that is currently pointed at (can be null) */
  28554. meshUnderPointer: Nullable<AbstractMesh>;
  28555. /** the original (browser) event that triggered the ActionEvent */
  28556. sourceEvent?: any;
  28557. /** additional data for the event */
  28558. additionalData?: any;
  28559. }
  28560. /**
  28561. * ActionEvent is the event being sent when an action is triggered.
  28562. */
  28563. export class ActionEvent implements IActionEvent {
  28564. /** The mesh or sprite that triggered the action */
  28565. source: any;
  28566. /** The X mouse cursor position at the time of the event */
  28567. pointerX: number;
  28568. /** The Y mouse cursor position at the time of the event */
  28569. pointerY: number;
  28570. /** The mesh that is currently pointed at (can be null) */
  28571. meshUnderPointer: Nullable<AbstractMesh>;
  28572. /** the original (browser) event that triggered the ActionEvent */
  28573. sourceEvent?: any;
  28574. /** additional data for the event */
  28575. additionalData?: any;
  28576. /**
  28577. * Creates a new ActionEvent
  28578. * @param source The mesh or sprite that triggered the action
  28579. * @param pointerX The X mouse cursor position at the time of the event
  28580. * @param pointerY The Y mouse cursor position at the time of the event
  28581. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28582. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28583. * @param additionalData additional data for the event
  28584. */
  28585. constructor(
  28586. /** The mesh or sprite that triggered the action */
  28587. source: any,
  28588. /** The X mouse cursor position at the time of the event */
  28589. pointerX: number,
  28590. /** The Y mouse cursor position at the time of the event */
  28591. pointerY: number,
  28592. /** The mesh that is currently pointed at (can be null) */
  28593. meshUnderPointer: Nullable<AbstractMesh>,
  28594. /** the original (browser) event that triggered the ActionEvent */
  28595. sourceEvent?: any,
  28596. /** additional data for the event */
  28597. additionalData?: any);
  28598. /**
  28599. * Helper function to auto-create an ActionEvent from a source mesh.
  28600. * @param source The source mesh that triggered the event
  28601. * @param evt The original (browser) event
  28602. * @param additionalData additional data for the event
  28603. * @returns the new ActionEvent
  28604. */
  28605. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28606. /**
  28607. * Helper function to auto-create an ActionEvent from a source sprite
  28608. * @param source The source sprite that triggered the event
  28609. * @param scene Scene associated with the sprite
  28610. * @param evt The original (browser) event
  28611. * @param additionalData additional data for the event
  28612. * @returns the new ActionEvent
  28613. */
  28614. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28615. /**
  28616. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28617. * @param scene the scene where the event occurred
  28618. * @param evt The original (browser) event
  28619. * @returns the new ActionEvent
  28620. */
  28621. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28622. /**
  28623. * Helper function to auto-create an ActionEvent from a primitive
  28624. * @param prim defines the target primitive
  28625. * @param pointerPos defines the pointer position
  28626. * @param evt The original (browser) event
  28627. * @param additionalData additional data for the event
  28628. * @returns the new ActionEvent
  28629. */
  28630. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28631. }
  28632. }
  28633. declare module BABYLON {
  28634. /**
  28635. * Abstract class used to decouple action Manager from scene and meshes.
  28636. * Do not instantiate.
  28637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28638. */
  28639. export abstract class AbstractActionManager implements IDisposable {
  28640. /** Gets the list of active triggers */
  28641. static Triggers: {
  28642. [key: string]: number;
  28643. };
  28644. /** Gets the cursor to use when hovering items */
  28645. hoverCursor: string;
  28646. /** Gets the list of actions */
  28647. actions: IAction[];
  28648. /**
  28649. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28650. */
  28651. isRecursive: boolean;
  28652. /**
  28653. * Releases all associated resources
  28654. */
  28655. abstract dispose(): void;
  28656. /**
  28657. * Does this action manager has pointer triggers
  28658. */
  28659. abstract get hasPointerTriggers(): boolean;
  28660. /**
  28661. * Does this action manager has pick triggers
  28662. */
  28663. abstract get hasPickTriggers(): boolean;
  28664. /**
  28665. * Process a specific trigger
  28666. * @param trigger defines the trigger to process
  28667. * @param evt defines the event details to be processed
  28668. */
  28669. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28670. /**
  28671. * Does this action manager handles actions of any of the given triggers
  28672. * @param triggers defines the triggers to be tested
  28673. * @return a boolean indicating whether one (or more) of the triggers is handled
  28674. */
  28675. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28676. /**
  28677. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28678. * speed.
  28679. * @param triggerA defines the trigger to be tested
  28680. * @param triggerB defines the trigger to be tested
  28681. * @return a boolean indicating whether one (or more) of the triggers is handled
  28682. */
  28683. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28684. /**
  28685. * Does this action manager handles actions of a given trigger
  28686. * @param trigger defines the trigger to be tested
  28687. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28688. * @return whether the trigger is handled
  28689. */
  28690. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28691. /**
  28692. * Serialize this manager to a JSON object
  28693. * @param name defines the property name to store this manager
  28694. * @returns a JSON representation of this manager
  28695. */
  28696. abstract serialize(name: string): any;
  28697. /**
  28698. * Registers an action to this action manager
  28699. * @param action defines the action to be registered
  28700. * @return the action amended (prepared) after registration
  28701. */
  28702. abstract registerAction(action: IAction): Nullable<IAction>;
  28703. /**
  28704. * Unregisters an action to this action manager
  28705. * @param action defines the action to be unregistered
  28706. * @return a boolean indicating whether the action has been unregistered
  28707. */
  28708. abstract unregisterAction(action: IAction): Boolean;
  28709. /**
  28710. * Does exist one action manager with at least one trigger
  28711. **/
  28712. static get HasTriggers(): boolean;
  28713. /**
  28714. * Does exist one action manager with at least one pick trigger
  28715. **/
  28716. static get HasPickTriggers(): boolean;
  28717. /**
  28718. * Does exist one action manager that handles actions of a given trigger
  28719. * @param trigger defines the trigger to be tested
  28720. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28721. **/
  28722. static HasSpecificTrigger(trigger: number): boolean;
  28723. }
  28724. }
  28725. declare module BABYLON {
  28726. /**
  28727. * Defines how a node can be built from a string name.
  28728. */
  28729. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28730. /**
  28731. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28732. */
  28733. export class Node implements IBehaviorAware<Node> {
  28734. /** @hidden */
  28735. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28736. private static _NodeConstructors;
  28737. /**
  28738. * Add a new node constructor
  28739. * @param type defines the type name of the node to construct
  28740. * @param constructorFunc defines the constructor function
  28741. */
  28742. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28743. /**
  28744. * Returns a node constructor based on type name
  28745. * @param type defines the type name
  28746. * @param name defines the new node name
  28747. * @param scene defines the hosting scene
  28748. * @param options defines optional options to transmit to constructors
  28749. * @returns the new constructor or null
  28750. */
  28751. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28752. /**
  28753. * Gets or sets the name of the node
  28754. */
  28755. name: string;
  28756. /**
  28757. * Gets or sets the id of the node
  28758. */
  28759. id: string;
  28760. /**
  28761. * Gets or sets the unique id of the node
  28762. */
  28763. uniqueId: number;
  28764. /**
  28765. * Gets or sets a string used to store user defined state for the node
  28766. */
  28767. state: string;
  28768. /**
  28769. * Gets or sets an object used to store user defined information for the node
  28770. */
  28771. metadata: any;
  28772. /**
  28773. * For internal use only. Please do not use.
  28774. */
  28775. reservedDataStore: any;
  28776. /**
  28777. * List of inspectable custom properties (used by the Inspector)
  28778. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28779. */
  28780. inspectableCustomProperties: IInspectable[];
  28781. private _doNotSerialize;
  28782. /**
  28783. * Gets or sets a boolean used to define if the node must be serialized
  28784. */
  28785. get doNotSerialize(): boolean;
  28786. set doNotSerialize(value: boolean);
  28787. /** @hidden */
  28788. _isDisposed: boolean;
  28789. /**
  28790. * Gets a list of Animations associated with the node
  28791. */
  28792. animations: Animation[];
  28793. protected _ranges: {
  28794. [name: string]: Nullable<AnimationRange>;
  28795. };
  28796. /**
  28797. * Callback raised when the node is ready to be used
  28798. */
  28799. onReady: Nullable<(node: Node) => void>;
  28800. private _isEnabled;
  28801. private _isParentEnabled;
  28802. private _isReady;
  28803. /** @hidden */
  28804. _currentRenderId: number;
  28805. private _parentUpdateId;
  28806. /** @hidden */
  28807. _childUpdateId: number;
  28808. /** @hidden */
  28809. _waitingParentId: Nullable<string>;
  28810. /** @hidden */
  28811. _scene: Scene;
  28812. /** @hidden */
  28813. _cache: any;
  28814. private _parentNode;
  28815. private _children;
  28816. /** @hidden */
  28817. _worldMatrix: Matrix;
  28818. /** @hidden */
  28819. _worldMatrixDeterminant: number;
  28820. /** @hidden */
  28821. _worldMatrixDeterminantIsDirty: boolean;
  28822. /** @hidden */
  28823. private _sceneRootNodesIndex;
  28824. /**
  28825. * Gets a boolean indicating if the node has been disposed
  28826. * @returns true if the node was disposed
  28827. */
  28828. isDisposed(): boolean;
  28829. /**
  28830. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28831. * @see https://doc.babylonjs.com/how_to/parenting
  28832. */
  28833. set parent(parent: Nullable<Node>);
  28834. get parent(): Nullable<Node>;
  28835. /** @hidden */
  28836. _addToSceneRootNodes(): void;
  28837. /** @hidden */
  28838. _removeFromSceneRootNodes(): void;
  28839. private _animationPropertiesOverride;
  28840. /**
  28841. * Gets or sets the animation properties override
  28842. */
  28843. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28844. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28845. /**
  28846. * Gets a string idenfifying the name of the class
  28847. * @returns "Node" string
  28848. */
  28849. getClassName(): string;
  28850. /** @hidden */
  28851. readonly _isNode: boolean;
  28852. /**
  28853. * An event triggered when the mesh is disposed
  28854. */
  28855. onDisposeObservable: Observable<Node>;
  28856. private _onDisposeObserver;
  28857. /**
  28858. * Sets a callback that will be raised when the node will be disposed
  28859. */
  28860. set onDispose(callback: () => void);
  28861. /**
  28862. * Creates a new Node
  28863. * @param name the name and id to be given to this node
  28864. * @param scene the scene this node will be added to
  28865. */
  28866. constructor(name: string, scene?: Nullable<Scene>);
  28867. /**
  28868. * Gets the scene of the node
  28869. * @returns a scene
  28870. */
  28871. getScene(): Scene;
  28872. /**
  28873. * Gets the engine of the node
  28874. * @returns a Engine
  28875. */
  28876. getEngine(): Engine;
  28877. private _behaviors;
  28878. /**
  28879. * Attach a behavior to the node
  28880. * @see http://doc.babylonjs.com/features/behaviour
  28881. * @param behavior defines the behavior to attach
  28882. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28883. * @returns the current Node
  28884. */
  28885. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28886. /**
  28887. * Remove an attached behavior
  28888. * @see http://doc.babylonjs.com/features/behaviour
  28889. * @param behavior defines the behavior to attach
  28890. * @returns the current Node
  28891. */
  28892. removeBehavior(behavior: Behavior<Node>): Node;
  28893. /**
  28894. * Gets the list of attached behaviors
  28895. * @see http://doc.babylonjs.com/features/behaviour
  28896. */
  28897. get behaviors(): Behavior<Node>[];
  28898. /**
  28899. * Gets an attached behavior by name
  28900. * @param name defines the name of the behavior to look for
  28901. * @see http://doc.babylonjs.com/features/behaviour
  28902. * @returns null if behavior was not found else the requested behavior
  28903. */
  28904. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28905. /**
  28906. * Returns the latest update of the World matrix
  28907. * @returns a Matrix
  28908. */
  28909. getWorldMatrix(): Matrix;
  28910. /** @hidden */
  28911. _getWorldMatrixDeterminant(): number;
  28912. /**
  28913. * Returns directly the latest state of the mesh World matrix.
  28914. * A Matrix is returned.
  28915. */
  28916. get worldMatrixFromCache(): Matrix;
  28917. /** @hidden */
  28918. _initCache(): void;
  28919. /** @hidden */
  28920. updateCache(force?: boolean): void;
  28921. /** @hidden */
  28922. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28923. /** @hidden */
  28924. _updateCache(ignoreParentClass?: boolean): void;
  28925. /** @hidden */
  28926. _isSynchronized(): boolean;
  28927. /** @hidden */
  28928. _markSyncedWithParent(): void;
  28929. /** @hidden */
  28930. isSynchronizedWithParent(): boolean;
  28931. /** @hidden */
  28932. isSynchronized(): boolean;
  28933. /**
  28934. * Is this node ready to be used/rendered
  28935. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28936. * @return true if the node is ready
  28937. */
  28938. isReady(completeCheck?: boolean): boolean;
  28939. /**
  28940. * Is this node enabled?
  28941. * 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
  28942. * @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
  28943. * @return whether this node (and its parent) is enabled
  28944. */
  28945. isEnabled(checkAncestors?: boolean): boolean;
  28946. /** @hidden */
  28947. protected _syncParentEnabledState(): void;
  28948. /**
  28949. * Set the enabled state of this node
  28950. * @param value defines the new enabled state
  28951. */
  28952. setEnabled(value: boolean): void;
  28953. /**
  28954. * Is this node a descendant of the given node?
  28955. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28956. * @param ancestor defines the parent node to inspect
  28957. * @returns a boolean indicating if this node is a descendant of the given node
  28958. */
  28959. isDescendantOf(ancestor: Node): boolean;
  28960. /** @hidden */
  28961. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28962. /**
  28963. * Will return all nodes that have this node as ascendant
  28964. * @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
  28965. * @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
  28966. * @return all children nodes of all types
  28967. */
  28968. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28969. /**
  28970. * Get all child-meshes of this node
  28971. * @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)
  28972. * @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
  28973. * @returns an array of AbstractMesh
  28974. */
  28975. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28976. /**
  28977. * Get all direct children of this node
  28978. * @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
  28979. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  28980. * @returns an array of Node
  28981. */
  28982. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28983. /** @hidden */
  28984. _setReady(state: boolean): void;
  28985. /**
  28986. * Get an animation by name
  28987. * @param name defines the name of the animation to look for
  28988. * @returns null if not found else the requested animation
  28989. */
  28990. getAnimationByName(name: string): Nullable<Animation>;
  28991. /**
  28992. * Creates an animation range for this node
  28993. * @param name defines the name of the range
  28994. * @param from defines the starting key
  28995. * @param to defines the end key
  28996. */
  28997. createAnimationRange(name: string, from: number, to: number): void;
  28998. /**
  28999. * Delete a specific animation range
  29000. * @param name defines the name of the range to delete
  29001. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29002. */
  29003. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29004. /**
  29005. * Get an animation range by name
  29006. * @param name defines the name of the animation range to look for
  29007. * @returns null if not found else the requested animation range
  29008. */
  29009. getAnimationRange(name: string): Nullable<AnimationRange>;
  29010. /**
  29011. * Gets the list of all animation ranges defined on this node
  29012. * @returns an array
  29013. */
  29014. getAnimationRanges(): Nullable<AnimationRange>[];
  29015. /**
  29016. * Will start the animation sequence
  29017. * @param name defines the range frames for animation sequence
  29018. * @param loop defines if the animation should loop (false by default)
  29019. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29020. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29021. * @returns the object created for this animation. If range does not exist, it will return null
  29022. */
  29023. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29024. /**
  29025. * Serialize animation ranges into a JSON compatible object
  29026. * @returns serialization object
  29027. */
  29028. serializeAnimationRanges(): any;
  29029. /**
  29030. * Computes the world matrix of the node
  29031. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29032. * @returns the world matrix
  29033. */
  29034. computeWorldMatrix(force?: boolean): Matrix;
  29035. /**
  29036. * Releases resources associated with this node.
  29037. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29038. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29039. */
  29040. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29041. /**
  29042. * Parse animation range data from a serialization object and store them into a given node
  29043. * @param node defines where to store the animation ranges
  29044. * @param parsedNode defines the serialization object to read data from
  29045. * @param scene defines the hosting scene
  29046. */
  29047. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29048. /**
  29049. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29050. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29051. * @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
  29052. * @returns the new bounding vectors
  29053. */
  29054. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29055. min: Vector3;
  29056. max: Vector3;
  29057. };
  29058. }
  29059. }
  29060. declare module BABYLON {
  29061. /**
  29062. * @hidden
  29063. */
  29064. export class _IAnimationState {
  29065. key: number;
  29066. repeatCount: number;
  29067. workValue?: any;
  29068. loopMode?: number;
  29069. offsetValue?: any;
  29070. highLimitValue?: any;
  29071. }
  29072. /**
  29073. * Class used to store any kind of animation
  29074. */
  29075. export class Animation {
  29076. /**Name of the animation */
  29077. name: string;
  29078. /**Property to animate */
  29079. targetProperty: string;
  29080. /**The frames per second of the animation */
  29081. framePerSecond: number;
  29082. /**The data type of the animation */
  29083. dataType: number;
  29084. /**The loop mode of the animation */
  29085. loopMode?: number | undefined;
  29086. /**Specifies if blending should be enabled */
  29087. enableBlending?: boolean | undefined;
  29088. /**
  29089. * Use matrix interpolation instead of using direct key value when animating matrices
  29090. */
  29091. static AllowMatricesInterpolation: boolean;
  29092. /**
  29093. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29094. */
  29095. static AllowMatrixDecomposeForInterpolation: boolean;
  29096. /**
  29097. * Stores the key frames of the animation
  29098. */
  29099. private _keys;
  29100. /**
  29101. * Stores the easing function of the animation
  29102. */
  29103. private _easingFunction;
  29104. /**
  29105. * @hidden Internal use only
  29106. */
  29107. _runtimeAnimations: RuntimeAnimation[];
  29108. /**
  29109. * The set of event that will be linked to this animation
  29110. */
  29111. private _events;
  29112. /**
  29113. * Stores an array of target property paths
  29114. */
  29115. targetPropertyPath: string[];
  29116. /**
  29117. * Stores the blending speed of the animation
  29118. */
  29119. blendingSpeed: number;
  29120. /**
  29121. * Stores the animation ranges for the animation
  29122. */
  29123. private _ranges;
  29124. /**
  29125. * @hidden Internal use
  29126. */
  29127. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29128. /**
  29129. * Sets up an animation
  29130. * @param property The property to animate
  29131. * @param animationType The animation type to apply
  29132. * @param framePerSecond The frames per second of the animation
  29133. * @param easingFunction The easing function used in the animation
  29134. * @returns The created animation
  29135. */
  29136. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29137. /**
  29138. * Create and start an animation on a node
  29139. * @param name defines the name of the global animation that will be run on all nodes
  29140. * @param node defines the root node where the animation will take place
  29141. * @param targetProperty defines property to animate
  29142. * @param framePerSecond defines the number of frame per second yo use
  29143. * @param totalFrame defines the number of frames in total
  29144. * @param from defines the initial value
  29145. * @param to defines the final value
  29146. * @param loopMode defines which loop mode you want to use (off by default)
  29147. * @param easingFunction defines the easing function to use (linear by default)
  29148. * @param onAnimationEnd defines the callback to call when animation end
  29149. * @returns the animatable created for this animation
  29150. */
  29151. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29152. /**
  29153. * Create and start an animation on a node and its descendants
  29154. * @param name defines the name of the global animation that will be run on all nodes
  29155. * @param node defines the root node where the animation will take place
  29156. * @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
  29157. * @param targetProperty defines property to animate
  29158. * @param framePerSecond defines the number of frame per second to use
  29159. * @param totalFrame defines the number of frames in total
  29160. * @param from defines the initial value
  29161. * @param to defines the final value
  29162. * @param loopMode defines which loop mode you want to use (off by default)
  29163. * @param easingFunction defines the easing function to use (linear by default)
  29164. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29165. * @returns the list of animatables created for all nodes
  29166. * @example https://www.babylonjs-playground.com/#MH0VLI
  29167. */
  29168. 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[]>;
  29169. /**
  29170. * Creates a new animation, merges it with the existing animations and starts it
  29171. * @param name Name of the animation
  29172. * @param node Node which contains the scene that begins the animations
  29173. * @param targetProperty Specifies which property to animate
  29174. * @param framePerSecond The frames per second of the animation
  29175. * @param totalFrame The total number of frames
  29176. * @param from The frame at the beginning of the animation
  29177. * @param to The frame at the end of the animation
  29178. * @param loopMode Specifies the loop mode of the animation
  29179. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29180. * @param onAnimationEnd Callback to run once the animation is complete
  29181. * @returns Nullable animation
  29182. */
  29183. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29184. /**
  29185. * Transition property of an host to the target Value
  29186. * @param property The property to transition
  29187. * @param targetValue The target Value of the property
  29188. * @param host The object where the property to animate belongs
  29189. * @param scene Scene used to run the animation
  29190. * @param frameRate Framerate (in frame/s) to use
  29191. * @param transition The transition type we want to use
  29192. * @param duration The duration of the animation, in milliseconds
  29193. * @param onAnimationEnd Callback trigger at the end of the animation
  29194. * @returns Nullable animation
  29195. */
  29196. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29197. /**
  29198. * Return the array of runtime animations currently using this animation
  29199. */
  29200. get runtimeAnimations(): RuntimeAnimation[];
  29201. /**
  29202. * Specifies if any of the runtime animations are currently running
  29203. */
  29204. get hasRunningRuntimeAnimations(): boolean;
  29205. /**
  29206. * Initializes the animation
  29207. * @param name Name of the animation
  29208. * @param targetProperty Property to animate
  29209. * @param framePerSecond The frames per second of the animation
  29210. * @param dataType The data type of the animation
  29211. * @param loopMode The loop mode of the animation
  29212. * @param enableBlending Specifies if blending should be enabled
  29213. */
  29214. constructor(
  29215. /**Name of the animation */
  29216. name: string,
  29217. /**Property to animate */
  29218. targetProperty: string,
  29219. /**The frames per second of the animation */
  29220. framePerSecond: number,
  29221. /**The data type of the animation */
  29222. dataType: number,
  29223. /**The loop mode of the animation */
  29224. loopMode?: number | undefined,
  29225. /**Specifies if blending should be enabled */
  29226. enableBlending?: boolean | undefined);
  29227. /**
  29228. * Converts the animation to a string
  29229. * @param fullDetails support for multiple levels of logging within scene loading
  29230. * @returns String form of the animation
  29231. */
  29232. toString(fullDetails?: boolean): string;
  29233. /**
  29234. * Add an event to this animation
  29235. * @param event Event to add
  29236. */
  29237. addEvent(event: AnimationEvent): void;
  29238. /**
  29239. * Remove all events found at the given frame
  29240. * @param frame The frame to remove events from
  29241. */
  29242. removeEvents(frame: number): void;
  29243. /**
  29244. * Retrieves all the events from the animation
  29245. * @returns Events from the animation
  29246. */
  29247. getEvents(): AnimationEvent[];
  29248. /**
  29249. * Creates an animation range
  29250. * @param name Name of the animation range
  29251. * @param from Starting frame of the animation range
  29252. * @param to Ending frame of the animation
  29253. */
  29254. createRange(name: string, from: number, to: number): void;
  29255. /**
  29256. * Deletes an animation range by name
  29257. * @param name Name of the animation range to delete
  29258. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29259. */
  29260. deleteRange(name: string, deleteFrames?: boolean): void;
  29261. /**
  29262. * Gets the animation range by name, or null if not defined
  29263. * @param name Name of the animation range
  29264. * @returns Nullable animation range
  29265. */
  29266. getRange(name: string): Nullable<AnimationRange>;
  29267. /**
  29268. * Gets the key frames from the animation
  29269. * @returns The key frames of the animation
  29270. */
  29271. getKeys(): Array<IAnimationKey>;
  29272. /**
  29273. * Gets the highest frame rate of the animation
  29274. * @returns Highest frame rate of the animation
  29275. */
  29276. getHighestFrame(): number;
  29277. /**
  29278. * Gets the easing function of the animation
  29279. * @returns Easing function of the animation
  29280. */
  29281. getEasingFunction(): IEasingFunction;
  29282. /**
  29283. * Sets the easing function of the animation
  29284. * @param easingFunction A custom mathematical formula for animation
  29285. */
  29286. setEasingFunction(easingFunction: EasingFunction): void;
  29287. /**
  29288. * Interpolates a scalar linearly
  29289. * @param startValue Start value of the animation curve
  29290. * @param endValue End value of the animation curve
  29291. * @param gradient Scalar amount to interpolate
  29292. * @returns Interpolated scalar value
  29293. */
  29294. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29295. /**
  29296. * Interpolates a scalar cubically
  29297. * @param startValue Start value of the animation curve
  29298. * @param outTangent End tangent of the animation
  29299. * @param endValue End value of the animation curve
  29300. * @param inTangent Start tangent of the animation curve
  29301. * @param gradient Scalar amount to interpolate
  29302. * @returns Interpolated scalar value
  29303. */
  29304. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29305. /**
  29306. * Interpolates a quaternion using a spherical linear interpolation
  29307. * @param startValue Start value of the animation curve
  29308. * @param endValue End value of the animation curve
  29309. * @param gradient Scalar amount to interpolate
  29310. * @returns Interpolated quaternion value
  29311. */
  29312. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29313. /**
  29314. * Interpolates a quaternion cubically
  29315. * @param startValue Start value of the animation curve
  29316. * @param outTangent End tangent of the animation curve
  29317. * @param endValue End value of the animation curve
  29318. * @param inTangent Start tangent of the animation curve
  29319. * @param gradient Scalar amount to interpolate
  29320. * @returns Interpolated quaternion value
  29321. */
  29322. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29323. /**
  29324. * Interpolates a Vector3 linearl
  29325. * @param startValue Start value of the animation curve
  29326. * @param endValue End value of the animation curve
  29327. * @param gradient Scalar amount to interpolate
  29328. * @returns Interpolated scalar value
  29329. */
  29330. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29331. /**
  29332. * Interpolates a Vector3 cubically
  29333. * @param startValue Start value of the animation curve
  29334. * @param outTangent End tangent of the animation
  29335. * @param endValue End value of the animation curve
  29336. * @param inTangent Start tangent of the animation curve
  29337. * @param gradient Scalar amount to interpolate
  29338. * @returns InterpolatedVector3 value
  29339. */
  29340. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29341. /**
  29342. * Interpolates a Vector2 linearly
  29343. * @param startValue Start value of the animation curve
  29344. * @param endValue End value of the animation curve
  29345. * @param gradient Scalar amount to interpolate
  29346. * @returns Interpolated Vector2 value
  29347. */
  29348. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29349. /**
  29350. * Interpolates a Vector2 cubically
  29351. * @param startValue Start value of the animation curve
  29352. * @param outTangent End tangent of the animation
  29353. * @param endValue End value of the animation curve
  29354. * @param inTangent Start tangent of the animation curve
  29355. * @param gradient Scalar amount to interpolate
  29356. * @returns Interpolated Vector2 value
  29357. */
  29358. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29359. /**
  29360. * Interpolates a size linearly
  29361. * @param startValue Start value of the animation curve
  29362. * @param endValue End value of the animation curve
  29363. * @param gradient Scalar amount to interpolate
  29364. * @returns Interpolated Size value
  29365. */
  29366. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29367. /**
  29368. * Interpolates a Color3 linearly
  29369. * @param startValue Start value of the animation curve
  29370. * @param endValue End value of the animation curve
  29371. * @param gradient Scalar amount to interpolate
  29372. * @returns Interpolated Color3 value
  29373. */
  29374. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29375. /**
  29376. * Interpolates a Color4 linearly
  29377. * @param startValue Start value of the animation curve
  29378. * @param endValue End value of the animation curve
  29379. * @param gradient Scalar amount to interpolate
  29380. * @returns Interpolated Color3 value
  29381. */
  29382. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29383. /**
  29384. * @hidden Internal use only
  29385. */
  29386. _getKeyValue(value: any): any;
  29387. /**
  29388. * @hidden Internal use only
  29389. */
  29390. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29391. /**
  29392. * Defines the function to use to interpolate matrices
  29393. * @param startValue defines the start matrix
  29394. * @param endValue defines the end matrix
  29395. * @param gradient defines the gradient between both matrices
  29396. * @param result defines an optional target matrix where to store the interpolation
  29397. * @returns the interpolated matrix
  29398. */
  29399. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29400. /**
  29401. * Makes a copy of the animation
  29402. * @returns Cloned animation
  29403. */
  29404. clone(): Animation;
  29405. /**
  29406. * Sets the key frames of the animation
  29407. * @param values The animation key frames to set
  29408. */
  29409. setKeys(values: Array<IAnimationKey>): void;
  29410. /**
  29411. * Serializes the animation to an object
  29412. * @returns Serialized object
  29413. */
  29414. serialize(): any;
  29415. /**
  29416. * Float animation type
  29417. */
  29418. static readonly ANIMATIONTYPE_FLOAT: number;
  29419. /**
  29420. * Vector3 animation type
  29421. */
  29422. static readonly ANIMATIONTYPE_VECTOR3: number;
  29423. /**
  29424. * Quaternion animation type
  29425. */
  29426. static readonly ANIMATIONTYPE_QUATERNION: number;
  29427. /**
  29428. * Matrix animation type
  29429. */
  29430. static readonly ANIMATIONTYPE_MATRIX: number;
  29431. /**
  29432. * Color3 animation type
  29433. */
  29434. static readonly ANIMATIONTYPE_COLOR3: number;
  29435. /**
  29436. * Color3 animation type
  29437. */
  29438. static readonly ANIMATIONTYPE_COLOR4: number;
  29439. /**
  29440. * Vector2 animation type
  29441. */
  29442. static readonly ANIMATIONTYPE_VECTOR2: number;
  29443. /**
  29444. * Size animation type
  29445. */
  29446. static readonly ANIMATIONTYPE_SIZE: number;
  29447. /**
  29448. * Relative Loop Mode
  29449. */
  29450. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29451. /**
  29452. * Cycle Loop Mode
  29453. */
  29454. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29455. /**
  29456. * Constant Loop Mode
  29457. */
  29458. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29459. /** @hidden */
  29460. static _UniversalLerp(left: any, right: any, amount: number): any;
  29461. /**
  29462. * Parses an animation object and creates an animation
  29463. * @param parsedAnimation Parsed animation object
  29464. * @returns Animation object
  29465. */
  29466. static Parse(parsedAnimation: any): Animation;
  29467. /**
  29468. * Appends the serialized animations from the source animations
  29469. * @param source Source containing the animations
  29470. * @param destination Target to store the animations
  29471. */
  29472. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29473. }
  29474. }
  29475. declare module BABYLON {
  29476. /**
  29477. * Interface containing an array of animations
  29478. */
  29479. export interface IAnimatable {
  29480. /**
  29481. * Array of animations
  29482. */
  29483. animations: Nullable<Array<Animation>>;
  29484. }
  29485. }
  29486. declare module BABYLON {
  29487. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29488. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29489. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29490. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29491. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29492. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29493. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29494. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29495. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29496. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29497. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29498. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29499. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29500. /**
  29501. * Decorator used to define property that can be serialized as reference to a camera
  29502. * @param sourceName defines the name of the property to decorate
  29503. */
  29504. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29505. /**
  29506. * Class used to help serialization objects
  29507. */
  29508. export class SerializationHelper {
  29509. /** @hidden */
  29510. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29511. /** @hidden */
  29512. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29513. /** @hidden */
  29514. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29515. /** @hidden */
  29516. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29517. /**
  29518. * Appends the serialized animations from the source animations
  29519. * @param source Source containing the animations
  29520. * @param destination Target to store the animations
  29521. */
  29522. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29523. /**
  29524. * Static function used to serialized a specific entity
  29525. * @param entity defines the entity to serialize
  29526. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29527. * @returns a JSON compatible object representing the serialization of the entity
  29528. */
  29529. static Serialize<T>(entity: T, serializationObject?: any): any;
  29530. /**
  29531. * Creates a new entity from a serialization data object
  29532. * @param creationFunction defines a function used to instanciated the new entity
  29533. * @param source defines the source serialization data
  29534. * @param scene defines the hosting scene
  29535. * @param rootUrl defines the root url for resources
  29536. * @returns a new entity
  29537. */
  29538. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29539. /**
  29540. * Clones an object
  29541. * @param creationFunction defines the function used to instanciate the new object
  29542. * @param source defines the source object
  29543. * @returns the cloned object
  29544. */
  29545. static Clone<T>(creationFunction: () => T, source: T): T;
  29546. /**
  29547. * Instanciates a new object based on a source one (some data will be shared between both object)
  29548. * @param creationFunction defines the function used to instanciate the new object
  29549. * @param source defines the source object
  29550. * @returns the new object
  29551. */
  29552. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29553. }
  29554. }
  29555. declare module BABYLON {
  29556. /**
  29557. * Class used to manipulate GUIDs
  29558. */
  29559. export class GUID {
  29560. /**
  29561. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29562. * Be aware Math.random() could cause collisions, but:
  29563. * "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"
  29564. * @returns a pseudo random id
  29565. */
  29566. static RandomId(): string;
  29567. }
  29568. }
  29569. declare module BABYLON {
  29570. /**
  29571. * Base class of all the textures in babylon.
  29572. * It groups all the common properties the materials, post process, lights... might need
  29573. * in order to make a correct use of the texture.
  29574. */
  29575. export class BaseTexture implements IAnimatable {
  29576. /**
  29577. * Default anisotropic filtering level for the application.
  29578. * It is set to 4 as a good tradeoff between perf and quality.
  29579. */
  29580. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29581. /**
  29582. * Gets or sets the unique id of the texture
  29583. */
  29584. uniqueId: number;
  29585. /**
  29586. * Define the name of the texture.
  29587. */
  29588. name: string;
  29589. /**
  29590. * Gets or sets an object used to store user defined information.
  29591. */
  29592. metadata: any;
  29593. /**
  29594. * For internal use only. Please do not use.
  29595. */
  29596. reservedDataStore: any;
  29597. private _hasAlpha;
  29598. /**
  29599. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29600. */
  29601. set hasAlpha(value: boolean);
  29602. get hasAlpha(): boolean;
  29603. /**
  29604. * Defines if the alpha value should be determined via the rgb values.
  29605. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29606. */
  29607. getAlphaFromRGB: boolean;
  29608. /**
  29609. * Intensity or strength of the texture.
  29610. * It is commonly used by materials to fine tune the intensity of the texture
  29611. */
  29612. level: number;
  29613. /**
  29614. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29615. * This is part of the texture as textures usually maps to one uv set.
  29616. */
  29617. coordinatesIndex: number;
  29618. private _coordinatesMode;
  29619. /**
  29620. * How a texture is mapped.
  29621. *
  29622. * | Value | Type | Description |
  29623. * | ----- | ----------------------------------- | ----------- |
  29624. * | 0 | EXPLICIT_MODE | |
  29625. * | 1 | SPHERICAL_MODE | |
  29626. * | 2 | PLANAR_MODE | |
  29627. * | 3 | CUBIC_MODE | |
  29628. * | 4 | PROJECTION_MODE | |
  29629. * | 5 | SKYBOX_MODE | |
  29630. * | 6 | INVCUBIC_MODE | |
  29631. * | 7 | EQUIRECTANGULAR_MODE | |
  29632. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29633. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29634. */
  29635. set coordinatesMode(value: number);
  29636. get coordinatesMode(): number;
  29637. /**
  29638. * | Value | Type | Description |
  29639. * | ----- | ------------------ | ----------- |
  29640. * | 0 | CLAMP_ADDRESSMODE | |
  29641. * | 1 | WRAP_ADDRESSMODE | |
  29642. * | 2 | MIRROR_ADDRESSMODE | |
  29643. */
  29644. wrapU: number;
  29645. /**
  29646. * | Value | Type | Description |
  29647. * | ----- | ------------------ | ----------- |
  29648. * | 0 | CLAMP_ADDRESSMODE | |
  29649. * | 1 | WRAP_ADDRESSMODE | |
  29650. * | 2 | MIRROR_ADDRESSMODE | |
  29651. */
  29652. wrapV: number;
  29653. /**
  29654. * | Value | Type | Description |
  29655. * | ----- | ------------------ | ----------- |
  29656. * | 0 | CLAMP_ADDRESSMODE | |
  29657. * | 1 | WRAP_ADDRESSMODE | |
  29658. * | 2 | MIRROR_ADDRESSMODE | |
  29659. */
  29660. wrapR: number;
  29661. /**
  29662. * With compliant hardware and browser (supporting anisotropic filtering)
  29663. * this defines the level of anisotropic filtering in the texture.
  29664. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29665. */
  29666. anisotropicFilteringLevel: number;
  29667. /**
  29668. * Define if the texture is a cube texture or if false a 2d texture.
  29669. */
  29670. get isCube(): boolean;
  29671. set isCube(value: boolean);
  29672. /**
  29673. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29674. */
  29675. get is3D(): boolean;
  29676. set is3D(value: boolean);
  29677. /**
  29678. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29679. */
  29680. get is2DArray(): boolean;
  29681. set is2DArray(value: boolean);
  29682. /**
  29683. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29684. * HDR texture are usually stored in linear space.
  29685. * This only impacts the PBR and Background materials
  29686. */
  29687. gammaSpace: boolean;
  29688. /**
  29689. * Gets or sets whether or not the texture contains RGBD data.
  29690. */
  29691. get isRGBD(): boolean;
  29692. set isRGBD(value: boolean);
  29693. /**
  29694. * Is Z inverted in the texture (useful in a cube texture).
  29695. */
  29696. invertZ: boolean;
  29697. /**
  29698. * Are mip maps generated for this texture or not.
  29699. */
  29700. get noMipmap(): boolean;
  29701. /**
  29702. * @hidden
  29703. */
  29704. lodLevelInAlpha: boolean;
  29705. /**
  29706. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29707. */
  29708. get lodGenerationOffset(): number;
  29709. set lodGenerationOffset(value: number);
  29710. /**
  29711. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29712. */
  29713. get lodGenerationScale(): number;
  29714. set lodGenerationScale(value: number);
  29715. /**
  29716. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29717. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29718. * average roughness values.
  29719. */
  29720. get linearSpecularLOD(): boolean;
  29721. set linearSpecularLOD(value: boolean);
  29722. /**
  29723. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29724. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29725. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29726. */
  29727. get irradianceTexture(): Nullable<BaseTexture>;
  29728. set irradianceTexture(value: Nullable<BaseTexture>);
  29729. /**
  29730. * Define if the texture is a render target.
  29731. */
  29732. isRenderTarget: boolean;
  29733. /**
  29734. * Define the unique id of the texture in the scene.
  29735. */
  29736. get uid(): string;
  29737. /**
  29738. * Return a string representation of the texture.
  29739. * @returns the texture as a string
  29740. */
  29741. toString(): string;
  29742. /**
  29743. * Get the class name of the texture.
  29744. * @returns "BaseTexture"
  29745. */
  29746. getClassName(): string;
  29747. /**
  29748. * Define the list of animation attached to the texture.
  29749. */
  29750. animations: Animation[];
  29751. /**
  29752. * An event triggered when the texture is disposed.
  29753. */
  29754. onDisposeObservable: Observable<BaseTexture>;
  29755. private _onDisposeObserver;
  29756. /**
  29757. * Callback triggered when the texture has been disposed.
  29758. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29759. */
  29760. set onDispose(callback: () => void);
  29761. /**
  29762. * Define the current state of the loading sequence when in delayed load mode.
  29763. */
  29764. delayLoadState: number;
  29765. private _scene;
  29766. /** @hidden */
  29767. _texture: Nullable<InternalTexture>;
  29768. private _uid;
  29769. /**
  29770. * Define if the texture is preventinga material to render or not.
  29771. * If not and the texture is not ready, the engine will use a default black texture instead.
  29772. */
  29773. get isBlocking(): boolean;
  29774. /**
  29775. * Instantiates a new BaseTexture.
  29776. * Base class of all the textures in babylon.
  29777. * It groups all the common properties the materials, post process, lights... might need
  29778. * in order to make a correct use of the texture.
  29779. * @param scene Define the scene the texture blongs to
  29780. */
  29781. constructor(scene: Nullable<Scene>);
  29782. /**
  29783. * Get the scene the texture belongs to.
  29784. * @returns the scene or null if undefined
  29785. */
  29786. getScene(): Nullable<Scene>;
  29787. /**
  29788. * Get the texture transform matrix used to offset tile the texture for istance.
  29789. * @returns the transformation matrix
  29790. */
  29791. getTextureMatrix(): Matrix;
  29792. /**
  29793. * Get the texture reflection matrix used to rotate/transform the reflection.
  29794. * @returns the reflection matrix
  29795. */
  29796. getReflectionTextureMatrix(): Matrix;
  29797. /**
  29798. * Get the underlying lower level texture from Babylon.
  29799. * @returns the insternal texture
  29800. */
  29801. getInternalTexture(): Nullable<InternalTexture>;
  29802. /**
  29803. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29804. * @returns true if ready or not blocking
  29805. */
  29806. isReadyOrNotBlocking(): boolean;
  29807. /**
  29808. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29809. * @returns true if fully ready
  29810. */
  29811. isReady(): boolean;
  29812. private _cachedSize;
  29813. /**
  29814. * Get the size of the texture.
  29815. * @returns the texture size.
  29816. */
  29817. getSize(): ISize;
  29818. /**
  29819. * Get the base size of the texture.
  29820. * It can be different from the size if the texture has been resized for POT for instance
  29821. * @returns the base size
  29822. */
  29823. getBaseSize(): ISize;
  29824. /**
  29825. * Update the sampling mode of the texture.
  29826. * Default is Trilinear mode.
  29827. *
  29828. * | Value | Type | Description |
  29829. * | ----- | ------------------ | ----------- |
  29830. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29831. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29832. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29833. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29834. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29835. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29836. * | 7 | NEAREST_LINEAR | |
  29837. * | 8 | NEAREST_NEAREST | |
  29838. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29839. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29840. * | 11 | LINEAR_LINEAR | |
  29841. * | 12 | LINEAR_NEAREST | |
  29842. *
  29843. * > _mag_: magnification filter (close to the viewer)
  29844. * > _min_: minification filter (far from the viewer)
  29845. * > _mip_: filter used between mip map levels
  29846. *@param samplingMode Define the new sampling mode of the texture
  29847. */
  29848. updateSamplingMode(samplingMode: number): void;
  29849. /**
  29850. * Scales the texture if is `canRescale()`
  29851. * @param ratio the resize factor we want to use to rescale
  29852. */
  29853. scale(ratio: number): void;
  29854. /**
  29855. * Get if the texture can rescale.
  29856. */
  29857. get canRescale(): boolean;
  29858. /** @hidden */
  29859. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29860. /** @hidden */
  29861. _rebuild(): void;
  29862. /**
  29863. * Triggers the load sequence in delayed load mode.
  29864. */
  29865. delayLoad(): void;
  29866. /**
  29867. * Clones the texture.
  29868. * @returns the cloned texture
  29869. */
  29870. clone(): Nullable<BaseTexture>;
  29871. /**
  29872. * Get the texture underlying type (INT, FLOAT...)
  29873. */
  29874. get textureType(): number;
  29875. /**
  29876. * Get the texture underlying format (RGB, RGBA...)
  29877. */
  29878. get textureFormat(): number;
  29879. /**
  29880. * Indicates that textures need to be re-calculated for all materials
  29881. */
  29882. protected _markAllSubMeshesAsTexturesDirty(): void;
  29883. /**
  29884. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29885. * This will returns an RGBA array buffer containing either in values (0-255) or
  29886. * float values (0-1) depending of the underlying buffer type.
  29887. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29888. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29889. * @param buffer defines a user defined buffer to fill with data (can be null)
  29890. * @returns The Array buffer containing the pixels data.
  29891. */
  29892. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29893. /**
  29894. * Release and destroy the underlying lower level texture aka internalTexture.
  29895. */
  29896. releaseInternalTexture(): void;
  29897. /** @hidden */
  29898. get _lodTextureHigh(): Nullable<BaseTexture>;
  29899. /** @hidden */
  29900. get _lodTextureMid(): Nullable<BaseTexture>;
  29901. /** @hidden */
  29902. get _lodTextureLow(): Nullable<BaseTexture>;
  29903. /**
  29904. * Dispose the texture and release its associated resources.
  29905. */
  29906. dispose(): void;
  29907. /**
  29908. * Serialize the texture into a JSON representation that can be parsed later on.
  29909. * @returns the JSON representation of the texture
  29910. */
  29911. serialize(): any;
  29912. /**
  29913. * Helper function to be called back once a list of texture contains only ready textures.
  29914. * @param textures Define the list of textures to wait for
  29915. * @param callback Define the callback triggered once the entire list will be ready
  29916. */
  29917. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29918. }
  29919. }
  29920. declare module BABYLON {
  29921. /**
  29922. * Options to be used when creating an effect.
  29923. */
  29924. export interface IEffectCreationOptions {
  29925. /**
  29926. * Atrributes that will be used in the shader.
  29927. */
  29928. attributes: string[];
  29929. /**
  29930. * Uniform varible names that will be set in the shader.
  29931. */
  29932. uniformsNames: string[];
  29933. /**
  29934. * Uniform buffer variable names that will be set in the shader.
  29935. */
  29936. uniformBuffersNames: string[];
  29937. /**
  29938. * Sampler texture variable names that will be set in the shader.
  29939. */
  29940. samplers: string[];
  29941. /**
  29942. * Define statements that will be set in the shader.
  29943. */
  29944. defines: any;
  29945. /**
  29946. * Possible fallbacks for this effect to improve performance when needed.
  29947. */
  29948. fallbacks: Nullable<IEffectFallbacks>;
  29949. /**
  29950. * Callback that will be called when the shader is compiled.
  29951. */
  29952. onCompiled: Nullable<(effect: Effect) => void>;
  29953. /**
  29954. * Callback that will be called if an error occurs during shader compilation.
  29955. */
  29956. onError: Nullable<(effect: Effect, errors: string) => void>;
  29957. /**
  29958. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29959. */
  29960. indexParameters?: any;
  29961. /**
  29962. * Max number of lights that can be used in the shader.
  29963. */
  29964. maxSimultaneousLights?: number;
  29965. /**
  29966. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29967. */
  29968. transformFeedbackVaryings?: Nullable<string[]>;
  29969. }
  29970. /**
  29971. * Effect containing vertex and fragment shader that can be executed on an object.
  29972. */
  29973. export class Effect implements IDisposable {
  29974. /**
  29975. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29976. */
  29977. static ShadersRepository: string;
  29978. /**
  29979. * Name of the effect.
  29980. */
  29981. name: any;
  29982. /**
  29983. * String container all the define statements that should be set on the shader.
  29984. */
  29985. defines: string;
  29986. /**
  29987. * Callback that will be called when the shader is compiled.
  29988. */
  29989. onCompiled: Nullable<(effect: Effect) => void>;
  29990. /**
  29991. * Callback that will be called if an error occurs during shader compilation.
  29992. */
  29993. onError: Nullable<(effect: Effect, errors: string) => void>;
  29994. /**
  29995. * Callback that will be called when effect is bound.
  29996. */
  29997. onBind: Nullable<(effect: Effect) => void>;
  29998. /**
  29999. * Unique ID of the effect.
  30000. */
  30001. uniqueId: number;
  30002. /**
  30003. * Observable that will be called when the shader is compiled.
  30004. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30005. */
  30006. onCompileObservable: Observable<Effect>;
  30007. /**
  30008. * Observable that will be called if an error occurs during shader compilation.
  30009. */
  30010. onErrorObservable: Observable<Effect>;
  30011. /** @hidden */
  30012. _onBindObservable: Nullable<Observable<Effect>>;
  30013. /**
  30014. * @hidden
  30015. * Specifies if the effect was previously ready
  30016. */
  30017. _wasPreviouslyReady: boolean;
  30018. /**
  30019. * Observable that will be called when effect is bound.
  30020. */
  30021. get onBindObservable(): Observable<Effect>;
  30022. /** @hidden */
  30023. _bonesComputationForcedToCPU: boolean;
  30024. private static _uniqueIdSeed;
  30025. private _engine;
  30026. private _uniformBuffersNames;
  30027. private _uniformsNames;
  30028. private _samplerList;
  30029. private _samplers;
  30030. private _isReady;
  30031. private _compilationError;
  30032. private _allFallbacksProcessed;
  30033. private _attributesNames;
  30034. private _attributes;
  30035. private _attributeLocationByName;
  30036. private _uniforms;
  30037. /**
  30038. * Key for the effect.
  30039. * @hidden
  30040. */
  30041. _key: string;
  30042. private _indexParameters;
  30043. private _fallbacks;
  30044. private _vertexSourceCode;
  30045. private _fragmentSourceCode;
  30046. private _vertexSourceCodeOverride;
  30047. private _fragmentSourceCodeOverride;
  30048. private _transformFeedbackVaryings;
  30049. /**
  30050. * Compiled shader to webGL program.
  30051. * @hidden
  30052. */
  30053. _pipelineContext: Nullable<IPipelineContext>;
  30054. private _valueCache;
  30055. private static _baseCache;
  30056. /**
  30057. * Instantiates an effect.
  30058. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30059. * @param baseName Name of the effect.
  30060. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30061. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30062. * @param samplers List of sampler variables that will be passed to the shader.
  30063. * @param engine Engine to be used to render the effect
  30064. * @param defines Define statements to be added to the shader.
  30065. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30066. * @param onCompiled Callback that will be called when the shader is compiled.
  30067. * @param onError Callback that will be called if an error occurs during shader compilation.
  30068. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30069. */
  30070. 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);
  30071. private _useFinalCode;
  30072. /**
  30073. * Unique key for this effect
  30074. */
  30075. get key(): string;
  30076. /**
  30077. * If the effect has been compiled and prepared.
  30078. * @returns if the effect is compiled and prepared.
  30079. */
  30080. isReady(): boolean;
  30081. private _isReadyInternal;
  30082. /**
  30083. * The engine the effect was initialized with.
  30084. * @returns the engine.
  30085. */
  30086. getEngine(): Engine;
  30087. /**
  30088. * The pipeline context for this effect
  30089. * @returns the associated pipeline context
  30090. */
  30091. getPipelineContext(): Nullable<IPipelineContext>;
  30092. /**
  30093. * The set of names of attribute variables for the shader.
  30094. * @returns An array of attribute names.
  30095. */
  30096. getAttributesNames(): string[];
  30097. /**
  30098. * Returns the attribute at the given index.
  30099. * @param index The index of the attribute.
  30100. * @returns The location of the attribute.
  30101. */
  30102. getAttributeLocation(index: number): number;
  30103. /**
  30104. * Returns the attribute based on the name of the variable.
  30105. * @param name of the attribute to look up.
  30106. * @returns the attribute location.
  30107. */
  30108. getAttributeLocationByName(name: string): number;
  30109. /**
  30110. * The number of attributes.
  30111. * @returns the numnber of attributes.
  30112. */
  30113. getAttributesCount(): number;
  30114. /**
  30115. * Gets the index of a uniform variable.
  30116. * @param uniformName of the uniform to look up.
  30117. * @returns the index.
  30118. */
  30119. getUniformIndex(uniformName: string): number;
  30120. /**
  30121. * Returns the attribute based on the name of the variable.
  30122. * @param uniformName of the uniform to look up.
  30123. * @returns the location of the uniform.
  30124. */
  30125. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30126. /**
  30127. * Returns an array of sampler variable names
  30128. * @returns The array of sampler variable neames.
  30129. */
  30130. getSamplers(): string[];
  30131. /**
  30132. * The error from the last compilation.
  30133. * @returns the error string.
  30134. */
  30135. getCompilationError(): string;
  30136. /**
  30137. * Gets a boolean indicating that all fallbacks were used during compilation
  30138. * @returns true if all fallbacks were used
  30139. */
  30140. allFallbacksProcessed(): boolean;
  30141. /**
  30142. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30143. * @param func The callback to be used.
  30144. */
  30145. executeWhenCompiled(func: (effect: Effect) => void): void;
  30146. private _checkIsReady;
  30147. private _loadShader;
  30148. /**
  30149. * Recompiles the webGL program
  30150. * @param vertexSourceCode The source code for the vertex shader.
  30151. * @param fragmentSourceCode The source code for the fragment shader.
  30152. * @param onCompiled Callback called when completed.
  30153. * @param onError Callback called on error.
  30154. * @hidden
  30155. */
  30156. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30157. /**
  30158. * Prepares the effect
  30159. * @hidden
  30160. */
  30161. _prepareEffect(): void;
  30162. private _processCompilationErrors;
  30163. /**
  30164. * Checks if the effect is supported. (Must be called after compilation)
  30165. */
  30166. get isSupported(): boolean;
  30167. /**
  30168. * Binds a texture to the engine to be used as output of the shader.
  30169. * @param channel Name of the output variable.
  30170. * @param texture Texture to bind.
  30171. * @hidden
  30172. */
  30173. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30174. /**
  30175. * Sets a texture on the engine to be used in the shader.
  30176. * @param channel Name of the sampler variable.
  30177. * @param texture Texture to set.
  30178. */
  30179. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30180. /**
  30181. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30182. * @param channel Name of the sampler variable.
  30183. * @param texture Texture to set.
  30184. */
  30185. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30186. /**
  30187. * Sets an array of textures on the engine to be used in the shader.
  30188. * @param channel Name of the variable.
  30189. * @param textures Textures to set.
  30190. */
  30191. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30192. /**
  30193. * 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)
  30194. * @param channel Name of the sampler variable.
  30195. * @param postProcess Post process to get the input texture from.
  30196. */
  30197. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30198. /**
  30199. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30200. * 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)
  30201. * @param channel Name of the sampler variable.
  30202. * @param postProcess Post process to get the output texture from.
  30203. */
  30204. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30205. /** @hidden */
  30206. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30207. /** @hidden */
  30208. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30209. /** @hidden */
  30210. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30211. /** @hidden */
  30212. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30213. /**
  30214. * Binds a buffer to a uniform.
  30215. * @param buffer Buffer to bind.
  30216. * @param name Name of the uniform variable to bind to.
  30217. */
  30218. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30219. /**
  30220. * Binds block to a uniform.
  30221. * @param blockName Name of the block to bind.
  30222. * @param index Index to bind.
  30223. */
  30224. bindUniformBlock(blockName: string, index: number): void;
  30225. /**
  30226. * Sets an interger value on a uniform variable.
  30227. * @param uniformName Name of the variable.
  30228. * @param value Value to be set.
  30229. * @returns this effect.
  30230. */
  30231. setInt(uniformName: string, value: number): Effect;
  30232. /**
  30233. * Sets an int array on a uniform variable.
  30234. * @param uniformName Name of the variable.
  30235. * @param array array to be set.
  30236. * @returns this effect.
  30237. */
  30238. setIntArray(uniformName: string, array: Int32Array): Effect;
  30239. /**
  30240. * 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)
  30241. * @param uniformName Name of the variable.
  30242. * @param array array to be set.
  30243. * @returns this effect.
  30244. */
  30245. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30246. /**
  30247. * 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)
  30248. * @param uniformName Name of the variable.
  30249. * @param array array to be set.
  30250. * @returns this effect.
  30251. */
  30252. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30253. /**
  30254. * 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)
  30255. * @param uniformName Name of the variable.
  30256. * @param array array to be set.
  30257. * @returns this effect.
  30258. */
  30259. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30260. /**
  30261. * Sets an float array on a uniform variable.
  30262. * @param uniformName Name of the variable.
  30263. * @param array array to be set.
  30264. * @returns this effect.
  30265. */
  30266. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30267. /**
  30268. * 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)
  30269. * @param uniformName Name of the variable.
  30270. * @param array array to be set.
  30271. * @returns this effect.
  30272. */
  30273. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30274. /**
  30275. * 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)
  30276. * @param uniformName Name of the variable.
  30277. * @param array array to be set.
  30278. * @returns this effect.
  30279. */
  30280. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30281. /**
  30282. * 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)
  30283. * @param uniformName Name of the variable.
  30284. * @param array array to be set.
  30285. * @returns this effect.
  30286. */
  30287. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30288. /**
  30289. * Sets an array on a uniform variable.
  30290. * @param uniformName Name of the variable.
  30291. * @param array array to be set.
  30292. * @returns this effect.
  30293. */
  30294. setArray(uniformName: string, array: number[]): Effect;
  30295. /**
  30296. * 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)
  30297. * @param uniformName Name of the variable.
  30298. * @param array array to be set.
  30299. * @returns this effect.
  30300. */
  30301. setArray2(uniformName: string, array: number[]): Effect;
  30302. /**
  30303. * 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)
  30304. * @param uniformName Name of the variable.
  30305. * @param array array to be set.
  30306. * @returns this effect.
  30307. */
  30308. setArray3(uniformName: string, array: number[]): Effect;
  30309. /**
  30310. * 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)
  30311. * @param uniformName Name of the variable.
  30312. * @param array array to be set.
  30313. * @returns this effect.
  30314. */
  30315. setArray4(uniformName: string, array: number[]): Effect;
  30316. /**
  30317. * Sets matrices on a uniform variable.
  30318. * @param uniformName Name of the variable.
  30319. * @param matrices matrices to be set.
  30320. * @returns this effect.
  30321. */
  30322. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30323. /**
  30324. * Sets matrix on a uniform variable.
  30325. * @param uniformName Name of the variable.
  30326. * @param matrix matrix to be set.
  30327. * @returns this effect.
  30328. */
  30329. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30330. /**
  30331. * 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)
  30332. * @param uniformName Name of the variable.
  30333. * @param matrix matrix to be set.
  30334. * @returns this effect.
  30335. */
  30336. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30337. /**
  30338. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30339. * @param uniformName Name of the variable.
  30340. * @param matrix matrix to be set.
  30341. * @returns this effect.
  30342. */
  30343. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30344. /**
  30345. * Sets a float on a uniform variable.
  30346. * @param uniformName Name of the variable.
  30347. * @param value value to be set.
  30348. * @returns this effect.
  30349. */
  30350. setFloat(uniformName: string, value: number): Effect;
  30351. /**
  30352. * Sets a boolean on a uniform variable.
  30353. * @param uniformName Name of the variable.
  30354. * @param bool value to be set.
  30355. * @returns this effect.
  30356. */
  30357. setBool(uniformName: string, bool: boolean): Effect;
  30358. /**
  30359. * Sets a Vector2 on a uniform variable.
  30360. * @param uniformName Name of the variable.
  30361. * @param vector2 vector2 to be set.
  30362. * @returns this effect.
  30363. */
  30364. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30365. /**
  30366. * Sets a float2 on a uniform variable.
  30367. * @param uniformName Name of the variable.
  30368. * @param x First float in float2.
  30369. * @param y Second float in float2.
  30370. * @returns this effect.
  30371. */
  30372. setFloat2(uniformName: string, x: number, y: number): Effect;
  30373. /**
  30374. * Sets a Vector3 on a uniform variable.
  30375. * @param uniformName Name of the variable.
  30376. * @param vector3 Value to be set.
  30377. * @returns this effect.
  30378. */
  30379. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30380. /**
  30381. * Sets a float3 on a uniform variable.
  30382. * @param uniformName Name of the variable.
  30383. * @param x First float in float3.
  30384. * @param y Second float in float3.
  30385. * @param z Third float in float3.
  30386. * @returns this effect.
  30387. */
  30388. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30389. /**
  30390. * Sets a Vector4 on a uniform variable.
  30391. * @param uniformName Name of the variable.
  30392. * @param vector4 Value to be set.
  30393. * @returns this effect.
  30394. */
  30395. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30396. /**
  30397. * Sets a float4 on a uniform variable.
  30398. * @param uniformName Name of the variable.
  30399. * @param x First float in float4.
  30400. * @param y Second float in float4.
  30401. * @param z Third float in float4.
  30402. * @param w Fourth float in float4.
  30403. * @returns this effect.
  30404. */
  30405. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30406. /**
  30407. * Sets a Color3 on a uniform variable.
  30408. * @param uniformName Name of the variable.
  30409. * @param color3 Value to be set.
  30410. * @returns this effect.
  30411. */
  30412. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30413. /**
  30414. * Sets a Color4 on a uniform variable.
  30415. * @param uniformName Name of the variable.
  30416. * @param color3 Value to be set.
  30417. * @param alpha Alpha value to be set.
  30418. * @returns this effect.
  30419. */
  30420. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30421. /**
  30422. * Sets a Color4 on a uniform variable
  30423. * @param uniformName defines the name of the variable
  30424. * @param color4 defines the value to be set
  30425. * @returns this effect.
  30426. */
  30427. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30428. /** Release all associated resources */
  30429. dispose(): void;
  30430. /**
  30431. * This function will add a new shader to the shader store
  30432. * @param name the name of the shader
  30433. * @param pixelShader optional pixel shader content
  30434. * @param vertexShader optional vertex shader content
  30435. */
  30436. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30437. /**
  30438. * Store of each shader (The can be looked up using effect.key)
  30439. */
  30440. static ShadersStore: {
  30441. [key: string]: string;
  30442. };
  30443. /**
  30444. * Store of each included file for a shader (The can be looked up using effect.key)
  30445. */
  30446. static IncludesShadersStore: {
  30447. [key: string]: string;
  30448. };
  30449. /**
  30450. * Resets the cache of effects.
  30451. */
  30452. static ResetCache(): void;
  30453. }
  30454. }
  30455. declare module BABYLON {
  30456. /**
  30457. * Interface used to describe the capabilities of the engine relatively to the current browser
  30458. */
  30459. export interface EngineCapabilities {
  30460. /** Maximum textures units per fragment shader */
  30461. maxTexturesImageUnits: number;
  30462. /** Maximum texture units per vertex shader */
  30463. maxVertexTextureImageUnits: number;
  30464. /** Maximum textures units in the entire pipeline */
  30465. maxCombinedTexturesImageUnits: number;
  30466. /** Maximum texture size */
  30467. maxTextureSize: number;
  30468. /** Maximum texture samples */
  30469. maxSamples?: number;
  30470. /** Maximum cube texture size */
  30471. maxCubemapTextureSize: number;
  30472. /** Maximum render texture size */
  30473. maxRenderTextureSize: number;
  30474. /** Maximum number of vertex attributes */
  30475. maxVertexAttribs: number;
  30476. /** Maximum number of varyings */
  30477. maxVaryingVectors: number;
  30478. /** Maximum number of uniforms per vertex shader */
  30479. maxVertexUniformVectors: number;
  30480. /** Maximum number of uniforms per fragment shader */
  30481. maxFragmentUniformVectors: number;
  30482. /** Defines if standard derivates (dx/dy) are supported */
  30483. standardDerivatives: boolean;
  30484. /** Defines if s3tc texture compression is supported */
  30485. s3tc?: WEBGL_compressed_texture_s3tc;
  30486. /** Defines if pvrtc texture compression is supported */
  30487. pvrtc: any;
  30488. /** Defines if etc1 texture compression is supported */
  30489. etc1: any;
  30490. /** Defines if etc2 texture compression is supported */
  30491. etc2: any;
  30492. /** Defines if astc texture compression is supported */
  30493. astc: any;
  30494. /** Defines if float textures are supported */
  30495. textureFloat: boolean;
  30496. /** Defines if vertex array objects are supported */
  30497. vertexArrayObject: boolean;
  30498. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30499. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30500. /** Gets the maximum level of anisotropy supported */
  30501. maxAnisotropy: number;
  30502. /** Defines if instancing is supported */
  30503. instancedArrays: boolean;
  30504. /** Defines if 32 bits indices are supported */
  30505. uintIndices: boolean;
  30506. /** Defines if high precision shaders are supported */
  30507. highPrecisionShaderSupported: boolean;
  30508. /** Defines if depth reading in the fragment shader is supported */
  30509. fragmentDepthSupported: boolean;
  30510. /** Defines if float texture linear filtering is supported*/
  30511. textureFloatLinearFiltering: boolean;
  30512. /** Defines if rendering to float textures is supported */
  30513. textureFloatRender: boolean;
  30514. /** Defines if half float textures are supported*/
  30515. textureHalfFloat: boolean;
  30516. /** Defines if half float texture linear filtering is supported*/
  30517. textureHalfFloatLinearFiltering: boolean;
  30518. /** Defines if rendering to half float textures is supported */
  30519. textureHalfFloatRender: boolean;
  30520. /** Defines if textureLOD shader command is supported */
  30521. textureLOD: boolean;
  30522. /** Defines if draw buffers extension is supported */
  30523. drawBuffersExtension: boolean;
  30524. /** Defines if depth textures are supported */
  30525. depthTextureExtension: boolean;
  30526. /** Defines if float color buffer are supported */
  30527. colorBufferFloat: boolean;
  30528. /** Gets disjoint timer query extension (null if not supported) */
  30529. timerQuery?: EXT_disjoint_timer_query;
  30530. /** Defines if timestamp can be used with timer query */
  30531. canUseTimestampForTimerQuery: boolean;
  30532. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30533. multiview?: any;
  30534. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30535. oculusMultiview?: any;
  30536. /** Function used to let the system compiles shaders in background */
  30537. parallelShaderCompile?: {
  30538. COMPLETION_STATUS_KHR: number;
  30539. };
  30540. /** Max number of texture samples for MSAA */
  30541. maxMSAASamples: number;
  30542. /** Defines if the blend min max extension is supported */
  30543. blendMinMax: boolean;
  30544. }
  30545. }
  30546. declare module BABYLON {
  30547. /**
  30548. * @hidden
  30549. **/
  30550. export class DepthCullingState {
  30551. private _isDepthTestDirty;
  30552. private _isDepthMaskDirty;
  30553. private _isDepthFuncDirty;
  30554. private _isCullFaceDirty;
  30555. private _isCullDirty;
  30556. private _isZOffsetDirty;
  30557. private _isFrontFaceDirty;
  30558. private _depthTest;
  30559. private _depthMask;
  30560. private _depthFunc;
  30561. private _cull;
  30562. private _cullFace;
  30563. private _zOffset;
  30564. private _frontFace;
  30565. /**
  30566. * Initializes the state.
  30567. */
  30568. constructor();
  30569. get isDirty(): boolean;
  30570. get zOffset(): number;
  30571. set zOffset(value: number);
  30572. get cullFace(): Nullable<number>;
  30573. set cullFace(value: Nullable<number>);
  30574. get cull(): Nullable<boolean>;
  30575. set cull(value: Nullable<boolean>);
  30576. get depthFunc(): Nullable<number>;
  30577. set depthFunc(value: Nullable<number>);
  30578. get depthMask(): boolean;
  30579. set depthMask(value: boolean);
  30580. get depthTest(): boolean;
  30581. set depthTest(value: boolean);
  30582. get frontFace(): Nullable<number>;
  30583. set frontFace(value: Nullable<number>);
  30584. reset(): void;
  30585. apply(gl: WebGLRenderingContext): void;
  30586. }
  30587. }
  30588. declare module BABYLON {
  30589. /**
  30590. * @hidden
  30591. **/
  30592. export class StencilState {
  30593. /** 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 */
  30594. static readonly ALWAYS: number;
  30595. /** Passed to stencilOperation to specify that stencil value must be kept */
  30596. static readonly KEEP: number;
  30597. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30598. static readonly REPLACE: number;
  30599. private _isStencilTestDirty;
  30600. private _isStencilMaskDirty;
  30601. private _isStencilFuncDirty;
  30602. private _isStencilOpDirty;
  30603. private _stencilTest;
  30604. private _stencilMask;
  30605. private _stencilFunc;
  30606. private _stencilFuncRef;
  30607. private _stencilFuncMask;
  30608. private _stencilOpStencilFail;
  30609. private _stencilOpDepthFail;
  30610. private _stencilOpStencilDepthPass;
  30611. get isDirty(): boolean;
  30612. get stencilFunc(): number;
  30613. set stencilFunc(value: number);
  30614. get stencilFuncRef(): number;
  30615. set stencilFuncRef(value: number);
  30616. get stencilFuncMask(): number;
  30617. set stencilFuncMask(value: number);
  30618. get stencilOpStencilFail(): number;
  30619. set stencilOpStencilFail(value: number);
  30620. get stencilOpDepthFail(): number;
  30621. set stencilOpDepthFail(value: number);
  30622. get stencilOpStencilDepthPass(): number;
  30623. set stencilOpStencilDepthPass(value: number);
  30624. get stencilMask(): number;
  30625. set stencilMask(value: number);
  30626. get stencilTest(): boolean;
  30627. set stencilTest(value: boolean);
  30628. constructor();
  30629. reset(): void;
  30630. apply(gl: WebGLRenderingContext): void;
  30631. }
  30632. }
  30633. declare module BABYLON {
  30634. /**
  30635. * @hidden
  30636. **/
  30637. export class AlphaState {
  30638. private _isAlphaBlendDirty;
  30639. private _isBlendFunctionParametersDirty;
  30640. private _isBlendEquationParametersDirty;
  30641. private _isBlendConstantsDirty;
  30642. private _alphaBlend;
  30643. private _blendFunctionParameters;
  30644. private _blendEquationParameters;
  30645. private _blendConstants;
  30646. /**
  30647. * Initializes the state.
  30648. */
  30649. constructor();
  30650. get isDirty(): boolean;
  30651. get alphaBlend(): boolean;
  30652. set alphaBlend(value: boolean);
  30653. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30654. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30655. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30656. reset(): void;
  30657. apply(gl: WebGLRenderingContext): void;
  30658. }
  30659. }
  30660. declare module BABYLON {
  30661. /** @hidden */
  30662. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30663. attributeProcessor(attribute: string): string;
  30664. varyingProcessor(varying: string, isFragment: boolean): string;
  30665. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30666. }
  30667. }
  30668. declare module BABYLON {
  30669. /**
  30670. * Interface for attribute information associated with buffer instanciation
  30671. */
  30672. export interface InstancingAttributeInfo {
  30673. /**
  30674. * Name of the GLSL attribute
  30675. * if attribute index is not specified, this is used to retrieve the index from the effect
  30676. */
  30677. attributeName: string;
  30678. /**
  30679. * Index/offset of the attribute in the vertex shader
  30680. * if not specified, this will be computes from the name.
  30681. */
  30682. index?: number;
  30683. /**
  30684. * size of the attribute, 1, 2, 3 or 4
  30685. */
  30686. attributeSize: number;
  30687. /**
  30688. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30689. */
  30690. offset: number;
  30691. /**
  30692. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30693. * default to 1
  30694. */
  30695. divisor?: number;
  30696. /**
  30697. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30698. * default is FLOAT
  30699. */
  30700. attributeType?: number;
  30701. /**
  30702. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30703. */
  30704. normalized?: boolean;
  30705. }
  30706. }
  30707. declare module BABYLON {
  30708. interface ThinEngine {
  30709. /**
  30710. * Update a video texture
  30711. * @param texture defines the texture to update
  30712. * @param video defines the video element to use
  30713. * @param invertY defines if data must be stored with Y axis inverted
  30714. */
  30715. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30716. }
  30717. }
  30718. declare module BABYLON {
  30719. /**
  30720. * Settings for finer control over video usage
  30721. */
  30722. export interface VideoTextureSettings {
  30723. /**
  30724. * Applies `autoplay` to video, if specified
  30725. */
  30726. autoPlay?: boolean;
  30727. /**
  30728. * Applies `loop` to video, if specified
  30729. */
  30730. loop?: boolean;
  30731. /**
  30732. * Automatically updates internal texture from video at every frame in the render loop
  30733. */
  30734. autoUpdateTexture: boolean;
  30735. /**
  30736. * Image src displayed during the video loading or until the user interacts with the video.
  30737. */
  30738. poster?: string;
  30739. }
  30740. /**
  30741. * If you want to display a video in your scene, this is the special texture for that.
  30742. * This special texture works similar to other textures, with the exception of a few parameters.
  30743. * @see https://doc.babylonjs.com/how_to/video_texture
  30744. */
  30745. export class VideoTexture extends Texture {
  30746. /**
  30747. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30748. */
  30749. readonly autoUpdateTexture: boolean;
  30750. /**
  30751. * The video instance used by the texture internally
  30752. */
  30753. readonly video: HTMLVideoElement;
  30754. private _onUserActionRequestedObservable;
  30755. /**
  30756. * Event triggerd when a dom action is required by the user to play the video.
  30757. * This happens due to recent changes in browser policies preventing video to auto start.
  30758. */
  30759. get onUserActionRequestedObservable(): Observable<Texture>;
  30760. private _generateMipMaps;
  30761. private _engine;
  30762. private _stillImageCaptured;
  30763. private _displayingPosterTexture;
  30764. private _settings;
  30765. private _createInternalTextureOnEvent;
  30766. private _frameId;
  30767. private _currentSrc;
  30768. /**
  30769. * Creates a video texture.
  30770. * If you want to display a video in your scene, this is the special texture for that.
  30771. * This special texture works similar to other textures, with the exception of a few parameters.
  30772. * @see https://doc.babylonjs.com/how_to/video_texture
  30773. * @param name optional name, will detect from video source, if not defined
  30774. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30775. * @param scene is obviously the current scene.
  30776. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30777. * @param invertY is false by default but can be used to invert video on Y axis
  30778. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30779. * @param settings allows finer control over video usage
  30780. */
  30781. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30782. private _getName;
  30783. private _getVideo;
  30784. private _createInternalTexture;
  30785. private reset;
  30786. /**
  30787. * @hidden Internal method to initiate `update`.
  30788. */
  30789. _rebuild(): void;
  30790. /**
  30791. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30792. */
  30793. update(): void;
  30794. /**
  30795. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30796. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30797. */
  30798. updateTexture(isVisible: boolean): void;
  30799. protected _updateInternalTexture: () => void;
  30800. /**
  30801. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30802. * @param url New url.
  30803. */
  30804. updateURL(url: string): void;
  30805. /**
  30806. * Clones the texture.
  30807. * @returns the cloned texture
  30808. */
  30809. clone(): VideoTexture;
  30810. /**
  30811. * Dispose the texture and release its associated resources.
  30812. */
  30813. dispose(): void;
  30814. /**
  30815. * Creates a video texture straight from a stream.
  30816. * @param scene Define the scene the texture should be created in
  30817. * @param stream Define the stream the texture should be created from
  30818. * @returns The created video texture as a promise
  30819. */
  30820. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30821. /**
  30822. * Creates a video texture straight from your WebCam video feed.
  30823. * @param scene Define the scene the texture should be created in
  30824. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30825. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30826. * @returns The created video texture as a promise
  30827. */
  30828. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30829. minWidth: number;
  30830. maxWidth: number;
  30831. minHeight: number;
  30832. maxHeight: number;
  30833. deviceId: string;
  30834. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30835. /**
  30836. * Creates a video texture straight from your WebCam video feed.
  30837. * @param scene Define the scene the texture should be created in
  30838. * @param onReady Define a callback to triggered once the texture will be ready
  30839. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30840. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30841. */
  30842. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30843. minWidth: number;
  30844. maxWidth: number;
  30845. minHeight: number;
  30846. maxHeight: number;
  30847. deviceId: string;
  30848. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30849. }
  30850. }
  30851. declare module BABYLON {
  30852. /**
  30853. * Defines the interface used by objects working like Scene
  30854. * @hidden
  30855. */
  30856. interface ISceneLike {
  30857. _addPendingData(data: any): void;
  30858. _removePendingData(data: any): void;
  30859. offlineProvider: IOfflineProvider;
  30860. }
  30861. /** Interface defining initialization parameters for Engine class */
  30862. export interface EngineOptions extends WebGLContextAttributes {
  30863. /**
  30864. * Defines if the engine should no exceed a specified device ratio
  30865. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30866. */
  30867. limitDeviceRatio?: number;
  30868. /**
  30869. * Defines if webvr should be enabled automatically
  30870. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30871. */
  30872. autoEnableWebVR?: boolean;
  30873. /**
  30874. * Defines if webgl2 should be turned off even if supported
  30875. * @see http://doc.babylonjs.com/features/webgl2
  30876. */
  30877. disableWebGL2Support?: boolean;
  30878. /**
  30879. * Defines if webaudio should be initialized as well
  30880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30881. */
  30882. audioEngine?: boolean;
  30883. /**
  30884. * Defines if animations should run using a deterministic lock step
  30885. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30886. */
  30887. deterministicLockstep?: boolean;
  30888. /** Defines the maximum steps to use with deterministic lock step mode */
  30889. lockstepMaxSteps?: number;
  30890. /** Defines the seconds between each deterministic lock step */
  30891. timeStep?: number;
  30892. /**
  30893. * Defines that engine should ignore context lost events
  30894. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30895. */
  30896. doNotHandleContextLost?: boolean;
  30897. /**
  30898. * Defines that engine should ignore modifying touch action attribute and style
  30899. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30900. */
  30901. doNotHandleTouchAction?: boolean;
  30902. /**
  30903. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30904. */
  30905. useHighPrecisionFloats?: boolean;
  30906. }
  30907. /**
  30908. * The base engine class (root of all engines)
  30909. */
  30910. export class ThinEngine {
  30911. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30912. static ExceptionList: ({
  30913. key: string;
  30914. capture: string;
  30915. captureConstraint: number;
  30916. targets: string[];
  30917. } | {
  30918. key: string;
  30919. capture: null;
  30920. captureConstraint: null;
  30921. targets: string[];
  30922. })[];
  30923. /** @hidden */
  30924. static _TextureLoaders: IInternalTextureLoader[];
  30925. /**
  30926. * Returns the current npm package of the sdk
  30927. */
  30928. static get NpmPackage(): string;
  30929. /**
  30930. * Returns the current version of the framework
  30931. */
  30932. static get Version(): string;
  30933. /**
  30934. * Returns a string describing the current engine
  30935. */
  30936. get description(): string;
  30937. /**
  30938. * Gets or sets the epsilon value used by collision engine
  30939. */
  30940. static CollisionsEpsilon: number;
  30941. /**
  30942. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30943. */
  30944. static get ShadersRepository(): string;
  30945. static set ShadersRepository(value: string);
  30946. /**
  30947. * Gets or sets the textures that the engine should not attempt to load as compressed
  30948. */
  30949. protected _excludedCompressedTextures: string[];
  30950. /**
  30951. * Filters the compressed texture formats to only include
  30952. * files that are not included in the skippable list
  30953. *
  30954. * @param url the current extension
  30955. * @param textureFormatInUse the current compressed texture format
  30956. * @returns "format" string
  30957. */
  30958. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30959. /** @hidden */
  30960. _shaderProcessor: IShaderProcessor;
  30961. /**
  30962. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30963. */
  30964. forcePOTTextures: boolean;
  30965. /**
  30966. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30967. */
  30968. isFullscreen: boolean;
  30969. /**
  30970. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30971. */
  30972. cullBackFaces: boolean;
  30973. /**
  30974. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30975. */
  30976. renderEvenInBackground: boolean;
  30977. /**
  30978. * Gets or sets a boolean indicating that cache can be kept between frames
  30979. */
  30980. preventCacheWipeBetweenFrames: boolean;
  30981. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30982. validateShaderPrograms: boolean;
  30983. /**
  30984. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30985. * This can provide greater z depth for distant objects.
  30986. */
  30987. useReverseDepthBuffer: boolean;
  30988. /**
  30989. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30990. */
  30991. disableUniformBuffers: boolean;
  30992. /** @hidden */
  30993. _uniformBuffers: UniformBuffer[];
  30994. /**
  30995. * Gets a boolean indicating that the engine supports uniform buffers
  30996. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30997. */
  30998. get supportsUniformBuffers(): boolean;
  30999. /** @hidden */
  31000. _gl: WebGLRenderingContext;
  31001. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31002. protected _windowIsBackground: boolean;
  31003. protected _webGLVersion: number;
  31004. protected _creationOptions: EngineOptions;
  31005. protected _highPrecisionShadersAllowed: boolean;
  31006. /** @hidden */
  31007. get _shouldUseHighPrecisionShader(): boolean;
  31008. /**
  31009. * Gets a boolean indicating that only power of 2 textures are supported
  31010. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31011. */
  31012. get needPOTTextures(): boolean;
  31013. /** @hidden */
  31014. _badOS: boolean;
  31015. /** @hidden */
  31016. _badDesktopOS: boolean;
  31017. private _hardwareScalingLevel;
  31018. /** @hidden */
  31019. _caps: EngineCapabilities;
  31020. private _isStencilEnable;
  31021. private _glVersion;
  31022. private _glRenderer;
  31023. private _glVendor;
  31024. /** @hidden */
  31025. _videoTextureSupported: boolean;
  31026. protected _renderingQueueLaunched: boolean;
  31027. protected _activeRenderLoops: (() => void)[];
  31028. /**
  31029. * Observable signaled when a context lost event is raised
  31030. */
  31031. onContextLostObservable: Observable<ThinEngine>;
  31032. /**
  31033. * Observable signaled when a context restored event is raised
  31034. */
  31035. onContextRestoredObservable: Observable<ThinEngine>;
  31036. private _onContextLost;
  31037. private _onContextRestored;
  31038. protected _contextWasLost: boolean;
  31039. /** @hidden */
  31040. _doNotHandleContextLost: boolean;
  31041. /**
  31042. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31043. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31044. */
  31045. get doNotHandleContextLost(): boolean;
  31046. set doNotHandleContextLost(value: boolean);
  31047. /**
  31048. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31049. */
  31050. disableVertexArrayObjects: boolean;
  31051. /** @hidden */
  31052. protected _colorWrite: boolean;
  31053. /** @hidden */
  31054. protected _colorWriteChanged: boolean;
  31055. /** @hidden */
  31056. protected _depthCullingState: DepthCullingState;
  31057. /** @hidden */
  31058. protected _stencilState: StencilState;
  31059. /** @hidden */
  31060. _alphaState: AlphaState;
  31061. /** @hidden */
  31062. _alphaMode: number;
  31063. /** @hidden */
  31064. _alphaEquation: number;
  31065. /** @hidden */
  31066. _internalTexturesCache: InternalTexture[];
  31067. /** @hidden */
  31068. protected _activeChannel: number;
  31069. private _currentTextureChannel;
  31070. /** @hidden */
  31071. protected _boundTexturesCache: {
  31072. [key: string]: Nullable<InternalTexture>;
  31073. };
  31074. /** @hidden */
  31075. protected _currentEffect: Nullable<Effect>;
  31076. /** @hidden */
  31077. protected _currentProgram: Nullable<WebGLProgram>;
  31078. private _compiledEffects;
  31079. private _vertexAttribArraysEnabled;
  31080. /** @hidden */
  31081. protected _cachedViewport: Nullable<IViewportLike>;
  31082. private _cachedVertexArrayObject;
  31083. /** @hidden */
  31084. protected _cachedVertexBuffers: any;
  31085. /** @hidden */
  31086. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31087. /** @hidden */
  31088. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31089. /** @hidden */
  31090. _currentRenderTarget: Nullable<InternalTexture>;
  31091. private _uintIndicesCurrentlySet;
  31092. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31093. /** @hidden */
  31094. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31095. private _currentBufferPointers;
  31096. private _currentInstanceLocations;
  31097. private _currentInstanceBuffers;
  31098. private _textureUnits;
  31099. /** @hidden */
  31100. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31101. /** @hidden */
  31102. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31103. /** @hidden */
  31104. _boundRenderFunction: any;
  31105. private _vaoRecordInProgress;
  31106. private _mustWipeVertexAttributes;
  31107. private _emptyTexture;
  31108. private _emptyCubeTexture;
  31109. private _emptyTexture3D;
  31110. private _emptyTexture2DArray;
  31111. /** @hidden */
  31112. _frameHandler: number;
  31113. private _nextFreeTextureSlots;
  31114. private _maxSimultaneousTextures;
  31115. private _activeRequests;
  31116. protected _texturesSupported: string[];
  31117. /** @hidden */
  31118. _textureFormatInUse: Nullable<string>;
  31119. protected get _supportsHardwareTextureRescaling(): boolean;
  31120. /**
  31121. * Gets the list of texture formats supported
  31122. */
  31123. get texturesSupported(): Array<string>;
  31124. /**
  31125. * Gets the list of texture formats in use
  31126. */
  31127. get textureFormatInUse(): Nullable<string>;
  31128. /**
  31129. * Gets the current viewport
  31130. */
  31131. get currentViewport(): Nullable<IViewportLike>;
  31132. /**
  31133. * Gets the default empty texture
  31134. */
  31135. get emptyTexture(): InternalTexture;
  31136. /**
  31137. * Gets the default empty 3D texture
  31138. */
  31139. get emptyTexture3D(): InternalTexture;
  31140. /**
  31141. * Gets the default empty 2D array texture
  31142. */
  31143. get emptyTexture2DArray(): InternalTexture;
  31144. /**
  31145. * Gets the default empty cube texture
  31146. */
  31147. get emptyCubeTexture(): InternalTexture;
  31148. /**
  31149. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31150. */
  31151. readonly premultipliedAlpha: boolean;
  31152. /**
  31153. * Observable event triggered before each texture is initialized
  31154. */
  31155. onBeforeTextureInitObservable: Observable<Texture>;
  31156. /**
  31157. * Creates a new engine
  31158. * @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
  31159. * @param antialias defines enable antialiasing (default: false)
  31160. * @param options defines further options to be sent to the getContext() function
  31161. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31162. */
  31163. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31164. private _rebuildInternalTextures;
  31165. private _rebuildEffects;
  31166. /**
  31167. * Gets a boolean indicating if all created effects are ready
  31168. * @returns true if all effects are ready
  31169. */
  31170. areAllEffectsReady(): boolean;
  31171. protected _rebuildBuffers(): void;
  31172. private _initGLContext;
  31173. /**
  31174. * Gets version of the current webGL context
  31175. */
  31176. get webGLVersion(): number;
  31177. /**
  31178. * Gets a string idenfifying the name of the class
  31179. * @returns "Engine" string
  31180. */
  31181. getClassName(): string;
  31182. /**
  31183. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31184. */
  31185. get isStencilEnable(): boolean;
  31186. /** @hidden */
  31187. _prepareWorkingCanvas(): void;
  31188. /**
  31189. * Reset the texture cache to empty state
  31190. */
  31191. resetTextureCache(): void;
  31192. /**
  31193. * Gets an object containing information about the current webGL context
  31194. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31195. */
  31196. getGlInfo(): {
  31197. vendor: string;
  31198. renderer: string;
  31199. version: string;
  31200. };
  31201. /**
  31202. * Defines the hardware scaling level.
  31203. * By default the hardware scaling level is computed from the window device ratio.
  31204. * 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.
  31205. * @param level defines the level to use
  31206. */
  31207. setHardwareScalingLevel(level: number): void;
  31208. /**
  31209. * Gets the current hardware scaling level.
  31210. * By default the hardware scaling level is computed from the window device ratio.
  31211. * 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.
  31212. * @returns a number indicating the current hardware scaling level
  31213. */
  31214. getHardwareScalingLevel(): number;
  31215. /**
  31216. * Gets the list of loaded textures
  31217. * @returns an array containing all loaded textures
  31218. */
  31219. getLoadedTexturesCache(): InternalTexture[];
  31220. /**
  31221. * Gets the object containing all engine capabilities
  31222. * @returns the EngineCapabilities object
  31223. */
  31224. getCaps(): EngineCapabilities;
  31225. /**
  31226. * stop executing a render loop function and remove it from the execution array
  31227. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31228. */
  31229. stopRenderLoop(renderFunction?: () => void): void;
  31230. /** @hidden */
  31231. _renderLoop(): void;
  31232. /**
  31233. * Gets the HTML canvas attached with the current webGL context
  31234. * @returns a HTML canvas
  31235. */
  31236. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31237. /**
  31238. * Gets host window
  31239. * @returns the host window object
  31240. */
  31241. getHostWindow(): Nullable<Window>;
  31242. /**
  31243. * Gets the current render width
  31244. * @param useScreen defines if screen size must be used (or the current render target if any)
  31245. * @returns a number defining the current render width
  31246. */
  31247. getRenderWidth(useScreen?: boolean): number;
  31248. /**
  31249. * Gets the current render height
  31250. * @param useScreen defines if screen size must be used (or the current render target if any)
  31251. * @returns a number defining the current render height
  31252. */
  31253. getRenderHeight(useScreen?: boolean): number;
  31254. /**
  31255. * Can be used to override the current requestAnimationFrame requester.
  31256. * @hidden
  31257. */
  31258. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31259. /**
  31260. * Register and execute a render loop. The engine can have more than one render function
  31261. * @param renderFunction defines the function to continuously execute
  31262. */
  31263. runRenderLoop(renderFunction: () => void): void;
  31264. /**
  31265. * Clear the current render buffer or the current render target (if any is set up)
  31266. * @param color defines the color to use
  31267. * @param backBuffer defines if the back buffer must be cleared
  31268. * @param depth defines if the depth buffer must be cleared
  31269. * @param stencil defines if the stencil buffer must be cleared
  31270. */
  31271. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31272. private _viewportCached;
  31273. /** @hidden */
  31274. _viewport(x: number, y: number, width: number, height: number): void;
  31275. /**
  31276. * Set the WebGL's viewport
  31277. * @param viewport defines the viewport element to be used
  31278. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31279. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31280. */
  31281. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31282. /**
  31283. * Begin a new frame
  31284. */
  31285. beginFrame(): void;
  31286. /**
  31287. * Enf the current frame
  31288. */
  31289. endFrame(): void;
  31290. /**
  31291. * Resize the view according to the canvas' size
  31292. */
  31293. resize(): void;
  31294. /**
  31295. * Force a specific size of the canvas
  31296. * @param width defines the new canvas' width
  31297. * @param height defines the new canvas' height
  31298. */
  31299. setSize(width: number, height: number): void;
  31300. /**
  31301. * Binds the frame buffer to the specified texture.
  31302. * @param texture The texture to render to or null for the default canvas
  31303. * @param faceIndex The face of the texture to render to in case of cube texture
  31304. * @param requiredWidth The width of the target to render to
  31305. * @param requiredHeight The height of the target to render to
  31306. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31307. * @param lodLevel defines the lod level to bind to the frame buffer
  31308. * @param layer defines the 2d array index to bind to frame buffer to
  31309. */
  31310. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31311. /** @hidden */
  31312. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31313. /**
  31314. * Unbind the current render target texture from the webGL context
  31315. * @param texture defines the render target texture to unbind
  31316. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31317. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31318. */
  31319. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31320. /**
  31321. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31322. */
  31323. flushFramebuffer(): void;
  31324. /**
  31325. * Unbind the current render target and bind the default framebuffer
  31326. */
  31327. restoreDefaultFramebuffer(): void;
  31328. /** @hidden */
  31329. protected _resetVertexBufferBinding(): void;
  31330. /**
  31331. * Creates a vertex buffer
  31332. * @param data the data for the vertex buffer
  31333. * @returns the new WebGL static buffer
  31334. */
  31335. createVertexBuffer(data: DataArray): DataBuffer;
  31336. private _createVertexBuffer;
  31337. /**
  31338. * Creates a dynamic vertex buffer
  31339. * @param data the data for the dynamic vertex buffer
  31340. * @returns the new WebGL dynamic buffer
  31341. */
  31342. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31343. protected _resetIndexBufferBinding(): void;
  31344. /**
  31345. * Creates a new index buffer
  31346. * @param indices defines the content of the index buffer
  31347. * @param updatable defines if the index buffer must be updatable
  31348. * @returns a new webGL buffer
  31349. */
  31350. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31351. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31352. /**
  31353. * Bind a webGL buffer to the webGL context
  31354. * @param buffer defines the buffer to bind
  31355. */
  31356. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31357. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31358. private bindBuffer;
  31359. /**
  31360. * update the bound buffer with the given data
  31361. * @param data defines the data to update
  31362. */
  31363. updateArrayBuffer(data: Float32Array): void;
  31364. private _vertexAttribPointer;
  31365. /** @hidden */
  31366. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31367. private _bindVertexBuffersAttributes;
  31368. /**
  31369. * Records a vertex array object
  31370. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31371. * @param vertexBuffers defines the list of vertex buffers to store
  31372. * @param indexBuffer defines the index buffer to store
  31373. * @param effect defines the effect to store
  31374. * @returns the new vertex array object
  31375. */
  31376. recordVertexArrayObject(vertexBuffers: {
  31377. [key: string]: VertexBuffer;
  31378. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31379. /**
  31380. * Bind a specific vertex array object
  31381. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31382. * @param vertexArrayObject defines the vertex array object to bind
  31383. * @param indexBuffer defines the index buffer to bind
  31384. */
  31385. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31386. /**
  31387. * Bind webGl buffers directly to the webGL context
  31388. * @param vertexBuffer defines the vertex buffer to bind
  31389. * @param indexBuffer defines the index buffer to bind
  31390. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31391. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31392. * @param effect defines the effect associated with the vertex buffer
  31393. */
  31394. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31395. private _unbindVertexArrayObject;
  31396. /**
  31397. * Bind a list of vertex buffers to the webGL context
  31398. * @param vertexBuffers defines the list of vertex buffers to bind
  31399. * @param indexBuffer defines the index buffer to bind
  31400. * @param effect defines the effect associated with the vertex buffers
  31401. */
  31402. bindBuffers(vertexBuffers: {
  31403. [key: string]: Nullable<VertexBuffer>;
  31404. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31405. /**
  31406. * Unbind all instance attributes
  31407. */
  31408. unbindInstanceAttributes(): void;
  31409. /**
  31410. * Release and free the memory of a vertex array object
  31411. * @param vao defines the vertex array object to delete
  31412. */
  31413. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31414. /** @hidden */
  31415. _releaseBuffer(buffer: DataBuffer): boolean;
  31416. protected _deleteBuffer(buffer: DataBuffer): void;
  31417. /**
  31418. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31419. * @param instancesBuffer defines the webGL buffer to update and bind
  31420. * @param data defines the data to store in the buffer
  31421. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31422. */
  31423. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31424. /**
  31425. * Bind the content of a webGL buffer used with instantiation
  31426. * @param instancesBuffer defines the webGL buffer to bind
  31427. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31428. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31429. */
  31430. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31431. /**
  31432. * Disable the instance attribute corresponding to the name in parameter
  31433. * @param name defines the name of the attribute to disable
  31434. */
  31435. disableInstanceAttributeByName(name: string): void;
  31436. /**
  31437. * Disable the instance attribute corresponding to the location in parameter
  31438. * @param attributeLocation defines the attribute location of the attribute to disable
  31439. */
  31440. disableInstanceAttribute(attributeLocation: number): void;
  31441. /**
  31442. * Disable the attribute corresponding to the location in parameter
  31443. * @param attributeLocation defines the attribute location of the attribute to disable
  31444. */
  31445. disableAttributeByIndex(attributeLocation: number): void;
  31446. /**
  31447. * Send a draw order
  31448. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31449. * @param indexStart defines the starting index
  31450. * @param indexCount defines the number of index to draw
  31451. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31452. */
  31453. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31454. /**
  31455. * Draw a list of points
  31456. * @param verticesStart defines the index of first vertex to draw
  31457. * @param verticesCount defines the count of vertices to draw
  31458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31459. */
  31460. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31461. /**
  31462. * Draw a list of unindexed primitives
  31463. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31464. * @param verticesStart defines the index of first vertex to draw
  31465. * @param verticesCount defines the count of vertices to draw
  31466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31467. */
  31468. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31469. /**
  31470. * Draw a list of indexed primitives
  31471. * @param fillMode defines the primitive to use
  31472. * @param indexStart defines the starting index
  31473. * @param indexCount defines the number of index to draw
  31474. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31475. */
  31476. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31477. /**
  31478. * Draw a list of unindexed primitives
  31479. * @param fillMode defines the primitive to use
  31480. * @param verticesStart defines the index of first vertex to draw
  31481. * @param verticesCount defines the count of vertices to draw
  31482. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31483. */
  31484. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31485. private _drawMode;
  31486. /** @hidden */
  31487. protected _reportDrawCall(): void;
  31488. /** @hidden */
  31489. _releaseEffect(effect: Effect): void;
  31490. /** @hidden */
  31491. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31492. /**
  31493. * Create a new effect (used to store vertex/fragment shaders)
  31494. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31495. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31496. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31497. * @param samplers defines an array of string used to represent textures
  31498. * @param defines defines the string containing the defines to use to compile the shaders
  31499. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31500. * @param onCompiled defines a function to call when the effect creation is successful
  31501. * @param onError defines a function to call when the effect creation has failed
  31502. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31503. * @returns the new Effect
  31504. */
  31505. 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;
  31506. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31507. private _compileShader;
  31508. private _compileRawShader;
  31509. /**
  31510. * Directly creates a webGL program
  31511. * @param pipelineContext defines the pipeline context to attach to
  31512. * @param vertexCode defines the vertex shader code to use
  31513. * @param fragmentCode defines the fragment shader code to use
  31514. * @param context defines the webGL context to use (if not set, the current one will be used)
  31515. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31516. * @returns the new webGL program
  31517. */
  31518. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31519. /**
  31520. * Creates a webGL program
  31521. * @param pipelineContext defines the pipeline context to attach to
  31522. * @param vertexCode defines the vertex shader code to use
  31523. * @param fragmentCode defines the fragment shader code to use
  31524. * @param defines defines the string containing the defines to use to compile the shaders
  31525. * @param context defines the webGL context to use (if not set, the current one will be used)
  31526. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31527. * @returns the new webGL program
  31528. */
  31529. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31530. /**
  31531. * Creates a new pipeline context
  31532. * @returns the new pipeline
  31533. */
  31534. createPipelineContext(): IPipelineContext;
  31535. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31536. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31537. /** @hidden */
  31538. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31539. /** @hidden */
  31540. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31541. /** @hidden */
  31542. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31543. /**
  31544. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31545. * @param pipelineContext defines the pipeline context to use
  31546. * @param uniformsNames defines the list of uniform names
  31547. * @returns an array of webGL uniform locations
  31548. */
  31549. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31550. /**
  31551. * Gets the lsit of active attributes for a given webGL program
  31552. * @param pipelineContext defines the pipeline context to use
  31553. * @param attributesNames defines the list of attribute names to get
  31554. * @returns an array of indices indicating the offset of each attribute
  31555. */
  31556. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31557. /**
  31558. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31559. * @param effect defines the effect to activate
  31560. */
  31561. enableEffect(effect: Nullable<Effect>): void;
  31562. /**
  31563. * Set the value of an uniform to a number (int)
  31564. * @param uniform defines the webGL uniform location where to store the value
  31565. * @param value defines the int number to store
  31566. */
  31567. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31568. /**
  31569. * Set the value of an uniform to an array of int32
  31570. * @param uniform defines the webGL uniform location where to store the value
  31571. * @param array defines the array of int32 to store
  31572. */
  31573. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31574. /**
  31575. * Set the value of an uniform to an array of int32 (stored as vec2)
  31576. * @param uniform defines the webGL uniform location where to store the value
  31577. * @param array defines the array of int32 to store
  31578. */
  31579. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31580. /**
  31581. * Set the value of an uniform to an array of int32 (stored as vec3)
  31582. * @param uniform defines the webGL uniform location where to store the value
  31583. * @param array defines the array of int32 to store
  31584. */
  31585. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31586. /**
  31587. * Set the value of an uniform to an array of int32 (stored as vec4)
  31588. * @param uniform defines the webGL uniform location where to store the value
  31589. * @param array defines the array of int32 to store
  31590. */
  31591. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31592. /**
  31593. * Set the value of an uniform to an array of number
  31594. * @param uniform defines the webGL uniform location where to store the value
  31595. * @param array defines the array of number to store
  31596. */
  31597. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31598. /**
  31599. * Set the value of an uniform to an array of number (stored as vec2)
  31600. * @param uniform defines the webGL uniform location where to store the value
  31601. * @param array defines the array of number to store
  31602. */
  31603. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31604. /**
  31605. * Set the value of an uniform to an array of number (stored as vec3)
  31606. * @param uniform defines the webGL uniform location where to store the value
  31607. * @param array defines the array of number to store
  31608. */
  31609. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31610. /**
  31611. * Set the value of an uniform to an array of number (stored as vec4)
  31612. * @param uniform defines the webGL uniform location where to store the value
  31613. * @param array defines the array of number to store
  31614. */
  31615. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31616. /**
  31617. * Set the value of an uniform to an array of float32 (stored as matrices)
  31618. * @param uniform defines the webGL uniform location where to store the value
  31619. * @param matrices defines the array of float32 to store
  31620. */
  31621. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31622. /**
  31623. * Set the value of an uniform to a matrix (3x3)
  31624. * @param uniform defines the webGL uniform location where to store the value
  31625. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31626. */
  31627. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31628. /**
  31629. * Set the value of an uniform to a matrix (2x2)
  31630. * @param uniform defines the webGL uniform location where to store the value
  31631. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31632. */
  31633. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31634. /**
  31635. * Set the value of an uniform to a number (float)
  31636. * @param uniform defines the webGL uniform location where to store the value
  31637. * @param value defines the float number to store
  31638. */
  31639. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31640. /**
  31641. * Set the value of an uniform to a vec2
  31642. * @param uniform defines the webGL uniform location where to store the value
  31643. * @param x defines the 1st component of the value
  31644. * @param y defines the 2nd component of the value
  31645. */
  31646. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31647. /**
  31648. * Set the value of an uniform to a vec3
  31649. * @param uniform defines the webGL uniform location where to store the value
  31650. * @param x defines the 1st component of the value
  31651. * @param y defines the 2nd component of the value
  31652. * @param z defines the 3rd component of the value
  31653. */
  31654. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31655. /**
  31656. * Set the value of an uniform to a vec4
  31657. * @param uniform defines the webGL uniform location where to store the value
  31658. * @param x defines the 1st component of the value
  31659. * @param y defines the 2nd component of the value
  31660. * @param z defines the 3rd component of the value
  31661. * @param w defines the 4th component of the value
  31662. */
  31663. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31664. /**
  31665. * Apply all cached states (depth, culling, stencil and alpha)
  31666. */
  31667. applyStates(): void;
  31668. /**
  31669. * Enable or disable color writing
  31670. * @param enable defines the state to set
  31671. */
  31672. setColorWrite(enable: boolean): void;
  31673. /**
  31674. * Gets a boolean indicating if color writing is enabled
  31675. * @returns the current color writing state
  31676. */
  31677. getColorWrite(): boolean;
  31678. /**
  31679. * Gets the depth culling state manager
  31680. */
  31681. get depthCullingState(): DepthCullingState;
  31682. /**
  31683. * Gets the alpha state manager
  31684. */
  31685. get alphaState(): AlphaState;
  31686. /**
  31687. * Gets the stencil state manager
  31688. */
  31689. get stencilState(): StencilState;
  31690. /**
  31691. * Clears the list of texture accessible through engine.
  31692. * This can help preventing texture load conflict due to name collision.
  31693. */
  31694. clearInternalTexturesCache(): void;
  31695. /**
  31696. * Force the entire cache to be cleared
  31697. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31698. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31699. */
  31700. wipeCaches(bruteForce?: boolean): void;
  31701. /** @hidden */
  31702. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31703. min: number;
  31704. mag: number;
  31705. };
  31706. /** @hidden */
  31707. _createTexture(): WebGLTexture;
  31708. /**
  31709. * Usually called from Texture.ts.
  31710. * Passed information to create a WebGLTexture
  31711. * @param urlArg defines a value which contains one of the following:
  31712. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31713. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31714. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31715. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31716. * @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)
  31717. * @param scene needed for loading to the correct scene
  31718. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31719. * @param onLoad optional callback to be called upon successful completion
  31720. * @param onError optional callback to be called upon failure
  31721. * @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
  31722. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31723. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31724. * @param forcedExtension defines the extension to use to pick the right loader
  31725. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31726. * @param mimeType defines an optional mime type
  31727. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31728. */
  31729. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31730. /**
  31731. * Loads an image as an HTMLImageElement.
  31732. * @param input url string, ArrayBuffer, or Blob to load
  31733. * @param onLoad callback called when the image successfully loads
  31734. * @param onError callback called when the image fails to load
  31735. * @param offlineProvider offline provider for caching
  31736. * @param mimeType optional mime type
  31737. * @returns the HTMLImageElement of the loaded image
  31738. * @hidden
  31739. */
  31740. 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>;
  31741. /**
  31742. * @hidden
  31743. */
  31744. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31745. /**
  31746. * Creates a raw texture
  31747. * @param data defines the data to store in the texture
  31748. * @param width defines the width of the texture
  31749. * @param height defines the height of the texture
  31750. * @param format defines the format of the data
  31751. * @param generateMipMaps defines if the engine should generate the mip levels
  31752. * @param invertY defines if data must be stored with Y axis inverted
  31753. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31754. * @param compression defines the compression used (null by default)
  31755. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31756. * @returns the raw texture inside an InternalTexture
  31757. */
  31758. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31759. /**
  31760. * Creates a new raw cube texture
  31761. * @param data defines the array of data to use to create each face
  31762. * @param size defines the size of the textures
  31763. * @param format defines the format of the data
  31764. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31765. * @param generateMipMaps defines if the engine should generate the mip levels
  31766. * @param invertY defines if data must be stored with Y axis inverted
  31767. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31768. * @param compression defines the compression used (null by default)
  31769. * @returns the cube texture as an InternalTexture
  31770. */
  31771. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31772. /**
  31773. * Creates a new raw 3D texture
  31774. * @param data defines the data used to create the texture
  31775. * @param width defines the width of the texture
  31776. * @param height defines the height of the texture
  31777. * @param depth defines the depth of the texture
  31778. * @param format defines the format of the texture
  31779. * @param generateMipMaps defines if the engine must generate mip levels
  31780. * @param invertY defines if data must be stored with Y axis inverted
  31781. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31782. * @param compression defines the compressed used (can be null)
  31783. * @param textureType defines the compressed used (can be null)
  31784. * @returns a new raw 3D texture (stored in an InternalTexture)
  31785. */
  31786. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31787. /**
  31788. * Creates a new raw 2D array texture
  31789. * @param data defines the data used to create the texture
  31790. * @param width defines the width of the texture
  31791. * @param height defines the height of the texture
  31792. * @param depth defines the number of layers of the texture
  31793. * @param format defines the format of the texture
  31794. * @param generateMipMaps defines if the engine must generate mip levels
  31795. * @param invertY defines if data must be stored with Y axis inverted
  31796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31797. * @param compression defines the compressed used (can be null)
  31798. * @param textureType defines the compressed used (can be null)
  31799. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31800. */
  31801. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31802. private _unpackFlipYCached;
  31803. /**
  31804. * In case you are sharing the context with other applications, it might
  31805. * be interested to not cache the unpack flip y state to ensure a consistent
  31806. * value would be set.
  31807. */
  31808. enableUnpackFlipYCached: boolean;
  31809. /** @hidden */
  31810. _unpackFlipY(value: boolean): void;
  31811. /** @hidden */
  31812. _getUnpackAlignement(): number;
  31813. private _getTextureTarget;
  31814. /**
  31815. * Update the sampling mode of a given texture
  31816. * @param samplingMode defines the required sampling mode
  31817. * @param texture defines the texture to update
  31818. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31819. */
  31820. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31821. /**
  31822. * Update the sampling mode of a given texture
  31823. * @param texture defines the texture to update
  31824. * @param wrapU defines the texture wrap mode of the u coordinates
  31825. * @param wrapV defines the texture wrap mode of the v coordinates
  31826. * @param wrapR defines the texture wrap mode of the r coordinates
  31827. */
  31828. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31829. /** @hidden */
  31830. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31831. width: number;
  31832. height: number;
  31833. layers?: number;
  31834. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31835. /** @hidden */
  31836. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31837. /** @hidden */
  31838. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31839. /**
  31840. * Update a portion of an internal texture
  31841. * @param texture defines the texture to update
  31842. * @param imageData defines the data to store into the texture
  31843. * @param xOffset defines the x coordinates of the update rectangle
  31844. * @param yOffset defines the y coordinates of the update rectangle
  31845. * @param width defines the width of the update rectangle
  31846. * @param height defines the height of the update rectangle
  31847. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31848. * @param lod defines the lod level to update (0 by default)
  31849. */
  31850. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31851. /** @hidden */
  31852. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31853. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31854. private _prepareWebGLTexture;
  31855. /** @hidden */
  31856. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31857. private _getDepthStencilBuffer;
  31858. /** @hidden */
  31859. _releaseFramebufferObjects(texture: InternalTexture): void;
  31860. /** @hidden */
  31861. _releaseTexture(texture: InternalTexture): void;
  31862. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31863. protected _setProgram(program: WebGLProgram): void;
  31864. protected _boundUniforms: {
  31865. [key: number]: WebGLUniformLocation;
  31866. };
  31867. /**
  31868. * Binds an effect to the webGL context
  31869. * @param effect defines the effect to bind
  31870. */
  31871. bindSamplers(effect: Effect): void;
  31872. private _activateCurrentTexture;
  31873. /** @hidden */
  31874. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31875. /** @hidden */
  31876. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31877. /**
  31878. * Unbind all textures from the webGL context
  31879. */
  31880. unbindAllTextures(): void;
  31881. /**
  31882. * Sets a texture to the according uniform.
  31883. * @param channel The texture channel
  31884. * @param uniform The uniform to set
  31885. * @param texture The texture to apply
  31886. */
  31887. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31888. private _bindSamplerUniformToChannel;
  31889. private _getTextureWrapMode;
  31890. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31891. /**
  31892. * Sets an array of texture to the webGL context
  31893. * @param channel defines the channel where the texture array must be set
  31894. * @param uniform defines the associated uniform location
  31895. * @param textures defines the array of textures to bind
  31896. */
  31897. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31898. /** @hidden */
  31899. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31900. private _setTextureParameterFloat;
  31901. private _setTextureParameterInteger;
  31902. /**
  31903. * Unbind all vertex attributes from the webGL context
  31904. */
  31905. unbindAllAttributes(): void;
  31906. /**
  31907. * 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
  31908. */
  31909. releaseEffects(): void;
  31910. /**
  31911. * Dispose and release all associated resources
  31912. */
  31913. dispose(): void;
  31914. /**
  31915. * Attach a new callback raised when context lost event is fired
  31916. * @param callback defines the callback to call
  31917. */
  31918. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31919. /**
  31920. * Attach a new callback raised when context restored event is fired
  31921. * @param callback defines the callback to call
  31922. */
  31923. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31924. /**
  31925. * Get the current error code of the webGL context
  31926. * @returns the error code
  31927. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31928. */
  31929. getError(): number;
  31930. private _canRenderToFloatFramebuffer;
  31931. private _canRenderToHalfFloatFramebuffer;
  31932. private _canRenderToFramebuffer;
  31933. /** @hidden */
  31934. _getWebGLTextureType(type: number): number;
  31935. /** @hidden */
  31936. _getInternalFormat(format: number): number;
  31937. /** @hidden */
  31938. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31939. /** @hidden */
  31940. _getRGBAMultiSampleBufferFormat(type: number): number;
  31941. /** @hidden */
  31942. _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;
  31943. /**
  31944. * Loads a file from a url
  31945. * @param url url to load
  31946. * @param onSuccess callback called when the file successfully loads
  31947. * @param onProgress callback called while file is loading (if the server supports this mode)
  31948. * @param offlineProvider defines the offline provider for caching
  31949. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31950. * @param onError callback called when the file fails to load
  31951. * @returns a file request object
  31952. * @hidden
  31953. */
  31954. 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;
  31955. /**
  31956. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31957. * @param x defines the x coordinate of the rectangle where pixels must be read
  31958. * @param y defines the y coordinate of the rectangle where pixels must be read
  31959. * @param width defines the width of the rectangle where pixels must be read
  31960. * @param height defines the height of the rectangle where pixels must be read
  31961. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31962. * @returns a Uint8Array containing RGBA colors
  31963. */
  31964. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31965. private static _isSupported;
  31966. /**
  31967. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31968. * @returns true if the engine can be created
  31969. * @ignorenaming
  31970. */
  31971. static isSupported(): boolean;
  31972. /**
  31973. * Find the next highest power of two.
  31974. * @param x Number to start search from.
  31975. * @return Next highest power of two.
  31976. */
  31977. static CeilingPOT(x: number): number;
  31978. /**
  31979. * Find the next lowest power of two.
  31980. * @param x Number to start search from.
  31981. * @return Next lowest power of two.
  31982. */
  31983. static FloorPOT(x: number): number;
  31984. /**
  31985. * Find the nearest power of two.
  31986. * @param x Number to start search from.
  31987. * @return Next nearest power of two.
  31988. */
  31989. static NearestPOT(x: number): number;
  31990. /**
  31991. * Get the closest exponent of two
  31992. * @param value defines the value to approximate
  31993. * @param max defines the maximum value to return
  31994. * @param mode defines how to define the closest value
  31995. * @returns closest exponent of two of the given value
  31996. */
  31997. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31998. /**
  31999. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32000. * @param func - the function to be called
  32001. * @param requester - the object that will request the next frame. Falls back to window.
  32002. * @returns frame number
  32003. */
  32004. static QueueNewFrame(func: () => void, requester?: any): number;
  32005. /**
  32006. * Gets host document
  32007. * @returns the host document object
  32008. */
  32009. getHostDocument(): Nullable<Document>;
  32010. }
  32011. }
  32012. declare module BABYLON {
  32013. /**
  32014. * Class representing spherical harmonics coefficients to the 3rd degree
  32015. */
  32016. export class SphericalHarmonics {
  32017. /**
  32018. * Defines whether or not the harmonics have been prescaled for rendering.
  32019. */
  32020. preScaled: boolean;
  32021. /**
  32022. * The l0,0 coefficients of the spherical harmonics
  32023. */
  32024. l00: Vector3;
  32025. /**
  32026. * The l1,-1 coefficients of the spherical harmonics
  32027. */
  32028. l1_1: Vector3;
  32029. /**
  32030. * The l1,0 coefficients of the spherical harmonics
  32031. */
  32032. l10: Vector3;
  32033. /**
  32034. * The l1,1 coefficients of the spherical harmonics
  32035. */
  32036. l11: Vector3;
  32037. /**
  32038. * The l2,-2 coefficients of the spherical harmonics
  32039. */
  32040. l2_2: Vector3;
  32041. /**
  32042. * The l2,-1 coefficients of the spherical harmonics
  32043. */
  32044. l2_1: Vector3;
  32045. /**
  32046. * The l2,0 coefficients of the spherical harmonics
  32047. */
  32048. l20: Vector3;
  32049. /**
  32050. * The l2,1 coefficients of the spherical harmonics
  32051. */
  32052. l21: Vector3;
  32053. /**
  32054. * The l2,2 coefficients of the spherical harmonics
  32055. */
  32056. l22: Vector3;
  32057. /**
  32058. * Adds a light to the spherical harmonics
  32059. * @param direction the direction of the light
  32060. * @param color the color of the light
  32061. * @param deltaSolidAngle the delta solid angle of the light
  32062. */
  32063. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32064. /**
  32065. * Scales the spherical harmonics by the given amount
  32066. * @param scale the amount to scale
  32067. */
  32068. scaleInPlace(scale: number): void;
  32069. /**
  32070. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32071. *
  32072. * ```
  32073. * E_lm = A_l * L_lm
  32074. * ```
  32075. *
  32076. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32077. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32078. * the scaling factors are given in equation 9.
  32079. */
  32080. convertIncidentRadianceToIrradiance(): void;
  32081. /**
  32082. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32083. *
  32084. * ```
  32085. * L = (1/pi) * E * rho
  32086. * ```
  32087. *
  32088. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32089. */
  32090. convertIrradianceToLambertianRadiance(): void;
  32091. /**
  32092. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32093. * required operations at run time.
  32094. *
  32095. * This is simply done by scaling back the SH with Ylm constants parameter.
  32096. * The trigonometric part being applied by the shader at run time.
  32097. */
  32098. preScaleForRendering(): void;
  32099. /**
  32100. * Constructs a spherical harmonics from an array.
  32101. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32102. * @returns the spherical harmonics
  32103. */
  32104. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32105. /**
  32106. * Gets the spherical harmonics from polynomial
  32107. * @param polynomial the spherical polynomial
  32108. * @returns the spherical harmonics
  32109. */
  32110. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32111. }
  32112. /**
  32113. * Class representing spherical polynomial coefficients to the 3rd degree
  32114. */
  32115. export class SphericalPolynomial {
  32116. private _harmonics;
  32117. /**
  32118. * The spherical harmonics used to create the polynomials.
  32119. */
  32120. get preScaledHarmonics(): SphericalHarmonics;
  32121. /**
  32122. * The x coefficients of the spherical polynomial
  32123. */
  32124. x: Vector3;
  32125. /**
  32126. * The y coefficients of the spherical polynomial
  32127. */
  32128. y: Vector3;
  32129. /**
  32130. * The z coefficients of the spherical polynomial
  32131. */
  32132. z: Vector3;
  32133. /**
  32134. * The xx coefficients of the spherical polynomial
  32135. */
  32136. xx: Vector3;
  32137. /**
  32138. * The yy coefficients of the spherical polynomial
  32139. */
  32140. yy: Vector3;
  32141. /**
  32142. * The zz coefficients of the spherical polynomial
  32143. */
  32144. zz: Vector3;
  32145. /**
  32146. * The xy coefficients of the spherical polynomial
  32147. */
  32148. xy: Vector3;
  32149. /**
  32150. * The yz coefficients of the spherical polynomial
  32151. */
  32152. yz: Vector3;
  32153. /**
  32154. * The zx coefficients of the spherical polynomial
  32155. */
  32156. zx: Vector3;
  32157. /**
  32158. * Adds an ambient color to the spherical polynomial
  32159. * @param color the color to add
  32160. */
  32161. addAmbient(color: Color3): void;
  32162. /**
  32163. * Scales the spherical polynomial by the given amount
  32164. * @param scale the amount to scale
  32165. */
  32166. scaleInPlace(scale: number): void;
  32167. /**
  32168. * Gets the spherical polynomial from harmonics
  32169. * @param harmonics the spherical harmonics
  32170. * @returns the spherical polynomial
  32171. */
  32172. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32173. /**
  32174. * Constructs a spherical polynomial from an array.
  32175. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32176. * @returns the spherical polynomial
  32177. */
  32178. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32179. }
  32180. }
  32181. declare module BABYLON {
  32182. /**
  32183. * Defines the source of the internal texture
  32184. */
  32185. export enum InternalTextureSource {
  32186. /**
  32187. * The source of the texture data is unknown
  32188. */
  32189. Unknown = 0,
  32190. /**
  32191. * Texture data comes from an URL
  32192. */
  32193. Url = 1,
  32194. /**
  32195. * Texture data is only used for temporary storage
  32196. */
  32197. Temp = 2,
  32198. /**
  32199. * Texture data comes from raw data (ArrayBuffer)
  32200. */
  32201. Raw = 3,
  32202. /**
  32203. * Texture content is dynamic (video or dynamic texture)
  32204. */
  32205. Dynamic = 4,
  32206. /**
  32207. * Texture content is generated by rendering to it
  32208. */
  32209. RenderTarget = 5,
  32210. /**
  32211. * Texture content is part of a multi render target process
  32212. */
  32213. MultiRenderTarget = 6,
  32214. /**
  32215. * Texture data comes from a cube data file
  32216. */
  32217. Cube = 7,
  32218. /**
  32219. * Texture data comes from a raw cube data
  32220. */
  32221. CubeRaw = 8,
  32222. /**
  32223. * Texture data come from a prefiltered cube data file
  32224. */
  32225. CubePrefiltered = 9,
  32226. /**
  32227. * Texture content is raw 3D data
  32228. */
  32229. Raw3D = 10,
  32230. /**
  32231. * Texture content is raw 2D array data
  32232. */
  32233. Raw2DArray = 11,
  32234. /**
  32235. * Texture content is a depth texture
  32236. */
  32237. Depth = 12,
  32238. /**
  32239. * Texture data comes from a raw cube data encoded with RGBD
  32240. */
  32241. CubeRawRGBD = 13
  32242. }
  32243. /**
  32244. * Class used to store data associated with WebGL texture data for the engine
  32245. * This class should not be used directly
  32246. */
  32247. export class InternalTexture {
  32248. /** @hidden */
  32249. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32250. /**
  32251. * Defines if the texture is ready
  32252. */
  32253. isReady: boolean;
  32254. /**
  32255. * Defines if the texture is a cube texture
  32256. */
  32257. isCube: boolean;
  32258. /**
  32259. * Defines if the texture contains 3D data
  32260. */
  32261. is3D: boolean;
  32262. /**
  32263. * Defines if the texture contains 2D array data
  32264. */
  32265. is2DArray: boolean;
  32266. /**
  32267. * Defines if the texture contains multiview data
  32268. */
  32269. isMultiview: boolean;
  32270. /**
  32271. * Gets the URL used to load this texture
  32272. */
  32273. url: string;
  32274. /**
  32275. * Gets the sampling mode of the texture
  32276. */
  32277. samplingMode: number;
  32278. /**
  32279. * Gets a boolean indicating if the texture needs mipmaps generation
  32280. */
  32281. generateMipMaps: boolean;
  32282. /**
  32283. * Gets the number of samples used by the texture (WebGL2+ only)
  32284. */
  32285. samples: number;
  32286. /**
  32287. * Gets the type of the texture (int, float...)
  32288. */
  32289. type: number;
  32290. /**
  32291. * Gets the format of the texture (RGB, RGBA...)
  32292. */
  32293. format: number;
  32294. /**
  32295. * Observable called when the texture is loaded
  32296. */
  32297. onLoadedObservable: Observable<InternalTexture>;
  32298. /**
  32299. * Gets the width of the texture
  32300. */
  32301. width: number;
  32302. /**
  32303. * Gets the height of the texture
  32304. */
  32305. height: number;
  32306. /**
  32307. * Gets the depth of the texture
  32308. */
  32309. depth: number;
  32310. /**
  32311. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32312. */
  32313. baseWidth: number;
  32314. /**
  32315. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32316. */
  32317. baseHeight: number;
  32318. /**
  32319. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32320. */
  32321. baseDepth: number;
  32322. /**
  32323. * Gets a boolean indicating if the texture is inverted on Y axis
  32324. */
  32325. invertY: boolean;
  32326. /** @hidden */
  32327. _invertVScale: boolean;
  32328. /** @hidden */
  32329. _associatedChannel: number;
  32330. /** @hidden */
  32331. _source: InternalTextureSource;
  32332. /** @hidden */
  32333. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32334. /** @hidden */
  32335. _bufferView: Nullable<ArrayBufferView>;
  32336. /** @hidden */
  32337. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32338. /** @hidden */
  32339. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32340. /** @hidden */
  32341. _size: number;
  32342. /** @hidden */
  32343. _extension: string;
  32344. /** @hidden */
  32345. _files: Nullable<string[]>;
  32346. /** @hidden */
  32347. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32348. /** @hidden */
  32349. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32350. /** @hidden */
  32351. _framebuffer: Nullable<WebGLFramebuffer>;
  32352. /** @hidden */
  32353. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32354. /** @hidden */
  32355. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32356. /** @hidden */
  32357. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32358. /** @hidden */
  32359. _attachments: Nullable<number[]>;
  32360. /** @hidden */
  32361. _cachedCoordinatesMode: Nullable<number>;
  32362. /** @hidden */
  32363. _cachedWrapU: Nullable<number>;
  32364. /** @hidden */
  32365. _cachedWrapV: Nullable<number>;
  32366. /** @hidden */
  32367. _cachedWrapR: Nullable<number>;
  32368. /** @hidden */
  32369. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32370. /** @hidden */
  32371. _isDisabled: boolean;
  32372. /** @hidden */
  32373. _compression: Nullable<string>;
  32374. /** @hidden */
  32375. _generateStencilBuffer: boolean;
  32376. /** @hidden */
  32377. _generateDepthBuffer: boolean;
  32378. /** @hidden */
  32379. _comparisonFunction: number;
  32380. /** @hidden */
  32381. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32382. /** @hidden */
  32383. _lodGenerationScale: number;
  32384. /** @hidden */
  32385. _lodGenerationOffset: number;
  32386. /** @hidden */
  32387. _depthStencilTexture: Nullable<InternalTexture>;
  32388. /** @hidden */
  32389. _colorTextureArray: Nullable<WebGLTexture>;
  32390. /** @hidden */
  32391. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32392. /** @hidden */
  32393. _lodTextureHigh: Nullable<BaseTexture>;
  32394. /** @hidden */
  32395. _lodTextureMid: Nullable<BaseTexture>;
  32396. /** @hidden */
  32397. _lodTextureLow: Nullable<BaseTexture>;
  32398. /** @hidden */
  32399. _isRGBD: boolean;
  32400. /** @hidden */
  32401. _linearSpecularLOD: boolean;
  32402. /** @hidden */
  32403. _irradianceTexture: Nullable<BaseTexture>;
  32404. /** @hidden */
  32405. _webGLTexture: Nullable<WebGLTexture>;
  32406. /** @hidden */
  32407. _references: number;
  32408. private _engine;
  32409. /**
  32410. * Gets the Engine the texture belongs to.
  32411. * @returns The babylon engine
  32412. */
  32413. getEngine(): ThinEngine;
  32414. /**
  32415. * Gets the data source type of the texture
  32416. */
  32417. get source(): InternalTextureSource;
  32418. /**
  32419. * Creates a new InternalTexture
  32420. * @param engine defines the engine to use
  32421. * @param source defines the type of data that will be used
  32422. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32423. */
  32424. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32425. /**
  32426. * Increments the number of references (ie. the number of Texture that point to it)
  32427. */
  32428. incrementReferences(): void;
  32429. /**
  32430. * Change the size of the texture (not the size of the content)
  32431. * @param width defines the new width
  32432. * @param height defines the new height
  32433. * @param depth defines the new depth (1 by default)
  32434. */
  32435. updateSize(width: int, height: int, depth?: int): void;
  32436. /** @hidden */
  32437. _rebuild(): void;
  32438. /** @hidden */
  32439. _swapAndDie(target: InternalTexture): void;
  32440. /**
  32441. * Dispose the current allocated resources
  32442. */
  32443. dispose(): void;
  32444. }
  32445. }
  32446. declare module BABYLON {
  32447. /**
  32448. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32450. */
  32451. export class Analyser {
  32452. /**
  32453. * Gets or sets the smoothing
  32454. * @ignorenaming
  32455. */
  32456. SMOOTHING: number;
  32457. /**
  32458. * Gets or sets the FFT table size
  32459. * @ignorenaming
  32460. */
  32461. FFT_SIZE: number;
  32462. /**
  32463. * Gets or sets the bar graph amplitude
  32464. * @ignorenaming
  32465. */
  32466. BARGRAPHAMPLITUDE: number;
  32467. /**
  32468. * Gets or sets the position of the debug canvas
  32469. * @ignorenaming
  32470. */
  32471. DEBUGCANVASPOS: {
  32472. x: number;
  32473. y: number;
  32474. };
  32475. /**
  32476. * Gets or sets the debug canvas size
  32477. * @ignorenaming
  32478. */
  32479. DEBUGCANVASSIZE: {
  32480. width: number;
  32481. height: number;
  32482. };
  32483. private _byteFreqs;
  32484. private _byteTime;
  32485. private _floatFreqs;
  32486. private _webAudioAnalyser;
  32487. private _debugCanvas;
  32488. private _debugCanvasContext;
  32489. private _scene;
  32490. private _registerFunc;
  32491. private _audioEngine;
  32492. /**
  32493. * Creates a new analyser
  32494. * @param scene defines hosting scene
  32495. */
  32496. constructor(scene: Scene);
  32497. /**
  32498. * Get the number of data values you will have to play with for the visualization
  32499. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32500. * @returns a number
  32501. */
  32502. getFrequencyBinCount(): number;
  32503. /**
  32504. * Gets the current frequency data as a byte array
  32505. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32506. * @returns a Uint8Array
  32507. */
  32508. getByteFrequencyData(): Uint8Array;
  32509. /**
  32510. * Gets the current waveform as a byte array
  32511. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32512. * @returns a Uint8Array
  32513. */
  32514. getByteTimeDomainData(): Uint8Array;
  32515. /**
  32516. * Gets the current frequency data as a float array
  32517. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32518. * @returns a Float32Array
  32519. */
  32520. getFloatFrequencyData(): Float32Array;
  32521. /**
  32522. * Renders the debug canvas
  32523. */
  32524. drawDebugCanvas(): void;
  32525. /**
  32526. * Stops rendering the debug canvas and removes it
  32527. */
  32528. stopDebugCanvas(): void;
  32529. /**
  32530. * Connects two audio nodes
  32531. * @param inputAudioNode defines first node to connect
  32532. * @param outputAudioNode defines second node to connect
  32533. */
  32534. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32535. /**
  32536. * Releases all associated resources
  32537. */
  32538. dispose(): void;
  32539. }
  32540. }
  32541. declare module BABYLON {
  32542. /**
  32543. * This represents an audio engine and it is responsible
  32544. * to play, synchronize and analyse sounds throughout the application.
  32545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32546. */
  32547. export interface IAudioEngine extends IDisposable {
  32548. /**
  32549. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32550. */
  32551. readonly canUseWebAudio: boolean;
  32552. /**
  32553. * Gets the current AudioContext if available.
  32554. */
  32555. readonly audioContext: Nullable<AudioContext>;
  32556. /**
  32557. * The master gain node defines the global audio volume of your audio engine.
  32558. */
  32559. readonly masterGain: GainNode;
  32560. /**
  32561. * Gets whether or not mp3 are supported by your browser.
  32562. */
  32563. readonly isMP3supported: boolean;
  32564. /**
  32565. * Gets whether or not ogg are supported by your browser.
  32566. */
  32567. readonly isOGGsupported: boolean;
  32568. /**
  32569. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32570. * @ignoreNaming
  32571. */
  32572. WarnedWebAudioUnsupported: boolean;
  32573. /**
  32574. * Defines if the audio engine relies on a custom unlocked button.
  32575. * In this case, the embedded button will not be displayed.
  32576. */
  32577. useCustomUnlockedButton: boolean;
  32578. /**
  32579. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32580. */
  32581. readonly unlocked: boolean;
  32582. /**
  32583. * Event raised when audio has been unlocked on the browser.
  32584. */
  32585. onAudioUnlockedObservable: Observable<AudioEngine>;
  32586. /**
  32587. * Event raised when audio has been locked on the browser.
  32588. */
  32589. onAudioLockedObservable: Observable<AudioEngine>;
  32590. /**
  32591. * Flags the audio engine in Locked state.
  32592. * This happens due to new browser policies preventing audio to autoplay.
  32593. */
  32594. lock(): void;
  32595. /**
  32596. * Unlocks the audio engine once a user action has been done on the dom.
  32597. * This is helpful to resume play once browser policies have been satisfied.
  32598. */
  32599. unlock(): void;
  32600. }
  32601. /**
  32602. * This represents the default audio engine used in babylon.
  32603. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32605. */
  32606. export class AudioEngine implements IAudioEngine {
  32607. private _audioContext;
  32608. private _audioContextInitialized;
  32609. private _muteButton;
  32610. private _hostElement;
  32611. /**
  32612. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32613. */
  32614. canUseWebAudio: boolean;
  32615. /**
  32616. * The master gain node defines the global audio volume of your audio engine.
  32617. */
  32618. masterGain: GainNode;
  32619. /**
  32620. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32621. * @ignoreNaming
  32622. */
  32623. WarnedWebAudioUnsupported: boolean;
  32624. /**
  32625. * Gets whether or not mp3 are supported by your browser.
  32626. */
  32627. isMP3supported: boolean;
  32628. /**
  32629. * Gets whether or not ogg are supported by your browser.
  32630. */
  32631. isOGGsupported: boolean;
  32632. /**
  32633. * Gets whether audio has been unlocked on the device.
  32634. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32635. * a user interaction has happened.
  32636. */
  32637. unlocked: boolean;
  32638. /**
  32639. * Defines if the audio engine relies on a custom unlocked button.
  32640. * In this case, the embedded button will not be displayed.
  32641. */
  32642. useCustomUnlockedButton: boolean;
  32643. /**
  32644. * Event raised when audio has been unlocked on the browser.
  32645. */
  32646. onAudioUnlockedObservable: Observable<AudioEngine>;
  32647. /**
  32648. * Event raised when audio has been locked on the browser.
  32649. */
  32650. onAudioLockedObservable: Observable<AudioEngine>;
  32651. /**
  32652. * Gets the current AudioContext if available.
  32653. */
  32654. get audioContext(): Nullable<AudioContext>;
  32655. private _connectedAnalyser;
  32656. /**
  32657. * Instantiates a new audio engine.
  32658. *
  32659. * There should be only one per page as some browsers restrict the number
  32660. * of audio contexts you can create.
  32661. * @param hostElement defines the host element where to display the mute icon if necessary
  32662. */
  32663. constructor(hostElement?: Nullable<HTMLElement>);
  32664. /**
  32665. * Flags the audio engine in Locked state.
  32666. * This happens due to new browser policies preventing audio to autoplay.
  32667. */
  32668. lock(): void;
  32669. /**
  32670. * Unlocks the audio engine once a user action has been done on the dom.
  32671. * This is helpful to resume play once browser policies have been satisfied.
  32672. */
  32673. unlock(): void;
  32674. private _resumeAudioContext;
  32675. private _initializeAudioContext;
  32676. private _tryToRun;
  32677. private _triggerRunningState;
  32678. private _triggerSuspendedState;
  32679. private _displayMuteButton;
  32680. private _moveButtonToTopLeft;
  32681. private _onResize;
  32682. private _hideMuteButton;
  32683. /**
  32684. * Destroy and release the resources associated with the audio ccontext.
  32685. */
  32686. dispose(): void;
  32687. /**
  32688. * Gets the global volume sets on the master gain.
  32689. * @returns the global volume if set or -1 otherwise
  32690. */
  32691. getGlobalVolume(): number;
  32692. /**
  32693. * Sets the global volume of your experience (sets on the master gain).
  32694. * @param newVolume Defines the new global volume of the application
  32695. */
  32696. setGlobalVolume(newVolume: number): void;
  32697. /**
  32698. * Connect the audio engine to an audio analyser allowing some amazing
  32699. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32701. * @param analyser The analyser to connect to the engine
  32702. */
  32703. connectToAnalyser(analyser: Analyser): void;
  32704. }
  32705. }
  32706. declare module BABYLON {
  32707. /**
  32708. * Interface used to present a loading screen while loading a scene
  32709. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32710. */
  32711. export interface ILoadingScreen {
  32712. /**
  32713. * Function called to display the loading screen
  32714. */
  32715. displayLoadingUI: () => void;
  32716. /**
  32717. * Function called to hide the loading screen
  32718. */
  32719. hideLoadingUI: () => void;
  32720. /**
  32721. * Gets or sets the color to use for the background
  32722. */
  32723. loadingUIBackgroundColor: string;
  32724. /**
  32725. * Gets or sets the text to display while loading
  32726. */
  32727. loadingUIText: string;
  32728. }
  32729. /**
  32730. * Class used for the default loading screen
  32731. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32732. */
  32733. export class DefaultLoadingScreen implements ILoadingScreen {
  32734. private _renderingCanvas;
  32735. private _loadingText;
  32736. private _loadingDivBackgroundColor;
  32737. private _loadingDiv;
  32738. private _loadingTextDiv;
  32739. /** Gets or sets the logo url to use for the default loading screen */
  32740. static DefaultLogoUrl: string;
  32741. /** Gets or sets the spinner url to use for the default loading screen */
  32742. static DefaultSpinnerUrl: string;
  32743. /**
  32744. * Creates a new default loading screen
  32745. * @param _renderingCanvas defines the canvas used to render the scene
  32746. * @param _loadingText defines the default text to display
  32747. * @param _loadingDivBackgroundColor defines the default background color
  32748. */
  32749. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32750. /**
  32751. * Function called to display the loading screen
  32752. */
  32753. displayLoadingUI(): void;
  32754. /**
  32755. * Function called to hide the loading screen
  32756. */
  32757. hideLoadingUI(): void;
  32758. /**
  32759. * Gets or sets the text to display while loading
  32760. */
  32761. set loadingUIText(text: string);
  32762. get loadingUIText(): string;
  32763. /**
  32764. * Gets or sets the color to use for the background
  32765. */
  32766. get loadingUIBackgroundColor(): string;
  32767. set loadingUIBackgroundColor(color: string);
  32768. private _resizeLoadingUI;
  32769. }
  32770. }
  32771. declare module BABYLON {
  32772. /**
  32773. * Interface for any object that can request an animation frame
  32774. */
  32775. export interface ICustomAnimationFrameRequester {
  32776. /**
  32777. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32778. */
  32779. renderFunction?: Function;
  32780. /**
  32781. * Called to request the next frame to render to
  32782. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32783. */
  32784. requestAnimationFrame: Function;
  32785. /**
  32786. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32787. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32788. */
  32789. requestID?: number;
  32790. }
  32791. }
  32792. declare module BABYLON {
  32793. /**
  32794. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32795. */
  32796. export class PerformanceMonitor {
  32797. private _enabled;
  32798. private _rollingFrameTime;
  32799. private _lastFrameTimeMs;
  32800. /**
  32801. * constructor
  32802. * @param frameSampleSize The number of samples required to saturate the sliding window
  32803. */
  32804. constructor(frameSampleSize?: number);
  32805. /**
  32806. * Samples current frame
  32807. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32808. */
  32809. sampleFrame(timeMs?: number): void;
  32810. /**
  32811. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32812. */
  32813. get averageFrameTime(): number;
  32814. /**
  32815. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32816. */
  32817. get averageFrameTimeVariance(): number;
  32818. /**
  32819. * Returns the frame time of the most recent frame
  32820. */
  32821. get instantaneousFrameTime(): number;
  32822. /**
  32823. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32824. */
  32825. get averageFPS(): number;
  32826. /**
  32827. * Returns the average framerate in frames per second using the most recent frame time
  32828. */
  32829. get instantaneousFPS(): number;
  32830. /**
  32831. * Returns true if enough samples have been taken to completely fill the sliding window
  32832. */
  32833. get isSaturated(): boolean;
  32834. /**
  32835. * Enables contributions to the sliding window sample set
  32836. */
  32837. enable(): void;
  32838. /**
  32839. * Disables contributions to the sliding window sample set
  32840. * Samples will not be interpolated over the disabled period
  32841. */
  32842. disable(): void;
  32843. /**
  32844. * Returns true if sampling is enabled
  32845. */
  32846. get isEnabled(): boolean;
  32847. /**
  32848. * Resets performance monitor
  32849. */
  32850. reset(): void;
  32851. }
  32852. /**
  32853. * RollingAverage
  32854. *
  32855. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32856. */
  32857. export class RollingAverage {
  32858. /**
  32859. * Current average
  32860. */
  32861. average: number;
  32862. /**
  32863. * Current variance
  32864. */
  32865. variance: number;
  32866. protected _samples: Array<number>;
  32867. protected _sampleCount: number;
  32868. protected _pos: number;
  32869. protected _m2: number;
  32870. /**
  32871. * constructor
  32872. * @param length The number of samples required to saturate the sliding window
  32873. */
  32874. constructor(length: number);
  32875. /**
  32876. * Adds a sample to the sample set
  32877. * @param v The sample value
  32878. */
  32879. add(v: number): void;
  32880. /**
  32881. * Returns previously added values or null if outside of history or outside the sliding window domain
  32882. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32883. * @return Value previously recorded with add() or null if outside of range
  32884. */
  32885. history(i: number): number;
  32886. /**
  32887. * Returns true if enough samples have been taken to completely fill the sliding window
  32888. * @return true if sample-set saturated
  32889. */
  32890. isSaturated(): boolean;
  32891. /**
  32892. * Resets the rolling average (equivalent to 0 samples taken so far)
  32893. */
  32894. reset(): void;
  32895. /**
  32896. * Wraps a value around the sample range boundaries
  32897. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32898. * @return Wrapped position in sample range
  32899. */
  32900. protected _wrapPosition(i: number): number;
  32901. }
  32902. }
  32903. declare module BABYLON {
  32904. /**
  32905. * This class is used to track a performance counter which is number based.
  32906. * The user has access to many properties which give statistics of different nature.
  32907. *
  32908. * The implementer can track two kinds of Performance Counter: time and count.
  32909. * 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.
  32910. * 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.
  32911. */
  32912. export class PerfCounter {
  32913. /**
  32914. * Gets or sets a global boolean to turn on and off all the counters
  32915. */
  32916. static Enabled: boolean;
  32917. /**
  32918. * Returns the smallest value ever
  32919. */
  32920. get min(): number;
  32921. /**
  32922. * Returns the biggest value ever
  32923. */
  32924. get max(): number;
  32925. /**
  32926. * Returns the average value since the performance counter is running
  32927. */
  32928. get average(): number;
  32929. /**
  32930. * Returns the average value of the last second the counter was monitored
  32931. */
  32932. get lastSecAverage(): number;
  32933. /**
  32934. * Returns the current value
  32935. */
  32936. get current(): number;
  32937. /**
  32938. * Gets the accumulated total
  32939. */
  32940. get total(): number;
  32941. /**
  32942. * Gets the total value count
  32943. */
  32944. get count(): number;
  32945. /**
  32946. * Creates a new counter
  32947. */
  32948. constructor();
  32949. /**
  32950. * Call this method to start monitoring a new frame.
  32951. * 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.
  32952. */
  32953. fetchNewFrame(): void;
  32954. /**
  32955. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32956. * @param newCount the count value to add to the monitored count
  32957. * @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.
  32958. */
  32959. addCount(newCount: number, fetchResult: boolean): void;
  32960. /**
  32961. * Start monitoring this performance counter
  32962. */
  32963. beginMonitoring(): void;
  32964. /**
  32965. * Compute the time lapsed since the previous beginMonitoring() call.
  32966. * @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
  32967. */
  32968. endMonitoring(newFrame?: boolean): void;
  32969. private _fetchResult;
  32970. private _startMonitoringTime;
  32971. private _min;
  32972. private _max;
  32973. private _average;
  32974. private _current;
  32975. private _totalValueCount;
  32976. private _totalAccumulated;
  32977. private _lastSecAverage;
  32978. private _lastSecAccumulated;
  32979. private _lastSecTime;
  32980. private _lastSecValueCount;
  32981. }
  32982. }
  32983. declare module BABYLON {
  32984. interface ThinEngine {
  32985. /**
  32986. * Sets alpha constants used by some alpha blending modes
  32987. * @param r defines the red component
  32988. * @param g defines the green component
  32989. * @param b defines the blue component
  32990. * @param a defines the alpha component
  32991. */
  32992. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32993. /**
  32994. * Sets the current alpha mode
  32995. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32996. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32997. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32998. */
  32999. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33000. /**
  33001. * Gets the current alpha mode
  33002. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33003. * @returns the current alpha mode
  33004. */
  33005. getAlphaMode(): number;
  33006. /**
  33007. * Sets the current alpha equation
  33008. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33009. */
  33010. setAlphaEquation(equation: number): void;
  33011. /**
  33012. * Gets the current alpha equation.
  33013. * @returns the current alpha equation
  33014. */
  33015. getAlphaEquation(): number;
  33016. }
  33017. }
  33018. declare module BABYLON {
  33019. /**
  33020. * Defines the interface used by display changed events
  33021. */
  33022. export interface IDisplayChangedEventArgs {
  33023. /** Gets the vrDisplay object (if any) */
  33024. vrDisplay: Nullable<any>;
  33025. /** Gets a boolean indicating if webVR is supported */
  33026. vrSupported: boolean;
  33027. }
  33028. /**
  33029. * Defines the interface used by objects containing a viewport (like a camera)
  33030. */
  33031. interface IViewportOwnerLike {
  33032. /**
  33033. * Gets or sets the viewport
  33034. */
  33035. viewport: IViewportLike;
  33036. }
  33037. /**
  33038. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33039. */
  33040. export class Engine extends ThinEngine {
  33041. /** Defines that alpha blending is disabled */
  33042. static readonly ALPHA_DISABLE: number;
  33043. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33044. static readonly ALPHA_ADD: number;
  33045. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33046. static readonly ALPHA_COMBINE: number;
  33047. /** Defines that alpha blending to DEST - SRC * DEST */
  33048. static readonly ALPHA_SUBTRACT: number;
  33049. /** Defines that alpha blending to SRC * DEST */
  33050. static readonly ALPHA_MULTIPLY: number;
  33051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33052. static readonly ALPHA_MAXIMIZED: number;
  33053. /** Defines that alpha blending to SRC + DEST */
  33054. static readonly ALPHA_ONEONE: number;
  33055. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33056. static readonly ALPHA_PREMULTIPLIED: number;
  33057. /**
  33058. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33059. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33060. */
  33061. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33062. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33063. static readonly ALPHA_INTERPOLATE: number;
  33064. /**
  33065. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33066. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33067. */
  33068. static readonly ALPHA_SCREENMODE: number;
  33069. /** Defines that the ressource is not delayed*/
  33070. static readonly DELAYLOADSTATE_NONE: number;
  33071. /** Defines that the ressource was successfully delay loaded */
  33072. static readonly DELAYLOADSTATE_LOADED: number;
  33073. /** Defines that the ressource is currently delay loading */
  33074. static readonly DELAYLOADSTATE_LOADING: number;
  33075. /** Defines that the ressource is delayed and has not started loading */
  33076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33078. static readonly NEVER: number;
  33079. /** 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 */
  33080. static readonly ALWAYS: number;
  33081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33082. static readonly LESS: number;
  33083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33084. static readonly EQUAL: number;
  33085. /** 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 */
  33086. static readonly LEQUAL: number;
  33087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33088. static readonly GREATER: number;
  33089. /** 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 */
  33090. static readonly GEQUAL: number;
  33091. /** 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 */
  33092. static readonly NOTEQUAL: number;
  33093. /** Passed to stencilOperation to specify that stencil value must be kept */
  33094. static readonly KEEP: number;
  33095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33096. static readonly REPLACE: number;
  33097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33098. static readonly INCR: number;
  33099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33100. static readonly DECR: number;
  33101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33102. static readonly INVERT: number;
  33103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33104. static readonly INCR_WRAP: number;
  33105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33106. static readonly DECR_WRAP: number;
  33107. /** Texture is not repeating outside of 0..1 UVs */
  33108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33109. /** Texture is repeating outside of 0..1 UVs */
  33110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33111. /** Texture is repeating and mirrored */
  33112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33113. /** ALPHA */
  33114. static readonly TEXTUREFORMAT_ALPHA: number;
  33115. /** LUMINANCE */
  33116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33117. /** LUMINANCE_ALPHA */
  33118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33119. /** RGB */
  33120. static readonly TEXTUREFORMAT_RGB: number;
  33121. /** RGBA */
  33122. static readonly TEXTUREFORMAT_RGBA: number;
  33123. /** RED */
  33124. static readonly TEXTUREFORMAT_RED: number;
  33125. /** RED (2nd reference) */
  33126. static readonly TEXTUREFORMAT_R: number;
  33127. /** RG */
  33128. static readonly TEXTUREFORMAT_RG: number;
  33129. /** RED_INTEGER */
  33130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33131. /** RED_INTEGER (2nd reference) */
  33132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33133. /** RG_INTEGER */
  33134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33135. /** RGB_INTEGER */
  33136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33137. /** RGBA_INTEGER */
  33138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33139. /** UNSIGNED_BYTE */
  33140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33141. /** UNSIGNED_BYTE (2nd reference) */
  33142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33143. /** FLOAT */
  33144. static readonly TEXTURETYPE_FLOAT: number;
  33145. /** HALF_FLOAT */
  33146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33147. /** BYTE */
  33148. static readonly TEXTURETYPE_BYTE: number;
  33149. /** SHORT */
  33150. static readonly TEXTURETYPE_SHORT: number;
  33151. /** UNSIGNED_SHORT */
  33152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33153. /** INT */
  33154. static readonly TEXTURETYPE_INT: number;
  33155. /** UNSIGNED_INT */
  33156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33157. /** UNSIGNED_SHORT_4_4_4_4 */
  33158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33159. /** UNSIGNED_SHORT_5_5_5_1 */
  33160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33161. /** UNSIGNED_SHORT_5_6_5 */
  33162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33163. /** UNSIGNED_INT_2_10_10_10_REV */
  33164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33165. /** UNSIGNED_INT_24_8 */
  33166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33167. /** UNSIGNED_INT_10F_11F_11F_REV */
  33168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33169. /** UNSIGNED_INT_5_9_9_9_REV */
  33170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33173. /** nearest is mag = nearest and min = nearest and mip = linear */
  33174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33177. /** Trilinear is mag = linear and min = linear and mip = linear */
  33178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33179. /** nearest is mag = nearest and min = nearest and mip = linear */
  33180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33183. /** Trilinear is mag = linear and min = linear and mip = linear */
  33184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33185. /** mag = nearest and min = nearest and mip = nearest */
  33186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33187. /** mag = nearest and min = linear and mip = nearest */
  33188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33189. /** mag = nearest and min = linear and mip = linear */
  33190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33191. /** mag = nearest and min = linear and mip = none */
  33192. static readonly TEXTURE_NEAREST_LINEAR: number;
  33193. /** mag = nearest and min = nearest and mip = none */
  33194. static readonly TEXTURE_NEAREST_NEAREST: number;
  33195. /** mag = linear and min = nearest and mip = nearest */
  33196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33197. /** mag = linear and min = nearest and mip = linear */
  33198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33199. /** mag = linear and min = linear and mip = none */
  33200. static readonly TEXTURE_LINEAR_LINEAR: number;
  33201. /** mag = linear and min = nearest and mip = none */
  33202. static readonly TEXTURE_LINEAR_NEAREST: number;
  33203. /** Explicit coordinates mode */
  33204. static readonly TEXTURE_EXPLICIT_MODE: number;
  33205. /** Spherical coordinates mode */
  33206. static readonly TEXTURE_SPHERICAL_MODE: number;
  33207. /** Planar coordinates mode */
  33208. static readonly TEXTURE_PLANAR_MODE: number;
  33209. /** Cubic coordinates mode */
  33210. static readonly TEXTURE_CUBIC_MODE: number;
  33211. /** Projection coordinates mode */
  33212. static readonly TEXTURE_PROJECTION_MODE: number;
  33213. /** Skybox coordinates mode */
  33214. static readonly TEXTURE_SKYBOX_MODE: number;
  33215. /** Inverse Cubic coordinates mode */
  33216. static readonly TEXTURE_INVCUBIC_MODE: number;
  33217. /** Equirectangular coordinates mode */
  33218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33219. /** Equirectangular Fixed coordinates mode */
  33220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33221. /** Equirectangular Fixed Mirrored coordinates mode */
  33222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33224. static readonly SCALEMODE_FLOOR: number;
  33225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33226. static readonly SCALEMODE_NEAREST: number;
  33227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33228. static readonly SCALEMODE_CEILING: number;
  33229. /**
  33230. * Returns the current npm package of the sdk
  33231. */
  33232. static get NpmPackage(): string;
  33233. /**
  33234. * Returns the current version of the framework
  33235. */
  33236. static get Version(): string;
  33237. /** Gets the list of created engines */
  33238. static get Instances(): Engine[];
  33239. /**
  33240. * Gets the latest created engine
  33241. */
  33242. static get LastCreatedEngine(): Nullable<Engine>;
  33243. /**
  33244. * Gets the latest created scene
  33245. */
  33246. static get LastCreatedScene(): Nullable<Scene>;
  33247. /**
  33248. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33249. * @param flag defines which part of the materials must be marked as dirty
  33250. * @param predicate defines a predicate used to filter which materials should be affected
  33251. */
  33252. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33253. /**
  33254. * Method called to create the default loading screen.
  33255. * This can be overriden in your own app.
  33256. * @param canvas The rendering canvas element
  33257. * @returns The loading screen
  33258. */
  33259. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33260. /**
  33261. * Method called to create the default rescale post process on each engine.
  33262. */
  33263. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33264. /**
  33265. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33266. **/
  33267. enableOfflineSupport: boolean;
  33268. /**
  33269. * 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)
  33270. **/
  33271. disableManifestCheck: boolean;
  33272. /**
  33273. * Gets the list of created scenes
  33274. */
  33275. scenes: Scene[];
  33276. /**
  33277. * Event raised when a new scene is created
  33278. */
  33279. onNewSceneAddedObservable: Observable<Scene>;
  33280. /**
  33281. * Gets the list of created postprocesses
  33282. */
  33283. postProcesses: PostProcess[];
  33284. /**
  33285. * Gets a boolean indicating if the pointer is currently locked
  33286. */
  33287. isPointerLock: boolean;
  33288. /**
  33289. * Observable event triggered each time the rendering canvas is resized
  33290. */
  33291. onResizeObservable: Observable<Engine>;
  33292. /**
  33293. * Observable event triggered each time the canvas loses focus
  33294. */
  33295. onCanvasBlurObservable: Observable<Engine>;
  33296. /**
  33297. * Observable event triggered each time the canvas gains focus
  33298. */
  33299. onCanvasFocusObservable: Observable<Engine>;
  33300. /**
  33301. * Observable event triggered each time the canvas receives pointerout event
  33302. */
  33303. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33304. /**
  33305. * Observable raised when the engine begins a new frame
  33306. */
  33307. onBeginFrameObservable: Observable<Engine>;
  33308. /**
  33309. * If set, will be used to request the next animation frame for the render loop
  33310. */
  33311. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33312. /**
  33313. * Observable raised when the engine ends the current frame
  33314. */
  33315. onEndFrameObservable: Observable<Engine>;
  33316. /**
  33317. * Observable raised when the engine is about to compile a shader
  33318. */
  33319. onBeforeShaderCompilationObservable: Observable<Engine>;
  33320. /**
  33321. * Observable raised when the engine has jsut compiled a shader
  33322. */
  33323. onAfterShaderCompilationObservable: Observable<Engine>;
  33324. /**
  33325. * Gets the audio engine
  33326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33327. * @ignorenaming
  33328. */
  33329. static audioEngine: IAudioEngine;
  33330. /**
  33331. * Default AudioEngine factory responsible of creating the Audio Engine.
  33332. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33333. */
  33334. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33335. /**
  33336. * Default offline support factory responsible of creating a tool used to store data locally.
  33337. * By default, this will create a Database object if the workload has been embedded.
  33338. */
  33339. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33340. private _loadingScreen;
  33341. private _pointerLockRequested;
  33342. private _dummyFramebuffer;
  33343. private _rescalePostProcess;
  33344. private _deterministicLockstep;
  33345. private _lockstepMaxSteps;
  33346. private _timeStep;
  33347. protected get _supportsHardwareTextureRescaling(): boolean;
  33348. private _fps;
  33349. private _deltaTime;
  33350. /** @hidden */
  33351. _drawCalls: PerfCounter;
  33352. /** 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 */
  33353. canvasTabIndex: number;
  33354. /**
  33355. * Turn this value on if you want to pause FPS computation when in background
  33356. */
  33357. disablePerformanceMonitorInBackground: boolean;
  33358. private _performanceMonitor;
  33359. /**
  33360. * Gets the performance monitor attached to this engine
  33361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33362. */
  33363. get performanceMonitor(): PerformanceMonitor;
  33364. private _onFocus;
  33365. private _onBlur;
  33366. private _onCanvasPointerOut;
  33367. private _onCanvasBlur;
  33368. private _onCanvasFocus;
  33369. private _onFullscreenChange;
  33370. private _onPointerLockChange;
  33371. /**
  33372. * Gets the HTML element used to attach event listeners
  33373. * @returns a HTML element
  33374. */
  33375. getInputElement(): Nullable<HTMLElement>;
  33376. /**
  33377. * Creates a new engine
  33378. * @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
  33379. * @param antialias defines enable antialiasing (default: false)
  33380. * @param options defines further options to be sent to the getContext() function
  33381. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33382. */
  33383. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33384. /**
  33385. * Gets current aspect ratio
  33386. * @param viewportOwner defines the camera to use to get the aspect ratio
  33387. * @param useScreen defines if screen size must be used (or the current render target if any)
  33388. * @returns a number defining the aspect ratio
  33389. */
  33390. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33391. /**
  33392. * Gets current screen aspect ratio
  33393. * @returns a number defining the aspect ratio
  33394. */
  33395. getScreenAspectRatio(): number;
  33396. /**
  33397. * Gets the client rect of the HTML canvas attached with the current webGL context
  33398. * @returns a client rectanglee
  33399. */
  33400. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33401. /**
  33402. * Gets the client rect of the HTML element used for events
  33403. * @returns a client rectanglee
  33404. */
  33405. getInputElementClientRect(): Nullable<ClientRect>;
  33406. /**
  33407. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33408. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33409. * @returns true if engine is in deterministic lock step mode
  33410. */
  33411. isDeterministicLockStep(): boolean;
  33412. /**
  33413. * Gets the max steps when engine is running in deterministic lock step
  33414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33415. * @returns the max steps
  33416. */
  33417. getLockstepMaxSteps(): number;
  33418. /**
  33419. * Returns the time in ms between steps when using deterministic lock step.
  33420. * @returns time step in (ms)
  33421. */
  33422. getTimeStep(): number;
  33423. /**
  33424. * Force the mipmap generation for the given render target texture
  33425. * @param texture defines the render target texture to use
  33426. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33427. */
  33428. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33429. /** States */
  33430. /**
  33431. * Set various states to the webGL context
  33432. * @param culling defines backface culling state
  33433. * @param zOffset defines the value to apply to zOffset (0 by default)
  33434. * @param force defines if states must be applied even if cache is up to date
  33435. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33436. */
  33437. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33438. /**
  33439. * Set the z offset to apply to current rendering
  33440. * @param value defines the offset to apply
  33441. */
  33442. setZOffset(value: number): void;
  33443. /**
  33444. * Gets the current value of the zOffset
  33445. * @returns the current zOffset state
  33446. */
  33447. getZOffset(): number;
  33448. /**
  33449. * Enable or disable depth buffering
  33450. * @param enable defines the state to set
  33451. */
  33452. setDepthBuffer(enable: boolean): void;
  33453. /**
  33454. * Gets a boolean indicating if depth writing is enabled
  33455. * @returns the current depth writing state
  33456. */
  33457. getDepthWrite(): boolean;
  33458. /**
  33459. * Enable or disable depth writing
  33460. * @param enable defines the state to set
  33461. */
  33462. setDepthWrite(enable: boolean): void;
  33463. /**
  33464. * Gets a boolean indicating if stencil buffer is enabled
  33465. * @returns the current stencil buffer state
  33466. */
  33467. getStencilBuffer(): boolean;
  33468. /**
  33469. * Enable or disable the stencil buffer
  33470. * @param enable defines if the stencil buffer must be enabled or disabled
  33471. */
  33472. setStencilBuffer(enable: boolean): void;
  33473. /**
  33474. * Gets the current stencil mask
  33475. * @returns a number defining the new stencil mask to use
  33476. */
  33477. getStencilMask(): number;
  33478. /**
  33479. * Sets the current stencil mask
  33480. * @param mask defines the new stencil mask to use
  33481. */
  33482. setStencilMask(mask: number): void;
  33483. /**
  33484. * Gets the current stencil function
  33485. * @returns a number defining the stencil function to use
  33486. */
  33487. getStencilFunction(): number;
  33488. /**
  33489. * Gets the current stencil reference value
  33490. * @returns a number defining the stencil reference value to use
  33491. */
  33492. getStencilFunctionReference(): number;
  33493. /**
  33494. * Gets the current stencil mask
  33495. * @returns a number defining the stencil mask to use
  33496. */
  33497. getStencilFunctionMask(): number;
  33498. /**
  33499. * Sets the current stencil function
  33500. * @param stencilFunc defines the new stencil function to use
  33501. */
  33502. setStencilFunction(stencilFunc: number): void;
  33503. /**
  33504. * Sets the current stencil reference
  33505. * @param reference defines the new stencil reference to use
  33506. */
  33507. setStencilFunctionReference(reference: number): void;
  33508. /**
  33509. * Sets the current stencil mask
  33510. * @param mask defines the new stencil mask to use
  33511. */
  33512. setStencilFunctionMask(mask: number): void;
  33513. /**
  33514. * Gets the current stencil operation when stencil fails
  33515. * @returns a number defining stencil operation to use when stencil fails
  33516. */
  33517. getStencilOperationFail(): number;
  33518. /**
  33519. * Gets the current stencil operation when depth fails
  33520. * @returns a number defining stencil operation to use when depth fails
  33521. */
  33522. getStencilOperationDepthFail(): number;
  33523. /**
  33524. * Gets the current stencil operation when stencil passes
  33525. * @returns a number defining stencil operation to use when stencil passes
  33526. */
  33527. getStencilOperationPass(): number;
  33528. /**
  33529. * Sets the stencil operation to use when stencil fails
  33530. * @param operation defines the stencil operation to use when stencil fails
  33531. */
  33532. setStencilOperationFail(operation: number): void;
  33533. /**
  33534. * Sets the stencil operation to use when depth fails
  33535. * @param operation defines the stencil operation to use when depth fails
  33536. */
  33537. setStencilOperationDepthFail(operation: number): void;
  33538. /**
  33539. * Sets the stencil operation to use when stencil passes
  33540. * @param operation defines the stencil operation to use when stencil passes
  33541. */
  33542. setStencilOperationPass(operation: number): void;
  33543. /**
  33544. * Sets a boolean indicating if the dithering state is enabled or disabled
  33545. * @param value defines the dithering state
  33546. */
  33547. setDitheringState(value: boolean): void;
  33548. /**
  33549. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33550. * @param value defines the rasterizer state
  33551. */
  33552. setRasterizerState(value: boolean): void;
  33553. /**
  33554. * Gets the current depth function
  33555. * @returns a number defining the depth function
  33556. */
  33557. getDepthFunction(): Nullable<number>;
  33558. /**
  33559. * Sets the current depth function
  33560. * @param depthFunc defines the function to use
  33561. */
  33562. setDepthFunction(depthFunc: number): void;
  33563. /**
  33564. * Sets the current depth function to GREATER
  33565. */
  33566. setDepthFunctionToGreater(): void;
  33567. /**
  33568. * Sets the current depth function to GEQUAL
  33569. */
  33570. setDepthFunctionToGreaterOrEqual(): void;
  33571. /**
  33572. * Sets the current depth function to LESS
  33573. */
  33574. setDepthFunctionToLess(): void;
  33575. /**
  33576. * Sets the current depth function to LEQUAL
  33577. */
  33578. setDepthFunctionToLessOrEqual(): void;
  33579. private _cachedStencilBuffer;
  33580. private _cachedStencilFunction;
  33581. private _cachedStencilMask;
  33582. private _cachedStencilOperationPass;
  33583. private _cachedStencilOperationFail;
  33584. private _cachedStencilOperationDepthFail;
  33585. private _cachedStencilReference;
  33586. /**
  33587. * Caches the the state of the stencil buffer
  33588. */
  33589. cacheStencilState(): void;
  33590. /**
  33591. * Restores the state of the stencil buffer
  33592. */
  33593. restoreStencilState(): void;
  33594. /**
  33595. * Directly set the WebGL Viewport
  33596. * @param x defines the x coordinate of the viewport (in screen space)
  33597. * @param y defines the y coordinate of the viewport (in screen space)
  33598. * @param width defines the width of the viewport (in screen space)
  33599. * @param height defines the height of the viewport (in screen space)
  33600. * @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
  33601. */
  33602. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33603. /**
  33604. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33605. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33606. * @param y defines the y-coordinate of the corner of the clear rectangle
  33607. * @param width defines the width of the clear rectangle
  33608. * @param height defines the height of the clear rectangle
  33609. * @param clearColor defines the clear color
  33610. */
  33611. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33612. /**
  33613. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33614. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33615. * @param y defines the y-coordinate of the corner of the clear rectangle
  33616. * @param width defines the width of the clear rectangle
  33617. * @param height defines the height of the clear rectangle
  33618. */
  33619. enableScissor(x: number, y: number, width: number, height: number): void;
  33620. /**
  33621. * Disable previously set scissor test rectangle
  33622. */
  33623. disableScissor(): void;
  33624. protected _reportDrawCall(): void;
  33625. /**
  33626. * Initializes a webVR display and starts listening to display change events
  33627. * The onVRDisplayChangedObservable will be notified upon these changes
  33628. * @returns The onVRDisplayChangedObservable
  33629. */
  33630. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33631. /** @hidden */
  33632. _prepareVRComponent(): void;
  33633. /** @hidden */
  33634. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33635. /** @hidden */
  33636. _submitVRFrame(): void;
  33637. /**
  33638. * Call this function to leave webVR mode
  33639. * Will do nothing if webVR is not supported or if there is no webVR device
  33640. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33641. */
  33642. disableVR(): void;
  33643. /**
  33644. * Gets a boolean indicating that the system is in VR mode and is presenting
  33645. * @returns true if VR mode is engaged
  33646. */
  33647. isVRPresenting(): boolean;
  33648. /** @hidden */
  33649. _requestVRFrame(): void;
  33650. /** @hidden */
  33651. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33652. /**
  33653. * Gets the source code of the vertex shader associated with a specific webGL program
  33654. * @param program defines the program to use
  33655. * @returns a string containing the source code of the vertex shader associated with the program
  33656. */
  33657. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33658. /**
  33659. * Gets the source code of the fragment shader associated with a specific webGL program
  33660. * @param program defines the program to use
  33661. * @returns a string containing the source code of the fragment shader associated with the program
  33662. */
  33663. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33664. /**
  33665. * Sets a depth stencil texture from a render target to the according uniform.
  33666. * @param channel The texture channel
  33667. * @param uniform The uniform to set
  33668. * @param texture The render target texture containing the depth stencil texture to apply
  33669. */
  33670. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33671. /**
  33672. * Sets a texture to the webGL context from a postprocess
  33673. * @param channel defines the channel to use
  33674. * @param postProcess defines the source postprocess
  33675. */
  33676. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33677. /**
  33678. * Binds the output of the passed in post process to the texture channel specified
  33679. * @param channel The channel the texture should be bound to
  33680. * @param postProcess The post process which's output should be bound
  33681. */
  33682. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33683. /** @hidden */
  33684. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33685. protected _rebuildBuffers(): void;
  33686. /** @hidden */
  33687. _renderFrame(): void;
  33688. _renderLoop(): void;
  33689. /** @hidden */
  33690. _renderViews(): boolean;
  33691. /**
  33692. * Toggle full screen mode
  33693. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33694. */
  33695. switchFullscreen(requestPointerLock: boolean): void;
  33696. /**
  33697. * Enters full screen mode
  33698. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33699. */
  33700. enterFullscreen(requestPointerLock: boolean): void;
  33701. /**
  33702. * Exits full screen mode
  33703. */
  33704. exitFullscreen(): void;
  33705. /**
  33706. * Enters Pointerlock mode
  33707. */
  33708. enterPointerlock(): void;
  33709. /**
  33710. * Exits Pointerlock mode
  33711. */
  33712. exitPointerlock(): void;
  33713. /**
  33714. * Begin a new frame
  33715. */
  33716. beginFrame(): void;
  33717. /**
  33718. * Enf the current frame
  33719. */
  33720. endFrame(): void;
  33721. resize(): void;
  33722. /**
  33723. * Set the compressed texture format to use, based on the formats you have, and the formats
  33724. * supported by the hardware / browser.
  33725. *
  33726. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33727. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33728. * to API arguments needed to compressed textures. This puts the burden on the container
  33729. * generator to house the arcane code for determining these for current & future formats.
  33730. *
  33731. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33732. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33733. *
  33734. * Note: The result of this call is not taken into account when a texture is base64.
  33735. *
  33736. * @param formatsAvailable defines the list of those format families you have created
  33737. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33738. *
  33739. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33740. * @returns The extension selected.
  33741. */
  33742. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33743. /**
  33744. * Set the compressed texture extensions or file names to skip.
  33745. *
  33746. * @param skippedFiles defines the list of those texture files you want to skip
  33747. * Example: [".dds", ".env", "myfile.png"]
  33748. */
  33749. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33750. /**
  33751. * Force a specific size of the canvas
  33752. * @param width defines the new canvas' width
  33753. * @param height defines the new canvas' height
  33754. */
  33755. setSize(width: number, height: number): void;
  33756. /**
  33757. * Updates a dynamic vertex buffer.
  33758. * @param vertexBuffer the vertex buffer to update
  33759. * @param data the data used to update the vertex buffer
  33760. * @param byteOffset the byte offset of the data
  33761. * @param byteLength the byte length of the data
  33762. */
  33763. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33764. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33765. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33766. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33767. _releaseTexture(texture: InternalTexture): void;
  33768. /**
  33769. * @hidden
  33770. * Rescales a texture
  33771. * @param source input texutre
  33772. * @param destination destination texture
  33773. * @param scene scene to use to render the resize
  33774. * @param internalFormat format to use when resizing
  33775. * @param onComplete callback to be called when resize has completed
  33776. */
  33777. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33778. /**
  33779. * Gets the current framerate
  33780. * @returns a number representing the framerate
  33781. */
  33782. getFps(): number;
  33783. /**
  33784. * Gets the time spent between current and previous frame
  33785. * @returns a number representing the delta time in ms
  33786. */
  33787. getDeltaTime(): number;
  33788. private _measureFps;
  33789. /** @hidden */
  33790. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33791. /**
  33792. * Update a dynamic index buffer
  33793. * @param indexBuffer defines the target index buffer
  33794. * @param indices defines the data to update
  33795. * @param offset defines the offset in the target index buffer where update should start
  33796. */
  33797. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33798. /**
  33799. * Updates the sample count of a render target texture
  33800. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33801. * @param texture defines the texture to update
  33802. * @param samples defines the sample count to set
  33803. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33804. */
  33805. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33806. /**
  33807. * Updates a depth texture Comparison Mode and Function.
  33808. * If the comparison Function is equal to 0, the mode will be set to none.
  33809. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33810. * @param texture The texture to set the comparison function for
  33811. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33812. */
  33813. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33814. /**
  33815. * Creates a webGL buffer to use with instanciation
  33816. * @param capacity defines the size of the buffer
  33817. * @returns the webGL buffer
  33818. */
  33819. createInstancesBuffer(capacity: number): DataBuffer;
  33820. /**
  33821. * Delete a webGL buffer used with instanciation
  33822. * @param buffer defines the webGL buffer to delete
  33823. */
  33824. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33825. /** @hidden */
  33826. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33827. dispose(): void;
  33828. private _disableTouchAction;
  33829. /**
  33830. * Display the loading screen
  33831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33832. */
  33833. displayLoadingUI(): void;
  33834. /**
  33835. * Hide the loading screen
  33836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33837. */
  33838. hideLoadingUI(): void;
  33839. /**
  33840. * Gets the current loading screen object
  33841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33842. */
  33843. get loadingScreen(): ILoadingScreen;
  33844. /**
  33845. * Sets the current loading screen object
  33846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33847. */
  33848. set loadingScreen(loadingScreen: ILoadingScreen);
  33849. /**
  33850. * Sets the current loading screen text
  33851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33852. */
  33853. set loadingUIText(text: string);
  33854. /**
  33855. * Sets the current loading screen background color
  33856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33857. */
  33858. set loadingUIBackgroundColor(color: string);
  33859. /** Pointerlock and fullscreen */
  33860. /**
  33861. * Ask the browser to promote the current element to pointerlock mode
  33862. * @param element defines the DOM element to promote
  33863. */
  33864. static _RequestPointerlock(element: HTMLElement): void;
  33865. /**
  33866. * Asks the browser to exit pointerlock mode
  33867. */
  33868. static _ExitPointerlock(): void;
  33869. /**
  33870. * Ask the browser to promote the current element to fullscreen rendering mode
  33871. * @param element defines the DOM element to promote
  33872. */
  33873. static _RequestFullscreen(element: HTMLElement): void;
  33874. /**
  33875. * Asks the browser to exit fullscreen mode
  33876. */
  33877. static _ExitFullscreen(): void;
  33878. }
  33879. }
  33880. declare module BABYLON {
  33881. /**
  33882. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33883. * during the life time of the application.
  33884. */
  33885. export class EngineStore {
  33886. /** Gets the list of created engines */
  33887. static Instances: Engine[];
  33888. /** @hidden */
  33889. static _LastCreatedScene: Nullable<Scene>;
  33890. /**
  33891. * Gets the latest created engine
  33892. */
  33893. static get LastCreatedEngine(): Nullable<Engine>;
  33894. /**
  33895. * Gets the latest created scene
  33896. */
  33897. static get LastCreatedScene(): Nullable<Scene>;
  33898. /**
  33899. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33900. * @ignorenaming
  33901. */
  33902. static UseFallbackTexture: boolean;
  33903. /**
  33904. * Texture content used if a texture cannot loaded
  33905. * @ignorenaming
  33906. */
  33907. static FallbackTexture: string;
  33908. }
  33909. }
  33910. declare module BABYLON {
  33911. /**
  33912. * Helper class that provides a small promise polyfill
  33913. */
  33914. export class PromisePolyfill {
  33915. /**
  33916. * Static function used to check if the polyfill is required
  33917. * If this is the case then the function will inject the polyfill to window.Promise
  33918. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33919. */
  33920. static Apply(force?: boolean): void;
  33921. }
  33922. }
  33923. declare module BABYLON {
  33924. /**
  33925. * Interface for screenshot methods with describe argument called `size` as object with options
  33926. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33927. */
  33928. export interface IScreenshotSize {
  33929. /**
  33930. * number in pixels for canvas height
  33931. */
  33932. height?: number;
  33933. /**
  33934. * multiplier allowing render at a higher or lower resolution
  33935. * If value is defined then height and width will be ignored and taken from camera
  33936. */
  33937. precision?: number;
  33938. /**
  33939. * number in pixels for canvas width
  33940. */
  33941. width?: number;
  33942. }
  33943. }
  33944. declare module BABYLON {
  33945. interface IColor4Like {
  33946. r: float;
  33947. g: float;
  33948. b: float;
  33949. a: float;
  33950. }
  33951. /**
  33952. * Class containing a set of static utilities functions
  33953. */
  33954. export class Tools {
  33955. /**
  33956. * Gets or sets the base URL to use to load assets
  33957. */
  33958. static get BaseUrl(): string;
  33959. static set BaseUrl(value: string);
  33960. /**
  33961. * Enable/Disable Custom HTTP Request Headers globally.
  33962. * default = false
  33963. * @see CustomRequestHeaders
  33964. */
  33965. static UseCustomRequestHeaders: boolean;
  33966. /**
  33967. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33968. * i.e. when loading files, where the server/service expects an Authorization header
  33969. */
  33970. static CustomRequestHeaders: {
  33971. [key: string]: string;
  33972. };
  33973. /**
  33974. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33975. */
  33976. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33977. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33978. /**
  33979. * Default behaviour for cors in the application.
  33980. * It can be a string if the expected behavior is identical in the entire app.
  33981. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33982. */
  33983. static CorsBehavior: string | ((url: string | string[]) => string);
  33984. /**
  33985. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33986. * @ignorenaming
  33987. */
  33988. static get UseFallbackTexture(): boolean;
  33989. static set UseFallbackTexture(value: boolean);
  33990. /**
  33991. * Use this object to register external classes like custom textures or material
  33992. * to allow the laoders to instantiate them
  33993. */
  33994. static get RegisteredExternalClasses(): {
  33995. [key: string]: Object;
  33996. };
  33997. static set RegisteredExternalClasses(classes: {
  33998. [key: string]: Object;
  33999. });
  34000. /**
  34001. * Texture content used if a texture cannot loaded
  34002. * @ignorenaming
  34003. */
  34004. static get fallbackTexture(): string;
  34005. static set fallbackTexture(value: string);
  34006. /**
  34007. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34008. * @param u defines the coordinate on X axis
  34009. * @param v defines the coordinate on Y axis
  34010. * @param width defines the width of the source data
  34011. * @param height defines the height of the source data
  34012. * @param pixels defines the source byte array
  34013. * @param color defines the output color
  34014. */
  34015. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34016. /**
  34017. * Interpolates between a and b via alpha
  34018. * @param a The lower value (returned when alpha = 0)
  34019. * @param b The upper value (returned when alpha = 1)
  34020. * @param alpha The interpolation-factor
  34021. * @return The mixed value
  34022. */
  34023. static Mix(a: number, b: number, alpha: number): number;
  34024. /**
  34025. * Tries to instantiate a new object from a given class name
  34026. * @param className defines the class name to instantiate
  34027. * @returns the new object or null if the system was not able to do the instantiation
  34028. */
  34029. static Instantiate(className: string): any;
  34030. /**
  34031. * Provides a slice function that will work even on IE
  34032. * @param data defines the array to slice
  34033. * @param start defines the start of the data (optional)
  34034. * @param end defines the end of the data (optional)
  34035. * @returns the new sliced array
  34036. */
  34037. static Slice<T>(data: T, start?: number, end?: number): T;
  34038. /**
  34039. * Polyfill for setImmediate
  34040. * @param action defines the action to execute after the current execution block
  34041. */
  34042. static SetImmediate(action: () => void): void;
  34043. /**
  34044. * Function indicating if a number is an exponent of 2
  34045. * @param value defines the value to test
  34046. * @returns true if the value is an exponent of 2
  34047. */
  34048. static IsExponentOfTwo(value: number): boolean;
  34049. private static _tmpFloatArray;
  34050. /**
  34051. * Returns the nearest 32-bit single precision float representation of a Number
  34052. * @param value A Number. If the parameter is of a different type, it will get converted
  34053. * to a number or to NaN if it cannot be converted
  34054. * @returns number
  34055. */
  34056. static FloatRound(value: number): number;
  34057. /**
  34058. * Extracts the filename from a path
  34059. * @param path defines the path to use
  34060. * @returns the filename
  34061. */
  34062. static GetFilename(path: string): string;
  34063. /**
  34064. * Extracts the "folder" part of a path (everything before the filename).
  34065. * @param uri The URI to extract the info from
  34066. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34067. * @returns The "folder" part of the path
  34068. */
  34069. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34070. /**
  34071. * Extracts text content from a DOM element hierarchy
  34072. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34073. */
  34074. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34075. /**
  34076. * Convert an angle in radians to degrees
  34077. * @param angle defines the angle to convert
  34078. * @returns the angle in degrees
  34079. */
  34080. static ToDegrees(angle: number): number;
  34081. /**
  34082. * Convert an angle in degrees to radians
  34083. * @param angle defines the angle to convert
  34084. * @returns the angle in radians
  34085. */
  34086. static ToRadians(angle: number): number;
  34087. /**
  34088. * Returns an array if obj is not an array
  34089. * @param obj defines the object to evaluate as an array
  34090. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34091. * @returns either obj directly if obj is an array or a new array containing obj
  34092. */
  34093. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34094. /**
  34095. * Gets the pointer prefix to use
  34096. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34097. */
  34098. static GetPointerPrefix(): string;
  34099. /**
  34100. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34101. * @param url define the url we are trying
  34102. * @param element define the dom element where to configure the cors policy
  34103. */
  34104. static SetCorsBehavior(url: string | string[], element: {
  34105. crossOrigin: string | null;
  34106. }): void;
  34107. /**
  34108. * Removes unwanted characters from an url
  34109. * @param url defines the url to clean
  34110. * @returns the cleaned url
  34111. */
  34112. static CleanUrl(url: string): string;
  34113. /**
  34114. * Gets or sets a function used to pre-process url before using them to load assets
  34115. */
  34116. static get PreprocessUrl(): (url: string) => string;
  34117. static set PreprocessUrl(processor: (url: string) => string);
  34118. /**
  34119. * Loads an image as an HTMLImageElement.
  34120. * @param input url string, ArrayBuffer, or Blob to load
  34121. * @param onLoad callback called when the image successfully loads
  34122. * @param onError callback called when the image fails to load
  34123. * @param offlineProvider offline provider for caching
  34124. * @param mimeType optional mime type
  34125. * @returns the HTMLImageElement of the loaded image
  34126. */
  34127. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34128. /**
  34129. * Loads a file from a url
  34130. * @param url url string, ArrayBuffer, or Blob to load
  34131. * @param onSuccess callback called when the file successfully loads
  34132. * @param onProgress callback called while file is loading (if the server supports this mode)
  34133. * @param offlineProvider defines the offline provider for caching
  34134. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34135. * @param onError callback called when the file fails to load
  34136. * @returns a file request object
  34137. */
  34138. 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;
  34139. /**
  34140. * Loads a file from a url
  34141. * @param url the file url to load
  34142. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34143. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34144. */
  34145. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34146. /**
  34147. * Load a script (identified by an url). When the url returns, the
  34148. * content of this file is added into a new script element, attached to the DOM (body element)
  34149. * @param scriptUrl defines the url of the script to laod
  34150. * @param onSuccess defines the callback called when the script is loaded
  34151. * @param onError defines the callback to call if an error occurs
  34152. * @param scriptId defines the id of the script element
  34153. */
  34154. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34155. /**
  34156. * Load an asynchronous script (identified by an url). When the url returns, the
  34157. * content of this file is added into a new script element, attached to the DOM (body element)
  34158. * @param scriptUrl defines the url of the script to laod
  34159. * @param scriptId defines the id of the script element
  34160. * @returns a promise request object
  34161. */
  34162. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34163. /**
  34164. * Loads a file from a blob
  34165. * @param fileToLoad defines the blob to use
  34166. * @param callback defines the callback to call when data is loaded
  34167. * @param progressCallback defines the callback to call during loading process
  34168. * @returns a file request object
  34169. */
  34170. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34171. /**
  34172. * Reads a file from a File object
  34173. * @param file defines the file to load
  34174. * @param onSuccess defines the callback to call when data is loaded
  34175. * @param onProgress defines the callback to call during loading process
  34176. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34177. * @param onError defines the callback to call when an error occurs
  34178. * @returns a file request object
  34179. */
  34180. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34181. /**
  34182. * Creates a data url from a given string content
  34183. * @param content defines the content to convert
  34184. * @returns the new data url link
  34185. */
  34186. static FileAsURL(content: string): string;
  34187. /**
  34188. * Format the given number to a specific decimal format
  34189. * @param value defines the number to format
  34190. * @param decimals defines the number of decimals to use
  34191. * @returns the formatted string
  34192. */
  34193. static Format(value: number, decimals?: number): string;
  34194. /**
  34195. * Tries to copy an object by duplicating every property
  34196. * @param source defines the source object
  34197. * @param destination defines the target object
  34198. * @param doNotCopyList defines a list of properties to avoid
  34199. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34200. */
  34201. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34202. /**
  34203. * Gets a boolean indicating if the given object has no own property
  34204. * @param obj defines the object to test
  34205. * @returns true if object has no own property
  34206. */
  34207. static IsEmpty(obj: any): boolean;
  34208. /**
  34209. * Function used to register events at window level
  34210. * @param windowElement defines the Window object to use
  34211. * @param events defines the events to register
  34212. */
  34213. static RegisterTopRootEvents(windowElement: Window, events: {
  34214. name: string;
  34215. handler: Nullable<(e: FocusEvent) => any>;
  34216. }[]): void;
  34217. /**
  34218. * Function used to unregister events from window level
  34219. * @param windowElement defines the Window object to use
  34220. * @param events defines the events to unregister
  34221. */
  34222. static UnregisterTopRootEvents(windowElement: Window, events: {
  34223. name: string;
  34224. handler: Nullable<(e: FocusEvent) => any>;
  34225. }[]): void;
  34226. /**
  34227. * @ignore
  34228. */
  34229. static _ScreenshotCanvas: HTMLCanvasElement;
  34230. /**
  34231. * Dumps the current bound framebuffer
  34232. * @param width defines the rendering width
  34233. * @param height defines the rendering height
  34234. * @param engine defines the hosting engine
  34235. * @param successCallback defines the callback triggered once the data are available
  34236. * @param mimeType defines the mime type of the result
  34237. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34238. */
  34239. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34240. /**
  34241. * Converts the canvas data to blob.
  34242. * This acts as a polyfill for browsers not supporting the to blob function.
  34243. * @param canvas Defines the canvas to extract the data from
  34244. * @param successCallback Defines the callback triggered once the data are available
  34245. * @param mimeType Defines the mime type of the result
  34246. */
  34247. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34248. /**
  34249. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34250. * @param successCallback defines the callback triggered once the data are available
  34251. * @param mimeType defines the mime type of the result
  34252. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34253. */
  34254. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34255. /**
  34256. * Downloads a blob in the browser
  34257. * @param blob defines the blob to download
  34258. * @param fileName defines the name of the downloaded file
  34259. */
  34260. static Download(blob: Blob, fileName: string): void;
  34261. /**
  34262. * Captures a screenshot of the current rendering
  34263. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34264. * @param engine defines the rendering engine
  34265. * @param camera defines the source camera
  34266. * @param size This parameter can be set to a single number or to an object with the
  34267. * following (optional) properties: precision, width, height. If a single number is passed,
  34268. * it will be used for both width and height. If an object is passed, the screenshot size
  34269. * will be derived from the parameters. The precision property is a multiplier allowing
  34270. * rendering at a higher or lower resolution
  34271. * @param successCallback defines the callback receives a single parameter which contains the
  34272. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34273. * src parameter of an <img> to display it
  34274. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34275. * Check your browser for supported MIME types
  34276. */
  34277. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34278. /**
  34279. * Captures a screenshot of the current rendering
  34280. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34281. * @param engine defines the rendering engine
  34282. * @param camera defines the source camera
  34283. * @param size This parameter can be set to a single number or to an object with the
  34284. * following (optional) properties: precision, width, height. If a single number is passed,
  34285. * it will be used for both width and height. If an object is passed, the screenshot size
  34286. * will be derived from the parameters. The precision property is a multiplier allowing
  34287. * rendering at a higher or lower resolution
  34288. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34289. * Check your browser for supported MIME types
  34290. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34291. * to the src parameter of an <img> to display it
  34292. */
  34293. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34294. /**
  34295. * Generates an image screenshot from the specified camera.
  34296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34297. * @param engine The engine to use for rendering
  34298. * @param camera The camera to use for rendering
  34299. * @param size This parameter can be set to a single number or to an object with the
  34300. * following (optional) properties: precision, width, height. If a single number is passed,
  34301. * it will be used for both width and height. If an object is passed, the screenshot size
  34302. * will be derived from the parameters. The precision property is a multiplier allowing
  34303. * rendering at a higher or lower resolution
  34304. * @param successCallback The callback receives a single parameter which contains the
  34305. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34306. * src parameter of an <img> to display it
  34307. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34308. * Check your browser for supported MIME types
  34309. * @param samples Texture samples (default: 1)
  34310. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34311. * @param fileName A name for for the downloaded file.
  34312. */
  34313. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34314. /**
  34315. * Generates an image screenshot from the specified camera.
  34316. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34317. * @param engine The engine to use for rendering
  34318. * @param camera The camera to use for rendering
  34319. * @param size This parameter can be set to a single number or to an object with the
  34320. * following (optional) properties: precision, width, height. If a single number is passed,
  34321. * it will be used for both width and height. If an object is passed, the screenshot size
  34322. * will be derived from the parameters. The precision property is a multiplier allowing
  34323. * rendering at a higher or lower resolution
  34324. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34325. * Check your browser for supported MIME types
  34326. * @param samples Texture samples (default: 1)
  34327. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34328. * @param fileName A name for for the downloaded file.
  34329. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34330. * to the src parameter of an <img> to display it
  34331. */
  34332. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34333. /**
  34334. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34335. * Be aware Math.random() could cause collisions, but:
  34336. * "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"
  34337. * @returns a pseudo random id
  34338. */
  34339. static RandomId(): string;
  34340. /**
  34341. * Test if the given uri is a base64 string
  34342. * @param uri The uri to test
  34343. * @return True if the uri is a base64 string or false otherwise
  34344. */
  34345. static IsBase64(uri: string): boolean;
  34346. /**
  34347. * Decode the given base64 uri.
  34348. * @param uri The uri to decode
  34349. * @return The decoded base64 data.
  34350. */
  34351. static DecodeBase64(uri: string): ArrayBuffer;
  34352. /**
  34353. * Gets the absolute url.
  34354. * @param url the input url
  34355. * @return the absolute url
  34356. */
  34357. static GetAbsoluteUrl(url: string): string;
  34358. /**
  34359. * No log
  34360. */
  34361. static readonly NoneLogLevel: number;
  34362. /**
  34363. * Only message logs
  34364. */
  34365. static readonly MessageLogLevel: number;
  34366. /**
  34367. * Only warning logs
  34368. */
  34369. static readonly WarningLogLevel: number;
  34370. /**
  34371. * Only error logs
  34372. */
  34373. static readonly ErrorLogLevel: number;
  34374. /**
  34375. * All logs
  34376. */
  34377. static readonly AllLogLevel: number;
  34378. /**
  34379. * Gets a value indicating the number of loading errors
  34380. * @ignorenaming
  34381. */
  34382. static get errorsCount(): number;
  34383. /**
  34384. * Callback called when a new log is added
  34385. */
  34386. static OnNewCacheEntry: (entry: string) => void;
  34387. /**
  34388. * Log a message to the console
  34389. * @param message defines the message to log
  34390. */
  34391. static Log(message: string): void;
  34392. /**
  34393. * Write a warning message to the console
  34394. * @param message defines the message to log
  34395. */
  34396. static Warn(message: string): void;
  34397. /**
  34398. * Write an error message to the console
  34399. * @param message defines the message to log
  34400. */
  34401. static Error(message: string): void;
  34402. /**
  34403. * Gets current log cache (list of logs)
  34404. */
  34405. static get LogCache(): string;
  34406. /**
  34407. * Clears the log cache
  34408. */
  34409. static ClearLogCache(): void;
  34410. /**
  34411. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34412. */
  34413. static set LogLevels(level: number);
  34414. /**
  34415. * Checks if the window object exists
  34416. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34417. */
  34418. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34419. /**
  34420. * No performance log
  34421. */
  34422. static readonly PerformanceNoneLogLevel: number;
  34423. /**
  34424. * Use user marks to log performance
  34425. */
  34426. static readonly PerformanceUserMarkLogLevel: number;
  34427. /**
  34428. * Log performance to the console
  34429. */
  34430. static readonly PerformanceConsoleLogLevel: number;
  34431. private static _performance;
  34432. /**
  34433. * Sets the current performance log level
  34434. */
  34435. static set PerformanceLogLevel(level: number);
  34436. private static _StartPerformanceCounterDisabled;
  34437. private static _EndPerformanceCounterDisabled;
  34438. private static _StartUserMark;
  34439. private static _EndUserMark;
  34440. private static _StartPerformanceConsole;
  34441. private static _EndPerformanceConsole;
  34442. /**
  34443. * Starts a performance counter
  34444. */
  34445. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34446. /**
  34447. * Ends a specific performance coutner
  34448. */
  34449. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34450. /**
  34451. * Gets either window.performance.now() if supported or Date.now() else
  34452. */
  34453. static get Now(): number;
  34454. /**
  34455. * This method will return the name of the class used to create the instance of the given object.
  34456. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34457. * @param object the object to get the class name from
  34458. * @param isType defines if the object is actually a type
  34459. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34460. */
  34461. static GetClassName(object: any, isType?: boolean): string;
  34462. /**
  34463. * Gets the first element of an array satisfying a given predicate
  34464. * @param array defines the array to browse
  34465. * @param predicate defines the predicate to use
  34466. * @returns null if not found or the element
  34467. */
  34468. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34469. /**
  34470. * This method will return the name of the full name of the class, including its owning module (if any).
  34471. * 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).
  34472. * @param object the object to get the class name from
  34473. * @param isType defines if the object is actually a type
  34474. * @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.
  34475. * @ignorenaming
  34476. */
  34477. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34478. /**
  34479. * Returns a promise that resolves after the given amount of time.
  34480. * @param delay Number of milliseconds to delay
  34481. * @returns Promise that resolves after the given amount of time
  34482. */
  34483. static DelayAsync(delay: number): Promise<void>;
  34484. /**
  34485. * Utility function to detect if the current user agent is Safari
  34486. * @returns whether or not the current user agent is safari
  34487. */
  34488. static IsSafari(): boolean;
  34489. }
  34490. /**
  34491. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34492. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34493. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34494. * @param name The name of the class, case should be preserved
  34495. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34496. */
  34497. export function className(name: string, module?: string): (target: Object) => void;
  34498. /**
  34499. * An implementation of a loop for asynchronous functions.
  34500. */
  34501. export class AsyncLoop {
  34502. /**
  34503. * Defines the number of iterations for the loop
  34504. */
  34505. iterations: number;
  34506. /**
  34507. * Defines the current index of the loop.
  34508. */
  34509. index: number;
  34510. private _done;
  34511. private _fn;
  34512. private _successCallback;
  34513. /**
  34514. * Constructor.
  34515. * @param iterations the number of iterations.
  34516. * @param func the function to run each iteration
  34517. * @param successCallback the callback that will be called upon succesful execution
  34518. * @param offset starting offset.
  34519. */
  34520. constructor(
  34521. /**
  34522. * Defines the number of iterations for the loop
  34523. */
  34524. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34525. /**
  34526. * Execute the next iteration. Must be called after the last iteration was finished.
  34527. */
  34528. executeNext(): void;
  34529. /**
  34530. * Break the loop and run the success callback.
  34531. */
  34532. breakLoop(): void;
  34533. /**
  34534. * Create and run an async loop.
  34535. * @param iterations the number of iterations.
  34536. * @param fn the function to run each iteration
  34537. * @param successCallback the callback that will be called upon succesful execution
  34538. * @param offset starting offset.
  34539. * @returns the created async loop object
  34540. */
  34541. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34542. /**
  34543. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34544. * @param iterations total number of iterations
  34545. * @param syncedIterations number of synchronous iterations in each async iteration.
  34546. * @param fn the function to call each iteration.
  34547. * @param callback a success call back that will be called when iterating stops.
  34548. * @param breakFunction a break condition (optional)
  34549. * @param timeout timeout settings for the setTimeout function. default - 0.
  34550. * @returns the created async loop object
  34551. */
  34552. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34553. }
  34554. }
  34555. declare module BABYLON {
  34556. /**
  34557. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34558. * The underlying implementation relies on an associative array to ensure the best performances.
  34559. * The value can be anything including 'null' but except 'undefined'
  34560. */
  34561. export class StringDictionary<T> {
  34562. /**
  34563. * This will clear this dictionary and copy the content from the 'source' one.
  34564. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34565. * @param source the dictionary to take the content from and copy to this dictionary
  34566. */
  34567. copyFrom(source: StringDictionary<T>): void;
  34568. /**
  34569. * Get a value based from its key
  34570. * @param key the given key to get the matching value from
  34571. * @return the value if found, otherwise undefined is returned
  34572. */
  34573. get(key: string): T | undefined;
  34574. /**
  34575. * Get a value from its key or add it if it doesn't exist.
  34576. * This method will ensure you that a given key/data will be present in the dictionary.
  34577. * @param key the given key to get the matching value from
  34578. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34579. * The factory will only be invoked if there's no data for the given key.
  34580. * @return the value corresponding to the key.
  34581. */
  34582. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34583. /**
  34584. * Get a value from its key if present in the dictionary otherwise add it
  34585. * @param key the key to get the value from
  34586. * @param val if there's no such key/value pair in the dictionary add it with this value
  34587. * @return the value corresponding to the key
  34588. */
  34589. getOrAdd(key: string, val: T): T;
  34590. /**
  34591. * Check if there's a given key in the dictionary
  34592. * @param key the key to check for
  34593. * @return true if the key is present, false otherwise
  34594. */
  34595. contains(key: string): boolean;
  34596. /**
  34597. * Add a new key and its corresponding value
  34598. * @param key the key to add
  34599. * @param value the value corresponding to the key
  34600. * @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
  34601. */
  34602. add(key: string, value: T): boolean;
  34603. /**
  34604. * Update a specific value associated to a key
  34605. * @param key defines the key to use
  34606. * @param value defines the value to store
  34607. * @returns true if the value was updated (or false if the key was not found)
  34608. */
  34609. set(key: string, value: T): boolean;
  34610. /**
  34611. * Get the element of the given key and remove it from the dictionary
  34612. * @param key defines the key to search
  34613. * @returns the value associated with the key or null if not found
  34614. */
  34615. getAndRemove(key: string): Nullable<T>;
  34616. /**
  34617. * Remove a key/value from the dictionary.
  34618. * @param key the key to remove
  34619. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34620. */
  34621. remove(key: string): boolean;
  34622. /**
  34623. * Clear the whole content of the dictionary
  34624. */
  34625. clear(): void;
  34626. /**
  34627. * Gets the current count
  34628. */
  34629. get count(): number;
  34630. /**
  34631. * Execute a callback on each key/val of the dictionary.
  34632. * Note that you can remove any element in this dictionary in the callback implementation
  34633. * @param callback the callback to execute on a given key/value pair
  34634. */
  34635. forEach(callback: (key: string, val: T) => void): void;
  34636. /**
  34637. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34638. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34639. * Note that you can remove any element in this dictionary in the callback implementation
  34640. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34641. * @returns the first item
  34642. */
  34643. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34644. private _count;
  34645. private _data;
  34646. }
  34647. }
  34648. declare module BABYLON {
  34649. /** @hidden */
  34650. export interface ICollisionCoordinator {
  34651. createCollider(): Collider;
  34652. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34653. init(scene: Scene): void;
  34654. }
  34655. /** @hidden */
  34656. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34657. private _scene;
  34658. private _scaledPosition;
  34659. private _scaledVelocity;
  34660. private _finalPosition;
  34661. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34662. createCollider(): Collider;
  34663. init(scene: Scene): void;
  34664. private _collideWithWorld;
  34665. }
  34666. }
  34667. declare module BABYLON {
  34668. /**
  34669. * Class used to manage all inputs for the scene.
  34670. */
  34671. export class InputManager {
  34672. /** The distance in pixel that you have to move to prevent some events */
  34673. static DragMovementThreshold: number;
  34674. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34675. static LongPressDelay: number;
  34676. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34677. static DoubleClickDelay: number;
  34678. /** If you need to check double click without raising a single click at first click, enable this flag */
  34679. static ExclusiveDoubleClickMode: boolean;
  34680. private _wheelEventName;
  34681. private _onPointerMove;
  34682. private _onPointerDown;
  34683. private _onPointerUp;
  34684. private _initClickEvent;
  34685. private _initActionManager;
  34686. private _delayedSimpleClick;
  34687. private _delayedSimpleClickTimeout;
  34688. private _previousDelayedSimpleClickTimeout;
  34689. private _meshPickProceed;
  34690. private _previousButtonPressed;
  34691. private _currentPickResult;
  34692. private _previousPickResult;
  34693. private _totalPointersPressed;
  34694. private _doubleClickOccured;
  34695. private _pointerOverMesh;
  34696. private _pickedDownMesh;
  34697. private _pickedUpMesh;
  34698. private _pointerX;
  34699. private _pointerY;
  34700. private _unTranslatedPointerX;
  34701. private _unTranslatedPointerY;
  34702. private _startingPointerPosition;
  34703. private _previousStartingPointerPosition;
  34704. private _startingPointerTime;
  34705. private _previousStartingPointerTime;
  34706. private _pointerCaptures;
  34707. private _onKeyDown;
  34708. private _onKeyUp;
  34709. private _onCanvasFocusObserver;
  34710. private _onCanvasBlurObserver;
  34711. private _scene;
  34712. /**
  34713. * Creates a new InputManager
  34714. * @param scene defines the hosting scene
  34715. */
  34716. constructor(scene: Scene);
  34717. /**
  34718. * Gets the mesh that is currently under the pointer
  34719. */
  34720. get meshUnderPointer(): Nullable<AbstractMesh>;
  34721. /**
  34722. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34723. */
  34724. get unTranslatedPointer(): Vector2;
  34725. /**
  34726. * Gets or sets the current on-screen X position of the pointer
  34727. */
  34728. get pointerX(): number;
  34729. set pointerX(value: number);
  34730. /**
  34731. * Gets or sets the current on-screen Y position of the pointer
  34732. */
  34733. get pointerY(): number;
  34734. set pointerY(value: number);
  34735. private _updatePointerPosition;
  34736. private _processPointerMove;
  34737. private _setRayOnPointerInfo;
  34738. private _checkPrePointerObservable;
  34739. /**
  34740. * Use this method to simulate a pointer move on a mesh
  34741. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34742. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34743. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34744. */
  34745. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34746. /**
  34747. * Use this method to simulate a pointer down on a mesh
  34748. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34749. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34750. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34751. */
  34752. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34753. private _processPointerDown;
  34754. /** @hidden */
  34755. _isPointerSwiping(): boolean;
  34756. /**
  34757. * Use this method to simulate a pointer up on a mesh
  34758. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34759. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34760. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34761. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34762. */
  34763. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34764. private _processPointerUp;
  34765. /**
  34766. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34767. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34768. * @returns true if the pointer was captured
  34769. */
  34770. isPointerCaptured(pointerId?: number): boolean;
  34771. /**
  34772. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34773. * @param attachUp defines if you want to attach events to pointerup
  34774. * @param attachDown defines if you want to attach events to pointerdown
  34775. * @param attachMove defines if you want to attach events to pointermove
  34776. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34777. */
  34778. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34779. /**
  34780. * Detaches all event handlers
  34781. */
  34782. detachControl(): void;
  34783. /**
  34784. * Force the value of meshUnderPointer
  34785. * @param mesh defines the mesh to use
  34786. */
  34787. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34788. /**
  34789. * Gets the mesh under the pointer
  34790. * @returns a Mesh or null if no mesh is under the pointer
  34791. */
  34792. getPointerOverMesh(): Nullable<AbstractMesh>;
  34793. }
  34794. }
  34795. declare module BABYLON {
  34796. /**
  34797. * Helper class used to generate session unique ID
  34798. */
  34799. export class UniqueIdGenerator {
  34800. private static _UniqueIdCounter;
  34801. /**
  34802. * Gets an unique (relatively to the current scene) Id
  34803. */
  34804. static get UniqueId(): number;
  34805. }
  34806. }
  34807. declare module BABYLON {
  34808. /**
  34809. * This class defines the direct association between an animation and a target
  34810. */
  34811. export class TargetedAnimation {
  34812. /**
  34813. * Animation to perform
  34814. */
  34815. animation: Animation;
  34816. /**
  34817. * Target to animate
  34818. */
  34819. target: any;
  34820. /**
  34821. * Serialize the object
  34822. * @returns the JSON object representing the current entity
  34823. */
  34824. serialize(): any;
  34825. }
  34826. /**
  34827. * Use this class to create coordinated animations on multiple targets
  34828. */
  34829. export class AnimationGroup implements IDisposable {
  34830. /** The name of the animation group */
  34831. name: string;
  34832. private _scene;
  34833. private _targetedAnimations;
  34834. private _animatables;
  34835. private _from;
  34836. private _to;
  34837. private _isStarted;
  34838. private _isPaused;
  34839. private _speedRatio;
  34840. private _loopAnimation;
  34841. /**
  34842. * Gets or sets the unique id of the node
  34843. */
  34844. uniqueId: number;
  34845. /**
  34846. * This observable will notify when one animation have ended
  34847. */
  34848. onAnimationEndObservable: Observable<TargetedAnimation>;
  34849. /**
  34850. * Observer raised when one animation loops
  34851. */
  34852. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34853. /**
  34854. * Observer raised when all animations have looped
  34855. */
  34856. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34857. /**
  34858. * This observable will notify when all animations have ended.
  34859. */
  34860. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34861. /**
  34862. * This observable will notify when all animations have paused.
  34863. */
  34864. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34865. /**
  34866. * This observable will notify when all animations are playing.
  34867. */
  34868. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34869. /**
  34870. * Gets the first frame
  34871. */
  34872. get from(): number;
  34873. /**
  34874. * Gets the last frame
  34875. */
  34876. get to(): number;
  34877. /**
  34878. * Define if the animations are started
  34879. */
  34880. get isStarted(): boolean;
  34881. /**
  34882. * Gets a value indicating that the current group is playing
  34883. */
  34884. get isPlaying(): boolean;
  34885. /**
  34886. * Gets or sets the speed ratio to use for all animations
  34887. */
  34888. get speedRatio(): number;
  34889. /**
  34890. * Gets or sets the speed ratio to use for all animations
  34891. */
  34892. set speedRatio(value: number);
  34893. /**
  34894. * Gets or sets if all animations should loop or not
  34895. */
  34896. get loopAnimation(): boolean;
  34897. set loopAnimation(value: boolean);
  34898. /**
  34899. * Gets the targeted animations for this animation group
  34900. */
  34901. get targetedAnimations(): Array<TargetedAnimation>;
  34902. /**
  34903. * returning the list of animatables controlled by this animation group.
  34904. */
  34905. get animatables(): Array<Animatable>;
  34906. /**
  34907. * Instantiates a new Animation Group.
  34908. * This helps managing several animations at once.
  34909. * @see http://doc.babylonjs.com/how_to/group
  34910. * @param name Defines the name of the group
  34911. * @param scene Defines the scene the group belongs to
  34912. */
  34913. constructor(
  34914. /** The name of the animation group */
  34915. name: string, scene?: Nullable<Scene>);
  34916. /**
  34917. * Add an animation (with its target) in the group
  34918. * @param animation defines the animation we want to add
  34919. * @param target defines the target of the animation
  34920. * @returns the TargetedAnimation object
  34921. */
  34922. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34923. /**
  34924. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34925. * It can add constant keys at begin or end
  34926. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34927. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34928. * @returns the animation group
  34929. */
  34930. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34931. private _animationLoopCount;
  34932. private _animationLoopFlags;
  34933. private _processLoop;
  34934. /**
  34935. * Start all animations on given targets
  34936. * @param loop defines if animations must loop
  34937. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34938. * @param from defines the from key (optional)
  34939. * @param to defines the to key (optional)
  34940. * @returns the current animation group
  34941. */
  34942. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34943. /**
  34944. * Pause all animations
  34945. * @returns the animation group
  34946. */
  34947. pause(): AnimationGroup;
  34948. /**
  34949. * Play all animations to initial state
  34950. * This function will start() the animations if they were not started or will restart() them if they were paused
  34951. * @param loop defines if animations must loop
  34952. * @returns the animation group
  34953. */
  34954. play(loop?: boolean): AnimationGroup;
  34955. /**
  34956. * Reset all animations to initial state
  34957. * @returns the animation group
  34958. */
  34959. reset(): AnimationGroup;
  34960. /**
  34961. * Restart animations from key 0
  34962. * @returns the animation group
  34963. */
  34964. restart(): AnimationGroup;
  34965. /**
  34966. * Stop all animations
  34967. * @returns the animation group
  34968. */
  34969. stop(): AnimationGroup;
  34970. /**
  34971. * Set animation weight for all animatables
  34972. * @param weight defines the weight to use
  34973. * @return the animationGroup
  34974. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34975. */
  34976. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34977. /**
  34978. * Synchronize and normalize all animatables with a source animatable
  34979. * @param root defines the root animatable to synchronize with
  34980. * @return the animationGroup
  34981. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34982. */
  34983. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34984. /**
  34985. * Goes to a specific frame in this animation group
  34986. * @param frame the frame number to go to
  34987. * @return the animationGroup
  34988. */
  34989. goToFrame(frame: number): AnimationGroup;
  34990. /**
  34991. * Dispose all associated resources
  34992. */
  34993. dispose(): void;
  34994. private _checkAnimationGroupEnded;
  34995. /**
  34996. * Clone the current animation group and returns a copy
  34997. * @param newName defines the name of the new group
  34998. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34999. * @returns the new aniamtion group
  35000. */
  35001. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35002. /**
  35003. * Serializes the animationGroup to an object
  35004. * @returns Serialized object
  35005. */
  35006. serialize(): any;
  35007. /**
  35008. * Returns a new AnimationGroup object parsed from the source provided.
  35009. * @param parsedAnimationGroup defines the source
  35010. * @param scene defines the scene that will receive the animationGroup
  35011. * @returns a new AnimationGroup
  35012. */
  35013. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35014. /**
  35015. * Returns the string "AnimationGroup"
  35016. * @returns "AnimationGroup"
  35017. */
  35018. getClassName(): string;
  35019. /**
  35020. * Creates a detailled string about the object
  35021. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35022. * @returns a string representing the object
  35023. */
  35024. toString(fullDetails?: boolean): string;
  35025. }
  35026. }
  35027. declare module BABYLON {
  35028. /**
  35029. * Define an interface for all classes that will hold resources
  35030. */
  35031. export interface IDisposable {
  35032. /**
  35033. * Releases all held resources
  35034. */
  35035. dispose(): void;
  35036. }
  35037. /** Interface defining initialization parameters for Scene class */
  35038. export interface SceneOptions {
  35039. /**
  35040. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35041. * It will improve performance when the number of geometries becomes important.
  35042. */
  35043. useGeometryUniqueIdsMap?: boolean;
  35044. /**
  35045. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35046. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35047. */
  35048. useMaterialMeshMap?: boolean;
  35049. /**
  35050. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35051. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35052. */
  35053. useClonedMeshMap?: boolean;
  35054. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35055. virtual?: boolean;
  35056. }
  35057. /**
  35058. * Represents a scene to be rendered by the engine.
  35059. * @see http://doc.babylonjs.com/features/scene
  35060. */
  35061. export class Scene extends AbstractScene implements IAnimatable {
  35062. /** The fog is deactivated */
  35063. static readonly FOGMODE_NONE: number;
  35064. /** The fog density is following an exponential function */
  35065. static readonly FOGMODE_EXP: number;
  35066. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35067. static readonly FOGMODE_EXP2: number;
  35068. /** The fog density is following a linear function. */
  35069. static readonly FOGMODE_LINEAR: number;
  35070. /**
  35071. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35072. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35073. */
  35074. static MinDeltaTime: number;
  35075. /**
  35076. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35077. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35078. */
  35079. static MaxDeltaTime: number;
  35080. /**
  35081. * Factory used to create the default material.
  35082. * @param name The name of the material to create
  35083. * @param scene The scene to create the material for
  35084. * @returns The default material
  35085. */
  35086. static DefaultMaterialFactory(scene: Scene): Material;
  35087. /**
  35088. * Factory used to create the a collision coordinator.
  35089. * @returns The collision coordinator
  35090. */
  35091. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35092. /** @hidden */
  35093. _inputManager: InputManager;
  35094. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35095. cameraToUseForPointers: Nullable<Camera>;
  35096. /** @hidden */
  35097. readonly _isScene: boolean;
  35098. /** @hidden */
  35099. _blockEntityCollection: boolean;
  35100. /**
  35101. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35102. */
  35103. autoClear: boolean;
  35104. /**
  35105. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35106. */
  35107. autoClearDepthAndStencil: boolean;
  35108. /**
  35109. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35110. */
  35111. clearColor: Color4;
  35112. /**
  35113. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35114. */
  35115. ambientColor: Color3;
  35116. /**
  35117. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35118. * It should only be one of the following (if not the default embedded one):
  35119. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35120. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35121. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35122. * The material properties need to be setup according to the type of texture in use.
  35123. */
  35124. environmentBRDFTexture: BaseTexture;
  35125. /** @hidden */
  35126. protected _environmentTexture: Nullable<BaseTexture>;
  35127. /**
  35128. * Texture used in all pbr material as the reflection texture.
  35129. * As in the majority of the scene they are the same (exception for multi room and so on),
  35130. * this is easier to reference from here than from all the materials.
  35131. */
  35132. get environmentTexture(): Nullable<BaseTexture>;
  35133. /**
  35134. * Texture used in all pbr material as the reflection texture.
  35135. * As in the majority of the scene they are the same (exception for multi room and so on),
  35136. * this is easier to set here than in all the materials.
  35137. */
  35138. set environmentTexture(value: Nullable<BaseTexture>);
  35139. /** @hidden */
  35140. protected _environmentIntensity: number;
  35141. /**
  35142. * Intensity of the environment in all pbr material.
  35143. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35144. * As in the majority of the scene they are the same (exception for multi room and so on),
  35145. * this is easier to reference from here than from all the materials.
  35146. */
  35147. get environmentIntensity(): number;
  35148. /**
  35149. * Intensity of the environment in all pbr material.
  35150. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35151. * As in the majority of the scene they are the same (exception for multi room and so on),
  35152. * this is easier to set here than in all the materials.
  35153. */
  35154. set environmentIntensity(value: number);
  35155. /** @hidden */
  35156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35157. /**
  35158. * Default image processing configuration used either in the rendering
  35159. * Forward main pass or through the imageProcessingPostProcess if present.
  35160. * As in the majority of the scene they are the same (exception for multi camera),
  35161. * this is easier to reference from here than from all the materials and post process.
  35162. *
  35163. * No setter as we it is a shared configuration, you can set the values instead.
  35164. */
  35165. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35166. private _forceWireframe;
  35167. /**
  35168. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35169. */
  35170. set forceWireframe(value: boolean);
  35171. get forceWireframe(): boolean;
  35172. private _skipFrustumClipping;
  35173. /**
  35174. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35175. */
  35176. set skipFrustumClipping(value: boolean);
  35177. get skipFrustumClipping(): boolean;
  35178. private _forcePointsCloud;
  35179. /**
  35180. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35181. */
  35182. set forcePointsCloud(value: boolean);
  35183. get forcePointsCloud(): boolean;
  35184. /**
  35185. * Gets or sets the active clipplane 1
  35186. */
  35187. clipPlane: Nullable<Plane>;
  35188. /**
  35189. * Gets or sets the active clipplane 2
  35190. */
  35191. clipPlane2: Nullable<Plane>;
  35192. /**
  35193. * Gets or sets the active clipplane 3
  35194. */
  35195. clipPlane3: Nullable<Plane>;
  35196. /**
  35197. * Gets or sets the active clipplane 4
  35198. */
  35199. clipPlane4: Nullable<Plane>;
  35200. /**
  35201. * Gets or sets the active clipplane 5
  35202. */
  35203. clipPlane5: Nullable<Plane>;
  35204. /**
  35205. * Gets or sets the active clipplane 6
  35206. */
  35207. clipPlane6: Nullable<Plane>;
  35208. /**
  35209. * Gets or sets a boolean indicating if animations are enabled
  35210. */
  35211. animationsEnabled: boolean;
  35212. private _animationPropertiesOverride;
  35213. /**
  35214. * Gets or sets the animation properties override
  35215. */
  35216. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35217. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35218. /**
  35219. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35220. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35221. */
  35222. useConstantAnimationDeltaTime: boolean;
  35223. /**
  35224. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35225. * Please note that it requires to run a ray cast through the scene on every frame
  35226. */
  35227. constantlyUpdateMeshUnderPointer: boolean;
  35228. /**
  35229. * Defines the HTML cursor to use when hovering over interactive elements
  35230. */
  35231. hoverCursor: string;
  35232. /**
  35233. * Defines the HTML default cursor to use (empty by default)
  35234. */
  35235. defaultCursor: string;
  35236. /**
  35237. * Defines whether cursors are handled by the scene.
  35238. */
  35239. doNotHandleCursors: boolean;
  35240. /**
  35241. * This is used to call preventDefault() on pointer down
  35242. * in order to block unwanted artifacts like system double clicks
  35243. */
  35244. preventDefaultOnPointerDown: boolean;
  35245. /**
  35246. * This is used to call preventDefault() on pointer up
  35247. * in order to block unwanted artifacts like system double clicks
  35248. */
  35249. preventDefaultOnPointerUp: boolean;
  35250. /**
  35251. * Gets or sets user defined metadata
  35252. */
  35253. metadata: any;
  35254. /**
  35255. * For internal use only. Please do not use.
  35256. */
  35257. reservedDataStore: any;
  35258. /**
  35259. * Gets the name of the plugin used to load this scene (null by default)
  35260. */
  35261. loadingPluginName: string;
  35262. /**
  35263. * Use this array to add regular expressions used to disable offline support for specific urls
  35264. */
  35265. disableOfflineSupportExceptionRules: RegExp[];
  35266. /**
  35267. * An event triggered when the scene is disposed.
  35268. */
  35269. onDisposeObservable: Observable<Scene>;
  35270. private _onDisposeObserver;
  35271. /** Sets a function to be executed when this scene is disposed. */
  35272. set onDispose(callback: () => void);
  35273. /**
  35274. * An event triggered before rendering the scene (right after animations and physics)
  35275. */
  35276. onBeforeRenderObservable: Observable<Scene>;
  35277. private _onBeforeRenderObserver;
  35278. /** Sets a function to be executed before rendering this scene */
  35279. set beforeRender(callback: Nullable<() => void>);
  35280. /**
  35281. * An event triggered after rendering the scene
  35282. */
  35283. onAfterRenderObservable: Observable<Scene>;
  35284. /**
  35285. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35286. */
  35287. onAfterRenderCameraObservable: Observable<Camera>;
  35288. private _onAfterRenderObserver;
  35289. /** Sets a function to be executed after rendering this scene */
  35290. set afterRender(callback: Nullable<() => void>);
  35291. /**
  35292. * An event triggered before animating the scene
  35293. */
  35294. onBeforeAnimationsObservable: Observable<Scene>;
  35295. /**
  35296. * An event triggered after animations processing
  35297. */
  35298. onAfterAnimationsObservable: Observable<Scene>;
  35299. /**
  35300. * An event triggered before draw calls are ready to be sent
  35301. */
  35302. onBeforeDrawPhaseObservable: Observable<Scene>;
  35303. /**
  35304. * An event triggered after draw calls have been sent
  35305. */
  35306. onAfterDrawPhaseObservable: Observable<Scene>;
  35307. /**
  35308. * An event triggered when the scene is ready
  35309. */
  35310. onReadyObservable: Observable<Scene>;
  35311. /**
  35312. * An event triggered before rendering a camera
  35313. */
  35314. onBeforeCameraRenderObservable: Observable<Camera>;
  35315. private _onBeforeCameraRenderObserver;
  35316. /** Sets a function to be executed before rendering a camera*/
  35317. set beforeCameraRender(callback: () => void);
  35318. /**
  35319. * An event triggered after rendering a camera
  35320. */
  35321. onAfterCameraRenderObservable: Observable<Camera>;
  35322. private _onAfterCameraRenderObserver;
  35323. /** Sets a function to be executed after rendering a camera*/
  35324. set afterCameraRender(callback: () => void);
  35325. /**
  35326. * An event triggered when active meshes evaluation is about to start
  35327. */
  35328. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35329. /**
  35330. * An event triggered when active meshes evaluation is done
  35331. */
  35332. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35333. /**
  35334. * An event triggered when particles rendering is about to start
  35335. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35336. */
  35337. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35338. /**
  35339. * An event triggered when particles rendering is done
  35340. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35341. */
  35342. onAfterParticlesRenderingObservable: Observable<Scene>;
  35343. /**
  35344. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35345. */
  35346. onDataLoadedObservable: Observable<Scene>;
  35347. /**
  35348. * An event triggered when a camera is created
  35349. */
  35350. onNewCameraAddedObservable: Observable<Camera>;
  35351. /**
  35352. * An event triggered when a camera is removed
  35353. */
  35354. onCameraRemovedObservable: Observable<Camera>;
  35355. /**
  35356. * An event triggered when a light is created
  35357. */
  35358. onNewLightAddedObservable: Observable<Light>;
  35359. /**
  35360. * An event triggered when a light is removed
  35361. */
  35362. onLightRemovedObservable: Observable<Light>;
  35363. /**
  35364. * An event triggered when a geometry is created
  35365. */
  35366. onNewGeometryAddedObservable: Observable<Geometry>;
  35367. /**
  35368. * An event triggered when a geometry is removed
  35369. */
  35370. onGeometryRemovedObservable: Observable<Geometry>;
  35371. /**
  35372. * An event triggered when a transform node is created
  35373. */
  35374. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35375. /**
  35376. * An event triggered when a transform node is removed
  35377. */
  35378. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35379. /**
  35380. * An event triggered when a mesh is created
  35381. */
  35382. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35383. /**
  35384. * An event triggered when a mesh is removed
  35385. */
  35386. onMeshRemovedObservable: Observable<AbstractMesh>;
  35387. /**
  35388. * An event triggered when a skeleton is created
  35389. */
  35390. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35391. /**
  35392. * An event triggered when a skeleton is removed
  35393. */
  35394. onSkeletonRemovedObservable: Observable<Skeleton>;
  35395. /**
  35396. * An event triggered when a material is created
  35397. */
  35398. onNewMaterialAddedObservable: Observable<Material>;
  35399. /**
  35400. * An event triggered when a material is removed
  35401. */
  35402. onMaterialRemovedObservable: Observable<Material>;
  35403. /**
  35404. * An event triggered when a texture is created
  35405. */
  35406. onNewTextureAddedObservable: Observable<BaseTexture>;
  35407. /**
  35408. * An event triggered when a texture is removed
  35409. */
  35410. onTextureRemovedObservable: Observable<BaseTexture>;
  35411. /**
  35412. * An event triggered when render targets are about to be rendered
  35413. * Can happen multiple times per frame.
  35414. */
  35415. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35416. /**
  35417. * An event triggered when render targets were rendered.
  35418. * Can happen multiple times per frame.
  35419. */
  35420. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35421. /**
  35422. * An event triggered before calculating deterministic simulation step
  35423. */
  35424. onBeforeStepObservable: Observable<Scene>;
  35425. /**
  35426. * An event triggered after calculating deterministic simulation step
  35427. */
  35428. onAfterStepObservable: Observable<Scene>;
  35429. /**
  35430. * An event triggered when the activeCamera property is updated
  35431. */
  35432. onActiveCameraChanged: Observable<Scene>;
  35433. /**
  35434. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35435. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35436. * 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)
  35437. */
  35438. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35439. /**
  35440. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35441. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35442. * 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)
  35443. */
  35444. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35445. /**
  35446. * This Observable will when a mesh has been imported into the scene.
  35447. */
  35448. onMeshImportedObservable: Observable<AbstractMesh>;
  35449. /**
  35450. * This Observable will when an animation file has been imported into the scene.
  35451. */
  35452. onAnimationFileImportedObservable: Observable<Scene>;
  35453. /**
  35454. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35455. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35456. */
  35457. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35458. /** @hidden */
  35459. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35460. /**
  35461. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35462. */
  35463. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35464. /**
  35465. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35466. */
  35467. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35468. /**
  35469. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35470. */
  35471. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35472. /** Callback called when a pointer move is detected */
  35473. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35474. /** Callback called when a pointer down is detected */
  35475. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35476. /** Callback called when a pointer up is detected */
  35477. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35478. /** Callback called when a pointer pick is detected */
  35479. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35480. /**
  35481. * 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).
  35482. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35483. */
  35484. onPrePointerObservable: Observable<PointerInfoPre>;
  35485. /**
  35486. * Observable event triggered each time an input event is received from the rendering canvas
  35487. */
  35488. onPointerObservable: Observable<PointerInfo>;
  35489. /**
  35490. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35491. */
  35492. get unTranslatedPointer(): Vector2;
  35493. /**
  35494. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35495. */
  35496. static get DragMovementThreshold(): number;
  35497. static set DragMovementThreshold(value: number);
  35498. /**
  35499. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35500. */
  35501. static get LongPressDelay(): number;
  35502. static set LongPressDelay(value: number);
  35503. /**
  35504. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35505. */
  35506. static get DoubleClickDelay(): number;
  35507. static set DoubleClickDelay(value: number);
  35508. /** If you need to check double click without raising a single click at first click, enable this flag */
  35509. static get ExclusiveDoubleClickMode(): boolean;
  35510. static set ExclusiveDoubleClickMode(value: boolean);
  35511. /** @hidden */
  35512. _mirroredCameraPosition: Nullable<Vector3>;
  35513. /**
  35514. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35515. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35516. */
  35517. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35518. /**
  35519. * Observable event triggered each time an keyboard event is received from the hosting window
  35520. */
  35521. onKeyboardObservable: Observable<KeyboardInfo>;
  35522. private _useRightHandedSystem;
  35523. /**
  35524. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35525. */
  35526. set useRightHandedSystem(value: boolean);
  35527. get useRightHandedSystem(): boolean;
  35528. private _timeAccumulator;
  35529. private _currentStepId;
  35530. private _currentInternalStep;
  35531. /**
  35532. * Sets the step Id used by deterministic lock step
  35533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35534. * @param newStepId defines the step Id
  35535. */
  35536. setStepId(newStepId: number): void;
  35537. /**
  35538. * Gets the step Id used by deterministic lock step
  35539. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35540. * @returns the step Id
  35541. */
  35542. getStepId(): number;
  35543. /**
  35544. * Gets the internal step used by deterministic lock step
  35545. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35546. * @returns the internal step
  35547. */
  35548. getInternalStep(): number;
  35549. private _fogEnabled;
  35550. /**
  35551. * Gets or sets a boolean indicating if fog is enabled on this scene
  35552. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35553. * (Default is true)
  35554. */
  35555. set fogEnabled(value: boolean);
  35556. get fogEnabled(): boolean;
  35557. private _fogMode;
  35558. /**
  35559. * Gets or sets the fog mode to use
  35560. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35561. * | mode | value |
  35562. * | --- | --- |
  35563. * | FOGMODE_NONE | 0 |
  35564. * | FOGMODE_EXP | 1 |
  35565. * | FOGMODE_EXP2 | 2 |
  35566. * | FOGMODE_LINEAR | 3 |
  35567. */
  35568. set fogMode(value: number);
  35569. get fogMode(): number;
  35570. /**
  35571. * Gets or sets the fog color to use
  35572. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35573. * (Default is Color3(0.2, 0.2, 0.3))
  35574. */
  35575. fogColor: Color3;
  35576. /**
  35577. * Gets or sets the fog density to use
  35578. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35579. * (Default is 0.1)
  35580. */
  35581. fogDensity: number;
  35582. /**
  35583. * Gets or sets the fog start distance to use
  35584. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35585. * (Default is 0)
  35586. */
  35587. fogStart: number;
  35588. /**
  35589. * Gets or sets the fog end distance to use
  35590. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35591. * (Default is 1000)
  35592. */
  35593. fogEnd: number;
  35594. private _shadowsEnabled;
  35595. /**
  35596. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35597. */
  35598. set shadowsEnabled(value: boolean);
  35599. get shadowsEnabled(): boolean;
  35600. private _lightsEnabled;
  35601. /**
  35602. * Gets or sets a boolean indicating if lights are enabled on this scene
  35603. */
  35604. set lightsEnabled(value: boolean);
  35605. get lightsEnabled(): boolean;
  35606. /** All of the active cameras added to this scene. */
  35607. activeCameras: Camera[];
  35608. /** @hidden */
  35609. _activeCamera: Nullable<Camera>;
  35610. /** Gets or sets the current active camera */
  35611. get activeCamera(): Nullable<Camera>;
  35612. set activeCamera(value: Nullable<Camera>);
  35613. private _defaultMaterial;
  35614. /** The default material used on meshes when no material is affected */
  35615. get defaultMaterial(): Material;
  35616. /** The default material used on meshes when no material is affected */
  35617. set defaultMaterial(value: Material);
  35618. private _texturesEnabled;
  35619. /**
  35620. * Gets or sets a boolean indicating if textures are enabled on this scene
  35621. */
  35622. set texturesEnabled(value: boolean);
  35623. get texturesEnabled(): boolean;
  35624. /**
  35625. * Gets or sets a boolean indicating if particles are enabled on this scene
  35626. */
  35627. particlesEnabled: boolean;
  35628. /**
  35629. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35630. */
  35631. spritesEnabled: boolean;
  35632. private _skeletonsEnabled;
  35633. /**
  35634. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35635. */
  35636. set skeletonsEnabled(value: boolean);
  35637. get skeletonsEnabled(): boolean;
  35638. /**
  35639. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35640. */
  35641. lensFlaresEnabled: boolean;
  35642. /**
  35643. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35644. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35645. */
  35646. collisionsEnabled: boolean;
  35647. private _collisionCoordinator;
  35648. /** @hidden */
  35649. get collisionCoordinator(): ICollisionCoordinator;
  35650. /**
  35651. * Defines the gravity applied to this scene (used only for collisions)
  35652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35653. */
  35654. gravity: Vector3;
  35655. /**
  35656. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35657. */
  35658. postProcessesEnabled: boolean;
  35659. /**
  35660. * The list of postprocesses added to the scene
  35661. */
  35662. postProcesses: PostProcess[];
  35663. /**
  35664. * Gets the current postprocess manager
  35665. */
  35666. postProcessManager: PostProcessManager;
  35667. /**
  35668. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35669. */
  35670. renderTargetsEnabled: boolean;
  35671. /**
  35672. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35673. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35674. */
  35675. dumpNextRenderTargets: boolean;
  35676. /**
  35677. * The list of user defined render targets added to the scene
  35678. */
  35679. customRenderTargets: RenderTargetTexture[];
  35680. /**
  35681. * Defines if texture loading must be delayed
  35682. * If true, textures will only be loaded when they need to be rendered
  35683. */
  35684. useDelayedTextureLoading: boolean;
  35685. /**
  35686. * Gets the list of meshes imported to the scene through SceneLoader
  35687. */
  35688. importedMeshesFiles: String[];
  35689. /**
  35690. * Gets or sets a boolean indicating if probes are enabled on this scene
  35691. */
  35692. probesEnabled: boolean;
  35693. /**
  35694. * Gets or sets the current offline provider to use to store scene data
  35695. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35696. */
  35697. offlineProvider: IOfflineProvider;
  35698. /**
  35699. * Gets or sets the action manager associated with the scene
  35700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35701. */
  35702. actionManager: AbstractActionManager;
  35703. private _meshesForIntersections;
  35704. /**
  35705. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35706. */
  35707. proceduralTexturesEnabled: boolean;
  35708. private _engine;
  35709. private _totalVertices;
  35710. /** @hidden */
  35711. _activeIndices: PerfCounter;
  35712. /** @hidden */
  35713. _activeParticles: PerfCounter;
  35714. /** @hidden */
  35715. _activeBones: PerfCounter;
  35716. private _animationRatio;
  35717. /** @hidden */
  35718. _animationTimeLast: number;
  35719. /** @hidden */
  35720. _animationTime: number;
  35721. /**
  35722. * Gets or sets a general scale for animation speed
  35723. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35724. */
  35725. animationTimeScale: number;
  35726. /** @hidden */
  35727. _cachedMaterial: Nullable<Material>;
  35728. /** @hidden */
  35729. _cachedEffect: Nullable<Effect>;
  35730. /** @hidden */
  35731. _cachedVisibility: Nullable<number>;
  35732. private _renderId;
  35733. private _frameId;
  35734. private _executeWhenReadyTimeoutId;
  35735. private _intermediateRendering;
  35736. private _viewUpdateFlag;
  35737. private _projectionUpdateFlag;
  35738. /** @hidden */
  35739. _toBeDisposed: Nullable<IDisposable>[];
  35740. private _activeRequests;
  35741. /** @hidden */
  35742. _pendingData: any[];
  35743. private _isDisposed;
  35744. /**
  35745. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35746. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35747. */
  35748. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35749. private _activeMeshes;
  35750. private _processedMaterials;
  35751. private _renderTargets;
  35752. /** @hidden */
  35753. _activeParticleSystems: SmartArray<IParticleSystem>;
  35754. private _activeSkeletons;
  35755. private _softwareSkinnedMeshes;
  35756. private _renderingManager;
  35757. /** @hidden */
  35758. _activeAnimatables: Animatable[];
  35759. private _transformMatrix;
  35760. private _sceneUbo;
  35761. /** @hidden */
  35762. _viewMatrix: Matrix;
  35763. private _projectionMatrix;
  35764. /** @hidden */
  35765. _forcedViewPosition: Nullable<Vector3>;
  35766. /** @hidden */
  35767. _frustumPlanes: Plane[];
  35768. /**
  35769. * Gets the list of frustum planes (built from the active camera)
  35770. */
  35771. get frustumPlanes(): Plane[];
  35772. /**
  35773. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35774. * This is useful if there are more lights that the maximum simulteanous authorized
  35775. */
  35776. requireLightSorting: boolean;
  35777. /** @hidden */
  35778. readonly useMaterialMeshMap: boolean;
  35779. /** @hidden */
  35780. readonly useClonedMeshMap: boolean;
  35781. private _externalData;
  35782. private _uid;
  35783. /**
  35784. * @hidden
  35785. * Backing store of defined scene components.
  35786. */
  35787. _components: ISceneComponent[];
  35788. /**
  35789. * @hidden
  35790. * Backing store of defined scene components.
  35791. */
  35792. _serializableComponents: ISceneSerializableComponent[];
  35793. /**
  35794. * List of components to register on the next registration step.
  35795. */
  35796. private _transientComponents;
  35797. /**
  35798. * Registers the transient components if needed.
  35799. */
  35800. private _registerTransientComponents;
  35801. /**
  35802. * @hidden
  35803. * Add a component to the scene.
  35804. * Note that the ccomponent could be registered on th next frame if this is called after
  35805. * the register component stage.
  35806. * @param component Defines the component to add to the scene
  35807. */
  35808. _addComponent(component: ISceneComponent): void;
  35809. /**
  35810. * @hidden
  35811. * Gets a component from the scene.
  35812. * @param name defines the name of the component to retrieve
  35813. * @returns the component or null if not present
  35814. */
  35815. _getComponent(name: string): Nullable<ISceneComponent>;
  35816. /**
  35817. * @hidden
  35818. * Defines the actions happening before camera updates.
  35819. */
  35820. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35821. /**
  35822. * @hidden
  35823. * Defines the actions happening before clear the canvas.
  35824. */
  35825. _beforeClearStage: Stage<SimpleStageAction>;
  35826. /**
  35827. * @hidden
  35828. * Defines the actions when collecting render targets for the frame.
  35829. */
  35830. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35831. /**
  35832. * @hidden
  35833. * Defines the actions happening for one camera in the frame.
  35834. */
  35835. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35836. /**
  35837. * @hidden
  35838. * Defines the actions happening during the per mesh ready checks.
  35839. */
  35840. _isReadyForMeshStage: Stage<MeshStageAction>;
  35841. /**
  35842. * @hidden
  35843. * Defines the actions happening before evaluate active mesh checks.
  35844. */
  35845. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35846. /**
  35847. * @hidden
  35848. * Defines the actions happening during the evaluate sub mesh checks.
  35849. */
  35850. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35851. /**
  35852. * @hidden
  35853. * Defines the actions happening during the active mesh stage.
  35854. */
  35855. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35856. /**
  35857. * @hidden
  35858. * Defines the actions happening during the per camera render target step.
  35859. */
  35860. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35861. /**
  35862. * @hidden
  35863. * Defines the actions happening just before the active camera is drawing.
  35864. */
  35865. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35866. /**
  35867. * @hidden
  35868. * Defines the actions happening just before a render target is drawing.
  35869. */
  35870. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35871. /**
  35872. * @hidden
  35873. * Defines the actions happening just before a rendering group is drawing.
  35874. */
  35875. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35876. /**
  35877. * @hidden
  35878. * Defines the actions happening just before a mesh is drawing.
  35879. */
  35880. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35881. /**
  35882. * @hidden
  35883. * Defines the actions happening just after a mesh has been drawn.
  35884. */
  35885. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35886. /**
  35887. * @hidden
  35888. * Defines the actions happening just after a rendering group has been drawn.
  35889. */
  35890. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35891. /**
  35892. * @hidden
  35893. * Defines the actions happening just after the active camera has been drawn.
  35894. */
  35895. _afterCameraDrawStage: Stage<CameraStageAction>;
  35896. /**
  35897. * @hidden
  35898. * Defines the actions happening just after a render target has been drawn.
  35899. */
  35900. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35901. /**
  35902. * @hidden
  35903. * Defines the actions happening just after rendering all cameras and computing intersections.
  35904. */
  35905. _afterRenderStage: Stage<SimpleStageAction>;
  35906. /**
  35907. * @hidden
  35908. * Defines the actions happening when a pointer move event happens.
  35909. */
  35910. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35911. /**
  35912. * @hidden
  35913. * Defines the actions happening when a pointer down event happens.
  35914. */
  35915. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35916. /**
  35917. * @hidden
  35918. * Defines the actions happening when a pointer up event happens.
  35919. */
  35920. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35921. /**
  35922. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35923. */
  35924. private geometriesByUniqueId;
  35925. /**
  35926. * Creates a new Scene
  35927. * @param engine defines the engine to use to render this scene
  35928. * @param options defines the scene options
  35929. */
  35930. constructor(engine: Engine, options?: SceneOptions);
  35931. /**
  35932. * Gets a string idenfifying the name of the class
  35933. * @returns "Scene" string
  35934. */
  35935. getClassName(): string;
  35936. private _defaultMeshCandidates;
  35937. /**
  35938. * @hidden
  35939. */
  35940. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35941. private _defaultSubMeshCandidates;
  35942. /**
  35943. * @hidden
  35944. */
  35945. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35946. /**
  35947. * Sets the default candidate providers for the scene.
  35948. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35949. * and getCollidingSubMeshCandidates to their default function
  35950. */
  35951. setDefaultCandidateProviders(): void;
  35952. /**
  35953. * Gets the mesh that is currently under the pointer
  35954. */
  35955. get meshUnderPointer(): Nullable<AbstractMesh>;
  35956. /**
  35957. * Gets or sets the current on-screen X position of the pointer
  35958. */
  35959. get pointerX(): number;
  35960. set pointerX(value: number);
  35961. /**
  35962. * Gets or sets the current on-screen Y position of the pointer
  35963. */
  35964. get pointerY(): number;
  35965. set pointerY(value: number);
  35966. /**
  35967. * Gets the cached material (ie. the latest rendered one)
  35968. * @returns the cached material
  35969. */
  35970. getCachedMaterial(): Nullable<Material>;
  35971. /**
  35972. * Gets the cached effect (ie. the latest rendered one)
  35973. * @returns the cached effect
  35974. */
  35975. getCachedEffect(): Nullable<Effect>;
  35976. /**
  35977. * Gets the cached visibility state (ie. the latest rendered one)
  35978. * @returns the cached visibility state
  35979. */
  35980. getCachedVisibility(): Nullable<number>;
  35981. /**
  35982. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35983. * @param material defines the current material
  35984. * @param effect defines the current effect
  35985. * @param visibility defines the current visibility state
  35986. * @returns true if one parameter is not cached
  35987. */
  35988. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35989. /**
  35990. * Gets the engine associated with the scene
  35991. * @returns an Engine
  35992. */
  35993. getEngine(): Engine;
  35994. /**
  35995. * Gets the total number of vertices rendered per frame
  35996. * @returns the total number of vertices rendered per frame
  35997. */
  35998. getTotalVertices(): number;
  35999. /**
  36000. * Gets the performance counter for total vertices
  36001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36002. */
  36003. get totalVerticesPerfCounter(): PerfCounter;
  36004. /**
  36005. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36006. * @returns the total number of active indices rendered per frame
  36007. */
  36008. getActiveIndices(): number;
  36009. /**
  36010. * Gets the performance counter for active indices
  36011. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36012. */
  36013. get totalActiveIndicesPerfCounter(): PerfCounter;
  36014. /**
  36015. * Gets the total number of active particles rendered per frame
  36016. * @returns the total number of active particles rendered per frame
  36017. */
  36018. getActiveParticles(): number;
  36019. /**
  36020. * Gets the performance counter for active particles
  36021. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36022. */
  36023. get activeParticlesPerfCounter(): PerfCounter;
  36024. /**
  36025. * Gets the total number of active bones rendered per frame
  36026. * @returns the total number of active bones rendered per frame
  36027. */
  36028. getActiveBones(): number;
  36029. /**
  36030. * Gets the performance counter for active bones
  36031. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36032. */
  36033. get activeBonesPerfCounter(): PerfCounter;
  36034. /**
  36035. * Gets the array of active meshes
  36036. * @returns an array of AbstractMesh
  36037. */
  36038. getActiveMeshes(): SmartArray<AbstractMesh>;
  36039. /**
  36040. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36041. * @returns a number
  36042. */
  36043. getAnimationRatio(): number;
  36044. /**
  36045. * Gets an unique Id for the current render phase
  36046. * @returns a number
  36047. */
  36048. getRenderId(): number;
  36049. /**
  36050. * Gets an unique Id for the current frame
  36051. * @returns a number
  36052. */
  36053. getFrameId(): number;
  36054. /** Call this function if you want to manually increment the render Id*/
  36055. incrementRenderId(): void;
  36056. private _createUbo;
  36057. /**
  36058. * Use this method to simulate a pointer move on a mesh
  36059. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36060. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36061. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36062. * @returns the current scene
  36063. */
  36064. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36065. /**
  36066. * Use this method to simulate a pointer down on a mesh
  36067. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36068. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36069. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36070. * @returns the current scene
  36071. */
  36072. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36073. /**
  36074. * Use this method to simulate a pointer up on a mesh
  36075. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36076. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36077. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36078. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36079. * @returns the current scene
  36080. */
  36081. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36082. /**
  36083. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36084. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36085. * @returns true if the pointer was captured
  36086. */
  36087. isPointerCaptured(pointerId?: number): boolean;
  36088. /**
  36089. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36090. * @param attachUp defines if you want to attach events to pointerup
  36091. * @param attachDown defines if you want to attach events to pointerdown
  36092. * @param attachMove defines if you want to attach events to pointermove
  36093. */
  36094. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36095. /** Detaches all event handlers*/
  36096. detachControl(): void;
  36097. /**
  36098. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36099. * Delay loaded resources are not taking in account
  36100. * @return true if all required resources are ready
  36101. */
  36102. isReady(): boolean;
  36103. /** Resets all cached information relative to material (including effect and visibility) */
  36104. resetCachedMaterial(): void;
  36105. /**
  36106. * Registers a function to be called before every frame render
  36107. * @param func defines the function to register
  36108. */
  36109. registerBeforeRender(func: () => void): void;
  36110. /**
  36111. * Unregisters a function called before every frame render
  36112. * @param func defines the function to unregister
  36113. */
  36114. unregisterBeforeRender(func: () => void): void;
  36115. /**
  36116. * Registers a function to be called after every frame render
  36117. * @param func defines the function to register
  36118. */
  36119. registerAfterRender(func: () => void): void;
  36120. /**
  36121. * Unregisters a function called after every frame render
  36122. * @param func defines the function to unregister
  36123. */
  36124. unregisterAfterRender(func: () => void): void;
  36125. private _executeOnceBeforeRender;
  36126. /**
  36127. * The provided function will run before render once and will be disposed afterwards.
  36128. * A timeout delay can be provided so that the function will be executed in N ms.
  36129. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36130. * @param func The function to be executed.
  36131. * @param timeout optional delay in ms
  36132. */
  36133. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36134. /** @hidden */
  36135. _addPendingData(data: any): void;
  36136. /** @hidden */
  36137. _removePendingData(data: any): void;
  36138. /**
  36139. * Returns the number of items waiting to be loaded
  36140. * @returns the number of items waiting to be loaded
  36141. */
  36142. getWaitingItemsCount(): number;
  36143. /**
  36144. * Returns a boolean indicating if the scene is still loading data
  36145. */
  36146. get isLoading(): boolean;
  36147. /**
  36148. * Registers a function to be executed when the scene is ready
  36149. * @param {Function} func - the function to be executed
  36150. */
  36151. executeWhenReady(func: () => void): void;
  36152. /**
  36153. * Returns a promise that resolves when the scene is ready
  36154. * @returns A promise that resolves when the scene is ready
  36155. */
  36156. whenReadyAsync(): Promise<void>;
  36157. /** @hidden */
  36158. _checkIsReady(): void;
  36159. /**
  36160. * Gets all animatable attached to the scene
  36161. */
  36162. get animatables(): Animatable[];
  36163. /**
  36164. * Resets the last animation time frame.
  36165. * Useful to override when animations start running when loading a scene for the first time.
  36166. */
  36167. resetLastAnimationTimeFrame(): void;
  36168. /**
  36169. * Gets the current view matrix
  36170. * @returns a Matrix
  36171. */
  36172. getViewMatrix(): Matrix;
  36173. /**
  36174. * Gets the current projection matrix
  36175. * @returns a Matrix
  36176. */
  36177. getProjectionMatrix(): Matrix;
  36178. /**
  36179. * Gets the current transform matrix
  36180. * @returns a Matrix made of View * Projection
  36181. */
  36182. getTransformMatrix(): Matrix;
  36183. /**
  36184. * Sets the current transform matrix
  36185. * @param viewL defines the View matrix to use
  36186. * @param projectionL defines the Projection matrix to use
  36187. * @param viewR defines the right View matrix to use (if provided)
  36188. * @param projectionR defines the right Projection matrix to use (if provided)
  36189. */
  36190. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36191. /**
  36192. * Gets the uniform buffer used to store scene data
  36193. * @returns a UniformBuffer
  36194. */
  36195. getSceneUniformBuffer(): UniformBuffer;
  36196. /**
  36197. * Gets an unique (relatively to the current scene) Id
  36198. * @returns an unique number for the scene
  36199. */
  36200. getUniqueId(): number;
  36201. /**
  36202. * Add a mesh to the list of scene's meshes
  36203. * @param newMesh defines the mesh to add
  36204. * @param recursive if all child meshes should also be added to the scene
  36205. */
  36206. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36207. /**
  36208. * Remove a mesh for the list of scene's meshes
  36209. * @param toRemove defines the mesh to remove
  36210. * @param recursive if all child meshes should also be removed from the scene
  36211. * @returns the index where the mesh was in the mesh list
  36212. */
  36213. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36214. /**
  36215. * Add a transform node to the list of scene's transform nodes
  36216. * @param newTransformNode defines the transform node to add
  36217. */
  36218. addTransformNode(newTransformNode: TransformNode): void;
  36219. /**
  36220. * Remove a transform node for the list of scene's transform nodes
  36221. * @param toRemove defines the transform node to remove
  36222. * @returns the index where the transform node was in the transform node list
  36223. */
  36224. removeTransformNode(toRemove: TransformNode): number;
  36225. /**
  36226. * Remove a skeleton for the list of scene's skeletons
  36227. * @param toRemove defines the skeleton to remove
  36228. * @returns the index where the skeleton was in the skeleton list
  36229. */
  36230. removeSkeleton(toRemove: Skeleton): number;
  36231. /**
  36232. * Remove a morph target for the list of scene's morph targets
  36233. * @param toRemove defines the morph target to remove
  36234. * @returns the index where the morph target was in the morph target list
  36235. */
  36236. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36237. /**
  36238. * Remove a light for the list of scene's lights
  36239. * @param toRemove defines the light to remove
  36240. * @returns the index where the light was in the light list
  36241. */
  36242. removeLight(toRemove: Light): number;
  36243. /**
  36244. * Remove a camera for the list of scene's cameras
  36245. * @param toRemove defines the camera to remove
  36246. * @returns the index where the camera was in the camera list
  36247. */
  36248. removeCamera(toRemove: Camera): number;
  36249. /**
  36250. * Remove a particle system for the list of scene's particle systems
  36251. * @param toRemove defines the particle system to remove
  36252. * @returns the index where the particle system was in the particle system list
  36253. */
  36254. removeParticleSystem(toRemove: IParticleSystem): number;
  36255. /**
  36256. * Remove a animation for the list of scene's animations
  36257. * @param toRemove defines the animation to remove
  36258. * @returns the index where the animation was in the animation list
  36259. */
  36260. removeAnimation(toRemove: Animation): number;
  36261. /**
  36262. * Will stop the animation of the given target
  36263. * @param target - the target
  36264. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36265. * @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)
  36266. */
  36267. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36268. /**
  36269. * Removes the given animation group from this scene.
  36270. * @param toRemove The animation group to remove
  36271. * @returns The index of the removed animation group
  36272. */
  36273. removeAnimationGroup(toRemove: AnimationGroup): number;
  36274. /**
  36275. * Removes the given multi-material from this scene.
  36276. * @param toRemove The multi-material to remove
  36277. * @returns The index of the removed multi-material
  36278. */
  36279. removeMultiMaterial(toRemove: MultiMaterial): number;
  36280. /**
  36281. * Removes the given material from this scene.
  36282. * @param toRemove The material to remove
  36283. * @returns The index of the removed material
  36284. */
  36285. removeMaterial(toRemove: Material): number;
  36286. /**
  36287. * Removes the given action manager from this scene.
  36288. * @param toRemove The action manager to remove
  36289. * @returns The index of the removed action manager
  36290. */
  36291. removeActionManager(toRemove: AbstractActionManager): number;
  36292. /**
  36293. * Removes the given texture from this scene.
  36294. * @param toRemove The texture to remove
  36295. * @returns The index of the removed texture
  36296. */
  36297. removeTexture(toRemove: BaseTexture): number;
  36298. /**
  36299. * Adds the given light to this scene
  36300. * @param newLight The light to add
  36301. */
  36302. addLight(newLight: Light): void;
  36303. /**
  36304. * Sorts the list list based on light priorities
  36305. */
  36306. sortLightsByPriority(): void;
  36307. /**
  36308. * Adds the given camera to this scene
  36309. * @param newCamera The camera to add
  36310. */
  36311. addCamera(newCamera: Camera): void;
  36312. /**
  36313. * Adds the given skeleton to this scene
  36314. * @param newSkeleton The skeleton to add
  36315. */
  36316. addSkeleton(newSkeleton: Skeleton): void;
  36317. /**
  36318. * Adds the given particle system to this scene
  36319. * @param newParticleSystem The particle system to add
  36320. */
  36321. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36322. /**
  36323. * Adds the given animation to this scene
  36324. * @param newAnimation The animation to add
  36325. */
  36326. addAnimation(newAnimation: Animation): void;
  36327. /**
  36328. * Adds the given animation group to this scene.
  36329. * @param newAnimationGroup The animation group to add
  36330. */
  36331. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36332. /**
  36333. * Adds the given multi-material to this scene
  36334. * @param newMultiMaterial The multi-material to add
  36335. */
  36336. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36337. /**
  36338. * Adds the given material to this scene
  36339. * @param newMaterial The material to add
  36340. */
  36341. addMaterial(newMaterial: Material): void;
  36342. /**
  36343. * Adds the given morph target to this scene
  36344. * @param newMorphTargetManager The morph target to add
  36345. */
  36346. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36347. /**
  36348. * Adds the given geometry to this scene
  36349. * @param newGeometry The geometry to add
  36350. */
  36351. addGeometry(newGeometry: Geometry): void;
  36352. /**
  36353. * Adds the given action manager to this scene
  36354. * @param newActionManager The action manager to add
  36355. */
  36356. addActionManager(newActionManager: AbstractActionManager): void;
  36357. /**
  36358. * Adds the given texture to this scene.
  36359. * @param newTexture The texture to add
  36360. */
  36361. addTexture(newTexture: BaseTexture): void;
  36362. /**
  36363. * Switch active camera
  36364. * @param newCamera defines the new active camera
  36365. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36366. */
  36367. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36368. /**
  36369. * sets the active camera of the scene using its ID
  36370. * @param id defines the camera's ID
  36371. * @return the new active camera or null if none found.
  36372. */
  36373. setActiveCameraByID(id: string): Nullable<Camera>;
  36374. /**
  36375. * sets the active camera of the scene using its name
  36376. * @param name defines the camera's name
  36377. * @returns the new active camera or null if none found.
  36378. */
  36379. setActiveCameraByName(name: string): Nullable<Camera>;
  36380. /**
  36381. * get an animation group using its name
  36382. * @param name defines the material's name
  36383. * @return the animation group or null if none found.
  36384. */
  36385. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36386. /**
  36387. * Get a material using its unique id
  36388. * @param uniqueId defines the material's unique id
  36389. * @return the material or null if none found.
  36390. */
  36391. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36392. /**
  36393. * get a material using its id
  36394. * @param id defines the material's ID
  36395. * @return the material or null if none found.
  36396. */
  36397. getMaterialByID(id: string): Nullable<Material>;
  36398. /**
  36399. * Gets a the last added material using a given id
  36400. * @param id defines the material's ID
  36401. * @return the last material with the given id or null if none found.
  36402. */
  36403. getLastMaterialByID(id: string): Nullable<Material>;
  36404. /**
  36405. * Gets a material using its name
  36406. * @param name defines the material's name
  36407. * @return the material or null if none found.
  36408. */
  36409. getMaterialByName(name: string): Nullable<Material>;
  36410. /**
  36411. * Get a texture using its unique id
  36412. * @param uniqueId defines the texture's unique id
  36413. * @return the texture or null if none found.
  36414. */
  36415. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36416. /**
  36417. * Gets a camera using its id
  36418. * @param id defines the id to look for
  36419. * @returns the camera or null if not found
  36420. */
  36421. getCameraByID(id: string): Nullable<Camera>;
  36422. /**
  36423. * Gets a camera using its unique id
  36424. * @param uniqueId defines the unique id to look for
  36425. * @returns the camera or null if not found
  36426. */
  36427. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36428. /**
  36429. * Gets a camera using its name
  36430. * @param name defines the camera's name
  36431. * @return the camera or null if none found.
  36432. */
  36433. getCameraByName(name: string): Nullable<Camera>;
  36434. /**
  36435. * Gets a bone using its id
  36436. * @param id defines the bone's id
  36437. * @return the bone or null if not found
  36438. */
  36439. getBoneByID(id: string): Nullable<Bone>;
  36440. /**
  36441. * Gets a bone using its id
  36442. * @param name defines the bone's name
  36443. * @return the bone or null if not found
  36444. */
  36445. getBoneByName(name: string): Nullable<Bone>;
  36446. /**
  36447. * Gets a light node using its name
  36448. * @param name defines the the light's name
  36449. * @return the light or null if none found.
  36450. */
  36451. getLightByName(name: string): Nullable<Light>;
  36452. /**
  36453. * Gets a light node using its id
  36454. * @param id defines the light's id
  36455. * @return the light or null if none found.
  36456. */
  36457. getLightByID(id: string): Nullable<Light>;
  36458. /**
  36459. * Gets a light node using its scene-generated unique ID
  36460. * @param uniqueId defines the light's unique id
  36461. * @return the light or null if none found.
  36462. */
  36463. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36464. /**
  36465. * Gets a particle system by id
  36466. * @param id defines the particle system id
  36467. * @return the corresponding system or null if none found
  36468. */
  36469. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36470. /**
  36471. * Gets a geometry using its ID
  36472. * @param id defines the geometry's id
  36473. * @return the geometry or null if none found.
  36474. */
  36475. getGeometryByID(id: string): Nullable<Geometry>;
  36476. private _getGeometryByUniqueID;
  36477. /**
  36478. * Add a new geometry to this scene
  36479. * @param geometry defines the geometry to be added to the scene.
  36480. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36481. * @return a boolean defining if the geometry was added or not
  36482. */
  36483. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36484. /**
  36485. * Removes an existing geometry
  36486. * @param geometry defines the geometry to be removed from the scene
  36487. * @return a boolean defining if the geometry was removed or not
  36488. */
  36489. removeGeometry(geometry: Geometry): boolean;
  36490. /**
  36491. * Gets the list of geometries attached to the scene
  36492. * @returns an array of Geometry
  36493. */
  36494. getGeometries(): Geometry[];
  36495. /**
  36496. * Gets the first added mesh found of a given ID
  36497. * @param id defines the id to search for
  36498. * @return the mesh found or null if not found at all
  36499. */
  36500. getMeshByID(id: string): Nullable<AbstractMesh>;
  36501. /**
  36502. * Gets a list of meshes using their id
  36503. * @param id defines the id to search for
  36504. * @returns a list of meshes
  36505. */
  36506. getMeshesByID(id: string): Array<AbstractMesh>;
  36507. /**
  36508. * Gets the first added transform node found of a given ID
  36509. * @param id defines the id to search for
  36510. * @return the found transform node or null if not found at all.
  36511. */
  36512. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36513. /**
  36514. * Gets a transform node with its auto-generated unique id
  36515. * @param uniqueId efines the unique id to search for
  36516. * @return the found transform node or null if not found at all.
  36517. */
  36518. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36519. /**
  36520. * Gets a list of transform nodes using their id
  36521. * @param id defines the id to search for
  36522. * @returns a list of transform nodes
  36523. */
  36524. getTransformNodesByID(id: string): Array<TransformNode>;
  36525. /**
  36526. * Gets a mesh with its auto-generated unique id
  36527. * @param uniqueId defines the unique id to search for
  36528. * @return the found mesh or null if not found at all.
  36529. */
  36530. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36531. /**
  36532. * Gets a the last added mesh using a given id
  36533. * @param id defines the id to search for
  36534. * @return the found mesh or null if not found at all.
  36535. */
  36536. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36537. /**
  36538. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36539. * @param id defines the id to search for
  36540. * @return the found node or null if not found at all
  36541. */
  36542. getLastEntryByID(id: string): Nullable<Node>;
  36543. /**
  36544. * Gets a node (Mesh, Camera, Light) using a given id
  36545. * @param id defines the id to search for
  36546. * @return the found node or null if not found at all
  36547. */
  36548. getNodeByID(id: string): Nullable<Node>;
  36549. /**
  36550. * Gets a node (Mesh, Camera, Light) using a given name
  36551. * @param name defines the name to search for
  36552. * @return the found node or null if not found at all.
  36553. */
  36554. getNodeByName(name: string): Nullable<Node>;
  36555. /**
  36556. * Gets a mesh using a given name
  36557. * @param name defines the name to search for
  36558. * @return the found mesh or null if not found at all.
  36559. */
  36560. getMeshByName(name: string): Nullable<AbstractMesh>;
  36561. /**
  36562. * Gets a transform node using a given name
  36563. * @param name defines the name to search for
  36564. * @return the found transform node or null if not found at all.
  36565. */
  36566. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36567. /**
  36568. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36569. * @param id defines the id to search for
  36570. * @return the found skeleton or null if not found at all.
  36571. */
  36572. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36573. /**
  36574. * Gets a skeleton using a given auto generated unique id
  36575. * @param uniqueId defines the unique id to search for
  36576. * @return the found skeleton or null if not found at all.
  36577. */
  36578. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36579. /**
  36580. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36581. * @param id defines the id to search for
  36582. * @return the found skeleton or null if not found at all.
  36583. */
  36584. getSkeletonById(id: string): Nullable<Skeleton>;
  36585. /**
  36586. * Gets a skeleton using a given name
  36587. * @param name defines the name to search for
  36588. * @return the found skeleton or null if not found at all.
  36589. */
  36590. getSkeletonByName(name: string): Nullable<Skeleton>;
  36591. /**
  36592. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36593. * @param id defines the id to search for
  36594. * @return the found morph target manager or null if not found at all.
  36595. */
  36596. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36597. /**
  36598. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36599. * @param id defines the id to search for
  36600. * @return the found morph target or null if not found at all.
  36601. */
  36602. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36603. /**
  36604. * Gets a boolean indicating if the given mesh is active
  36605. * @param mesh defines the mesh to look for
  36606. * @returns true if the mesh is in the active list
  36607. */
  36608. isActiveMesh(mesh: AbstractMesh): boolean;
  36609. /**
  36610. * Return a unique id as a string which can serve as an identifier for the scene
  36611. */
  36612. get uid(): string;
  36613. /**
  36614. * Add an externaly attached data from its key.
  36615. * This method call will fail and return false, if such key already exists.
  36616. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36617. * @param key the unique key that identifies the data
  36618. * @param data the data object to associate to the key for this Engine instance
  36619. * @return true if no such key were already present and the data was added successfully, false otherwise
  36620. */
  36621. addExternalData<T>(key: string, data: T): boolean;
  36622. /**
  36623. * Get an externaly attached data from its key
  36624. * @param key the unique key that identifies the data
  36625. * @return the associated data, if present (can be null), or undefined if not present
  36626. */
  36627. getExternalData<T>(key: string): Nullable<T>;
  36628. /**
  36629. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36630. * @param key the unique key that identifies the data
  36631. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36632. * @return the associated data, can be null if the factory returned null.
  36633. */
  36634. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36635. /**
  36636. * Remove an externaly attached data from the Engine instance
  36637. * @param key the unique key that identifies the data
  36638. * @return true if the data was successfully removed, false if it doesn't exist
  36639. */
  36640. removeExternalData(key: string): boolean;
  36641. private _evaluateSubMesh;
  36642. /**
  36643. * Clear the processed materials smart array preventing retention point in material dispose.
  36644. */
  36645. freeProcessedMaterials(): void;
  36646. private _preventFreeActiveMeshesAndRenderingGroups;
  36647. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36648. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36649. * when disposing several meshes in a row or a hierarchy of meshes.
  36650. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36651. */
  36652. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36653. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36654. /**
  36655. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36656. */
  36657. freeActiveMeshes(): void;
  36658. /**
  36659. * Clear the info related to rendering groups preventing retention points during dispose.
  36660. */
  36661. freeRenderingGroups(): void;
  36662. /** @hidden */
  36663. _isInIntermediateRendering(): boolean;
  36664. /**
  36665. * Lambda returning the list of potentially active meshes.
  36666. */
  36667. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36668. /**
  36669. * Lambda returning the list of potentially active sub meshes.
  36670. */
  36671. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36672. /**
  36673. * Lambda returning the list of potentially intersecting sub meshes.
  36674. */
  36675. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36676. /**
  36677. * Lambda returning the list of potentially colliding sub meshes.
  36678. */
  36679. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36680. private _activeMeshesFrozen;
  36681. private _skipEvaluateActiveMeshesCompletely;
  36682. /**
  36683. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36684. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36685. * @returns the current scene
  36686. */
  36687. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36688. /**
  36689. * Use this function to restart evaluating active meshes on every frame
  36690. * @returns the current scene
  36691. */
  36692. unfreezeActiveMeshes(): Scene;
  36693. private _evaluateActiveMeshes;
  36694. private _activeMesh;
  36695. /**
  36696. * Update the transform matrix to update from the current active camera
  36697. * @param force defines a boolean used to force the update even if cache is up to date
  36698. */
  36699. updateTransformMatrix(force?: boolean): void;
  36700. private _bindFrameBuffer;
  36701. /** @hidden */
  36702. _allowPostProcessClearColor: boolean;
  36703. /** @hidden */
  36704. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36705. private _processSubCameras;
  36706. private _checkIntersections;
  36707. /** @hidden */
  36708. _advancePhysicsEngineStep(step: number): void;
  36709. /**
  36710. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36711. */
  36712. getDeterministicFrameTime: () => number;
  36713. /** @hidden */
  36714. _animate(): void;
  36715. /** Execute all animations (for a frame) */
  36716. animate(): void;
  36717. /**
  36718. * Render the scene
  36719. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36720. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36721. */
  36722. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36723. /**
  36724. * Freeze all materials
  36725. * A frozen material will not be updatable but should be faster to render
  36726. */
  36727. freezeMaterials(): void;
  36728. /**
  36729. * Unfreeze all materials
  36730. * A frozen material will not be updatable but should be faster to render
  36731. */
  36732. unfreezeMaterials(): void;
  36733. /**
  36734. * Releases all held ressources
  36735. */
  36736. dispose(): void;
  36737. /**
  36738. * Gets if the scene is already disposed
  36739. */
  36740. get isDisposed(): boolean;
  36741. /**
  36742. * Call this function to reduce memory footprint of the scene.
  36743. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36744. */
  36745. clearCachedVertexData(): void;
  36746. /**
  36747. * This function will remove the local cached buffer data from texture.
  36748. * It will save memory but will prevent the texture from being rebuilt
  36749. */
  36750. cleanCachedTextureBuffer(): void;
  36751. /**
  36752. * Get the world extend vectors with an optional filter
  36753. *
  36754. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36755. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36756. */
  36757. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36758. min: Vector3;
  36759. max: Vector3;
  36760. };
  36761. /**
  36762. * Creates a ray that can be used to pick in the scene
  36763. * @param x defines the x coordinate of the origin (on-screen)
  36764. * @param y defines the y coordinate of the origin (on-screen)
  36765. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36766. * @param camera defines the camera to use for the picking
  36767. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36768. * @returns a Ray
  36769. */
  36770. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36771. /**
  36772. * Creates a ray that can be used to pick in the scene
  36773. * @param x defines the x coordinate of the origin (on-screen)
  36774. * @param y defines the y coordinate of the origin (on-screen)
  36775. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36776. * @param result defines the ray where to store the picking ray
  36777. * @param camera defines the camera to use for the picking
  36778. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36779. * @returns the current scene
  36780. */
  36781. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36782. /**
  36783. * Creates a ray that can be used to pick in the scene
  36784. * @param x defines the x coordinate of the origin (on-screen)
  36785. * @param y defines the y coordinate of the origin (on-screen)
  36786. * @param camera defines the camera to use for the picking
  36787. * @returns a Ray
  36788. */
  36789. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36790. /**
  36791. * Creates a ray that can be used to pick in the scene
  36792. * @param x defines the x coordinate of the origin (on-screen)
  36793. * @param y defines the y coordinate of the origin (on-screen)
  36794. * @param result defines the ray where to store the picking ray
  36795. * @param camera defines the camera to use for the picking
  36796. * @returns the current scene
  36797. */
  36798. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36799. /** Launch a ray to try to pick a mesh in the scene
  36800. * @param x position on screen
  36801. * @param y position on screen
  36802. * @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
  36803. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36804. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36805. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36806. * @returns a PickingInfo
  36807. */
  36808. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36809. /** Use the given ray to pick a mesh in the scene
  36810. * @param ray The ray to use to pick meshes
  36811. * @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
  36812. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36813. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36814. * @returns a PickingInfo
  36815. */
  36816. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36817. /**
  36818. * Launch a ray to try to pick a mesh in the scene
  36819. * @param x X position on screen
  36820. * @param y Y position on screen
  36821. * @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
  36822. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36823. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36824. * @returns an array of PickingInfo
  36825. */
  36826. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36827. /**
  36828. * Launch a ray to try to pick a mesh in the scene
  36829. * @param ray Ray to use
  36830. * @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
  36831. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36832. * @returns an array of PickingInfo
  36833. */
  36834. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36835. /**
  36836. * Force the value of meshUnderPointer
  36837. * @param mesh defines the mesh to use
  36838. */
  36839. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36840. /**
  36841. * Gets the mesh under the pointer
  36842. * @returns a Mesh or null if no mesh is under the pointer
  36843. */
  36844. getPointerOverMesh(): Nullable<AbstractMesh>;
  36845. /** @hidden */
  36846. _rebuildGeometries(): void;
  36847. /** @hidden */
  36848. _rebuildTextures(): void;
  36849. private _getByTags;
  36850. /**
  36851. * Get a list of meshes by tags
  36852. * @param tagsQuery defines the tags query to use
  36853. * @param forEach defines a predicate used to filter results
  36854. * @returns an array of Mesh
  36855. */
  36856. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36857. /**
  36858. * Get a list of cameras by tags
  36859. * @param tagsQuery defines the tags query to use
  36860. * @param forEach defines a predicate used to filter results
  36861. * @returns an array of Camera
  36862. */
  36863. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36864. /**
  36865. * Get a list of lights by tags
  36866. * @param tagsQuery defines the tags query to use
  36867. * @param forEach defines a predicate used to filter results
  36868. * @returns an array of Light
  36869. */
  36870. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36871. /**
  36872. * Get a list of materials by tags
  36873. * @param tagsQuery defines the tags query to use
  36874. * @param forEach defines a predicate used to filter results
  36875. * @returns an array of Material
  36876. */
  36877. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36878. /**
  36879. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36880. * This allowed control for front to back rendering or reversly depending of the special needs.
  36881. *
  36882. * @param renderingGroupId The rendering group id corresponding to its index
  36883. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36884. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36885. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36886. */
  36887. 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;
  36888. /**
  36889. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36890. *
  36891. * @param renderingGroupId The rendering group id corresponding to its index
  36892. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36893. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36894. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36895. */
  36896. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36897. /**
  36898. * Gets the current auto clear configuration for one rendering group of the rendering
  36899. * manager.
  36900. * @param index the rendering group index to get the information for
  36901. * @returns The auto clear setup for the requested rendering group
  36902. */
  36903. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36904. private _blockMaterialDirtyMechanism;
  36905. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36906. get blockMaterialDirtyMechanism(): boolean;
  36907. set blockMaterialDirtyMechanism(value: boolean);
  36908. /**
  36909. * Will flag all materials as dirty to trigger new shader compilation
  36910. * @param flag defines the flag used to specify which material part must be marked as dirty
  36911. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36912. */
  36913. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36914. /** @hidden */
  36915. _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;
  36916. /** @hidden */
  36917. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36918. /** @hidden */
  36919. _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;
  36920. /** @hidden */
  36921. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36922. /** @hidden */
  36923. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36924. /** @hidden */
  36925. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36926. }
  36927. }
  36928. declare module BABYLON {
  36929. /**
  36930. * Set of assets to keep when moving a scene into an asset container.
  36931. */
  36932. export class KeepAssets extends AbstractScene {
  36933. }
  36934. /**
  36935. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36936. */
  36937. export class InstantiatedEntries {
  36938. /**
  36939. * List of new root nodes (eg. nodes with no parent)
  36940. */
  36941. rootNodes: TransformNode[];
  36942. /**
  36943. * List of new skeletons
  36944. */
  36945. skeletons: Skeleton[];
  36946. /**
  36947. * List of new animation groups
  36948. */
  36949. animationGroups: AnimationGroup[];
  36950. }
  36951. /**
  36952. * Container with a set of assets that can be added or removed from a scene.
  36953. */
  36954. export class AssetContainer extends AbstractScene {
  36955. private _wasAddedToScene;
  36956. /**
  36957. * The scene the AssetContainer belongs to.
  36958. */
  36959. scene: Scene;
  36960. /**
  36961. * Instantiates an AssetContainer.
  36962. * @param scene The scene the AssetContainer belongs to.
  36963. */
  36964. constructor(scene: Scene);
  36965. /**
  36966. * Instantiate or clone all meshes and add the new ones to the scene.
  36967. * Skeletons and animation groups will all be cloned
  36968. * @param nameFunction defines an optional function used to get new names for clones
  36969. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36970. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36971. */
  36972. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36973. /**
  36974. * Adds all the assets from the container to the scene.
  36975. */
  36976. addAllToScene(): void;
  36977. /**
  36978. * Removes all the assets in the container from the scene
  36979. */
  36980. removeAllFromScene(): void;
  36981. /**
  36982. * Disposes all the assets in the container
  36983. */
  36984. dispose(): void;
  36985. private _moveAssets;
  36986. /**
  36987. * Removes all the assets contained in the scene and adds them to the container.
  36988. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36989. */
  36990. moveAllFromScene(keepAssets?: KeepAssets): void;
  36991. /**
  36992. * 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.
  36993. * @returns the root mesh
  36994. */
  36995. createRootMesh(): Mesh;
  36996. /**
  36997. * Merge animations from this asset container into a scene
  36998. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36999. * @param animatables set of animatables to retarget to a node from the scene
  37000. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37001. */
  37002. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37003. }
  37004. }
  37005. declare module BABYLON {
  37006. /**
  37007. * Defines how the parser contract is defined.
  37008. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37009. */
  37010. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37011. /**
  37012. * Defines how the individual parser contract is defined.
  37013. * These parser can parse an individual asset
  37014. */
  37015. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37016. /**
  37017. * Base class of the scene acting as a container for the different elements composing a scene.
  37018. * This class is dynamically extended by the different components of the scene increasing
  37019. * flexibility and reducing coupling
  37020. */
  37021. export abstract class AbstractScene {
  37022. /**
  37023. * Stores the list of available parsers in the application.
  37024. */
  37025. private static _BabylonFileParsers;
  37026. /**
  37027. * Stores the list of available individual parsers in the application.
  37028. */
  37029. private static _IndividualBabylonFileParsers;
  37030. /**
  37031. * Adds a parser in the list of available ones
  37032. * @param name Defines the name of the parser
  37033. * @param parser Defines the parser to add
  37034. */
  37035. static AddParser(name: string, parser: BabylonFileParser): void;
  37036. /**
  37037. * Gets a general parser from the list of avaialble ones
  37038. * @param name Defines the name of the parser
  37039. * @returns the requested parser or null
  37040. */
  37041. static GetParser(name: string): Nullable<BabylonFileParser>;
  37042. /**
  37043. * Adds n individual parser in the list of available ones
  37044. * @param name Defines the name of the parser
  37045. * @param parser Defines the parser to add
  37046. */
  37047. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37048. /**
  37049. * Gets an individual parser from the list of avaialble ones
  37050. * @param name Defines the name of the parser
  37051. * @returns the requested parser or null
  37052. */
  37053. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37054. /**
  37055. * Parser json data and populate both a scene and its associated container object
  37056. * @param jsonData Defines the data to parse
  37057. * @param scene Defines the scene to parse the data for
  37058. * @param container Defines the container attached to the parsing sequence
  37059. * @param rootUrl Defines the root url of the data
  37060. */
  37061. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37062. /**
  37063. * Gets the list of root nodes (ie. nodes with no parent)
  37064. */
  37065. rootNodes: Node[];
  37066. /** All of the cameras added to this scene
  37067. * @see http://doc.babylonjs.com/babylon101/cameras
  37068. */
  37069. cameras: Camera[];
  37070. /**
  37071. * All of the lights added to this scene
  37072. * @see http://doc.babylonjs.com/babylon101/lights
  37073. */
  37074. lights: Light[];
  37075. /**
  37076. * All of the (abstract) meshes added to this scene
  37077. */
  37078. meshes: AbstractMesh[];
  37079. /**
  37080. * The list of skeletons added to the scene
  37081. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37082. */
  37083. skeletons: Skeleton[];
  37084. /**
  37085. * All of the particle systems added to this scene
  37086. * @see http://doc.babylonjs.com/babylon101/particles
  37087. */
  37088. particleSystems: IParticleSystem[];
  37089. /**
  37090. * Gets a list of Animations associated with the scene
  37091. */
  37092. animations: Animation[];
  37093. /**
  37094. * All of the animation groups added to this scene
  37095. * @see http://doc.babylonjs.com/how_to/group
  37096. */
  37097. animationGroups: AnimationGroup[];
  37098. /**
  37099. * All of the multi-materials added to this scene
  37100. * @see http://doc.babylonjs.com/how_to/multi_materials
  37101. */
  37102. multiMaterials: MultiMaterial[];
  37103. /**
  37104. * All of the materials added to this scene
  37105. * In the context of a Scene, it is not supposed to be modified manually.
  37106. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37107. * Note also that the order of the Material within the array is not significant and might change.
  37108. * @see http://doc.babylonjs.com/babylon101/materials
  37109. */
  37110. materials: Material[];
  37111. /**
  37112. * The list of morph target managers added to the scene
  37113. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37114. */
  37115. morphTargetManagers: MorphTargetManager[];
  37116. /**
  37117. * The list of geometries used in the scene.
  37118. */
  37119. geometries: Geometry[];
  37120. /**
  37121. * All of the tranform nodes added to this scene
  37122. * In the context of a Scene, it is not supposed to be modified manually.
  37123. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37124. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37125. * @see http://doc.babylonjs.com/how_to/transformnode
  37126. */
  37127. transformNodes: TransformNode[];
  37128. /**
  37129. * ActionManagers available on the scene.
  37130. */
  37131. actionManagers: AbstractActionManager[];
  37132. /**
  37133. * Textures to keep.
  37134. */
  37135. textures: BaseTexture[];
  37136. /**
  37137. * Environment texture for the scene
  37138. */
  37139. environmentTexture: Nullable<BaseTexture>;
  37140. /**
  37141. * @returns all meshes, lights, cameras, transformNodes and bones
  37142. */
  37143. getNodes(): Array<Node>;
  37144. }
  37145. }
  37146. declare module BABYLON {
  37147. /**
  37148. * Interface used to define options for Sound class
  37149. */
  37150. export interface ISoundOptions {
  37151. /**
  37152. * Does the sound autoplay once loaded.
  37153. */
  37154. autoplay?: boolean;
  37155. /**
  37156. * Does the sound loop after it finishes playing once.
  37157. */
  37158. loop?: boolean;
  37159. /**
  37160. * Sound's volume
  37161. */
  37162. volume?: number;
  37163. /**
  37164. * Is it a spatial sound?
  37165. */
  37166. spatialSound?: boolean;
  37167. /**
  37168. * Maximum distance to hear that sound
  37169. */
  37170. maxDistance?: number;
  37171. /**
  37172. * Uses user defined attenuation function
  37173. */
  37174. useCustomAttenuation?: boolean;
  37175. /**
  37176. * Define the roll off factor of spatial sounds.
  37177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37178. */
  37179. rolloffFactor?: number;
  37180. /**
  37181. * Define the reference distance the sound should be heard perfectly.
  37182. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37183. */
  37184. refDistance?: number;
  37185. /**
  37186. * Define the distance attenuation model the sound will follow.
  37187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37188. */
  37189. distanceModel?: string;
  37190. /**
  37191. * Defines the playback speed (1 by default)
  37192. */
  37193. playbackRate?: number;
  37194. /**
  37195. * Defines if the sound is from a streaming source
  37196. */
  37197. streaming?: boolean;
  37198. /**
  37199. * Defines an optional length (in seconds) inside the sound file
  37200. */
  37201. length?: number;
  37202. /**
  37203. * Defines an optional offset (in seconds) inside the sound file
  37204. */
  37205. offset?: number;
  37206. /**
  37207. * If true, URLs will not be required to state the audio file codec to use.
  37208. */
  37209. skipCodecCheck?: boolean;
  37210. }
  37211. /**
  37212. * Defines a sound that can be played in the application.
  37213. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37215. */
  37216. export class Sound {
  37217. /**
  37218. * The name of the sound in the scene.
  37219. */
  37220. name: string;
  37221. /**
  37222. * Does the sound autoplay once loaded.
  37223. */
  37224. autoplay: boolean;
  37225. /**
  37226. * Does the sound loop after it finishes playing once.
  37227. */
  37228. loop: boolean;
  37229. /**
  37230. * Does the sound use a custom attenuation curve to simulate the falloff
  37231. * happening when the source gets further away from the camera.
  37232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37233. */
  37234. useCustomAttenuation: boolean;
  37235. /**
  37236. * The sound track id this sound belongs to.
  37237. */
  37238. soundTrackId: number;
  37239. /**
  37240. * Is this sound currently played.
  37241. */
  37242. isPlaying: boolean;
  37243. /**
  37244. * Is this sound currently paused.
  37245. */
  37246. isPaused: boolean;
  37247. /**
  37248. * Does this sound enables spatial sound.
  37249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37250. */
  37251. spatialSound: boolean;
  37252. /**
  37253. * Define the reference distance the sound should be heard perfectly.
  37254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37255. */
  37256. refDistance: number;
  37257. /**
  37258. * Define the roll off factor of spatial sounds.
  37259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37260. */
  37261. rolloffFactor: number;
  37262. /**
  37263. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37265. */
  37266. maxDistance: number;
  37267. /**
  37268. * Define the distance attenuation model the sound will follow.
  37269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37270. */
  37271. distanceModel: string;
  37272. /**
  37273. * @hidden
  37274. * Back Compat
  37275. **/
  37276. onended: () => any;
  37277. /**
  37278. * Observable event when the current playing sound finishes.
  37279. */
  37280. onEndedObservable: Observable<Sound>;
  37281. private _panningModel;
  37282. private _playbackRate;
  37283. private _streaming;
  37284. private _startTime;
  37285. private _startOffset;
  37286. private _position;
  37287. /** @hidden */
  37288. _positionInEmitterSpace: boolean;
  37289. private _localDirection;
  37290. private _volume;
  37291. private _isReadyToPlay;
  37292. private _isDirectional;
  37293. private _readyToPlayCallback;
  37294. private _audioBuffer;
  37295. private _soundSource;
  37296. private _streamingSource;
  37297. private _soundPanner;
  37298. private _soundGain;
  37299. private _inputAudioNode;
  37300. private _outputAudioNode;
  37301. private _coneInnerAngle;
  37302. private _coneOuterAngle;
  37303. private _coneOuterGain;
  37304. private _scene;
  37305. private _connectedTransformNode;
  37306. private _customAttenuationFunction;
  37307. private _registerFunc;
  37308. private _isOutputConnected;
  37309. private _htmlAudioElement;
  37310. private _urlType;
  37311. private _length?;
  37312. private _offset?;
  37313. /** @hidden */
  37314. static _SceneComponentInitialization: (scene: Scene) => void;
  37315. /**
  37316. * Create a sound and attach it to a scene
  37317. * @param name Name of your sound
  37318. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37319. * @param scene defines the scene the sound belongs to
  37320. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37321. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37322. */
  37323. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37324. /**
  37325. * Release the sound and its associated resources
  37326. */
  37327. dispose(): void;
  37328. /**
  37329. * Gets if the sounds is ready to be played or not.
  37330. * @returns true if ready, otherwise false
  37331. */
  37332. isReady(): boolean;
  37333. private _soundLoaded;
  37334. /**
  37335. * Sets the data of the sound from an audiobuffer
  37336. * @param audioBuffer The audioBuffer containing the data
  37337. */
  37338. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37339. /**
  37340. * Updates the current sounds options such as maxdistance, loop...
  37341. * @param options A JSON object containing values named as the object properties
  37342. */
  37343. updateOptions(options: ISoundOptions): void;
  37344. private _createSpatialParameters;
  37345. private _updateSpatialParameters;
  37346. /**
  37347. * Switch the panning model to HRTF:
  37348. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37350. */
  37351. switchPanningModelToHRTF(): void;
  37352. /**
  37353. * Switch the panning model to Equal Power:
  37354. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37355. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37356. */
  37357. switchPanningModelToEqualPower(): void;
  37358. private _switchPanningModel;
  37359. /**
  37360. * Connect this sound to a sound track audio node like gain...
  37361. * @param soundTrackAudioNode the sound track audio node to connect to
  37362. */
  37363. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37364. /**
  37365. * Transform this sound into a directional source
  37366. * @param coneInnerAngle Size of the inner cone in degree
  37367. * @param coneOuterAngle Size of the outer cone in degree
  37368. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37369. */
  37370. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37371. /**
  37372. * Gets or sets the inner angle for the directional cone.
  37373. */
  37374. get directionalConeInnerAngle(): number;
  37375. /**
  37376. * Gets or sets the inner angle for the directional cone.
  37377. */
  37378. set directionalConeInnerAngle(value: number);
  37379. /**
  37380. * Gets or sets the outer angle for the directional cone.
  37381. */
  37382. get directionalConeOuterAngle(): number;
  37383. /**
  37384. * Gets or sets the outer angle for the directional cone.
  37385. */
  37386. set directionalConeOuterAngle(value: number);
  37387. /**
  37388. * Sets the position of the emitter if spatial sound is enabled
  37389. * @param newPosition Defines the new posisiton
  37390. */
  37391. setPosition(newPosition: Vector3): void;
  37392. /**
  37393. * Sets the local direction of the emitter if spatial sound is enabled
  37394. * @param newLocalDirection Defines the new local direction
  37395. */
  37396. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37397. private _updateDirection;
  37398. /** @hidden */
  37399. updateDistanceFromListener(): void;
  37400. /**
  37401. * Sets a new custom attenuation function for the sound.
  37402. * @param callback Defines the function used for the attenuation
  37403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37404. */
  37405. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37406. /**
  37407. * Play the sound
  37408. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37409. * @param offset (optional) Start the sound at a specific time in seconds
  37410. * @param length (optional) Sound duration (in seconds)
  37411. */
  37412. play(time?: number, offset?: number, length?: number): void;
  37413. private _onended;
  37414. /**
  37415. * Stop the sound
  37416. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37417. */
  37418. stop(time?: number): void;
  37419. /**
  37420. * Put the sound in pause
  37421. */
  37422. pause(): void;
  37423. /**
  37424. * Sets a dedicated volume for this sounds
  37425. * @param newVolume Define the new volume of the sound
  37426. * @param time Define time for gradual change to new volume
  37427. */
  37428. setVolume(newVolume: number, time?: number): void;
  37429. /**
  37430. * Set the sound play back rate
  37431. * @param newPlaybackRate Define the playback rate the sound should be played at
  37432. */
  37433. setPlaybackRate(newPlaybackRate: number): void;
  37434. /**
  37435. * Gets the volume of the sound.
  37436. * @returns the volume of the sound
  37437. */
  37438. getVolume(): number;
  37439. /**
  37440. * Attach the sound to a dedicated mesh
  37441. * @param transformNode The transform node to connect the sound with
  37442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37443. */
  37444. attachToMesh(transformNode: TransformNode): void;
  37445. /**
  37446. * Detach the sound from the previously attached mesh
  37447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37448. */
  37449. detachFromMesh(): void;
  37450. private _onRegisterAfterWorldMatrixUpdate;
  37451. /**
  37452. * Clone the current sound in the scene.
  37453. * @returns the new sound clone
  37454. */
  37455. clone(): Nullable<Sound>;
  37456. /**
  37457. * Gets the current underlying audio buffer containing the data
  37458. * @returns the audio buffer
  37459. */
  37460. getAudioBuffer(): Nullable<AudioBuffer>;
  37461. /**
  37462. * Serializes the Sound in a JSON representation
  37463. * @returns the JSON representation of the sound
  37464. */
  37465. serialize(): any;
  37466. /**
  37467. * Parse a JSON representation of a sound to innstantiate in a given scene
  37468. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37469. * @param scene Define the scene the new parsed sound should be created in
  37470. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37471. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37472. * @returns the newly parsed sound
  37473. */
  37474. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37475. }
  37476. }
  37477. declare module BABYLON {
  37478. /**
  37479. * This defines an action helpful to play a defined sound on a triggered action.
  37480. */
  37481. export class PlaySoundAction extends Action {
  37482. private _sound;
  37483. /**
  37484. * Instantiate the action
  37485. * @param triggerOptions defines the trigger options
  37486. * @param sound defines the sound to play
  37487. * @param condition defines the trigger related conditions
  37488. */
  37489. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37490. /** @hidden */
  37491. _prepare(): void;
  37492. /**
  37493. * Execute the action and play the sound.
  37494. */
  37495. execute(): void;
  37496. /**
  37497. * Serializes the actions and its related information.
  37498. * @param parent defines the object to serialize in
  37499. * @returns the serialized object
  37500. */
  37501. serialize(parent: any): any;
  37502. }
  37503. /**
  37504. * This defines an action helpful to stop a defined sound on a triggered action.
  37505. */
  37506. export class StopSoundAction extends Action {
  37507. private _sound;
  37508. /**
  37509. * Instantiate the action
  37510. * @param triggerOptions defines the trigger options
  37511. * @param sound defines the sound to stop
  37512. * @param condition defines the trigger related conditions
  37513. */
  37514. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37515. /** @hidden */
  37516. _prepare(): void;
  37517. /**
  37518. * Execute the action and stop the sound.
  37519. */
  37520. execute(): void;
  37521. /**
  37522. * Serializes the actions and its related information.
  37523. * @param parent defines the object to serialize in
  37524. * @returns the serialized object
  37525. */
  37526. serialize(parent: any): any;
  37527. }
  37528. }
  37529. declare module BABYLON {
  37530. /**
  37531. * This defines an action responsible to change the value of a property
  37532. * by interpolating between its current value and the newly set one once triggered.
  37533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37534. */
  37535. export class InterpolateValueAction extends Action {
  37536. /**
  37537. * Defines the path of the property where the value should be interpolated
  37538. */
  37539. propertyPath: string;
  37540. /**
  37541. * Defines the target value at the end of the interpolation.
  37542. */
  37543. value: any;
  37544. /**
  37545. * Defines the time it will take for the property to interpolate to the value.
  37546. */
  37547. duration: number;
  37548. /**
  37549. * Defines if the other scene animations should be stopped when the action has been triggered
  37550. */
  37551. stopOtherAnimations?: boolean;
  37552. /**
  37553. * Defines a callback raised once the interpolation animation has been done.
  37554. */
  37555. onInterpolationDone?: () => void;
  37556. /**
  37557. * Observable triggered once the interpolation animation has been done.
  37558. */
  37559. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37560. private _target;
  37561. private _effectiveTarget;
  37562. private _property;
  37563. /**
  37564. * Instantiate the action
  37565. * @param triggerOptions defines the trigger options
  37566. * @param target defines the object containing the value to interpolate
  37567. * @param propertyPath defines the path to the property in the target object
  37568. * @param value defines the target value at the end of the interpolation
  37569. * @param duration deines the time it will take for the property to interpolate to the value.
  37570. * @param condition defines the trigger related conditions
  37571. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37572. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37573. */
  37574. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37575. /** @hidden */
  37576. _prepare(): void;
  37577. /**
  37578. * Execute the action starts the value interpolation.
  37579. */
  37580. execute(): void;
  37581. /**
  37582. * Serializes the actions and its related information.
  37583. * @param parent defines the object to serialize in
  37584. * @returns the serialized object
  37585. */
  37586. serialize(parent: any): any;
  37587. }
  37588. }
  37589. declare module BABYLON {
  37590. /**
  37591. * Options allowed during the creation of a sound track.
  37592. */
  37593. export interface ISoundTrackOptions {
  37594. /**
  37595. * The volume the sound track should take during creation
  37596. */
  37597. volume?: number;
  37598. /**
  37599. * Define if the sound track is the main sound track of the scene
  37600. */
  37601. mainTrack?: boolean;
  37602. }
  37603. /**
  37604. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37605. * It will be also used in a future release to apply effects on a specific track.
  37606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37607. */
  37608. export class SoundTrack {
  37609. /**
  37610. * The unique identifier of the sound track in the scene.
  37611. */
  37612. id: number;
  37613. /**
  37614. * The list of sounds included in the sound track.
  37615. */
  37616. soundCollection: Array<Sound>;
  37617. private _outputAudioNode;
  37618. private _scene;
  37619. private _connectedAnalyser;
  37620. private _options;
  37621. private _isInitialized;
  37622. /**
  37623. * Creates a new sound track.
  37624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37625. * @param scene Define the scene the sound track belongs to
  37626. * @param options
  37627. */
  37628. constructor(scene: Scene, options?: ISoundTrackOptions);
  37629. private _initializeSoundTrackAudioGraph;
  37630. /**
  37631. * Release the sound track and its associated resources
  37632. */
  37633. dispose(): void;
  37634. /**
  37635. * Adds a sound to this sound track
  37636. * @param sound define the cound to add
  37637. * @ignoreNaming
  37638. */
  37639. AddSound(sound: Sound): void;
  37640. /**
  37641. * Removes a sound to this sound track
  37642. * @param sound define the cound to remove
  37643. * @ignoreNaming
  37644. */
  37645. RemoveSound(sound: Sound): void;
  37646. /**
  37647. * Set a global volume for the full sound track.
  37648. * @param newVolume Define the new volume of the sound track
  37649. */
  37650. setVolume(newVolume: number): void;
  37651. /**
  37652. * Switch the panning model to HRTF:
  37653. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37655. */
  37656. switchPanningModelToHRTF(): void;
  37657. /**
  37658. * Switch the panning model to Equal Power:
  37659. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37661. */
  37662. switchPanningModelToEqualPower(): void;
  37663. /**
  37664. * Connect the sound track to an audio analyser allowing some amazing
  37665. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37667. * @param analyser The analyser to connect to the engine
  37668. */
  37669. connectToAnalyser(analyser: Analyser): void;
  37670. }
  37671. }
  37672. declare module BABYLON {
  37673. interface AbstractScene {
  37674. /**
  37675. * The list of sounds used in the scene.
  37676. */
  37677. sounds: Nullable<Array<Sound>>;
  37678. }
  37679. interface Scene {
  37680. /**
  37681. * @hidden
  37682. * Backing field
  37683. */
  37684. _mainSoundTrack: SoundTrack;
  37685. /**
  37686. * The main sound track played by the scene.
  37687. * It cotains your primary collection of sounds.
  37688. */
  37689. mainSoundTrack: SoundTrack;
  37690. /**
  37691. * The list of sound tracks added to the scene
  37692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37693. */
  37694. soundTracks: Nullable<Array<SoundTrack>>;
  37695. /**
  37696. * Gets a sound using a given name
  37697. * @param name defines the name to search for
  37698. * @return the found sound or null if not found at all.
  37699. */
  37700. getSoundByName(name: string): Nullable<Sound>;
  37701. /**
  37702. * Gets or sets if audio support is enabled
  37703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37704. */
  37705. audioEnabled: boolean;
  37706. /**
  37707. * Gets or sets if audio will be output to headphones
  37708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37709. */
  37710. headphone: boolean;
  37711. /**
  37712. * Gets or sets custom audio listener position provider
  37713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37714. */
  37715. audioListenerPositionProvider: Nullable<() => Vector3>;
  37716. /**
  37717. * Gets or sets a refresh rate when using 3D audio positioning
  37718. */
  37719. audioPositioningRefreshRate: number;
  37720. }
  37721. /**
  37722. * Defines the sound scene component responsible to manage any sounds
  37723. * in a given scene.
  37724. */
  37725. export class AudioSceneComponent implements ISceneSerializableComponent {
  37726. /**
  37727. * The component name helpfull to identify the component in the list of scene components.
  37728. */
  37729. readonly name: string;
  37730. /**
  37731. * The scene the component belongs to.
  37732. */
  37733. scene: Scene;
  37734. private _audioEnabled;
  37735. /**
  37736. * Gets whether audio is enabled or not.
  37737. * Please use related enable/disable method to switch state.
  37738. */
  37739. get audioEnabled(): boolean;
  37740. private _headphone;
  37741. /**
  37742. * Gets whether audio is outputing to headphone or not.
  37743. * Please use the according Switch methods to change output.
  37744. */
  37745. get headphone(): boolean;
  37746. /**
  37747. * Gets or sets a refresh rate when using 3D audio positioning
  37748. */
  37749. audioPositioningRefreshRate: number;
  37750. private _audioListenerPositionProvider;
  37751. /**
  37752. * Gets the current audio listener position provider
  37753. */
  37754. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37755. /**
  37756. * Sets a custom listener position for all sounds in the scene
  37757. * By default, this is the position of the first active camera
  37758. */
  37759. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37760. /**
  37761. * Creates a new instance of the component for the given scene
  37762. * @param scene Defines the scene to register the component in
  37763. */
  37764. constructor(scene: Scene);
  37765. /**
  37766. * Registers the component in a given scene
  37767. */
  37768. register(): void;
  37769. /**
  37770. * Rebuilds the elements related to this component in case of
  37771. * context lost for instance.
  37772. */
  37773. rebuild(): void;
  37774. /**
  37775. * Serializes the component data to the specified json object
  37776. * @param serializationObject The object to serialize to
  37777. */
  37778. serialize(serializationObject: any): void;
  37779. /**
  37780. * Adds all the elements from the container to the scene
  37781. * @param container the container holding the elements
  37782. */
  37783. addFromContainer(container: AbstractScene): void;
  37784. /**
  37785. * Removes all the elements in the container from the scene
  37786. * @param container contains the elements to remove
  37787. * @param dispose if the removed element should be disposed (default: false)
  37788. */
  37789. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37790. /**
  37791. * Disposes the component and the associated ressources.
  37792. */
  37793. dispose(): void;
  37794. /**
  37795. * Disables audio in the associated scene.
  37796. */
  37797. disableAudio(): void;
  37798. /**
  37799. * Enables audio in the associated scene.
  37800. */
  37801. enableAudio(): void;
  37802. /**
  37803. * Switch audio to headphone output.
  37804. */
  37805. switchAudioModeForHeadphones(): void;
  37806. /**
  37807. * Switch audio to normal speakers.
  37808. */
  37809. switchAudioModeForNormalSpeakers(): void;
  37810. private _cachedCameraDirection;
  37811. private _cachedCameraPosition;
  37812. private _lastCheck;
  37813. private _afterRender;
  37814. }
  37815. }
  37816. declare module BABYLON {
  37817. /**
  37818. * Wraps one or more Sound objects and selects one with random weight for playback.
  37819. */
  37820. export class WeightedSound {
  37821. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37822. loop: boolean;
  37823. private _coneInnerAngle;
  37824. private _coneOuterAngle;
  37825. private _volume;
  37826. /** A Sound is currently playing. */
  37827. isPlaying: boolean;
  37828. /** A Sound is currently paused. */
  37829. isPaused: boolean;
  37830. private _sounds;
  37831. private _weights;
  37832. private _currentIndex?;
  37833. /**
  37834. * Creates a new WeightedSound from the list of sounds given.
  37835. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37836. * @param sounds Array of Sounds that will be selected from.
  37837. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37838. */
  37839. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37840. /**
  37841. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37842. */
  37843. get directionalConeInnerAngle(): number;
  37844. /**
  37845. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37846. */
  37847. set directionalConeInnerAngle(value: number);
  37848. /**
  37849. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37850. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37851. */
  37852. get directionalConeOuterAngle(): number;
  37853. /**
  37854. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37855. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37856. */
  37857. set directionalConeOuterAngle(value: number);
  37858. /**
  37859. * Playback volume.
  37860. */
  37861. get volume(): number;
  37862. /**
  37863. * Playback volume.
  37864. */
  37865. set volume(value: number);
  37866. private _onended;
  37867. /**
  37868. * Suspend playback
  37869. */
  37870. pause(): void;
  37871. /**
  37872. * Stop playback
  37873. */
  37874. stop(): void;
  37875. /**
  37876. * Start playback.
  37877. * @param startOffset Position the clip head at a specific time in seconds.
  37878. */
  37879. play(startOffset?: number): void;
  37880. }
  37881. }
  37882. declare module BABYLON {
  37883. /**
  37884. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37885. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37886. */
  37887. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37888. /**
  37889. * Gets the name of the behavior.
  37890. */
  37891. get name(): string;
  37892. /**
  37893. * The easing function used by animations
  37894. */
  37895. static EasingFunction: BackEase;
  37896. /**
  37897. * The easing mode used by animations
  37898. */
  37899. static EasingMode: number;
  37900. /**
  37901. * The duration of the animation, in milliseconds
  37902. */
  37903. transitionDuration: number;
  37904. /**
  37905. * Length of the distance animated by the transition when lower radius is reached
  37906. */
  37907. lowerRadiusTransitionRange: number;
  37908. /**
  37909. * Length of the distance animated by the transition when upper radius is reached
  37910. */
  37911. upperRadiusTransitionRange: number;
  37912. private _autoTransitionRange;
  37913. /**
  37914. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37915. */
  37916. get autoTransitionRange(): boolean;
  37917. /**
  37918. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37919. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37920. */
  37921. set autoTransitionRange(value: boolean);
  37922. private _attachedCamera;
  37923. private _onAfterCheckInputsObserver;
  37924. private _onMeshTargetChangedObserver;
  37925. /**
  37926. * Initializes the behavior.
  37927. */
  37928. init(): void;
  37929. /**
  37930. * Attaches the behavior to its arc rotate camera.
  37931. * @param camera Defines the camera to attach the behavior to
  37932. */
  37933. attach(camera: ArcRotateCamera): void;
  37934. /**
  37935. * Detaches the behavior from its current arc rotate camera.
  37936. */
  37937. detach(): void;
  37938. private _radiusIsAnimating;
  37939. private _radiusBounceTransition;
  37940. private _animatables;
  37941. private _cachedWheelPrecision;
  37942. /**
  37943. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37944. * @param radiusLimit The limit to check against.
  37945. * @return Bool to indicate if at limit.
  37946. */
  37947. private _isRadiusAtLimit;
  37948. /**
  37949. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37950. * @param radiusDelta The delta by which to animate to. Can be negative.
  37951. */
  37952. private _applyBoundRadiusAnimation;
  37953. /**
  37954. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37955. */
  37956. protected _clearAnimationLocks(): void;
  37957. /**
  37958. * Stops and removes all animations that have been applied to the camera
  37959. */
  37960. stopAllAnimations(): void;
  37961. }
  37962. }
  37963. declare module BABYLON {
  37964. /**
  37965. * 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.
  37966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37967. */
  37968. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37969. /**
  37970. * Gets the name of the behavior.
  37971. */
  37972. get name(): string;
  37973. private _mode;
  37974. private _radiusScale;
  37975. private _positionScale;
  37976. private _defaultElevation;
  37977. private _elevationReturnTime;
  37978. private _elevationReturnWaitTime;
  37979. private _zoomStopsAnimation;
  37980. private _framingTime;
  37981. /**
  37982. * The easing function used by animations
  37983. */
  37984. static EasingFunction: ExponentialEase;
  37985. /**
  37986. * The easing mode used by animations
  37987. */
  37988. static EasingMode: number;
  37989. /**
  37990. * Sets the current mode used by the behavior
  37991. */
  37992. set mode(mode: number);
  37993. /**
  37994. * Gets current mode used by the behavior.
  37995. */
  37996. get mode(): number;
  37997. /**
  37998. * Sets the scale applied to the radius (1 by default)
  37999. */
  38000. set radiusScale(radius: number);
  38001. /**
  38002. * Gets the scale applied to the radius
  38003. */
  38004. get radiusScale(): number;
  38005. /**
  38006. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38007. */
  38008. set positionScale(scale: number);
  38009. /**
  38010. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38011. */
  38012. get positionScale(): number;
  38013. /**
  38014. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38015. * behaviour is triggered, in radians.
  38016. */
  38017. set defaultElevation(elevation: number);
  38018. /**
  38019. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38020. * behaviour is triggered, in radians.
  38021. */
  38022. get defaultElevation(): number;
  38023. /**
  38024. * Sets the time (in milliseconds) taken to return to the default beta position.
  38025. * Negative value indicates camera should not return to default.
  38026. */
  38027. set elevationReturnTime(speed: number);
  38028. /**
  38029. * Gets the time (in milliseconds) taken to return to the default beta position.
  38030. * Negative value indicates camera should not return to default.
  38031. */
  38032. get elevationReturnTime(): number;
  38033. /**
  38034. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38035. */
  38036. set elevationReturnWaitTime(time: number);
  38037. /**
  38038. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38039. */
  38040. get elevationReturnWaitTime(): number;
  38041. /**
  38042. * Sets the flag that indicates if user zooming should stop animation.
  38043. */
  38044. set zoomStopsAnimation(flag: boolean);
  38045. /**
  38046. * Gets the flag that indicates if user zooming should stop animation.
  38047. */
  38048. get zoomStopsAnimation(): boolean;
  38049. /**
  38050. * Sets the transition time when framing the mesh, in milliseconds
  38051. */
  38052. set framingTime(time: number);
  38053. /**
  38054. * Gets the transition time when framing the mesh, in milliseconds
  38055. */
  38056. get framingTime(): number;
  38057. /**
  38058. * Define if the behavior should automatically change the configured
  38059. * camera limits and sensibilities.
  38060. */
  38061. autoCorrectCameraLimitsAndSensibility: boolean;
  38062. private _onPrePointerObservableObserver;
  38063. private _onAfterCheckInputsObserver;
  38064. private _onMeshTargetChangedObserver;
  38065. private _attachedCamera;
  38066. private _isPointerDown;
  38067. private _lastInteractionTime;
  38068. /**
  38069. * Initializes the behavior.
  38070. */
  38071. init(): void;
  38072. /**
  38073. * Attaches the behavior to its arc rotate camera.
  38074. * @param camera Defines the camera to attach the behavior to
  38075. */
  38076. attach(camera: ArcRotateCamera): void;
  38077. /**
  38078. * Detaches the behavior from its current arc rotate camera.
  38079. */
  38080. detach(): void;
  38081. private _animatables;
  38082. private _betaIsAnimating;
  38083. private _betaTransition;
  38084. private _radiusTransition;
  38085. private _vectorTransition;
  38086. /**
  38087. * Targets the given mesh and updates zoom level accordingly.
  38088. * @param mesh The mesh to target.
  38089. * @param radius Optional. If a cached radius position already exists, overrides default.
  38090. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38091. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38092. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38093. */
  38094. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38095. /**
  38096. * Targets the given mesh with its children and updates zoom level accordingly.
  38097. * @param mesh The mesh to target.
  38098. * @param radius Optional. If a cached radius position already exists, overrides default.
  38099. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38100. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38101. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38102. */
  38103. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38104. /**
  38105. * Targets the given meshes with their children and updates zoom level accordingly.
  38106. * @param meshes The mesh to target.
  38107. * @param radius Optional. If a cached radius position already exists, overrides default.
  38108. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38109. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38110. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38111. */
  38112. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38113. /**
  38114. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38115. * @param minimumWorld Determines the smaller position of the bounding box extend
  38116. * @param maximumWorld Determines the bigger position of the bounding box extend
  38117. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38118. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38119. */
  38120. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38121. /**
  38122. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38123. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38124. * frustum width.
  38125. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38126. * to fully enclose the mesh in the viewing frustum.
  38127. */
  38128. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38129. /**
  38130. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38131. * is automatically returned to its default position (expected to be above ground plane).
  38132. */
  38133. private _maintainCameraAboveGround;
  38134. /**
  38135. * Returns the frustum slope based on the canvas ratio and camera FOV
  38136. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38137. */
  38138. private _getFrustumSlope;
  38139. /**
  38140. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38141. */
  38142. private _clearAnimationLocks;
  38143. /**
  38144. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38145. */
  38146. private _applyUserInteraction;
  38147. /**
  38148. * Stops and removes all animations that have been applied to the camera
  38149. */
  38150. stopAllAnimations(): void;
  38151. /**
  38152. * Gets a value indicating if the user is moving the camera
  38153. */
  38154. get isUserIsMoving(): boolean;
  38155. /**
  38156. * The camera can move all the way towards the mesh.
  38157. */
  38158. static IgnoreBoundsSizeMode: number;
  38159. /**
  38160. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38161. */
  38162. static FitFrustumSidesMode: number;
  38163. }
  38164. }
  38165. declare module BABYLON {
  38166. /**
  38167. * Base class for Camera Pointer Inputs.
  38168. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38169. * for example usage.
  38170. */
  38171. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38172. /**
  38173. * Defines the camera the input is attached to.
  38174. */
  38175. abstract camera: Camera;
  38176. /**
  38177. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38178. */
  38179. protected _altKey: boolean;
  38180. protected _ctrlKey: boolean;
  38181. protected _metaKey: boolean;
  38182. protected _shiftKey: boolean;
  38183. /**
  38184. * Which mouse buttons were pressed at time of last mouse event.
  38185. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38186. */
  38187. protected _buttonsPressed: number;
  38188. /**
  38189. * Defines the buttons associated with the input to handle camera move.
  38190. */
  38191. buttons: number[];
  38192. /**
  38193. * Attach the input controls to a specific dom element to get the input from.
  38194. * @param element Defines the element the controls should be listened from
  38195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38196. */
  38197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38198. /**
  38199. * Detach the current controls from the specified dom element.
  38200. * @param element Defines the element to stop listening the inputs from
  38201. */
  38202. detachControl(element: Nullable<HTMLElement>): void;
  38203. /**
  38204. * Gets the class name of the current input.
  38205. * @returns the class name
  38206. */
  38207. getClassName(): string;
  38208. /**
  38209. * Get the friendly name associated with the input class.
  38210. * @returns the input friendly name
  38211. */
  38212. getSimpleName(): string;
  38213. /**
  38214. * Called on pointer POINTERDOUBLETAP event.
  38215. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38216. */
  38217. protected onDoubleTap(type: string): void;
  38218. /**
  38219. * Called on pointer POINTERMOVE event if only a single touch is active.
  38220. * Override this method to provide functionality.
  38221. */
  38222. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38223. /**
  38224. * Called on pointer POINTERMOVE event if multiple touches are active.
  38225. * Override this method to provide functionality.
  38226. */
  38227. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38228. /**
  38229. * Called on JS contextmenu event.
  38230. * Override this method to provide functionality.
  38231. */
  38232. protected onContextMenu(evt: PointerEvent): void;
  38233. /**
  38234. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38235. * press.
  38236. * Override this method to provide functionality.
  38237. */
  38238. protected onButtonDown(evt: PointerEvent): void;
  38239. /**
  38240. * Called each time a new POINTERUP event occurs. Ie, for each button
  38241. * release.
  38242. * Override this method to provide functionality.
  38243. */
  38244. protected onButtonUp(evt: PointerEvent): void;
  38245. /**
  38246. * Called when window becomes inactive.
  38247. * Override this method to provide functionality.
  38248. */
  38249. protected onLostFocus(): void;
  38250. private _pointerInput;
  38251. private _observer;
  38252. private _onLostFocus;
  38253. private pointA;
  38254. private pointB;
  38255. }
  38256. }
  38257. declare module BABYLON {
  38258. /**
  38259. * Manage the pointers inputs to control an arc rotate camera.
  38260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38261. */
  38262. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38263. /**
  38264. * Defines the camera the input is attached to.
  38265. */
  38266. camera: ArcRotateCamera;
  38267. /**
  38268. * Gets the class name of the current input.
  38269. * @returns the class name
  38270. */
  38271. getClassName(): string;
  38272. /**
  38273. * Defines the buttons associated with the input to handle camera move.
  38274. */
  38275. buttons: number[];
  38276. /**
  38277. * Defines the pointer angular sensibility along the X axis or how fast is
  38278. * the camera rotating.
  38279. */
  38280. angularSensibilityX: number;
  38281. /**
  38282. * Defines the pointer angular sensibility along the Y axis or how fast is
  38283. * the camera rotating.
  38284. */
  38285. angularSensibilityY: number;
  38286. /**
  38287. * Defines the pointer pinch precision or how fast is the camera zooming.
  38288. */
  38289. pinchPrecision: number;
  38290. /**
  38291. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38292. * from 0.
  38293. * It defines the percentage of current camera.radius to use as delta when
  38294. * pinch zoom is used.
  38295. */
  38296. pinchDeltaPercentage: number;
  38297. /**
  38298. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38299. * that any object in the plane at the camera's target point will scale
  38300. * perfectly with finger motion.
  38301. * Overrides pinchDeltaPercentage and pinchPrecision.
  38302. */
  38303. useNaturalPinchZoom: boolean;
  38304. /**
  38305. * Defines the pointer panning sensibility or how fast is the camera moving.
  38306. */
  38307. panningSensibility: number;
  38308. /**
  38309. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38310. */
  38311. multiTouchPanning: boolean;
  38312. /**
  38313. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38314. * zoom (pinch) through multitouch.
  38315. */
  38316. multiTouchPanAndZoom: boolean;
  38317. /**
  38318. * Revers pinch action direction.
  38319. */
  38320. pinchInwards: boolean;
  38321. private _isPanClick;
  38322. private _twoFingerActivityCount;
  38323. private _isPinching;
  38324. /**
  38325. * Called on pointer POINTERMOVE event if only a single touch is active.
  38326. */
  38327. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38328. /**
  38329. * Called on pointer POINTERDOUBLETAP event.
  38330. */
  38331. protected onDoubleTap(type: string): void;
  38332. /**
  38333. * Called on pointer POINTERMOVE event if multiple touches are active.
  38334. */
  38335. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38336. /**
  38337. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38338. * press.
  38339. */
  38340. protected onButtonDown(evt: PointerEvent): void;
  38341. /**
  38342. * Called each time a new POINTERUP event occurs. Ie, for each button
  38343. * release.
  38344. */
  38345. protected onButtonUp(evt: PointerEvent): void;
  38346. /**
  38347. * Called when window becomes inactive.
  38348. */
  38349. protected onLostFocus(): void;
  38350. }
  38351. }
  38352. declare module BABYLON {
  38353. /**
  38354. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38356. */
  38357. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38358. /**
  38359. * Defines the camera the input is attached to.
  38360. */
  38361. camera: ArcRotateCamera;
  38362. /**
  38363. * Defines the list of key codes associated with the up action (increase alpha)
  38364. */
  38365. keysUp: number[];
  38366. /**
  38367. * Defines the list of key codes associated with the down action (decrease alpha)
  38368. */
  38369. keysDown: number[];
  38370. /**
  38371. * Defines the list of key codes associated with the left action (increase beta)
  38372. */
  38373. keysLeft: number[];
  38374. /**
  38375. * Defines the list of key codes associated with the right action (decrease beta)
  38376. */
  38377. keysRight: number[];
  38378. /**
  38379. * Defines the list of key codes associated with the reset action.
  38380. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38381. */
  38382. keysReset: number[];
  38383. /**
  38384. * Defines the panning sensibility of the inputs.
  38385. * (How fast is the camera panning)
  38386. */
  38387. panningSensibility: number;
  38388. /**
  38389. * Defines the zooming sensibility of the inputs.
  38390. * (How fast is the camera zooming)
  38391. */
  38392. zoomingSensibility: number;
  38393. /**
  38394. * Defines whether maintaining the alt key down switch the movement mode from
  38395. * orientation to zoom.
  38396. */
  38397. useAltToZoom: boolean;
  38398. /**
  38399. * Rotation speed of the camera
  38400. */
  38401. angularSpeed: number;
  38402. private _keys;
  38403. private _ctrlPressed;
  38404. private _altPressed;
  38405. private _onCanvasBlurObserver;
  38406. private _onKeyboardObserver;
  38407. private _engine;
  38408. private _scene;
  38409. /**
  38410. * Attach the input controls to a specific dom element to get the input from.
  38411. * @param element Defines the element the controls should be listened from
  38412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38413. */
  38414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38415. /**
  38416. * Detach the current controls from the specified dom element.
  38417. * @param element Defines the element to stop listening the inputs from
  38418. */
  38419. detachControl(element: Nullable<HTMLElement>): void;
  38420. /**
  38421. * Update the current camera state depending on the inputs that have been used this frame.
  38422. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38423. */
  38424. checkInputs(): void;
  38425. /**
  38426. * Gets the class name of the current intput.
  38427. * @returns the class name
  38428. */
  38429. getClassName(): string;
  38430. /**
  38431. * Get the friendly name associated with the input class.
  38432. * @returns the input friendly name
  38433. */
  38434. getSimpleName(): string;
  38435. }
  38436. }
  38437. declare module BABYLON {
  38438. /**
  38439. * Manage the mouse wheel inputs to control an arc rotate camera.
  38440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38441. */
  38442. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38443. /**
  38444. * Defines the camera the input is attached to.
  38445. */
  38446. camera: ArcRotateCamera;
  38447. /**
  38448. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38449. */
  38450. wheelPrecision: number;
  38451. /**
  38452. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38453. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38454. */
  38455. wheelDeltaPercentage: number;
  38456. private _wheel;
  38457. private _observer;
  38458. private computeDeltaFromMouseWheelLegacyEvent;
  38459. /**
  38460. * Attach the input controls to a specific dom element to get the input from.
  38461. * @param element Defines the element the controls should be listened from
  38462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38463. */
  38464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38465. /**
  38466. * Detach the current controls from the specified dom element.
  38467. * @param element Defines the element to stop listening the inputs from
  38468. */
  38469. detachControl(element: Nullable<HTMLElement>): void;
  38470. /**
  38471. * Gets the class name of the current intput.
  38472. * @returns the class name
  38473. */
  38474. getClassName(): string;
  38475. /**
  38476. * Get the friendly name associated with the input class.
  38477. * @returns the input friendly name
  38478. */
  38479. getSimpleName(): string;
  38480. }
  38481. }
  38482. declare module BABYLON {
  38483. /**
  38484. * Default Inputs manager for the ArcRotateCamera.
  38485. * It groups all the default supported inputs for ease of use.
  38486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38487. */
  38488. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38489. /**
  38490. * Instantiates a new ArcRotateCameraInputsManager.
  38491. * @param camera Defines the camera the inputs belong to
  38492. */
  38493. constructor(camera: ArcRotateCamera);
  38494. /**
  38495. * Add mouse wheel input support to the input manager.
  38496. * @returns the current input manager
  38497. */
  38498. addMouseWheel(): ArcRotateCameraInputsManager;
  38499. /**
  38500. * Add pointers input support to the input manager.
  38501. * @returns the current input manager
  38502. */
  38503. addPointers(): ArcRotateCameraInputsManager;
  38504. /**
  38505. * Add keyboard input support to the input manager.
  38506. * @returns the current input manager
  38507. */
  38508. addKeyboard(): ArcRotateCameraInputsManager;
  38509. }
  38510. }
  38511. declare module BABYLON {
  38512. /**
  38513. * This represents an orbital type of camera.
  38514. *
  38515. * 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.
  38516. * 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.
  38517. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38518. */
  38519. export class ArcRotateCamera extends TargetCamera {
  38520. /**
  38521. * Defines the rotation angle of the camera along the longitudinal axis.
  38522. */
  38523. alpha: number;
  38524. /**
  38525. * Defines the rotation angle of the camera along the latitudinal axis.
  38526. */
  38527. beta: number;
  38528. /**
  38529. * Defines the radius of the camera from it s target point.
  38530. */
  38531. radius: number;
  38532. protected _target: Vector3;
  38533. protected _targetHost: Nullable<AbstractMesh>;
  38534. /**
  38535. * Defines the target point of the camera.
  38536. * The camera looks towards it form the radius distance.
  38537. */
  38538. get target(): Vector3;
  38539. set target(value: Vector3);
  38540. /**
  38541. * Define the current local position of the camera in the scene
  38542. */
  38543. get position(): Vector3;
  38544. set position(newPosition: Vector3);
  38545. protected _upVector: Vector3;
  38546. protected _upToYMatrix: Matrix;
  38547. protected _YToUpMatrix: Matrix;
  38548. /**
  38549. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38550. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38551. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38552. */
  38553. set upVector(vec: Vector3);
  38554. get upVector(): Vector3;
  38555. /**
  38556. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38557. */
  38558. setMatUp(): void;
  38559. /**
  38560. * Current inertia value on the longitudinal axis.
  38561. * The bigger this number the longer it will take for the camera to stop.
  38562. */
  38563. inertialAlphaOffset: number;
  38564. /**
  38565. * Current inertia value on the latitudinal axis.
  38566. * The bigger this number the longer it will take for the camera to stop.
  38567. */
  38568. inertialBetaOffset: number;
  38569. /**
  38570. * Current inertia value on the radius axis.
  38571. * The bigger this number the longer it will take for the camera to stop.
  38572. */
  38573. inertialRadiusOffset: number;
  38574. /**
  38575. * Minimum allowed angle on the longitudinal axis.
  38576. * This can help limiting how the Camera is able to move in the scene.
  38577. */
  38578. lowerAlphaLimit: Nullable<number>;
  38579. /**
  38580. * Maximum allowed angle on the longitudinal axis.
  38581. * This can help limiting how the Camera is able to move in the scene.
  38582. */
  38583. upperAlphaLimit: Nullable<number>;
  38584. /**
  38585. * Minimum allowed angle on the latitudinal axis.
  38586. * This can help limiting how the Camera is able to move in the scene.
  38587. */
  38588. lowerBetaLimit: number;
  38589. /**
  38590. * Maximum allowed angle on the latitudinal axis.
  38591. * This can help limiting how the Camera is able to move in the scene.
  38592. */
  38593. upperBetaLimit: number;
  38594. /**
  38595. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38596. * This can help limiting how the Camera is able to move in the scene.
  38597. */
  38598. lowerRadiusLimit: Nullable<number>;
  38599. /**
  38600. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38601. * This can help limiting how the Camera is able to move in the scene.
  38602. */
  38603. upperRadiusLimit: Nullable<number>;
  38604. /**
  38605. * Defines the current inertia value used during panning of the camera along the X axis.
  38606. */
  38607. inertialPanningX: number;
  38608. /**
  38609. * Defines the current inertia value used during panning of the camera along the Y axis.
  38610. */
  38611. inertialPanningY: number;
  38612. /**
  38613. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38614. * Basically if your fingers moves away from more than this distance you will be considered
  38615. * in pinch mode.
  38616. */
  38617. pinchToPanMaxDistance: number;
  38618. /**
  38619. * Defines the maximum distance the camera can pan.
  38620. * This could help keeping the cammera always in your scene.
  38621. */
  38622. panningDistanceLimit: Nullable<number>;
  38623. /**
  38624. * Defines the target of the camera before paning.
  38625. */
  38626. panningOriginTarget: Vector3;
  38627. /**
  38628. * Defines the value of the inertia used during panning.
  38629. * 0 would mean stop inertia and one would mean no decelleration at all.
  38630. */
  38631. panningInertia: number;
  38632. /**
  38633. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38634. */
  38635. get angularSensibilityX(): number;
  38636. set angularSensibilityX(value: number);
  38637. /**
  38638. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38639. */
  38640. get angularSensibilityY(): number;
  38641. set angularSensibilityY(value: number);
  38642. /**
  38643. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38644. */
  38645. get pinchPrecision(): number;
  38646. set pinchPrecision(value: number);
  38647. /**
  38648. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38649. * It will be used instead of pinchDeltaPrecision if different from 0.
  38650. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38651. */
  38652. get pinchDeltaPercentage(): number;
  38653. set pinchDeltaPercentage(value: number);
  38654. /**
  38655. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38656. * and pinch delta percentage.
  38657. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38658. * that any object in the plane at the camera's target point will scale
  38659. * perfectly with finger motion.
  38660. */
  38661. get useNaturalPinchZoom(): boolean;
  38662. set useNaturalPinchZoom(value: boolean);
  38663. /**
  38664. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38665. */
  38666. get panningSensibility(): number;
  38667. set panningSensibility(value: number);
  38668. /**
  38669. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38670. */
  38671. get keysUp(): number[];
  38672. set keysUp(value: number[]);
  38673. /**
  38674. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38675. */
  38676. get keysDown(): number[];
  38677. set keysDown(value: number[]);
  38678. /**
  38679. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38680. */
  38681. get keysLeft(): number[];
  38682. set keysLeft(value: number[]);
  38683. /**
  38684. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38685. */
  38686. get keysRight(): number[];
  38687. set keysRight(value: number[]);
  38688. /**
  38689. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38690. */
  38691. get wheelPrecision(): number;
  38692. set wheelPrecision(value: number);
  38693. /**
  38694. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38695. * It will be used instead of pinchDeltaPrecision if different from 0.
  38696. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38697. */
  38698. get wheelDeltaPercentage(): number;
  38699. set wheelDeltaPercentage(value: number);
  38700. /**
  38701. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38702. */
  38703. zoomOnFactor: number;
  38704. /**
  38705. * Defines a screen offset for the camera position.
  38706. */
  38707. targetScreenOffset: Vector2;
  38708. /**
  38709. * Allows the camera to be completely reversed.
  38710. * If false the camera can not arrive upside down.
  38711. */
  38712. allowUpsideDown: boolean;
  38713. /**
  38714. * Define if double tap/click is used to restore the previously saved state of the camera.
  38715. */
  38716. useInputToRestoreState: boolean;
  38717. /** @hidden */
  38718. _viewMatrix: Matrix;
  38719. /** @hidden */
  38720. _useCtrlForPanning: boolean;
  38721. /** @hidden */
  38722. _panningMouseButton: number;
  38723. /**
  38724. * Defines the input associated to the camera.
  38725. */
  38726. inputs: ArcRotateCameraInputsManager;
  38727. /** @hidden */
  38728. _reset: () => void;
  38729. /**
  38730. * Defines the allowed panning axis.
  38731. */
  38732. panningAxis: Vector3;
  38733. protected _localDirection: Vector3;
  38734. protected _transformedDirection: Vector3;
  38735. private _bouncingBehavior;
  38736. /**
  38737. * Gets the bouncing behavior of the camera if it has been enabled.
  38738. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38739. */
  38740. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38741. /**
  38742. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38744. */
  38745. get useBouncingBehavior(): boolean;
  38746. set useBouncingBehavior(value: boolean);
  38747. private _framingBehavior;
  38748. /**
  38749. * Gets the framing behavior of the camera if it has been enabled.
  38750. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38751. */
  38752. get framingBehavior(): Nullable<FramingBehavior>;
  38753. /**
  38754. * Defines if the framing behavior of the camera is enabled on the camera.
  38755. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38756. */
  38757. get useFramingBehavior(): boolean;
  38758. set useFramingBehavior(value: boolean);
  38759. private _autoRotationBehavior;
  38760. /**
  38761. * Gets the auto rotation behavior of the camera if it has been enabled.
  38762. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38763. */
  38764. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38765. /**
  38766. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38767. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38768. */
  38769. get useAutoRotationBehavior(): boolean;
  38770. set useAutoRotationBehavior(value: boolean);
  38771. /**
  38772. * Observable triggered when the mesh target has been changed on the camera.
  38773. */
  38774. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38775. /**
  38776. * Event raised when the camera is colliding with a mesh.
  38777. */
  38778. onCollide: (collidedMesh: AbstractMesh) => void;
  38779. /**
  38780. * Defines whether the camera should check collision with the objects oh the scene.
  38781. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38782. */
  38783. checkCollisions: boolean;
  38784. /**
  38785. * Defines the collision radius of the camera.
  38786. * This simulates a sphere around the camera.
  38787. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38788. */
  38789. collisionRadius: Vector3;
  38790. protected _collider: Collider;
  38791. protected _previousPosition: Vector3;
  38792. protected _collisionVelocity: Vector3;
  38793. protected _newPosition: Vector3;
  38794. protected _previousAlpha: number;
  38795. protected _previousBeta: number;
  38796. protected _previousRadius: number;
  38797. protected _collisionTriggered: boolean;
  38798. protected _targetBoundingCenter: Nullable<Vector3>;
  38799. private _computationVector;
  38800. /**
  38801. * Instantiates a new ArcRotateCamera in a given scene
  38802. * @param name Defines the name of the camera
  38803. * @param alpha Defines the camera rotation along the logitudinal axis
  38804. * @param beta Defines the camera rotation along the latitudinal axis
  38805. * @param radius Defines the camera distance from its target
  38806. * @param target Defines the camera target
  38807. * @param scene Defines the scene the camera belongs to
  38808. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38809. */
  38810. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38811. /** @hidden */
  38812. _initCache(): void;
  38813. /** @hidden */
  38814. _updateCache(ignoreParentClass?: boolean): void;
  38815. protected _getTargetPosition(): Vector3;
  38816. private _storedAlpha;
  38817. private _storedBeta;
  38818. private _storedRadius;
  38819. private _storedTarget;
  38820. private _storedTargetScreenOffset;
  38821. /**
  38822. * Stores the current state of the camera (alpha, beta, radius and target)
  38823. * @returns the camera itself
  38824. */
  38825. storeState(): Camera;
  38826. /**
  38827. * @hidden
  38828. * Restored camera state. You must call storeState() first
  38829. */
  38830. _restoreStateValues(): boolean;
  38831. /** @hidden */
  38832. _isSynchronizedViewMatrix(): boolean;
  38833. /**
  38834. * Attached controls to the current camera.
  38835. * @param element Defines the element the controls should be listened from
  38836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38837. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38838. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38839. */
  38840. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38841. /**
  38842. * Detach the current controls from the camera.
  38843. * The camera will stop reacting to inputs.
  38844. * @param element Defines the element to stop listening the inputs from
  38845. */
  38846. detachControl(element: HTMLElement): void;
  38847. /** @hidden */
  38848. _checkInputs(): void;
  38849. protected _checkLimits(): void;
  38850. /**
  38851. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38852. */
  38853. rebuildAnglesAndRadius(): void;
  38854. /**
  38855. * Use a position to define the current camera related information like alpha, beta and radius
  38856. * @param position Defines the position to set the camera at
  38857. */
  38858. setPosition(position: Vector3): void;
  38859. /**
  38860. * Defines the target the camera should look at.
  38861. * This will automatically adapt alpha beta and radius to fit within the new target.
  38862. * @param target Defines the new target as a Vector or a mesh
  38863. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38864. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38865. */
  38866. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38867. /** @hidden */
  38868. _getViewMatrix(): Matrix;
  38869. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38870. /**
  38871. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38872. * @param meshes Defines the mesh to zoom on
  38873. * @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)
  38874. */
  38875. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38876. /**
  38877. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38878. * The target will be changed but the radius
  38879. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38880. * @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)
  38881. */
  38882. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38883. min: Vector3;
  38884. max: Vector3;
  38885. distance: number;
  38886. }, doNotUpdateMaxZ?: boolean): void;
  38887. /**
  38888. * @override
  38889. * Override Camera.createRigCamera
  38890. */
  38891. createRigCamera(name: string, cameraIndex: number): Camera;
  38892. /**
  38893. * @hidden
  38894. * @override
  38895. * Override Camera._updateRigCameras
  38896. */
  38897. _updateRigCameras(): void;
  38898. /**
  38899. * Destroy the camera and release the current resources hold by it.
  38900. */
  38901. dispose(): void;
  38902. /**
  38903. * Gets the current object class name.
  38904. * @return the class name
  38905. */
  38906. getClassName(): string;
  38907. }
  38908. }
  38909. declare module BABYLON {
  38910. /**
  38911. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38912. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38913. */
  38914. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38915. /**
  38916. * Gets the name of the behavior.
  38917. */
  38918. get name(): string;
  38919. private _zoomStopsAnimation;
  38920. private _idleRotationSpeed;
  38921. private _idleRotationWaitTime;
  38922. private _idleRotationSpinupTime;
  38923. /**
  38924. * Sets the flag that indicates if user zooming should stop animation.
  38925. */
  38926. set zoomStopsAnimation(flag: boolean);
  38927. /**
  38928. * Gets the flag that indicates if user zooming should stop animation.
  38929. */
  38930. get zoomStopsAnimation(): boolean;
  38931. /**
  38932. * Sets the default speed at which the camera rotates around the model.
  38933. */
  38934. set idleRotationSpeed(speed: number);
  38935. /**
  38936. * Gets the default speed at which the camera rotates around the model.
  38937. */
  38938. get idleRotationSpeed(): number;
  38939. /**
  38940. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38941. */
  38942. set idleRotationWaitTime(time: number);
  38943. /**
  38944. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38945. */
  38946. get idleRotationWaitTime(): number;
  38947. /**
  38948. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38949. */
  38950. set idleRotationSpinupTime(time: number);
  38951. /**
  38952. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38953. */
  38954. get idleRotationSpinupTime(): number;
  38955. /**
  38956. * Gets a value indicating if the camera is currently rotating because of this behavior
  38957. */
  38958. get rotationInProgress(): boolean;
  38959. private _onPrePointerObservableObserver;
  38960. private _onAfterCheckInputsObserver;
  38961. private _attachedCamera;
  38962. private _isPointerDown;
  38963. private _lastFrameTime;
  38964. private _lastInteractionTime;
  38965. private _cameraRotationSpeed;
  38966. /**
  38967. * Initializes the behavior.
  38968. */
  38969. init(): void;
  38970. /**
  38971. * Attaches the behavior to its arc rotate camera.
  38972. * @param camera Defines the camera to attach the behavior to
  38973. */
  38974. attach(camera: ArcRotateCamera): void;
  38975. /**
  38976. * Detaches the behavior from its current arc rotate camera.
  38977. */
  38978. detach(): void;
  38979. /**
  38980. * Returns true if user is scrolling.
  38981. * @return true if user is scrolling.
  38982. */
  38983. private _userIsZooming;
  38984. private _lastFrameRadius;
  38985. private _shouldAnimationStopForInteraction;
  38986. /**
  38987. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38988. */
  38989. private _applyUserInteraction;
  38990. private _userIsMoving;
  38991. }
  38992. }
  38993. declare module BABYLON {
  38994. /**
  38995. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38996. */
  38997. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38998. private ui;
  38999. /**
  39000. * The name of the behavior
  39001. */
  39002. name: string;
  39003. /**
  39004. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39005. */
  39006. distanceAwayFromFace: number;
  39007. /**
  39008. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39009. */
  39010. distanceAwayFromBottomOfFace: number;
  39011. private _faceVectors;
  39012. private _target;
  39013. private _scene;
  39014. private _onRenderObserver;
  39015. private _tmpMatrix;
  39016. private _tmpVector;
  39017. /**
  39018. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39019. * @param ui The transform node that should be attched to the mesh
  39020. */
  39021. constructor(ui: TransformNode);
  39022. /**
  39023. * Initializes the behavior
  39024. */
  39025. init(): void;
  39026. private _closestFace;
  39027. private _zeroVector;
  39028. private _lookAtTmpMatrix;
  39029. private _lookAtToRef;
  39030. /**
  39031. * Attaches the AttachToBoxBehavior to the passed in mesh
  39032. * @param target The mesh that the specified node will be attached to
  39033. */
  39034. attach(target: Mesh): void;
  39035. /**
  39036. * Detaches the behavior from the mesh
  39037. */
  39038. detach(): void;
  39039. }
  39040. }
  39041. declare module BABYLON {
  39042. /**
  39043. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39044. */
  39045. export class FadeInOutBehavior implements Behavior<Mesh> {
  39046. /**
  39047. * Time in milliseconds to delay before fading in (Default: 0)
  39048. */
  39049. delay: number;
  39050. /**
  39051. * Time in milliseconds for the mesh to fade in (Default: 300)
  39052. */
  39053. fadeInTime: number;
  39054. private _millisecondsPerFrame;
  39055. private _hovered;
  39056. private _hoverValue;
  39057. private _ownerNode;
  39058. /**
  39059. * Instatiates the FadeInOutBehavior
  39060. */
  39061. constructor();
  39062. /**
  39063. * The name of the behavior
  39064. */
  39065. get name(): string;
  39066. /**
  39067. * Initializes the behavior
  39068. */
  39069. init(): void;
  39070. /**
  39071. * Attaches the fade behavior on the passed in mesh
  39072. * @param ownerNode The mesh that will be faded in/out once attached
  39073. */
  39074. attach(ownerNode: Mesh): void;
  39075. /**
  39076. * Detaches the behavior from the mesh
  39077. */
  39078. detach(): void;
  39079. /**
  39080. * Triggers the mesh to begin fading in or out
  39081. * @param value if the object should fade in or out (true to fade in)
  39082. */
  39083. fadeIn(value: boolean): void;
  39084. private _update;
  39085. private _setAllVisibility;
  39086. }
  39087. }
  39088. declare module BABYLON {
  39089. /**
  39090. * Class containing a set of static utilities functions for managing Pivots
  39091. * @hidden
  39092. */
  39093. export class PivotTools {
  39094. private static _PivotCached;
  39095. private static _OldPivotPoint;
  39096. private static _PivotTranslation;
  39097. private static _PivotTmpVector;
  39098. /** @hidden */
  39099. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39100. /** @hidden */
  39101. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39102. }
  39103. }
  39104. declare module BABYLON {
  39105. /**
  39106. * Class containing static functions to help procedurally build meshes
  39107. */
  39108. export class PlaneBuilder {
  39109. /**
  39110. * Creates a plane mesh
  39111. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39112. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39113. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39115. * * 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
  39116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39117. * @param name defines the name of the mesh
  39118. * @param options defines the options used to create the mesh
  39119. * @param scene defines the hosting scene
  39120. * @returns the plane mesh
  39121. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39122. */
  39123. static CreatePlane(name: string, options: {
  39124. size?: number;
  39125. width?: number;
  39126. height?: number;
  39127. sideOrientation?: number;
  39128. frontUVs?: Vector4;
  39129. backUVs?: Vector4;
  39130. updatable?: boolean;
  39131. sourcePlane?: Plane;
  39132. }, scene?: Nullable<Scene>): Mesh;
  39133. }
  39134. }
  39135. declare module BABYLON {
  39136. /**
  39137. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39138. */
  39139. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39140. private static _AnyMouseID;
  39141. /**
  39142. * Abstract mesh the behavior is set on
  39143. */
  39144. attachedNode: AbstractMesh;
  39145. private _dragPlane;
  39146. private _scene;
  39147. private _pointerObserver;
  39148. private _beforeRenderObserver;
  39149. private static _planeScene;
  39150. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39151. /**
  39152. * 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)
  39153. */
  39154. maxDragAngle: number;
  39155. /**
  39156. * @hidden
  39157. */
  39158. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39159. /**
  39160. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39161. */
  39162. currentDraggingPointerID: number;
  39163. /**
  39164. * The last position where the pointer hit the drag plane in world space
  39165. */
  39166. lastDragPosition: Vector3;
  39167. /**
  39168. * If the behavior is currently in a dragging state
  39169. */
  39170. dragging: boolean;
  39171. /**
  39172. * 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)
  39173. */
  39174. dragDeltaRatio: number;
  39175. /**
  39176. * If the drag plane orientation should be updated during the dragging (Default: true)
  39177. */
  39178. updateDragPlane: boolean;
  39179. private _debugMode;
  39180. private _moving;
  39181. /**
  39182. * Fires each time the attached mesh is dragged with the pointer
  39183. * * delta between last drag position and current drag position in world space
  39184. * * dragDistance along the drag axis
  39185. * * dragPlaneNormal normal of the current drag plane used during the drag
  39186. * * dragPlanePoint in world space where the drag intersects the drag plane
  39187. */
  39188. onDragObservable: Observable<{
  39189. delta: Vector3;
  39190. dragPlanePoint: Vector3;
  39191. dragPlaneNormal: Vector3;
  39192. dragDistance: number;
  39193. pointerId: number;
  39194. }>;
  39195. /**
  39196. * Fires each time a drag begins (eg. mouse down on mesh)
  39197. */
  39198. onDragStartObservable: Observable<{
  39199. dragPlanePoint: Vector3;
  39200. pointerId: number;
  39201. }>;
  39202. /**
  39203. * Fires each time a drag ends (eg. mouse release after drag)
  39204. */
  39205. onDragEndObservable: Observable<{
  39206. dragPlanePoint: Vector3;
  39207. pointerId: number;
  39208. }>;
  39209. /**
  39210. * If the attached mesh should be moved when dragged
  39211. */
  39212. moveAttached: boolean;
  39213. /**
  39214. * If the drag behavior will react to drag events (Default: true)
  39215. */
  39216. enabled: boolean;
  39217. /**
  39218. * If pointer events should start and release the drag (Default: true)
  39219. */
  39220. startAndReleaseDragOnPointerEvents: boolean;
  39221. /**
  39222. * If camera controls should be detached during the drag
  39223. */
  39224. detachCameraControls: boolean;
  39225. /**
  39226. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39227. */
  39228. useObjectOrientationForDragging: boolean;
  39229. private _options;
  39230. /**
  39231. * Gets the options used by the behavior
  39232. */
  39233. get options(): {
  39234. dragAxis?: Vector3;
  39235. dragPlaneNormal?: Vector3;
  39236. };
  39237. /**
  39238. * Sets the options used by the behavior
  39239. */
  39240. set options(options: {
  39241. dragAxis?: Vector3;
  39242. dragPlaneNormal?: Vector3;
  39243. });
  39244. /**
  39245. * Creates a pointer drag behavior that can be attached to a mesh
  39246. * @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)
  39247. */
  39248. constructor(options?: {
  39249. dragAxis?: Vector3;
  39250. dragPlaneNormal?: Vector3;
  39251. });
  39252. /**
  39253. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39254. */
  39255. validateDrag: (targetPosition: Vector3) => boolean;
  39256. /**
  39257. * The name of the behavior
  39258. */
  39259. get name(): string;
  39260. /**
  39261. * Initializes the behavior
  39262. */
  39263. init(): void;
  39264. private _tmpVector;
  39265. private _alternatePickedPoint;
  39266. private _worldDragAxis;
  39267. private _targetPosition;
  39268. private _attachedElement;
  39269. /**
  39270. * Attaches the drag behavior the passed in mesh
  39271. * @param ownerNode The mesh that will be dragged around once attached
  39272. * @param predicate Predicate to use for pick filtering
  39273. */
  39274. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39275. /**
  39276. * Force relase the drag action by code.
  39277. */
  39278. releaseDrag(): void;
  39279. private _startDragRay;
  39280. private _lastPointerRay;
  39281. /**
  39282. * Simulates the start of a pointer drag event on the behavior
  39283. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39284. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39285. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39286. */
  39287. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39288. private _startDrag;
  39289. private _dragDelta;
  39290. private _moveDrag;
  39291. private _pickWithRayOnDragPlane;
  39292. private _pointA;
  39293. private _pointB;
  39294. private _pointC;
  39295. private _lineA;
  39296. private _lineB;
  39297. private _localAxis;
  39298. private _lookAt;
  39299. private _updateDragPlanePosition;
  39300. /**
  39301. * Detaches the behavior from the mesh
  39302. */
  39303. detach(): void;
  39304. }
  39305. }
  39306. declare module BABYLON {
  39307. /**
  39308. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39309. */
  39310. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39311. private _dragBehaviorA;
  39312. private _dragBehaviorB;
  39313. private _startDistance;
  39314. private _initialScale;
  39315. private _targetScale;
  39316. private _ownerNode;
  39317. private _sceneRenderObserver;
  39318. /**
  39319. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39320. */
  39321. constructor();
  39322. /**
  39323. * The name of the behavior
  39324. */
  39325. get name(): string;
  39326. /**
  39327. * Initializes the behavior
  39328. */
  39329. init(): void;
  39330. private _getCurrentDistance;
  39331. /**
  39332. * Attaches the scale behavior the passed in mesh
  39333. * @param ownerNode The mesh that will be scaled around once attached
  39334. */
  39335. attach(ownerNode: Mesh): void;
  39336. /**
  39337. * Detaches the behavior from the mesh
  39338. */
  39339. detach(): void;
  39340. }
  39341. }
  39342. declare module BABYLON {
  39343. /**
  39344. * 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
  39345. */
  39346. export class SixDofDragBehavior implements Behavior<Mesh> {
  39347. private static _virtualScene;
  39348. private _ownerNode;
  39349. private _sceneRenderObserver;
  39350. private _scene;
  39351. private _targetPosition;
  39352. private _virtualOriginMesh;
  39353. private _virtualDragMesh;
  39354. private _pointerObserver;
  39355. private _moving;
  39356. private _startingOrientation;
  39357. /**
  39358. * 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)
  39359. */
  39360. private zDragFactor;
  39361. /**
  39362. * If the object should rotate to face the drag origin
  39363. */
  39364. rotateDraggedObject: boolean;
  39365. /**
  39366. * If the behavior is currently in a dragging state
  39367. */
  39368. dragging: boolean;
  39369. /**
  39370. * 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)
  39371. */
  39372. dragDeltaRatio: number;
  39373. /**
  39374. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39375. */
  39376. currentDraggingPointerID: number;
  39377. /**
  39378. * If camera controls should be detached during the drag
  39379. */
  39380. detachCameraControls: boolean;
  39381. /**
  39382. * Fires each time a drag starts
  39383. */
  39384. onDragStartObservable: Observable<{}>;
  39385. /**
  39386. * Fires each time a drag ends (eg. mouse release after drag)
  39387. */
  39388. onDragEndObservable: Observable<{}>;
  39389. /**
  39390. * 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
  39391. */
  39392. constructor();
  39393. /**
  39394. * The name of the behavior
  39395. */
  39396. get name(): string;
  39397. /**
  39398. * Initializes the behavior
  39399. */
  39400. init(): void;
  39401. /**
  39402. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39403. */
  39404. private get _pointerCamera();
  39405. /**
  39406. * Attaches the scale behavior the passed in mesh
  39407. * @param ownerNode The mesh that will be scaled around once attached
  39408. */
  39409. attach(ownerNode: Mesh): void;
  39410. /**
  39411. * Detaches the behavior from the mesh
  39412. */
  39413. detach(): void;
  39414. }
  39415. }
  39416. declare module BABYLON {
  39417. /**
  39418. * Class used to apply inverse kinematics to bones
  39419. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39420. */
  39421. export class BoneIKController {
  39422. private static _tmpVecs;
  39423. private static _tmpQuat;
  39424. private static _tmpMats;
  39425. /**
  39426. * Gets or sets the target mesh
  39427. */
  39428. targetMesh: AbstractMesh;
  39429. /** Gets or sets the mesh used as pole */
  39430. poleTargetMesh: AbstractMesh;
  39431. /**
  39432. * Gets or sets the bone used as pole
  39433. */
  39434. poleTargetBone: Nullable<Bone>;
  39435. /**
  39436. * Gets or sets the target position
  39437. */
  39438. targetPosition: Vector3;
  39439. /**
  39440. * Gets or sets the pole target position
  39441. */
  39442. poleTargetPosition: Vector3;
  39443. /**
  39444. * Gets or sets the pole target local offset
  39445. */
  39446. poleTargetLocalOffset: Vector3;
  39447. /**
  39448. * Gets or sets the pole angle
  39449. */
  39450. poleAngle: number;
  39451. /**
  39452. * Gets or sets the mesh associated with the controller
  39453. */
  39454. mesh: AbstractMesh;
  39455. /**
  39456. * 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)
  39457. */
  39458. slerpAmount: number;
  39459. private _bone1Quat;
  39460. private _bone1Mat;
  39461. private _bone2Ang;
  39462. private _bone1;
  39463. private _bone2;
  39464. private _bone1Length;
  39465. private _bone2Length;
  39466. private _maxAngle;
  39467. private _maxReach;
  39468. private _rightHandedSystem;
  39469. private _bendAxis;
  39470. private _slerping;
  39471. private _adjustRoll;
  39472. /**
  39473. * Gets or sets maximum allowed angle
  39474. */
  39475. get maxAngle(): number;
  39476. set maxAngle(value: number);
  39477. /**
  39478. * Creates a new BoneIKController
  39479. * @param mesh defines the mesh to control
  39480. * @param bone defines the bone to control
  39481. * @param options defines options to set up the controller
  39482. */
  39483. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39484. targetMesh?: AbstractMesh;
  39485. poleTargetMesh?: AbstractMesh;
  39486. poleTargetBone?: Bone;
  39487. poleTargetLocalOffset?: Vector3;
  39488. poleAngle?: number;
  39489. bendAxis?: Vector3;
  39490. maxAngle?: number;
  39491. slerpAmount?: number;
  39492. });
  39493. private _setMaxAngle;
  39494. /**
  39495. * Force the controller to update the bones
  39496. */
  39497. update(): void;
  39498. }
  39499. }
  39500. declare module BABYLON {
  39501. /**
  39502. * Class used to make a bone look toward a point in space
  39503. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39504. */
  39505. export class BoneLookController {
  39506. private static _tmpVecs;
  39507. private static _tmpQuat;
  39508. private static _tmpMats;
  39509. /**
  39510. * The target Vector3 that the bone will look at
  39511. */
  39512. target: Vector3;
  39513. /**
  39514. * The mesh that the bone is attached to
  39515. */
  39516. mesh: AbstractMesh;
  39517. /**
  39518. * The bone that will be looking to the target
  39519. */
  39520. bone: Bone;
  39521. /**
  39522. * The up axis of the coordinate system that is used when the bone is rotated
  39523. */
  39524. upAxis: Vector3;
  39525. /**
  39526. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39527. */
  39528. upAxisSpace: Space;
  39529. /**
  39530. * Used to make an adjustment to the yaw of the bone
  39531. */
  39532. adjustYaw: number;
  39533. /**
  39534. * Used to make an adjustment to the pitch of the bone
  39535. */
  39536. adjustPitch: number;
  39537. /**
  39538. * Used to make an adjustment to the roll of the bone
  39539. */
  39540. adjustRoll: number;
  39541. /**
  39542. * 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)
  39543. */
  39544. slerpAmount: number;
  39545. private _minYaw;
  39546. private _maxYaw;
  39547. private _minPitch;
  39548. private _maxPitch;
  39549. private _minYawSin;
  39550. private _minYawCos;
  39551. private _maxYawSin;
  39552. private _maxYawCos;
  39553. private _midYawConstraint;
  39554. private _minPitchTan;
  39555. private _maxPitchTan;
  39556. private _boneQuat;
  39557. private _slerping;
  39558. private _transformYawPitch;
  39559. private _transformYawPitchInv;
  39560. private _firstFrameSkipped;
  39561. private _yawRange;
  39562. private _fowardAxis;
  39563. /**
  39564. * Gets or sets the minimum yaw angle that the bone can look to
  39565. */
  39566. get minYaw(): number;
  39567. set minYaw(value: number);
  39568. /**
  39569. * Gets or sets the maximum yaw angle that the bone can look to
  39570. */
  39571. get maxYaw(): number;
  39572. set maxYaw(value: number);
  39573. /**
  39574. * Gets or sets the minimum pitch angle that the bone can look to
  39575. */
  39576. get minPitch(): number;
  39577. set minPitch(value: number);
  39578. /**
  39579. * Gets or sets the maximum pitch angle that the bone can look to
  39580. */
  39581. get maxPitch(): number;
  39582. set maxPitch(value: number);
  39583. /**
  39584. * Create a BoneLookController
  39585. * @param mesh the mesh that the bone belongs to
  39586. * @param bone the bone that will be looking to the target
  39587. * @param target the target Vector3 to look at
  39588. * @param options optional settings:
  39589. * * maxYaw: the maximum angle the bone will yaw to
  39590. * * minYaw: the minimum angle the bone will yaw to
  39591. * * maxPitch: the maximum angle the bone will pitch to
  39592. * * minPitch: the minimum angle the bone will yaw to
  39593. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39594. * * upAxis: the up axis of the coordinate system
  39595. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39596. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39597. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39598. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39599. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39600. * * adjustRoll: used to make an adjustment to the roll of the bone
  39601. **/
  39602. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39603. maxYaw?: number;
  39604. minYaw?: number;
  39605. maxPitch?: number;
  39606. minPitch?: number;
  39607. slerpAmount?: number;
  39608. upAxis?: Vector3;
  39609. upAxisSpace?: Space;
  39610. yawAxis?: Vector3;
  39611. pitchAxis?: Vector3;
  39612. adjustYaw?: number;
  39613. adjustPitch?: number;
  39614. adjustRoll?: number;
  39615. });
  39616. /**
  39617. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39618. */
  39619. update(): void;
  39620. private _getAngleDiff;
  39621. private _getAngleBetween;
  39622. private _isAngleBetween;
  39623. }
  39624. }
  39625. declare module BABYLON {
  39626. /**
  39627. * Manage the gamepad inputs to control an arc rotate camera.
  39628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39629. */
  39630. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39631. /**
  39632. * Defines the camera the input is attached to.
  39633. */
  39634. camera: ArcRotateCamera;
  39635. /**
  39636. * Defines the gamepad the input is gathering event from.
  39637. */
  39638. gamepad: Nullable<Gamepad>;
  39639. /**
  39640. * Defines the gamepad rotation sensiblity.
  39641. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39642. */
  39643. gamepadRotationSensibility: number;
  39644. /**
  39645. * Defines the gamepad move sensiblity.
  39646. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39647. */
  39648. gamepadMoveSensibility: number;
  39649. private _yAxisScale;
  39650. /**
  39651. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39652. */
  39653. get invertYAxis(): boolean;
  39654. set invertYAxis(value: boolean);
  39655. private _onGamepadConnectedObserver;
  39656. private _onGamepadDisconnectedObserver;
  39657. /**
  39658. * Attach the input controls to a specific dom element to get the input from.
  39659. * @param element Defines the element the controls should be listened from
  39660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39661. */
  39662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39663. /**
  39664. * Detach the current controls from the specified dom element.
  39665. * @param element Defines the element to stop listening the inputs from
  39666. */
  39667. detachControl(element: Nullable<HTMLElement>): void;
  39668. /**
  39669. * Update the current camera state depending on the inputs that have been used this frame.
  39670. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39671. */
  39672. checkInputs(): void;
  39673. /**
  39674. * Gets the class name of the current intput.
  39675. * @returns the class name
  39676. */
  39677. getClassName(): string;
  39678. /**
  39679. * Get the friendly name associated with the input class.
  39680. * @returns the input friendly name
  39681. */
  39682. getSimpleName(): string;
  39683. }
  39684. }
  39685. declare module BABYLON {
  39686. interface ArcRotateCameraInputsManager {
  39687. /**
  39688. * Add orientation input support to the input manager.
  39689. * @returns the current input manager
  39690. */
  39691. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39692. }
  39693. /**
  39694. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39696. */
  39697. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39698. /**
  39699. * Defines the camera the input is attached to.
  39700. */
  39701. camera: ArcRotateCamera;
  39702. /**
  39703. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39704. */
  39705. alphaCorrection: number;
  39706. /**
  39707. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39708. */
  39709. gammaCorrection: number;
  39710. private _alpha;
  39711. private _gamma;
  39712. private _dirty;
  39713. private _deviceOrientationHandler;
  39714. /**
  39715. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39716. */
  39717. constructor();
  39718. /**
  39719. * Attach the input controls to a specific dom element to get the input from.
  39720. * @param element Defines the element the controls should be listened from
  39721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39722. */
  39723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39724. /** @hidden */
  39725. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39726. /**
  39727. * Update the current camera state depending on the inputs that have been used this frame.
  39728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39729. */
  39730. checkInputs(): void;
  39731. /**
  39732. * Detach the current controls from the specified dom element.
  39733. * @param element Defines the element to stop listening the inputs from
  39734. */
  39735. detachControl(element: Nullable<HTMLElement>): void;
  39736. /**
  39737. * Gets the class name of the current intput.
  39738. * @returns the class name
  39739. */
  39740. getClassName(): string;
  39741. /**
  39742. * Get the friendly name associated with the input class.
  39743. * @returns the input friendly name
  39744. */
  39745. getSimpleName(): string;
  39746. }
  39747. }
  39748. declare module BABYLON {
  39749. /**
  39750. * Listen to mouse events to control the camera.
  39751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39752. */
  39753. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39754. /**
  39755. * Defines the camera the input is attached to.
  39756. */
  39757. camera: FlyCamera;
  39758. /**
  39759. * Defines if touch is enabled. (Default is true.)
  39760. */
  39761. touchEnabled: boolean;
  39762. /**
  39763. * Defines the buttons associated with the input to handle camera rotation.
  39764. */
  39765. buttons: number[];
  39766. /**
  39767. * Assign buttons for Yaw control.
  39768. */
  39769. buttonsYaw: number[];
  39770. /**
  39771. * Assign buttons for Pitch control.
  39772. */
  39773. buttonsPitch: number[];
  39774. /**
  39775. * Assign buttons for Roll control.
  39776. */
  39777. buttonsRoll: number[];
  39778. /**
  39779. * Detect if any button is being pressed while mouse is moved.
  39780. * -1 = Mouse locked.
  39781. * 0 = Left button.
  39782. * 1 = Middle Button.
  39783. * 2 = Right Button.
  39784. */
  39785. activeButton: number;
  39786. /**
  39787. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39788. * Higher values reduce its sensitivity.
  39789. */
  39790. angularSensibility: number;
  39791. private _mousemoveCallback;
  39792. private _observer;
  39793. private _rollObserver;
  39794. private previousPosition;
  39795. private noPreventDefault;
  39796. private element;
  39797. /**
  39798. * Listen to mouse events to control the camera.
  39799. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39801. */
  39802. constructor(touchEnabled?: boolean);
  39803. /**
  39804. * Attach the mouse control to the HTML DOM element.
  39805. * @param element Defines the element that listens to the input events.
  39806. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39807. */
  39808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39809. /**
  39810. * Detach the current controls from the specified dom element.
  39811. * @param element Defines the element to stop listening the inputs from
  39812. */
  39813. detachControl(element: Nullable<HTMLElement>): void;
  39814. /**
  39815. * Gets the class name of the current input.
  39816. * @returns the class name.
  39817. */
  39818. getClassName(): string;
  39819. /**
  39820. * Get the friendly name associated with the input class.
  39821. * @returns the input's friendly name.
  39822. */
  39823. getSimpleName(): string;
  39824. private _pointerInput;
  39825. private _onMouseMove;
  39826. /**
  39827. * Rotate camera by mouse offset.
  39828. */
  39829. private rotateCamera;
  39830. }
  39831. }
  39832. declare module BABYLON {
  39833. /**
  39834. * Default Inputs manager for the FlyCamera.
  39835. * It groups all the default supported inputs for ease of use.
  39836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39837. */
  39838. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39839. /**
  39840. * Instantiates a new FlyCameraInputsManager.
  39841. * @param camera Defines the camera the inputs belong to.
  39842. */
  39843. constructor(camera: FlyCamera);
  39844. /**
  39845. * Add keyboard input support to the input manager.
  39846. * @returns the new FlyCameraKeyboardMoveInput().
  39847. */
  39848. addKeyboard(): FlyCameraInputsManager;
  39849. /**
  39850. * Add mouse input support to the input manager.
  39851. * @param touchEnabled Enable touch screen support.
  39852. * @returns the new FlyCameraMouseInput().
  39853. */
  39854. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39855. }
  39856. }
  39857. declare module BABYLON {
  39858. /**
  39859. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39860. * such as in a 3D Space Shooter or a Flight Simulator.
  39861. */
  39862. export class FlyCamera extends TargetCamera {
  39863. /**
  39864. * Define the collision ellipsoid of the camera.
  39865. * This is helpful for simulating a camera body, like a player's body.
  39866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39867. */
  39868. ellipsoid: Vector3;
  39869. /**
  39870. * Define an offset for the position of the ellipsoid around the camera.
  39871. * This can be helpful if the camera is attached away from the player's body center,
  39872. * such as at its head.
  39873. */
  39874. ellipsoidOffset: Vector3;
  39875. /**
  39876. * Enable or disable collisions of the camera with the rest of the scene objects.
  39877. */
  39878. checkCollisions: boolean;
  39879. /**
  39880. * Enable or disable gravity on the camera.
  39881. */
  39882. applyGravity: boolean;
  39883. /**
  39884. * Define the current direction the camera is moving to.
  39885. */
  39886. cameraDirection: Vector3;
  39887. /**
  39888. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39889. * This overrides and empties cameraRotation.
  39890. */
  39891. rotationQuaternion: Quaternion;
  39892. /**
  39893. * Track Roll to maintain the wanted Rolling when looking around.
  39894. */
  39895. _trackRoll: number;
  39896. /**
  39897. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39898. */
  39899. rollCorrect: number;
  39900. /**
  39901. * Mimic a banked turn, Rolling the camera when Yawing.
  39902. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39903. */
  39904. bankedTurn: boolean;
  39905. /**
  39906. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39907. */
  39908. bankedTurnLimit: number;
  39909. /**
  39910. * Value of 0 disables the banked Roll.
  39911. * Value of 1 is equal to the Yaw angle in radians.
  39912. */
  39913. bankedTurnMultiplier: number;
  39914. /**
  39915. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39916. */
  39917. inputs: FlyCameraInputsManager;
  39918. /**
  39919. * Gets the input sensibility for mouse input.
  39920. * Higher values reduce sensitivity.
  39921. */
  39922. get angularSensibility(): number;
  39923. /**
  39924. * Sets the input sensibility for a mouse input.
  39925. * Higher values reduce sensitivity.
  39926. */
  39927. set angularSensibility(value: number);
  39928. /**
  39929. * Get the keys for camera movement forward.
  39930. */
  39931. get keysForward(): number[];
  39932. /**
  39933. * Set the keys for camera movement forward.
  39934. */
  39935. set keysForward(value: number[]);
  39936. /**
  39937. * Get the keys for camera movement backward.
  39938. */
  39939. get keysBackward(): number[];
  39940. set keysBackward(value: number[]);
  39941. /**
  39942. * Get the keys for camera movement up.
  39943. */
  39944. get keysUp(): number[];
  39945. /**
  39946. * Set the keys for camera movement up.
  39947. */
  39948. set keysUp(value: number[]);
  39949. /**
  39950. * Get the keys for camera movement down.
  39951. */
  39952. get keysDown(): number[];
  39953. /**
  39954. * Set the keys for camera movement down.
  39955. */
  39956. set keysDown(value: number[]);
  39957. /**
  39958. * Get the keys for camera movement left.
  39959. */
  39960. get keysLeft(): number[];
  39961. /**
  39962. * Set the keys for camera movement left.
  39963. */
  39964. set keysLeft(value: number[]);
  39965. /**
  39966. * Set the keys for camera movement right.
  39967. */
  39968. get keysRight(): number[];
  39969. /**
  39970. * Set the keys for camera movement right.
  39971. */
  39972. set keysRight(value: number[]);
  39973. /**
  39974. * Event raised when the camera collides with a mesh in the scene.
  39975. */
  39976. onCollide: (collidedMesh: AbstractMesh) => void;
  39977. private _collider;
  39978. private _needMoveForGravity;
  39979. private _oldPosition;
  39980. private _diffPosition;
  39981. private _newPosition;
  39982. /** @hidden */
  39983. _localDirection: Vector3;
  39984. /** @hidden */
  39985. _transformedDirection: Vector3;
  39986. /**
  39987. * Instantiates a FlyCamera.
  39988. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39989. * such as in a 3D Space Shooter or a Flight Simulator.
  39990. * @param name Define the name of the camera in the scene.
  39991. * @param position Define the starting position of the camera in the scene.
  39992. * @param scene Define the scene the camera belongs to.
  39993. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39994. */
  39995. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39996. /**
  39997. * Attach a control to the HTML DOM element.
  39998. * @param element Defines the element that listens to the input events.
  39999. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40000. */
  40001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40002. /**
  40003. * Detach a control from the HTML DOM element.
  40004. * The camera will stop reacting to that input.
  40005. * @param element Defines the element that listens to the input events.
  40006. */
  40007. detachControl(element: HTMLElement): void;
  40008. private _collisionMask;
  40009. /**
  40010. * Get the mask that the camera ignores in collision events.
  40011. */
  40012. get collisionMask(): number;
  40013. /**
  40014. * Set the mask that the camera ignores in collision events.
  40015. */
  40016. set collisionMask(mask: number);
  40017. /** @hidden */
  40018. _collideWithWorld(displacement: Vector3): void;
  40019. /** @hidden */
  40020. private _onCollisionPositionChange;
  40021. /** @hidden */
  40022. _checkInputs(): void;
  40023. /** @hidden */
  40024. _decideIfNeedsToMove(): boolean;
  40025. /** @hidden */
  40026. _updatePosition(): void;
  40027. /**
  40028. * Restore the Roll to its target value at the rate specified.
  40029. * @param rate - Higher means slower restoring.
  40030. * @hidden
  40031. */
  40032. restoreRoll(rate: number): void;
  40033. /**
  40034. * Destroy the camera and release the current resources held by it.
  40035. */
  40036. dispose(): void;
  40037. /**
  40038. * Get the current object class name.
  40039. * @returns the class name.
  40040. */
  40041. getClassName(): string;
  40042. }
  40043. }
  40044. declare module BABYLON {
  40045. /**
  40046. * Listen to keyboard events to control the camera.
  40047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40048. */
  40049. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40050. /**
  40051. * Defines the camera the input is attached to.
  40052. */
  40053. camera: FlyCamera;
  40054. /**
  40055. * The list of keyboard keys used to control the forward move of the camera.
  40056. */
  40057. keysForward: number[];
  40058. /**
  40059. * The list of keyboard keys used to control the backward move of the camera.
  40060. */
  40061. keysBackward: number[];
  40062. /**
  40063. * The list of keyboard keys used to control the forward move of the camera.
  40064. */
  40065. keysUp: number[];
  40066. /**
  40067. * The list of keyboard keys used to control the backward move of the camera.
  40068. */
  40069. keysDown: number[];
  40070. /**
  40071. * The list of keyboard keys used to control the right strafe move of the camera.
  40072. */
  40073. keysRight: number[];
  40074. /**
  40075. * The list of keyboard keys used to control the left strafe move of the camera.
  40076. */
  40077. keysLeft: number[];
  40078. private _keys;
  40079. private _onCanvasBlurObserver;
  40080. private _onKeyboardObserver;
  40081. private _engine;
  40082. private _scene;
  40083. /**
  40084. * Attach the input controls to a specific dom element to get the input from.
  40085. * @param element Defines the element the controls should be listened from
  40086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40087. */
  40088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40089. /**
  40090. * Detach the current controls from the specified dom element.
  40091. * @param element Defines the element to stop listening the inputs from
  40092. */
  40093. detachControl(element: Nullable<HTMLElement>): void;
  40094. /**
  40095. * Gets the class name of the current intput.
  40096. * @returns the class name
  40097. */
  40098. getClassName(): string;
  40099. /** @hidden */
  40100. _onLostFocus(e: FocusEvent): void;
  40101. /**
  40102. * Get the friendly name associated with the input class.
  40103. * @returns the input friendly name
  40104. */
  40105. getSimpleName(): string;
  40106. /**
  40107. * Update the current camera state depending on the inputs that have been used this frame.
  40108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40109. */
  40110. checkInputs(): void;
  40111. }
  40112. }
  40113. declare module BABYLON {
  40114. /**
  40115. * Manage the mouse wheel inputs to control a follow camera.
  40116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40117. */
  40118. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40119. /**
  40120. * Defines the camera the input is attached to.
  40121. */
  40122. camera: FollowCamera;
  40123. /**
  40124. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40125. */
  40126. axisControlRadius: boolean;
  40127. /**
  40128. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40129. */
  40130. axisControlHeight: boolean;
  40131. /**
  40132. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40133. */
  40134. axisControlRotation: boolean;
  40135. /**
  40136. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40137. * relation to mouseWheel events.
  40138. */
  40139. wheelPrecision: number;
  40140. /**
  40141. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40142. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40143. */
  40144. wheelDeltaPercentage: number;
  40145. private _wheel;
  40146. private _observer;
  40147. /**
  40148. * Attach the input controls to a specific dom element to get the input from.
  40149. * @param element Defines the element the controls should be listened from
  40150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40151. */
  40152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40153. /**
  40154. * Detach the current controls from the specified dom element.
  40155. * @param element Defines the element to stop listening the inputs from
  40156. */
  40157. detachControl(element: Nullable<HTMLElement>): void;
  40158. /**
  40159. * Gets the class name of the current intput.
  40160. * @returns the class name
  40161. */
  40162. getClassName(): string;
  40163. /**
  40164. * Get the friendly name associated with the input class.
  40165. * @returns the input friendly name
  40166. */
  40167. getSimpleName(): string;
  40168. }
  40169. }
  40170. declare module BABYLON {
  40171. /**
  40172. * Manage the pointers inputs to control an follow camera.
  40173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40174. */
  40175. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40176. /**
  40177. * Defines the camera the input is attached to.
  40178. */
  40179. camera: FollowCamera;
  40180. /**
  40181. * Gets the class name of the current input.
  40182. * @returns the class name
  40183. */
  40184. getClassName(): string;
  40185. /**
  40186. * Defines the pointer angular sensibility along the X axis or how fast is
  40187. * the camera rotating.
  40188. * A negative number will reverse the axis direction.
  40189. */
  40190. angularSensibilityX: number;
  40191. /**
  40192. * Defines the pointer angular sensibility along the Y axis or how fast is
  40193. * the camera rotating.
  40194. * A negative number will reverse the axis direction.
  40195. */
  40196. angularSensibilityY: number;
  40197. /**
  40198. * Defines the pointer pinch precision or how fast is the camera zooming.
  40199. * A negative number will reverse the axis direction.
  40200. */
  40201. pinchPrecision: number;
  40202. /**
  40203. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40204. * from 0.
  40205. * It defines the percentage of current camera.radius to use as delta when
  40206. * pinch zoom is used.
  40207. */
  40208. pinchDeltaPercentage: number;
  40209. /**
  40210. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40211. */
  40212. axisXControlRadius: boolean;
  40213. /**
  40214. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40215. */
  40216. axisXControlHeight: boolean;
  40217. /**
  40218. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40219. */
  40220. axisXControlRotation: boolean;
  40221. /**
  40222. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40223. */
  40224. axisYControlRadius: boolean;
  40225. /**
  40226. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40227. */
  40228. axisYControlHeight: boolean;
  40229. /**
  40230. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40231. */
  40232. axisYControlRotation: boolean;
  40233. /**
  40234. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40235. */
  40236. axisPinchControlRadius: boolean;
  40237. /**
  40238. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40239. */
  40240. axisPinchControlHeight: boolean;
  40241. /**
  40242. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40243. */
  40244. axisPinchControlRotation: boolean;
  40245. /**
  40246. * Log error messages if basic misconfiguration has occurred.
  40247. */
  40248. warningEnable: boolean;
  40249. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40250. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40251. private _warningCounter;
  40252. private _warning;
  40253. }
  40254. }
  40255. declare module BABYLON {
  40256. /**
  40257. * Default Inputs manager for the FollowCamera.
  40258. * It groups all the default supported inputs for ease of use.
  40259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40260. */
  40261. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40262. /**
  40263. * Instantiates a new FollowCameraInputsManager.
  40264. * @param camera Defines the camera the inputs belong to
  40265. */
  40266. constructor(camera: FollowCamera);
  40267. /**
  40268. * Add keyboard input support to the input manager.
  40269. * @returns the current input manager
  40270. */
  40271. addKeyboard(): FollowCameraInputsManager;
  40272. /**
  40273. * Add mouse wheel input support to the input manager.
  40274. * @returns the current input manager
  40275. */
  40276. addMouseWheel(): FollowCameraInputsManager;
  40277. /**
  40278. * Add pointers input support to the input manager.
  40279. * @returns the current input manager
  40280. */
  40281. addPointers(): FollowCameraInputsManager;
  40282. /**
  40283. * Add orientation input support to the input manager.
  40284. * @returns the current input manager
  40285. */
  40286. addVRDeviceOrientation(): FollowCameraInputsManager;
  40287. }
  40288. }
  40289. declare module BABYLON {
  40290. /**
  40291. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40292. * an arc rotate version arcFollowCamera are available.
  40293. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40294. */
  40295. export class FollowCamera extends TargetCamera {
  40296. /**
  40297. * Distance the follow camera should follow an object at
  40298. */
  40299. radius: number;
  40300. /**
  40301. * Minimum allowed distance of the camera to the axis of rotation
  40302. * (The camera can not get closer).
  40303. * This can help limiting how the Camera is able to move in the scene.
  40304. */
  40305. lowerRadiusLimit: Nullable<number>;
  40306. /**
  40307. * Maximum allowed distance of the camera to the axis of rotation
  40308. * (The camera can not get further).
  40309. * This can help limiting how the Camera is able to move in the scene.
  40310. */
  40311. upperRadiusLimit: Nullable<number>;
  40312. /**
  40313. * Define a rotation offset between the camera and the object it follows
  40314. */
  40315. rotationOffset: number;
  40316. /**
  40317. * Minimum allowed angle to camera position relative to target object.
  40318. * This can help limiting how the Camera is able to move in the scene.
  40319. */
  40320. lowerRotationOffsetLimit: Nullable<number>;
  40321. /**
  40322. * Maximum allowed angle to camera position relative to target object.
  40323. * This can help limiting how the Camera is able to move in the scene.
  40324. */
  40325. upperRotationOffsetLimit: Nullable<number>;
  40326. /**
  40327. * Define a height offset between the camera and the object it follows.
  40328. * It can help following an object from the top (like a car chaing a plane)
  40329. */
  40330. heightOffset: number;
  40331. /**
  40332. * Minimum allowed height of camera position relative to target object.
  40333. * This can help limiting how the Camera is able to move in the scene.
  40334. */
  40335. lowerHeightOffsetLimit: Nullable<number>;
  40336. /**
  40337. * Maximum allowed height of camera position relative to target object.
  40338. * This can help limiting how the Camera is able to move in the scene.
  40339. */
  40340. upperHeightOffsetLimit: Nullable<number>;
  40341. /**
  40342. * Define how fast the camera can accelerate to follow it s target.
  40343. */
  40344. cameraAcceleration: number;
  40345. /**
  40346. * Define the speed limit of the camera following an object.
  40347. */
  40348. maxCameraSpeed: number;
  40349. /**
  40350. * Define the target of the camera.
  40351. */
  40352. lockedTarget: Nullable<AbstractMesh>;
  40353. /**
  40354. * Defines the input associated with the camera.
  40355. */
  40356. inputs: FollowCameraInputsManager;
  40357. /**
  40358. * Instantiates the follow camera.
  40359. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40360. * @param name Define the name of the camera in the scene
  40361. * @param position Define the position of the camera
  40362. * @param scene Define the scene the camera belong to
  40363. * @param lockedTarget Define the target of the camera
  40364. */
  40365. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40366. private _follow;
  40367. /**
  40368. * Attached controls to the current camera.
  40369. * @param element Defines the element the controls should be listened from
  40370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40371. */
  40372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40373. /**
  40374. * Detach the current controls from the camera.
  40375. * The camera will stop reacting to inputs.
  40376. * @param element Defines the element to stop listening the inputs from
  40377. */
  40378. detachControl(element: HTMLElement): void;
  40379. /** @hidden */
  40380. _checkInputs(): void;
  40381. private _checkLimits;
  40382. /**
  40383. * Gets the camera class name.
  40384. * @returns the class name
  40385. */
  40386. getClassName(): string;
  40387. }
  40388. /**
  40389. * Arc Rotate version of the follow camera.
  40390. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40391. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40392. */
  40393. export class ArcFollowCamera extends TargetCamera {
  40394. /** The longitudinal angle of the camera */
  40395. alpha: number;
  40396. /** The latitudinal angle of the camera */
  40397. beta: number;
  40398. /** The radius of the camera from its target */
  40399. radius: number;
  40400. /** Define the camera target (the messh it should follow) */
  40401. target: Nullable<AbstractMesh>;
  40402. private _cartesianCoordinates;
  40403. /**
  40404. * Instantiates a new ArcFollowCamera
  40405. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40406. * @param name Define the name of the camera
  40407. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40408. * @param beta Define the rotation angle of the camera around the elevation axis
  40409. * @param radius Define the radius of the camera from its target point
  40410. * @param target Define the target of the camera
  40411. * @param scene Define the scene the camera belongs to
  40412. */
  40413. constructor(name: string,
  40414. /** The longitudinal angle of the camera */
  40415. alpha: number,
  40416. /** The latitudinal angle of the camera */
  40417. beta: number,
  40418. /** The radius of the camera from its target */
  40419. radius: number,
  40420. /** Define the camera target (the messh it should follow) */
  40421. target: Nullable<AbstractMesh>, scene: Scene);
  40422. private _follow;
  40423. /** @hidden */
  40424. _checkInputs(): void;
  40425. /**
  40426. * Returns the class name of the object.
  40427. * It is mostly used internally for serialization purposes.
  40428. */
  40429. getClassName(): string;
  40430. }
  40431. }
  40432. declare module BABYLON {
  40433. /**
  40434. * Manage the keyboard inputs to control the movement of a follow camera.
  40435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40436. */
  40437. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40438. /**
  40439. * Defines the camera the input is attached to.
  40440. */
  40441. camera: FollowCamera;
  40442. /**
  40443. * Defines the list of key codes associated with the up action (increase heightOffset)
  40444. */
  40445. keysHeightOffsetIncr: number[];
  40446. /**
  40447. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40448. */
  40449. keysHeightOffsetDecr: number[];
  40450. /**
  40451. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40452. */
  40453. keysHeightOffsetModifierAlt: boolean;
  40454. /**
  40455. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40456. */
  40457. keysHeightOffsetModifierCtrl: boolean;
  40458. /**
  40459. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40460. */
  40461. keysHeightOffsetModifierShift: boolean;
  40462. /**
  40463. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40464. */
  40465. keysRotationOffsetIncr: number[];
  40466. /**
  40467. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40468. */
  40469. keysRotationOffsetDecr: number[];
  40470. /**
  40471. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40472. */
  40473. keysRotationOffsetModifierAlt: boolean;
  40474. /**
  40475. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40476. */
  40477. keysRotationOffsetModifierCtrl: boolean;
  40478. /**
  40479. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40480. */
  40481. keysRotationOffsetModifierShift: boolean;
  40482. /**
  40483. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40484. */
  40485. keysRadiusIncr: number[];
  40486. /**
  40487. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40488. */
  40489. keysRadiusDecr: number[];
  40490. /**
  40491. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40492. */
  40493. keysRadiusModifierAlt: boolean;
  40494. /**
  40495. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40496. */
  40497. keysRadiusModifierCtrl: boolean;
  40498. /**
  40499. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40500. */
  40501. keysRadiusModifierShift: boolean;
  40502. /**
  40503. * Defines the rate of change of heightOffset.
  40504. */
  40505. heightSensibility: number;
  40506. /**
  40507. * Defines the rate of change of rotationOffset.
  40508. */
  40509. rotationSensibility: number;
  40510. /**
  40511. * Defines the rate of change of radius.
  40512. */
  40513. radiusSensibility: number;
  40514. private _keys;
  40515. private _ctrlPressed;
  40516. private _altPressed;
  40517. private _shiftPressed;
  40518. private _onCanvasBlurObserver;
  40519. private _onKeyboardObserver;
  40520. private _engine;
  40521. private _scene;
  40522. /**
  40523. * Attach the input controls to a specific dom element to get the input from.
  40524. * @param element Defines the element the controls should be listened from
  40525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40526. */
  40527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40528. /**
  40529. * Detach the current controls from the specified dom element.
  40530. * @param element Defines the element to stop listening the inputs from
  40531. */
  40532. detachControl(element: Nullable<HTMLElement>): void;
  40533. /**
  40534. * Update the current camera state depending on the inputs that have been used this frame.
  40535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40536. */
  40537. checkInputs(): void;
  40538. /**
  40539. * Gets the class name of the current input.
  40540. * @returns the class name
  40541. */
  40542. getClassName(): string;
  40543. /**
  40544. * Get the friendly name associated with the input class.
  40545. * @returns the input friendly name
  40546. */
  40547. getSimpleName(): string;
  40548. /**
  40549. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40550. * allow modification of the heightOffset value.
  40551. */
  40552. private _modifierHeightOffset;
  40553. /**
  40554. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40555. * allow modification of the rotationOffset value.
  40556. */
  40557. private _modifierRotationOffset;
  40558. /**
  40559. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40560. * allow modification of the radius value.
  40561. */
  40562. private _modifierRadius;
  40563. }
  40564. }
  40565. declare module BABYLON {
  40566. interface FreeCameraInputsManager {
  40567. /**
  40568. * @hidden
  40569. */
  40570. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40571. /**
  40572. * Add orientation input support to the input manager.
  40573. * @returns the current input manager
  40574. */
  40575. addDeviceOrientation(): FreeCameraInputsManager;
  40576. }
  40577. /**
  40578. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40579. * Screen rotation is taken into account.
  40580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40581. */
  40582. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40583. private _camera;
  40584. private _screenOrientationAngle;
  40585. private _constantTranform;
  40586. private _screenQuaternion;
  40587. private _alpha;
  40588. private _beta;
  40589. private _gamma;
  40590. /**
  40591. * Can be used to detect if a device orientation sensor is available on a device
  40592. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40593. * @returns a promise that will resolve on orientation change
  40594. */
  40595. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40596. /**
  40597. * @hidden
  40598. */
  40599. _onDeviceOrientationChangedObservable: Observable<void>;
  40600. /**
  40601. * Instantiates a new input
  40602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40603. */
  40604. constructor();
  40605. /**
  40606. * Define the camera controlled by the input.
  40607. */
  40608. get camera(): FreeCamera;
  40609. set camera(camera: FreeCamera);
  40610. /**
  40611. * Attach the input controls to a specific dom element to get the input from.
  40612. * @param element Defines the element the controls should be listened from
  40613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40614. */
  40615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40616. private _orientationChanged;
  40617. private _deviceOrientation;
  40618. /**
  40619. * Detach the current controls from the specified dom element.
  40620. * @param element Defines the element to stop listening the inputs from
  40621. */
  40622. detachControl(element: Nullable<HTMLElement>): void;
  40623. /**
  40624. * Update the current camera state depending on the inputs that have been used this frame.
  40625. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40626. */
  40627. checkInputs(): void;
  40628. /**
  40629. * Gets the class name of the current intput.
  40630. * @returns the class name
  40631. */
  40632. getClassName(): string;
  40633. /**
  40634. * Get the friendly name associated with the input class.
  40635. * @returns the input friendly name
  40636. */
  40637. getSimpleName(): string;
  40638. }
  40639. }
  40640. declare module BABYLON {
  40641. /**
  40642. * Manage the gamepad inputs to control a free camera.
  40643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40644. */
  40645. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40646. /**
  40647. * Define the camera the input is attached to.
  40648. */
  40649. camera: FreeCamera;
  40650. /**
  40651. * Define the Gamepad controlling the input
  40652. */
  40653. gamepad: Nullable<Gamepad>;
  40654. /**
  40655. * Defines the gamepad rotation sensiblity.
  40656. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40657. */
  40658. gamepadAngularSensibility: number;
  40659. /**
  40660. * Defines the gamepad move sensiblity.
  40661. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40662. */
  40663. gamepadMoveSensibility: number;
  40664. private _yAxisScale;
  40665. /**
  40666. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40667. */
  40668. get invertYAxis(): boolean;
  40669. set invertYAxis(value: boolean);
  40670. private _onGamepadConnectedObserver;
  40671. private _onGamepadDisconnectedObserver;
  40672. private _cameraTransform;
  40673. private _deltaTransform;
  40674. private _vector3;
  40675. private _vector2;
  40676. /**
  40677. * Attach the input controls to a specific dom element to get the input from.
  40678. * @param element Defines the element the controls should be listened from
  40679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40680. */
  40681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40682. /**
  40683. * Detach the current controls from the specified dom element.
  40684. * @param element Defines the element to stop listening the inputs from
  40685. */
  40686. detachControl(element: Nullable<HTMLElement>): void;
  40687. /**
  40688. * Update the current camera state depending on the inputs that have been used this frame.
  40689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40690. */
  40691. checkInputs(): void;
  40692. /**
  40693. * Gets the class name of the current intput.
  40694. * @returns the class name
  40695. */
  40696. getClassName(): string;
  40697. /**
  40698. * Get the friendly name associated with the input class.
  40699. * @returns the input friendly name
  40700. */
  40701. getSimpleName(): string;
  40702. }
  40703. }
  40704. declare module BABYLON {
  40705. /**
  40706. * Defines the potential axis of a Joystick
  40707. */
  40708. export enum JoystickAxis {
  40709. /** X axis */
  40710. X = 0,
  40711. /** Y axis */
  40712. Y = 1,
  40713. /** Z axis */
  40714. Z = 2
  40715. }
  40716. /**
  40717. * Class used to define virtual joystick (used in touch mode)
  40718. */
  40719. export class VirtualJoystick {
  40720. /**
  40721. * Gets or sets a boolean indicating that left and right values must be inverted
  40722. */
  40723. reverseLeftRight: boolean;
  40724. /**
  40725. * Gets or sets a boolean indicating that up and down values must be inverted
  40726. */
  40727. reverseUpDown: boolean;
  40728. /**
  40729. * Gets the offset value for the position (ie. the change of the position value)
  40730. */
  40731. deltaPosition: Vector3;
  40732. /**
  40733. * Gets a boolean indicating if the virtual joystick was pressed
  40734. */
  40735. pressed: boolean;
  40736. /**
  40737. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40738. */
  40739. static Canvas: Nullable<HTMLCanvasElement>;
  40740. private static _globalJoystickIndex;
  40741. private static vjCanvasContext;
  40742. private static vjCanvasWidth;
  40743. private static vjCanvasHeight;
  40744. private static halfWidth;
  40745. private _action;
  40746. private _axisTargetedByLeftAndRight;
  40747. private _axisTargetedByUpAndDown;
  40748. private _joystickSensibility;
  40749. private _inversedSensibility;
  40750. private _joystickPointerID;
  40751. private _joystickColor;
  40752. private _joystickPointerPos;
  40753. private _joystickPreviousPointerPos;
  40754. private _joystickPointerStartPos;
  40755. private _deltaJoystickVector;
  40756. private _leftJoystick;
  40757. private _touches;
  40758. private _onPointerDownHandlerRef;
  40759. private _onPointerMoveHandlerRef;
  40760. private _onPointerUpHandlerRef;
  40761. private _onResize;
  40762. /**
  40763. * Creates a new virtual joystick
  40764. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40765. */
  40766. constructor(leftJoystick?: boolean);
  40767. /**
  40768. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40769. * @param newJoystickSensibility defines the new sensibility
  40770. */
  40771. setJoystickSensibility(newJoystickSensibility: number): void;
  40772. private _onPointerDown;
  40773. private _onPointerMove;
  40774. private _onPointerUp;
  40775. /**
  40776. * Change the color of the virtual joystick
  40777. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40778. */
  40779. setJoystickColor(newColor: string): void;
  40780. /**
  40781. * Defines a callback to call when the joystick is touched
  40782. * @param action defines the callback
  40783. */
  40784. setActionOnTouch(action: () => any): void;
  40785. /**
  40786. * Defines which axis you'd like to control for left & right
  40787. * @param axis defines the axis to use
  40788. */
  40789. setAxisForLeftRight(axis: JoystickAxis): void;
  40790. /**
  40791. * Defines which axis you'd like to control for up & down
  40792. * @param axis defines the axis to use
  40793. */
  40794. setAxisForUpDown(axis: JoystickAxis): void;
  40795. private _drawVirtualJoystick;
  40796. /**
  40797. * Release internal HTML canvas
  40798. */
  40799. releaseCanvas(): void;
  40800. }
  40801. }
  40802. declare module BABYLON {
  40803. interface FreeCameraInputsManager {
  40804. /**
  40805. * Add virtual joystick input support to the input manager.
  40806. * @returns the current input manager
  40807. */
  40808. addVirtualJoystick(): FreeCameraInputsManager;
  40809. }
  40810. /**
  40811. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40813. */
  40814. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40815. /**
  40816. * Defines the camera the input is attached to.
  40817. */
  40818. camera: FreeCamera;
  40819. private _leftjoystick;
  40820. private _rightjoystick;
  40821. /**
  40822. * Gets the left stick of the virtual joystick.
  40823. * @returns The virtual Joystick
  40824. */
  40825. getLeftJoystick(): VirtualJoystick;
  40826. /**
  40827. * Gets the right stick of the virtual joystick.
  40828. * @returns The virtual Joystick
  40829. */
  40830. getRightJoystick(): VirtualJoystick;
  40831. /**
  40832. * Update the current camera state depending on the inputs that have been used this frame.
  40833. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40834. */
  40835. checkInputs(): void;
  40836. /**
  40837. * Attach the input controls to a specific dom element to get the input from.
  40838. * @param element Defines the element the controls should be listened from
  40839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40840. */
  40841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40842. /**
  40843. * Detach the current controls from the specified dom element.
  40844. * @param element Defines the element to stop listening the inputs from
  40845. */
  40846. detachControl(element: Nullable<HTMLElement>): void;
  40847. /**
  40848. * Gets the class name of the current intput.
  40849. * @returns the class name
  40850. */
  40851. getClassName(): string;
  40852. /**
  40853. * Get the friendly name associated with the input class.
  40854. * @returns the input friendly name
  40855. */
  40856. getSimpleName(): string;
  40857. }
  40858. }
  40859. declare module BABYLON {
  40860. /**
  40861. * This represents a FPS type of camera controlled by touch.
  40862. * This is like a universal camera minus the Gamepad controls.
  40863. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40864. */
  40865. export class TouchCamera extends FreeCamera {
  40866. /**
  40867. * Defines the touch sensibility for rotation.
  40868. * The higher the faster.
  40869. */
  40870. get touchAngularSensibility(): number;
  40871. set touchAngularSensibility(value: number);
  40872. /**
  40873. * Defines the touch sensibility for move.
  40874. * The higher the faster.
  40875. */
  40876. get touchMoveSensibility(): number;
  40877. set touchMoveSensibility(value: number);
  40878. /**
  40879. * Instantiates a new touch camera.
  40880. * This represents a FPS type of camera controlled by touch.
  40881. * This is like a universal camera minus the Gamepad controls.
  40882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40883. * @param name Define the name of the camera in the scene
  40884. * @param position Define the start position of the camera in the scene
  40885. * @param scene Define the scene the camera belongs to
  40886. */
  40887. constructor(name: string, position: Vector3, scene: Scene);
  40888. /**
  40889. * Gets the current object class name.
  40890. * @return the class name
  40891. */
  40892. getClassName(): string;
  40893. /** @hidden */
  40894. _setupInputs(): void;
  40895. }
  40896. }
  40897. declare module BABYLON {
  40898. /**
  40899. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40900. * being tilted forward or back and left or right.
  40901. */
  40902. export class DeviceOrientationCamera extends FreeCamera {
  40903. private _initialQuaternion;
  40904. private _quaternionCache;
  40905. private _tmpDragQuaternion;
  40906. private _disablePointerInputWhenUsingDeviceOrientation;
  40907. /**
  40908. * Creates a new device orientation camera
  40909. * @param name The name of the camera
  40910. * @param position The start position camera
  40911. * @param scene The scene the camera belongs to
  40912. */
  40913. constructor(name: string, position: Vector3, scene: Scene);
  40914. /**
  40915. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40916. */
  40917. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40918. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40919. private _dragFactor;
  40920. /**
  40921. * Enabled turning on the y axis when the orientation sensor is active
  40922. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40923. */
  40924. enableHorizontalDragging(dragFactor?: number): void;
  40925. /**
  40926. * Gets the current instance class name ("DeviceOrientationCamera").
  40927. * This helps avoiding instanceof at run time.
  40928. * @returns the class name
  40929. */
  40930. getClassName(): string;
  40931. /**
  40932. * @hidden
  40933. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40934. */
  40935. _checkInputs(): void;
  40936. /**
  40937. * Reset the camera to its default orientation on the specified axis only.
  40938. * @param axis The axis to reset
  40939. */
  40940. resetToCurrentRotation(axis?: Axis): void;
  40941. }
  40942. }
  40943. declare module BABYLON {
  40944. /**
  40945. * Defines supported buttons for XBox360 compatible gamepads
  40946. */
  40947. export enum Xbox360Button {
  40948. /** A */
  40949. A = 0,
  40950. /** B */
  40951. B = 1,
  40952. /** X */
  40953. X = 2,
  40954. /** Y */
  40955. Y = 3,
  40956. /** Start */
  40957. Start = 4,
  40958. /** Back */
  40959. Back = 5,
  40960. /** Left button */
  40961. LB = 6,
  40962. /** Right button */
  40963. RB = 7,
  40964. /** Left stick */
  40965. LeftStick = 8,
  40966. /** Right stick */
  40967. RightStick = 9
  40968. }
  40969. /** Defines values for XBox360 DPad */
  40970. export enum Xbox360Dpad {
  40971. /** Up */
  40972. Up = 0,
  40973. /** Down */
  40974. Down = 1,
  40975. /** Left */
  40976. Left = 2,
  40977. /** Right */
  40978. Right = 3
  40979. }
  40980. /**
  40981. * Defines a XBox360 gamepad
  40982. */
  40983. export class Xbox360Pad extends Gamepad {
  40984. private _leftTrigger;
  40985. private _rightTrigger;
  40986. private _onlefttriggerchanged;
  40987. private _onrighttriggerchanged;
  40988. private _onbuttondown;
  40989. private _onbuttonup;
  40990. private _ondpaddown;
  40991. private _ondpadup;
  40992. /** Observable raised when a button is pressed */
  40993. onButtonDownObservable: Observable<Xbox360Button>;
  40994. /** Observable raised when a button is released */
  40995. onButtonUpObservable: Observable<Xbox360Button>;
  40996. /** Observable raised when a pad is pressed */
  40997. onPadDownObservable: Observable<Xbox360Dpad>;
  40998. /** Observable raised when a pad is released */
  40999. onPadUpObservable: Observable<Xbox360Dpad>;
  41000. private _buttonA;
  41001. private _buttonB;
  41002. private _buttonX;
  41003. private _buttonY;
  41004. private _buttonBack;
  41005. private _buttonStart;
  41006. private _buttonLB;
  41007. private _buttonRB;
  41008. private _buttonLeftStick;
  41009. private _buttonRightStick;
  41010. private _dPadUp;
  41011. private _dPadDown;
  41012. private _dPadLeft;
  41013. private _dPadRight;
  41014. private _isXboxOnePad;
  41015. /**
  41016. * Creates a new XBox360 gamepad object
  41017. * @param id defines the id of this gamepad
  41018. * @param index defines its index
  41019. * @param gamepad defines the internal HTML gamepad object
  41020. * @param xboxOne defines if it is a XBox One gamepad
  41021. */
  41022. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41023. /**
  41024. * Defines the callback to call when left trigger is pressed
  41025. * @param callback defines the callback to use
  41026. */
  41027. onlefttriggerchanged(callback: (value: number) => void): void;
  41028. /**
  41029. * Defines the callback to call when right trigger is pressed
  41030. * @param callback defines the callback to use
  41031. */
  41032. onrighttriggerchanged(callback: (value: number) => void): void;
  41033. /**
  41034. * Gets the left trigger value
  41035. */
  41036. get leftTrigger(): number;
  41037. /**
  41038. * Sets the left trigger value
  41039. */
  41040. set leftTrigger(newValue: number);
  41041. /**
  41042. * Gets the right trigger value
  41043. */
  41044. get rightTrigger(): number;
  41045. /**
  41046. * Sets the right trigger value
  41047. */
  41048. set rightTrigger(newValue: number);
  41049. /**
  41050. * Defines the callback to call when a button is pressed
  41051. * @param callback defines the callback to use
  41052. */
  41053. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41054. /**
  41055. * Defines the callback to call when a button is released
  41056. * @param callback defines the callback to use
  41057. */
  41058. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41059. /**
  41060. * Defines the callback to call when a pad is pressed
  41061. * @param callback defines the callback to use
  41062. */
  41063. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41064. /**
  41065. * Defines the callback to call when a pad is released
  41066. * @param callback defines the callback to use
  41067. */
  41068. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41069. private _setButtonValue;
  41070. private _setDPadValue;
  41071. /**
  41072. * Gets the value of the `A` button
  41073. */
  41074. get buttonA(): number;
  41075. /**
  41076. * Sets the value of the `A` button
  41077. */
  41078. set buttonA(value: number);
  41079. /**
  41080. * Gets the value of the `B` button
  41081. */
  41082. get buttonB(): number;
  41083. /**
  41084. * Sets the value of the `B` button
  41085. */
  41086. set buttonB(value: number);
  41087. /**
  41088. * Gets the value of the `X` button
  41089. */
  41090. get buttonX(): number;
  41091. /**
  41092. * Sets the value of the `X` button
  41093. */
  41094. set buttonX(value: number);
  41095. /**
  41096. * Gets the value of the `Y` button
  41097. */
  41098. get buttonY(): number;
  41099. /**
  41100. * Sets the value of the `Y` button
  41101. */
  41102. set buttonY(value: number);
  41103. /**
  41104. * Gets the value of the `Start` button
  41105. */
  41106. get buttonStart(): number;
  41107. /**
  41108. * Sets the value of the `Start` button
  41109. */
  41110. set buttonStart(value: number);
  41111. /**
  41112. * Gets the value of the `Back` button
  41113. */
  41114. get buttonBack(): number;
  41115. /**
  41116. * Sets the value of the `Back` button
  41117. */
  41118. set buttonBack(value: number);
  41119. /**
  41120. * Gets the value of the `Left` button
  41121. */
  41122. get buttonLB(): number;
  41123. /**
  41124. * Sets the value of the `Left` button
  41125. */
  41126. set buttonLB(value: number);
  41127. /**
  41128. * Gets the value of the `Right` button
  41129. */
  41130. get buttonRB(): number;
  41131. /**
  41132. * Sets the value of the `Right` button
  41133. */
  41134. set buttonRB(value: number);
  41135. /**
  41136. * Gets the value of the Left joystick
  41137. */
  41138. get buttonLeftStick(): number;
  41139. /**
  41140. * Sets the value of the Left joystick
  41141. */
  41142. set buttonLeftStick(value: number);
  41143. /**
  41144. * Gets the value of the Right joystick
  41145. */
  41146. get buttonRightStick(): number;
  41147. /**
  41148. * Sets the value of the Right joystick
  41149. */
  41150. set buttonRightStick(value: number);
  41151. /**
  41152. * Gets the value of D-pad up
  41153. */
  41154. get dPadUp(): number;
  41155. /**
  41156. * Sets the value of D-pad up
  41157. */
  41158. set dPadUp(value: number);
  41159. /**
  41160. * Gets the value of D-pad down
  41161. */
  41162. get dPadDown(): number;
  41163. /**
  41164. * Sets the value of D-pad down
  41165. */
  41166. set dPadDown(value: number);
  41167. /**
  41168. * Gets the value of D-pad left
  41169. */
  41170. get dPadLeft(): number;
  41171. /**
  41172. * Sets the value of D-pad left
  41173. */
  41174. set dPadLeft(value: number);
  41175. /**
  41176. * Gets the value of D-pad right
  41177. */
  41178. get dPadRight(): number;
  41179. /**
  41180. * Sets the value of D-pad right
  41181. */
  41182. set dPadRight(value: number);
  41183. /**
  41184. * Force the gamepad to synchronize with device values
  41185. */
  41186. update(): void;
  41187. /**
  41188. * Disposes the gamepad
  41189. */
  41190. dispose(): void;
  41191. }
  41192. }
  41193. declare module BABYLON {
  41194. /**
  41195. * Defines supported buttons for DualShock compatible gamepads
  41196. */
  41197. export enum DualShockButton {
  41198. /** Cross */
  41199. Cross = 0,
  41200. /** Circle */
  41201. Circle = 1,
  41202. /** Square */
  41203. Square = 2,
  41204. /** Triangle */
  41205. Triangle = 3,
  41206. /** Options */
  41207. Options = 4,
  41208. /** Share */
  41209. Share = 5,
  41210. /** L1 */
  41211. L1 = 6,
  41212. /** R1 */
  41213. R1 = 7,
  41214. /** Left stick */
  41215. LeftStick = 8,
  41216. /** Right stick */
  41217. RightStick = 9
  41218. }
  41219. /** Defines values for DualShock DPad */
  41220. export enum DualShockDpad {
  41221. /** Up */
  41222. Up = 0,
  41223. /** Down */
  41224. Down = 1,
  41225. /** Left */
  41226. Left = 2,
  41227. /** Right */
  41228. Right = 3
  41229. }
  41230. /**
  41231. * Defines a DualShock gamepad
  41232. */
  41233. export class DualShockPad extends Gamepad {
  41234. private _leftTrigger;
  41235. private _rightTrigger;
  41236. private _onlefttriggerchanged;
  41237. private _onrighttriggerchanged;
  41238. private _onbuttondown;
  41239. private _onbuttonup;
  41240. private _ondpaddown;
  41241. private _ondpadup;
  41242. /** Observable raised when a button is pressed */
  41243. onButtonDownObservable: Observable<DualShockButton>;
  41244. /** Observable raised when a button is released */
  41245. onButtonUpObservable: Observable<DualShockButton>;
  41246. /** Observable raised when a pad is pressed */
  41247. onPadDownObservable: Observable<DualShockDpad>;
  41248. /** Observable raised when a pad is released */
  41249. onPadUpObservable: Observable<DualShockDpad>;
  41250. private _buttonCross;
  41251. private _buttonCircle;
  41252. private _buttonSquare;
  41253. private _buttonTriangle;
  41254. private _buttonShare;
  41255. private _buttonOptions;
  41256. private _buttonL1;
  41257. private _buttonR1;
  41258. private _buttonLeftStick;
  41259. private _buttonRightStick;
  41260. private _dPadUp;
  41261. private _dPadDown;
  41262. private _dPadLeft;
  41263. private _dPadRight;
  41264. /**
  41265. * Creates a new DualShock gamepad object
  41266. * @param id defines the id of this gamepad
  41267. * @param index defines its index
  41268. * @param gamepad defines the internal HTML gamepad object
  41269. */
  41270. constructor(id: string, index: number, gamepad: any);
  41271. /**
  41272. * Defines the callback to call when left trigger is pressed
  41273. * @param callback defines the callback to use
  41274. */
  41275. onlefttriggerchanged(callback: (value: number) => void): void;
  41276. /**
  41277. * Defines the callback to call when right trigger is pressed
  41278. * @param callback defines the callback to use
  41279. */
  41280. onrighttriggerchanged(callback: (value: number) => void): void;
  41281. /**
  41282. * Gets the left trigger value
  41283. */
  41284. get leftTrigger(): number;
  41285. /**
  41286. * Sets the left trigger value
  41287. */
  41288. set leftTrigger(newValue: number);
  41289. /**
  41290. * Gets the right trigger value
  41291. */
  41292. get rightTrigger(): number;
  41293. /**
  41294. * Sets the right trigger value
  41295. */
  41296. set rightTrigger(newValue: number);
  41297. /**
  41298. * Defines the callback to call when a button is pressed
  41299. * @param callback defines the callback to use
  41300. */
  41301. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41302. /**
  41303. * Defines the callback to call when a button is released
  41304. * @param callback defines the callback to use
  41305. */
  41306. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41307. /**
  41308. * Defines the callback to call when a pad is pressed
  41309. * @param callback defines the callback to use
  41310. */
  41311. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41312. /**
  41313. * Defines the callback to call when a pad is released
  41314. * @param callback defines the callback to use
  41315. */
  41316. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41317. private _setButtonValue;
  41318. private _setDPadValue;
  41319. /**
  41320. * Gets the value of the `Cross` button
  41321. */
  41322. get buttonCross(): number;
  41323. /**
  41324. * Sets the value of the `Cross` button
  41325. */
  41326. set buttonCross(value: number);
  41327. /**
  41328. * Gets the value of the `Circle` button
  41329. */
  41330. get buttonCircle(): number;
  41331. /**
  41332. * Sets the value of the `Circle` button
  41333. */
  41334. set buttonCircle(value: number);
  41335. /**
  41336. * Gets the value of the `Square` button
  41337. */
  41338. get buttonSquare(): number;
  41339. /**
  41340. * Sets the value of the `Square` button
  41341. */
  41342. set buttonSquare(value: number);
  41343. /**
  41344. * Gets the value of the `Triangle` button
  41345. */
  41346. get buttonTriangle(): number;
  41347. /**
  41348. * Sets the value of the `Triangle` button
  41349. */
  41350. set buttonTriangle(value: number);
  41351. /**
  41352. * Gets the value of the `Options` button
  41353. */
  41354. get buttonOptions(): number;
  41355. /**
  41356. * Sets the value of the `Options` button
  41357. */
  41358. set buttonOptions(value: number);
  41359. /**
  41360. * Gets the value of the `Share` button
  41361. */
  41362. get buttonShare(): number;
  41363. /**
  41364. * Sets the value of the `Share` button
  41365. */
  41366. set buttonShare(value: number);
  41367. /**
  41368. * Gets the value of the `L1` button
  41369. */
  41370. get buttonL1(): number;
  41371. /**
  41372. * Sets the value of the `L1` button
  41373. */
  41374. set buttonL1(value: number);
  41375. /**
  41376. * Gets the value of the `R1` button
  41377. */
  41378. get buttonR1(): number;
  41379. /**
  41380. * Sets the value of the `R1` button
  41381. */
  41382. set buttonR1(value: number);
  41383. /**
  41384. * Gets the value of the Left joystick
  41385. */
  41386. get buttonLeftStick(): number;
  41387. /**
  41388. * Sets the value of the Left joystick
  41389. */
  41390. set buttonLeftStick(value: number);
  41391. /**
  41392. * Gets the value of the Right joystick
  41393. */
  41394. get buttonRightStick(): number;
  41395. /**
  41396. * Sets the value of the Right joystick
  41397. */
  41398. set buttonRightStick(value: number);
  41399. /**
  41400. * Gets the value of D-pad up
  41401. */
  41402. get dPadUp(): number;
  41403. /**
  41404. * Sets the value of D-pad up
  41405. */
  41406. set dPadUp(value: number);
  41407. /**
  41408. * Gets the value of D-pad down
  41409. */
  41410. get dPadDown(): number;
  41411. /**
  41412. * Sets the value of D-pad down
  41413. */
  41414. set dPadDown(value: number);
  41415. /**
  41416. * Gets the value of D-pad left
  41417. */
  41418. get dPadLeft(): number;
  41419. /**
  41420. * Sets the value of D-pad left
  41421. */
  41422. set dPadLeft(value: number);
  41423. /**
  41424. * Gets the value of D-pad right
  41425. */
  41426. get dPadRight(): number;
  41427. /**
  41428. * Sets the value of D-pad right
  41429. */
  41430. set dPadRight(value: number);
  41431. /**
  41432. * Force the gamepad to synchronize with device values
  41433. */
  41434. update(): void;
  41435. /**
  41436. * Disposes the gamepad
  41437. */
  41438. dispose(): void;
  41439. }
  41440. }
  41441. declare module BABYLON {
  41442. /**
  41443. * Manager for handling gamepads
  41444. */
  41445. export class GamepadManager {
  41446. private _scene?;
  41447. private _babylonGamepads;
  41448. private _oneGamepadConnected;
  41449. /** @hidden */
  41450. _isMonitoring: boolean;
  41451. private _gamepadEventSupported;
  41452. private _gamepadSupport?;
  41453. /**
  41454. * observable to be triggered when the gamepad controller has been connected
  41455. */
  41456. onGamepadConnectedObservable: Observable<Gamepad>;
  41457. /**
  41458. * observable to be triggered when the gamepad controller has been disconnected
  41459. */
  41460. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41461. private _onGamepadConnectedEvent;
  41462. private _onGamepadDisconnectedEvent;
  41463. /**
  41464. * Initializes the gamepad manager
  41465. * @param _scene BabylonJS scene
  41466. */
  41467. constructor(_scene?: Scene | undefined);
  41468. /**
  41469. * The gamepads in the game pad manager
  41470. */
  41471. get gamepads(): Gamepad[];
  41472. /**
  41473. * Get the gamepad controllers based on type
  41474. * @param type The type of gamepad controller
  41475. * @returns Nullable gamepad
  41476. */
  41477. getGamepadByType(type?: number): Nullable<Gamepad>;
  41478. /**
  41479. * Disposes the gamepad manager
  41480. */
  41481. dispose(): void;
  41482. private _addNewGamepad;
  41483. private _startMonitoringGamepads;
  41484. private _stopMonitoringGamepads;
  41485. /** @hidden */
  41486. _checkGamepadsStatus(): void;
  41487. private _updateGamepadObjects;
  41488. }
  41489. }
  41490. declare module BABYLON {
  41491. interface Scene {
  41492. /** @hidden */
  41493. _gamepadManager: Nullable<GamepadManager>;
  41494. /**
  41495. * Gets the gamepad manager associated with the scene
  41496. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41497. */
  41498. gamepadManager: GamepadManager;
  41499. }
  41500. /**
  41501. * Interface representing a free camera inputs manager
  41502. */
  41503. interface FreeCameraInputsManager {
  41504. /**
  41505. * Adds gamepad input support to the FreeCameraInputsManager.
  41506. * @returns the FreeCameraInputsManager
  41507. */
  41508. addGamepad(): FreeCameraInputsManager;
  41509. }
  41510. /**
  41511. * Interface representing an arc rotate camera inputs manager
  41512. */
  41513. interface ArcRotateCameraInputsManager {
  41514. /**
  41515. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41516. * @returns the camera inputs manager
  41517. */
  41518. addGamepad(): ArcRotateCameraInputsManager;
  41519. }
  41520. /**
  41521. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41522. */
  41523. export class GamepadSystemSceneComponent implements ISceneComponent {
  41524. /**
  41525. * The component name helpfull to identify the component in the list of scene components.
  41526. */
  41527. readonly name: string;
  41528. /**
  41529. * The scene the component belongs to.
  41530. */
  41531. scene: Scene;
  41532. /**
  41533. * Creates a new instance of the component for the given scene
  41534. * @param scene Defines the scene to register the component in
  41535. */
  41536. constructor(scene: Scene);
  41537. /**
  41538. * Registers the component in a given scene
  41539. */
  41540. register(): void;
  41541. /**
  41542. * Rebuilds the elements related to this component in case of
  41543. * context lost for instance.
  41544. */
  41545. rebuild(): void;
  41546. /**
  41547. * Disposes the component and the associated ressources
  41548. */
  41549. dispose(): void;
  41550. private _beforeCameraUpdate;
  41551. }
  41552. }
  41553. declare module BABYLON {
  41554. /**
  41555. * 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,
  41556. * which still works and will still be found in many Playgrounds.
  41557. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41558. */
  41559. export class UniversalCamera extends TouchCamera {
  41560. /**
  41561. * Defines the gamepad rotation sensiblity.
  41562. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41563. */
  41564. get gamepadAngularSensibility(): number;
  41565. set gamepadAngularSensibility(value: number);
  41566. /**
  41567. * Defines the gamepad move sensiblity.
  41568. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41569. */
  41570. get gamepadMoveSensibility(): number;
  41571. set gamepadMoveSensibility(value: number);
  41572. /**
  41573. * 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,
  41574. * which still works and will still be found in many Playgrounds.
  41575. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41576. * @param name Define the name of the camera in the scene
  41577. * @param position Define the start position of the camera in the scene
  41578. * @param scene Define the scene the camera belongs to
  41579. */
  41580. constructor(name: string, position: Vector3, scene: Scene);
  41581. /**
  41582. * Gets the current object class name.
  41583. * @return the class name
  41584. */
  41585. getClassName(): string;
  41586. }
  41587. }
  41588. declare module BABYLON {
  41589. /**
  41590. * This represents a FPS type of camera. This is only here for back compat purpose.
  41591. * Please use the UniversalCamera instead as both are identical.
  41592. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41593. */
  41594. export class GamepadCamera extends UniversalCamera {
  41595. /**
  41596. * Instantiates a new Gamepad Camera
  41597. * This represents a FPS type of camera. This is only here for back compat purpose.
  41598. * Please use the UniversalCamera instead as both are identical.
  41599. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41600. * @param name Define the name of the camera in the scene
  41601. * @param position Define the start position of the camera in the scene
  41602. * @param scene Define the scene the camera belongs to
  41603. */
  41604. constructor(name: string, position: Vector3, scene: Scene);
  41605. /**
  41606. * Gets the current object class name.
  41607. * @return the class name
  41608. */
  41609. getClassName(): string;
  41610. }
  41611. }
  41612. declare module BABYLON {
  41613. /** @hidden */
  41614. export var passPixelShader: {
  41615. name: string;
  41616. shader: string;
  41617. };
  41618. }
  41619. declare module BABYLON {
  41620. /** @hidden */
  41621. export var passCubePixelShader: {
  41622. name: string;
  41623. shader: string;
  41624. };
  41625. }
  41626. declare module BABYLON {
  41627. /**
  41628. * PassPostProcess which produces an output the same as it's input
  41629. */
  41630. export class PassPostProcess extends PostProcess {
  41631. /**
  41632. * Creates the PassPostProcess
  41633. * @param name The name of the effect.
  41634. * @param options The required width/height ratio to downsize to before computing the render pass.
  41635. * @param camera The camera to apply the render pass to.
  41636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41637. * @param engine The engine which the post process will be applied. (default: current engine)
  41638. * @param reusable If the post process can be reused on the same frame. (default: false)
  41639. * @param textureType The type of texture to be used when performing the post processing.
  41640. * @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)
  41641. */
  41642. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41643. }
  41644. /**
  41645. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41646. */
  41647. export class PassCubePostProcess extends PostProcess {
  41648. private _face;
  41649. /**
  41650. * Gets or sets the cube face to display.
  41651. * * 0 is +X
  41652. * * 1 is -X
  41653. * * 2 is +Y
  41654. * * 3 is -Y
  41655. * * 4 is +Z
  41656. * * 5 is -Z
  41657. */
  41658. get face(): number;
  41659. set face(value: number);
  41660. /**
  41661. * Creates the PassCubePostProcess
  41662. * @param name The name of the effect.
  41663. * @param options The required width/height ratio to downsize to before computing the render pass.
  41664. * @param camera The camera to apply the render pass to.
  41665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41666. * @param engine The engine which the post process will be applied. (default: current engine)
  41667. * @param reusable If the post process can be reused on the same frame. (default: false)
  41668. * @param textureType The type of texture to be used when performing the post processing.
  41669. * @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)
  41670. */
  41671. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41672. }
  41673. }
  41674. declare module BABYLON {
  41675. /** @hidden */
  41676. export var anaglyphPixelShader: {
  41677. name: string;
  41678. shader: string;
  41679. };
  41680. }
  41681. declare module BABYLON {
  41682. /**
  41683. * Postprocess used to generate anaglyphic rendering
  41684. */
  41685. export class AnaglyphPostProcess extends PostProcess {
  41686. private _passedProcess;
  41687. /**
  41688. * Creates a new AnaglyphPostProcess
  41689. * @param name defines postprocess name
  41690. * @param options defines creation options or target ratio scale
  41691. * @param rigCameras defines cameras using this postprocess
  41692. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41693. * @param engine defines hosting engine
  41694. * @param reusable defines if the postprocess will be reused multiple times per frame
  41695. */
  41696. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41697. }
  41698. }
  41699. declare module BABYLON {
  41700. /**
  41701. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41702. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41703. */
  41704. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41705. /**
  41706. * Creates a new AnaglyphArcRotateCamera
  41707. * @param name defines camera name
  41708. * @param alpha defines alpha angle (in radians)
  41709. * @param beta defines beta angle (in radians)
  41710. * @param radius defines radius
  41711. * @param target defines camera target
  41712. * @param interaxialDistance defines distance between each color axis
  41713. * @param scene defines the hosting scene
  41714. */
  41715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41716. /**
  41717. * Gets camera class name
  41718. * @returns AnaglyphArcRotateCamera
  41719. */
  41720. getClassName(): string;
  41721. }
  41722. }
  41723. declare module BABYLON {
  41724. /**
  41725. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41726. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41727. */
  41728. export class AnaglyphFreeCamera extends FreeCamera {
  41729. /**
  41730. * Creates a new AnaglyphFreeCamera
  41731. * @param name defines camera name
  41732. * @param position defines initial position
  41733. * @param interaxialDistance defines distance between each color axis
  41734. * @param scene defines the hosting scene
  41735. */
  41736. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41737. /**
  41738. * Gets camera class name
  41739. * @returns AnaglyphFreeCamera
  41740. */
  41741. getClassName(): string;
  41742. }
  41743. }
  41744. declare module BABYLON {
  41745. /**
  41746. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41747. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41748. */
  41749. export class AnaglyphGamepadCamera extends GamepadCamera {
  41750. /**
  41751. * Creates a new AnaglyphGamepadCamera
  41752. * @param name defines camera name
  41753. * @param position defines initial position
  41754. * @param interaxialDistance defines distance between each color axis
  41755. * @param scene defines the hosting scene
  41756. */
  41757. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41758. /**
  41759. * Gets camera class name
  41760. * @returns AnaglyphGamepadCamera
  41761. */
  41762. getClassName(): string;
  41763. }
  41764. }
  41765. declare module BABYLON {
  41766. /**
  41767. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41768. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41769. */
  41770. export class AnaglyphUniversalCamera extends UniversalCamera {
  41771. /**
  41772. * Creates a new AnaglyphUniversalCamera
  41773. * @param name defines camera name
  41774. * @param position defines initial position
  41775. * @param interaxialDistance defines distance between each color axis
  41776. * @param scene defines the hosting scene
  41777. */
  41778. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41779. /**
  41780. * Gets camera class name
  41781. * @returns AnaglyphUniversalCamera
  41782. */
  41783. getClassName(): string;
  41784. }
  41785. }
  41786. declare module BABYLON {
  41787. /** @hidden */
  41788. export var stereoscopicInterlacePixelShader: {
  41789. name: string;
  41790. shader: string;
  41791. };
  41792. }
  41793. declare module BABYLON {
  41794. /**
  41795. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41796. */
  41797. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41798. private _stepSize;
  41799. private _passedProcess;
  41800. /**
  41801. * Initializes a StereoscopicInterlacePostProcessI
  41802. * @param name The name of the effect.
  41803. * @param rigCameras The rig cameras to be appled to the post process
  41804. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41805. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41807. * @param engine The engine which the post process will be applied. (default: current engine)
  41808. * @param reusable If the post process can be reused on the same frame. (default: false)
  41809. */
  41810. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41811. }
  41812. /**
  41813. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41814. */
  41815. export class StereoscopicInterlacePostProcess extends PostProcess {
  41816. private _stepSize;
  41817. private _passedProcess;
  41818. /**
  41819. * Initializes a StereoscopicInterlacePostProcess
  41820. * @param name The name of the effect.
  41821. * @param rigCameras The rig cameras to be appled to the post process
  41822. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41824. * @param engine The engine which the post process will be applied. (default: current engine)
  41825. * @param reusable If the post process can be reused on the same frame. (default: false)
  41826. */
  41827. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41828. }
  41829. }
  41830. declare module BABYLON {
  41831. /**
  41832. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41833. * @see http://doc.babylonjs.com/features/cameras
  41834. */
  41835. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41836. /**
  41837. * Creates a new StereoscopicArcRotateCamera
  41838. * @param name defines camera name
  41839. * @param alpha defines alpha angle (in radians)
  41840. * @param beta defines beta angle (in radians)
  41841. * @param radius defines radius
  41842. * @param target defines camera target
  41843. * @param interaxialDistance defines distance between each color axis
  41844. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41845. * @param scene defines the hosting scene
  41846. */
  41847. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41848. /**
  41849. * Gets camera class name
  41850. * @returns StereoscopicArcRotateCamera
  41851. */
  41852. getClassName(): string;
  41853. }
  41854. }
  41855. declare module BABYLON {
  41856. /**
  41857. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41858. * @see http://doc.babylonjs.com/features/cameras
  41859. */
  41860. export class StereoscopicFreeCamera extends FreeCamera {
  41861. /**
  41862. * Creates a new StereoscopicFreeCamera
  41863. * @param name defines camera name
  41864. * @param position defines initial position
  41865. * @param interaxialDistance defines distance between each color axis
  41866. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41867. * @param scene defines the hosting scene
  41868. */
  41869. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41870. /**
  41871. * Gets camera class name
  41872. * @returns StereoscopicFreeCamera
  41873. */
  41874. getClassName(): string;
  41875. }
  41876. }
  41877. declare module BABYLON {
  41878. /**
  41879. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41880. * @see http://doc.babylonjs.com/features/cameras
  41881. */
  41882. export class StereoscopicGamepadCamera extends GamepadCamera {
  41883. /**
  41884. * Creates a new StereoscopicGamepadCamera
  41885. * @param name defines camera name
  41886. * @param position defines initial position
  41887. * @param interaxialDistance defines distance between each color axis
  41888. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41889. * @param scene defines the hosting scene
  41890. */
  41891. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41892. /**
  41893. * Gets camera class name
  41894. * @returns StereoscopicGamepadCamera
  41895. */
  41896. getClassName(): string;
  41897. }
  41898. }
  41899. declare module BABYLON {
  41900. /**
  41901. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41902. * @see http://doc.babylonjs.com/features/cameras
  41903. */
  41904. export class StereoscopicUniversalCamera extends UniversalCamera {
  41905. /**
  41906. * Creates a new StereoscopicUniversalCamera
  41907. * @param name defines camera name
  41908. * @param position defines initial position
  41909. * @param interaxialDistance defines distance between each color axis
  41910. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41911. * @param scene defines the hosting scene
  41912. */
  41913. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41914. /**
  41915. * Gets camera class name
  41916. * @returns StereoscopicUniversalCamera
  41917. */
  41918. getClassName(): string;
  41919. }
  41920. }
  41921. declare module BABYLON {
  41922. /**
  41923. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41924. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41925. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41926. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41927. */
  41928. export class VirtualJoysticksCamera extends FreeCamera {
  41929. /**
  41930. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41931. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41932. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41933. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41934. * @param name Define the name of the camera in the scene
  41935. * @param position Define the start position of the camera in the scene
  41936. * @param scene Define the scene the camera belongs to
  41937. */
  41938. constructor(name: string, position: Vector3, scene: Scene);
  41939. /**
  41940. * Gets the current object class name.
  41941. * @return the class name
  41942. */
  41943. getClassName(): string;
  41944. }
  41945. }
  41946. declare module BABYLON {
  41947. /**
  41948. * This represents all the required metrics to create a VR camera.
  41949. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41950. */
  41951. export class VRCameraMetrics {
  41952. /**
  41953. * Define the horizontal resolution off the screen.
  41954. */
  41955. hResolution: number;
  41956. /**
  41957. * Define the vertical resolution off the screen.
  41958. */
  41959. vResolution: number;
  41960. /**
  41961. * Define the horizontal screen size.
  41962. */
  41963. hScreenSize: number;
  41964. /**
  41965. * Define the vertical screen size.
  41966. */
  41967. vScreenSize: number;
  41968. /**
  41969. * Define the vertical screen center position.
  41970. */
  41971. vScreenCenter: number;
  41972. /**
  41973. * Define the distance of the eyes to the screen.
  41974. */
  41975. eyeToScreenDistance: number;
  41976. /**
  41977. * Define the distance between both lenses
  41978. */
  41979. lensSeparationDistance: number;
  41980. /**
  41981. * Define the distance between both viewer's eyes.
  41982. */
  41983. interpupillaryDistance: number;
  41984. /**
  41985. * Define the distortion factor of the VR postprocess.
  41986. * Please, touch with care.
  41987. */
  41988. distortionK: number[];
  41989. /**
  41990. * Define the chromatic aberration correction factors for the VR post process.
  41991. */
  41992. chromaAbCorrection: number[];
  41993. /**
  41994. * Define the scale factor of the post process.
  41995. * The smaller the better but the slower.
  41996. */
  41997. postProcessScaleFactor: number;
  41998. /**
  41999. * Define an offset for the lens center.
  42000. */
  42001. lensCenterOffset: number;
  42002. /**
  42003. * Define if the current vr camera should compensate the distortion of the lense or not.
  42004. */
  42005. compensateDistortion: boolean;
  42006. /**
  42007. * Defines if multiview should be enabled when rendering (Default: false)
  42008. */
  42009. multiviewEnabled: boolean;
  42010. /**
  42011. * Gets the rendering aspect ratio based on the provided resolutions.
  42012. */
  42013. get aspectRatio(): number;
  42014. /**
  42015. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42016. */
  42017. get aspectRatioFov(): number;
  42018. /**
  42019. * @hidden
  42020. */
  42021. get leftHMatrix(): Matrix;
  42022. /**
  42023. * @hidden
  42024. */
  42025. get rightHMatrix(): Matrix;
  42026. /**
  42027. * @hidden
  42028. */
  42029. get leftPreViewMatrix(): Matrix;
  42030. /**
  42031. * @hidden
  42032. */
  42033. get rightPreViewMatrix(): Matrix;
  42034. /**
  42035. * Get the default VRMetrics based on the most generic setup.
  42036. * @returns the default vr metrics
  42037. */
  42038. static GetDefault(): VRCameraMetrics;
  42039. }
  42040. }
  42041. declare module BABYLON {
  42042. /** @hidden */
  42043. export var vrDistortionCorrectionPixelShader: {
  42044. name: string;
  42045. shader: string;
  42046. };
  42047. }
  42048. declare module BABYLON {
  42049. /**
  42050. * VRDistortionCorrectionPostProcess used for mobile VR
  42051. */
  42052. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42053. private _isRightEye;
  42054. private _distortionFactors;
  42055. private _postProcessScaleFactor;
  42056. private _lensCenterOffset;
  42057. private _scaleIn;
  42058. private _scaleFactor;
  42059. private _lensCenter;
  42060. /**
  42061. * Initializes the VRDistortionCorrectionPostProcess
  42062. * @param name The name of the effect.
  42063. * @param camera The camera to apply the render pass to.
  42064. * @param isRightEye If this is for the right eye distortion
  42065. * @param vrMetrics All the required metrics for the VR camera
  42066. */
  42067. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42068. }
  42069. }
  42070. declare module BABYLON {
  42071. /**
  42072. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42073. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42074. */
  42075. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42076. /**
  42077. * Creates a new VRDeviceOrientationArcRotateCamera
  42078. * @param name defines camera name
  42079. * @param alpha defines the camera rotation along the logitudinal axis
  42080. * @param beta defines the camera rotation along the latitudinal axis
  42081. * @param radius defines the camera distance from its target
  42082. * @param target defines the camera target
  42083. * @param scene defines the scene the camera belongs to
  42084. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42085. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42086. */
  42087. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42088. /**
  42089. * Gets camera class name
  42090. * @returns VRDeviceOrientationArcRotateCamera
  42091. */
  42092. getClassName(): string;
  42093. }
  42094. }
  42095. declare module BABYLON {
  42096. /**
  42097. * Camera used to simulate VR rendering (based on FreeCamera)
  42098. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42099. */
  42100. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42101. /**
  42102. * Creates a new VRDeviceOrientationFreeCamera
  42103. * @param name defines camera name
  42104. * @param position defines the start position of the camera
  42105. * @param scene defines the scene the camera belongs to
  42106. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42107. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42108. */
  42109. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42110. /**
  42111. * Gets camera class name
  42112. * @returns VRDeviceOrientationFreeCamera
  42113. */
  42114. getClassName(): string;
  42115. }
  42116. }
  42117. declare module BABYLON {
  42118. /**
  42119. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42120. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42121. */
  42122. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42123. /**
  42124. * Creates a new VRDeviceOrientationGamepadCamera
  42125. * @param name defines camera name
  42126. * @param position defines the start position of the camera
  42127. * @param scene defines the scene the camera belongs to
  42128. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42129. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42130. */
  42131. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42132. /**
  42133. * Gets camera class name
  42134. * @returns VRDeviceOrientationGamepadCamera
  42135. */
  42136. getClassName(): string;
  42137. }
  42138. }
  42139. declare module BABYLON {
  42140. /** @hidden */
  42141. export var imageProcessingPixelShader: {
  42142. name: string;
  42143. shader: string;
  42144. };
  42145. }
  42146. declare module BABYLON {
  42147. /**
  42148. * ImageProcessingPostProcess
  42149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42150. */
  42151. export class ImageProcessingPostProcess extends PostProcess {
  42152. /**
  42153. * Default configuration related to image processing available in the PBR Material.
  42154. */
  42155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42156. /**
  42157. * Gets the image processing configuration used either in this material.
  42158. */
  42159. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42160. /**
  42161. * Sets the Default image processing configuration used either in the this material.
  42162. *
  42163. * If sets to null, the scene one is in use.
  42164. */
  42165. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42166. /**
  42167. * Keep track of the image processing observer to allow dispose and replace.
  42168. */
  42169. private _imageProcessingObserver;
  42170. /**
  42171. * Attaches a new image processing configuration to the PBR Material.
  42172. * @param configuration
  42173. */
  42174. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42175. /**
  42176. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42177. */
  42178. get colorCurves(): Nullable<ColorCurves>;
  42179. /**
  42180. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42181. */
  42182. set colorCurves(value: Nullable<ColorCurves>);
  42183. /**
  42184. * Gets wether the color curves effect is enabled.
  42185. */
  42186. get colorCurvesEnabled(): boolean;
  42187. /**
  42188. * Sets wether the color curves effect is enabled.
  42189. */
  42190. set colorCurvesEnabled(value: boolean);
  42191. /**
  42192. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42193. */
  42194. get colorGradingTexture(): Nullable<BaseTexture>;
  42195. /**
  42196. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42197. */
  42198. set colorGradingTexture(value: Nullable<BaseTexture>);
  42199. /**
  42200. * Gets wether the color grading effect is enabled.
  42201. */
  42202. get colorGradingEnabled(): boolean;
  42203. /**
  42204. * Gets wether the color grading effect is enabled.
  42205. */
  42206. set colorGradingEnabled(value: boolean);
  42207. /**
  42208. * Gets exposure used in the effect.
  42209. */
  42210. get exposure(): number;
  42211. /**
  42212. * Sets exposure used in the effect.
  42213. */
  42214. set exposure(value: number);
  42215. /**
  42216. * Gets wether tonemapping is enabled or not.
  42217. */
  42218. get toneMappingEnabled(): boolean;
  42219. /**
  42220. * Sets wether tonemapping is enabled or not
  42221. */
  42222. set toneMappingEnabled(value: boolean);
  42223. /**
  42224. * Gets the type of tone mapping effect.
  42225. */
  42226. get toneMappingType(): number;
  42227. /**
  42228. * Sets the type of tone mapping effect.
  42229. */
  42230. set toneMappingType(value: number);
  42231. /**
  42232. * Gets contrast used in the effect.
  42233. */
  42234. get contrast(): number;
  42235. /**
  42236. * Sets contrast used in the effect.
  42237. */
  42238. set contrast(value: number);
  42239. /**
  42240. * Gets Vignette stretch size.
  42241. */
  42242. get vignetteStretch(): number;
  42243. /**
  42244. * Sets Vignette stretch size.
  42245. */
  42246. set vignetteStretch(value: number);
  42247. /**
  42248. * Gets Vignette centre X Offset.
  42249. */
  42250. get vignetteCentreX(): number;
  42251. /**
  42252. * Sets Vignette centre X Offset.
  42253. */
  42254. set vignetteCentreX(value: number);
  42255. /**
  42256. * Gets Vignette centre Y Offset.
  42257. */
  42258. get vignetteCentreY(): number;
  42259. /**
  42260. * Sets Vignette centre Y Offset.
  42261. */
  42262. set vignetteCentreY(value: number);
  42263. /**
  42264. * Gets Vignette weight or intensity of the vignette effect.
  42265. */
  42266. get vignetteWeight(): number;
  42267. /**
  42268. * Sets Vignette weight or intensity of the vignette effect.
  42269. */
  42270. set vignetteWeight(value: number);
  42271. /**
  42272. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42273. * if vignetteEnabled is set to true.
  42274. */
  42275. get vignetteColor(): Color4;
  42276. /**
  42277. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42278. * if vignetteEnabled is set to true.
  42279. */
  42280. set vignetteColor(value: Color4);
  42281. /**
  42282. * Gets Camera field of view used by the Vignette effect.
  42283. */
  42284. get vignetteCameraFov(): number;
  42285. /**
  42286. * Sets Camera field of view used by the Vignette effect.
  42287. */
  42288. set vignetteCameraFov(value: number);
  42289. /**
  42290. * Gets the vignette blend mode allowing different kind of effect.
  42291. */
  42292. get vignetteBlendMode(): number;
  42293. /**
  42294. * Sets the vignette blend mode allowing different kind of effect.
  42295. */
  42296. set vignetteBlendMode(value: number);
  42297. /**
  42298. * Gets wether the vignette effect is enabled.
  42299. */
  42300. get vignetteEnabled(): boolean;
  42301. /**
  42302. * Sets wether the vignette effect is enabled.
  42303. */
  42304. set vignetteEnabled(value: boolean);
  42305. private _fromLinearSpace;
  42306. /**
  42307. * Gets wether the input of the processing is in Gamma or Linear Space.
  42308. */
  42309. get fromLinearSpace(): boolean;
  42310. /**
  42311. * Sets wether the input of the processing is in Gamma or Linear Space.
  42312. */
  42313. set fromLinearSpace(value: boolean);
  42314. /**
  42315. * Defines cache preventing GC.
  42316. */
  42317. private _defines;
  42318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42319. /**
  42320. * "ImageProcessingPostProcess"
  42321. * @returns "ImageProcessingPostProcess"
  42322. */
  42323. getClassName(): string;
  42324. protected _updateParameters(): void;
  42325. dispose(camera?: Camera): void;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * Class containing static functions to help procedurally build meshes
  42331. */
  42332. export class GroundBuilder {
  42333. /**
  42334. * Creates a ground mesh
  42335. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42336. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42338. * @param name defines the name of the mesh
  42339. * @param options defines the options used to create the mesh
  42340. * @param scene defines the hosting scene
  42341. * @returns the ground mesh
  42342. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42343. */
  42344. static CreateGround(name: string, options: {
  42345. width?: number;
  42346. height?: number;
  42347. subdivisions?: number;
  42348. subdivisionsX?: number;
  42349. subdivisionsY?: number;
  42350. updatable?: boolean;
  42351. }, scene: any): Mesh;
  42352. /**
  42353. * Creates a tiled ground mesh
  42354. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42355. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42356. * * 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
  42357. * * 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
  42358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42359. * @param name defines the name of the mesh
  42360. * @param options defines the options used to create the mesh
  42361. * @param scene defines the hosting scene
  42362. * @returns the tiled ground mesh
  42363. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42364. */
  42365. static CreateTiledGround(name: string, options: {
  42366. xmin: number;
  42367. zmin: number;
  42368. xmax: number;
  42369. zmax: number;
  42370. subdivisions?: {
  42371. w: number;
  42372. h: number;
  42373. };
  42374. precision?: {
  42375. w: number;
  42376. h: number;
  42377. };
  42378. updatable?: boolean;
  42379. }, scene?: Nullable<Scene>): Mesh;
  42380. /**
  42381. * Creates a ground mesh from a height map
  42382. * * The parameter `url` sets the URL of the height map image resource.
  42383. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42384. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42385. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42386. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42387. * * 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.
  42388. * * 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).
  42389. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42391. * @param name defines the name of the mesh
  42392. * @param url defines the url to the height map
  42393. * @param options defines the options used to create the mesh
  42394. * @param scene defines the hosting scene
  42395. * @returns the ground mesh
  42396. * @see https://doc.babylonjs.com/babylon101/height_map
  42397. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42398. */
  42399. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42400. width?: number;
  42401. height?: number;
  42402. subdivisions?: number;
  42403. minHeight?: number;
  42404. maxHeight?: number;
  42405. colorFilter?: Color3;
  42406. alphaFilter?: number;
  42407. updatable?: boolean;
  42408. onReady?: (mesh: GroundMesh) => void;
  42409. }, scene?: Nullable<Scene>): GroundMesh;
  42410. }
  42411. }
  42412. declare module BABYLON {
  42413. /**
  42414. * Class containing static functions to help procedurally build meshes
  42415. */
  42416. export class TorusBuilder {
  42417. /**
  42418. * Creates a torus mesh
  42419. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42420. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42421. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42423. * * 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
  42424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42425. * @param name defines the name of the mesh
  42426. * @param options defines the options used to create the mesh
  42427. * @param scene defines the hosting scene
  42428. * @returns the torus mesh
  42429. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42430. */
  42431. static CreateTorus(name: string, options: {
  42432. diameter?: number;
  42433. thickness?: number;
  42434. tessellation?: number;
  42435. updatable?: boolean;
  42436. sideOrientation?: number;
  42437. frontUVs?: Vector4;
  42438. backUVs?: Vector4;
  42439. }, scene: any): Mesh;
  42440. }
  42441. }
  42442. declare module BABYLON {
  42443. /**
  42444. * Class containing static functions to help procedurally build meshes
  42445. */
  42446. export class CylinderBuilder {
  42447. /**
  42448. * Creates a cylinder or a cone mesh
  42449. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42450. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42451. * * 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.
  42452. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42453. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42454. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42455. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42456. * * 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).
  42457. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42458. * * 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).
  42459. * * 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
  42460. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42461. * * 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
  42462. * * 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.
  42463. * * If `enclose` is false, a ring surface is one element.
  42464. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42465. * * 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
  42466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42467. * * 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
  42468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42469. * @param name defines the name of the mesh
  42470. * @param options defines the options used to create the mesh
  42471. * @param scene defines the hosting scene
  42472. * @returns the cylinder mesh
  42473. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42474. */
  42475. static CreateCylinder(name: string, options: {
  42476. height?: number;
  42477. diameterTop?: number;
  42478. diameterBottom?: number;
  42479. diameter?: number;
  42480. tessellation?: number;
  42481. subdivisions?: number;
  42482. arc?: number;
  42483. faceColors?: Color4[];
  42484. faceUV?: Vector4[];
  42485. updatable?: boolean;
  42486. hasRings?: boolean;
  42487. enclose?: boolean;
  42488. cap?: number;
  42489. sideOrientation?: number;
  42490. frontUVs?: Vector4;
  42491. backUVs?: Vector4;
  42492. }, scene: any): Mesh;
  42493. }
  42494. }
  42495. declare module BABYLON {
  42496. /**
  42497. * States of the webXR experience
  42498. */
  42499. export enum WebXRState {
  42500. /**
  42501. * Transitioning to being in XR mode
  42502. */
  42503. ENTERING_XR = 0,
  42504. /**
  42505. * Transitioning to non XR mode
  42506. */
  42507. EXITING_XR = 1,
  42508. /**
  42509. * In XR mode and presenting
  42510. */
  42511. IN_XR = 2,
  42512. /**
  42513. * Not entered XR mode
  42514. */
  42515. NOT_IN_XR = 3
  42516. }
  42517. /**
  42518. * Abstraction of the XR render target
  42519. */
  42520. export interface WebXRRenderTarget extends IDisposable {
  42521. /**
  42522. * xrpresent context of the canvas which can be used to display/mirror xr content
  42523. */
  42524. canvasContext: WebGLRenderingContext;
  42525. /**
  42526. * xr layer for the canvas
  42527. */
  42528. xrLayer: Nullable<XRWebGLLayer>;
  42529. /**
  42530. * Initializes the xr layer for the session
  42531. * @param xrSession xr session
  42532. * @returns a promise that will resolve once the XR Layer has been created
  42533. */
  42534. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42535. }
  42536. }
  42537. declare module BABYLON {
  42538. /**
  42539. * COnfiguration object for WebXR output canvas
  42540. */
  42541. export class WebXRManagedOutputCanvasOptions {
  42542. /**
  42543. * Options for this XR Layer output
  42544. */
  42545. canvasOptions?: XRWebGLLayerOptions;
  42546. /**
  42547. * CSS styling for a newly created canvas (if not provided)
  42548. */
  42549. newCanvasCssStyle?: string;
  42550. /**
  42551. * An optional canvas in case you wish to create it yourself and provide it here.
  42552. * If not provided, a new canvas will be created
  42553. */
  42554. canvasElement?: HTMLCanvasElement;
  42555. /**
  42556. * Get the default values of the configuration object
  42557. * @returns default values of this configuration object
  42558. */
  42559. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42560. }
  42561. /**
  42562. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42563. */
  42564. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42565. private _options;
  42566. private _engine;
  42567. private _canvas;
  42568. /**
  42569. * Rendering context of the canvas which can be used to display/mirror xr content
  42570. */
  42571. canvasContext: WebGLRenderingContext;
  42572. /**
  42573. * xr layer for the canvas
  42574. */
  42575. xrLayer: Nullable<XRWebGLLayer>;
  42576. /**
  42577. * Initializes the xr layer for the session
  42578. * @param xrSession xr session
  42579. * @returns a promise that will resolve once the XR Layer has been created
  42580. */
  42581. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42582. /**
  42583. * Initializes the canvas to be added/removed upon entering/exiting xr
  42584. * @param _xrSessionManager The XR Session manager
  42585. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42586. */
  42587. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42588. /**
  42589. * Disposes of the object
  42590. */
  42591. dispose(): void;
  42592. private _setManagedOutputCanvas;
  42593. private _addCanvas;
  42594. private _removeCanvas;
  42595. }
  42596. }
  42597. declare module BABYLON {
  42598. /**
  42599. * Manages an XRSession to work with Babylon's engine
  42600. * @see https://doc.babylonjs.com/how_to/webxr
  42601. */
  42602. export class WebXRSessionManager implements IDisposable {
  42603. /** The scene which the session should be created for */
  42604. scene: Scene;
  42605. /**
  42606. * Fires every time a new xrFrame arrives which can be used to update the camera
  42607. */
  42608. onXRFrameObservable: Observable<XRFrame>;
  42609. /**
  42610. * Fires when the xr session is ended either by the device or manually done
  42611. */
  42612. onXRSessionEnded: Observable<any>;
  42613. /**
  42614. * Fires when the xr session is ended either by the device or manually done
  42615. */
  42616. onXRSessionInit: Observable<XRSession>;
  42617. /**
  42618. * Fires when the reference space changed
  42619. */
  42620. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42621. /**
  42622. * Underlying xr session
  42623. */
  42624. session: XRSession;
  42625. /**
  42626. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42627. * or get the offset the player is currently at.
  42628. */
  42629. viewerReferenceSpace: XRReferenceSpace;
  42630. private _referenceSpace;
  42631. /**
  42632. * The current reference space used in this session. This reference space can constantly change!
  42633. * It is mainly used to offset the camera's position.
  42634. */
  42635. get referenceSpace(): XRReferenceSpace;
  42636. /**
  42637. * Set a new reference space and triggers the observable
  42638. */
  42639. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42640. /**
  42641. * The base reference space from which the session started. good if you want to reset your
  42642. * reference space
  42643. */
  42644. baseReferenceSpace: XRReferenceSpace;
  42645. /**
  42646. * Used just in case of a failure to initialize an immersive session.
  42647. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42648. */
  42649. defaultHeightCompensation: number;
  42650. /**
  42651. * Current XR frame
  42652. */
  42653. currentFrame: Nullable<XRFrame>;
  42654. /** WebXR timestamp updated every frame */
  42655. currentTimestamp: number;
  42656. private _xrNavigator;
  42657. private baseLayer;
  42658. private _rttProvider;
  42659. private _sessionEnded;
  42660. /**
  42661. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42662. * @param scene The scene which the session should be created for
  42663. */
  42664. constructor(
  42665. /** The scene which the session should be created for */
  42666. scene: Scene);
  42667. /**
  42668. * Initializes the manager
  42669. * After initialization enterXR can be called to start an XR session
  42670. * @returns Promise which resolves after it is initialized
  42671. */
  42672. initializeAsync(): Promise<void>;
  42673. /**
  42674. * Initializes an xr session
  42675. * @param xrSessionMode mode to initialize
  42676. * @param xrSessionInit defines optional and required values to pass to the session builder
  42677. * @returns a promise which will resolve once the session has been initialized
  42678. */
  42679. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42680. /**
  42681. * Sets the reference space on the xr session
  42682. * @param referenceSpaceType space to set
  42683. * @returns a promise that will resolve once the reference space has been set
  42684. */
  42685. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42686. /**
  42687. * Resets the reference space to the one started the session
  42688. */
  42689. resetReferenceSpace(): void;
  42690. /**
  42691. * Updates the render state of the session
  42692. * @param state state to set
  42693. * @returns a promise that resolves once the render state has been updated
  42694. */
  42695. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42696. /**
  42697. * Starts rendering to the xr layer
  42698. */
  42699. runXRRenderLoop(): void;
  42700. /**
  42701. * Gets the correct render target texture to be rendered this frame for this eye
  42702. * @param eye the eye for which to get the render target
  42703. * @returns the render target for the specified eye
  42704. */
  42705. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42706. /**
  42707. * Stops the xrSession and restores the renderloop
  42708. * @returns Promise which resolves after it exits XR
  42709. */
  42710. exitXRAsync(): Promise<void>;
  42711. /**
  42712. * Checks if a session would be supported for the creation options specified
  42713. * @param sessionMode session mode to check if supported eg. immersive-vr
  42714. * @returns A Promise that resolves to true if supported and false if not
  42715. */
  42716. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42717. /**
  42718. * Creates a WebXRRenderTarget object for the XR session
  42719. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42720. * @param options optional options to provide when creating a new render target
  42721. * @returns a WebXR render target to which the session can render
  42722. */
  42723. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42724. /**
  42725. * @hidden
  42726. * Converts the render layer of xrSession to a render target
  42727. * @param session session to create render target for
  42728. * @param scene scene the new render target should be created for
  42729. * @param baseLayer the webgl layer to create the render target for
  42730. */
  42731. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42732. /**
  42733. * Disposes of the session manager
  42734. */
  42735. dispose(): void;
  42736. /**
  42737. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42738. * @param sessionMode defines the session to test
  42739. * @returns a promise with boolean as final value
  42740. */
  42741. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42742. }
  42743. }
  42744. declare module BABYLON {
  42745. /**
  42746. * WebXR Camera which holds the views for the xrSession
  42747. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42748. */
  42749. export class WebXRCamera extends FreeCamera {
  42750. private _xrSessionManager;
  42751. private _firstFrame;
  42752. private _referenceQuaternion;
  42753. private _referencedPosition;
  42754. private _xrInvPositionCache;
  42755. private _xrInvQuaternionCache;
  42756. /**
  42757. * Should position compensation execute on first frame.
  42758. * This is used when copying the position from a native (non XR) camera
  42759. */
  42760. compensateOnFirstFrame: boolean;
  42761. /**
  42762. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42763. * @param name the name of the camera
  42764. * @param scene the scene to add the camera to
  42765. * @param _xrSessionManager a constructed xr session manager
  42766. */
  42767. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42768. /**
  42769. * Return the user's height, unrelated to the current ground.
  42770. * This will be the y position of this camera, when ground level is 0.
  42771. */
  42772. get realWorldHeight(): number;
  42773. /** @hidden */
  42774. _updateForDualEyeDebugging(): void;
  42775. /**
  42776. * Sets this camera's transformation based on a non-vr camera
  42777. * @param otherCamera the non-vr camera to copy the transformation from
  42778. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42779. */
  42780. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42781. private _updateFromXRSession;
  42782. private _updateNumberOfRigCameras;
  42783. private _updateReferenceSpace;
  42784. private _updateReferenceSpaceOffset;
  42785. }
  42786. }
  42787. declare module BABYLON {
  42788. /**
  42789. * Defining the interface required for a (webxr) feature
  42790. */
  42791. export interface IWebXRFeature extends IDisposable {
  42792. /**
  42793. * Is this feature attached
  42794. */
  42795. attached: boolean;
  42796. /**
  42797. * Should auto-attach be disabled?
  42798. */
  42799. disableAutoAttach: boolean;
  42800. /**
  42801. * Attach the feature to the session
  42802. * Will usually be called by the features manager
  42803. *
  42804. * @param force should attachment be forced (even when already attached)
  42805. * @returns true if successful.
  42806. */
  42807. attach(force?: boolean): boolean;
  42808. /**
  42809. * Detach the feature from the session
  42810. * Will usually be called by the features manager
  42811. *
  42812. * @returns true if successful.
  42813. */
  42814. detach(): boolean;
  42815. }
  42816. /**
  42817. * A list of the currently available features without referencing them
  42818. */
  42819. export class WebXRFeatureName {
  42820. /**
  42821. * The name of the hit test feature
  42822. */
  42823. static HIT_TEST: string;
  42824. /**
  42825. * The name of the anchor system feature
  42826. */
  42827. static ANCHOR_SYSTEM: string;
  42828. /**
  42829. * The name of the background remover feature
  42830. */
  42831. static BACKGROUND_REMOVER: string;
  42832. /**
  42833. * The name of the pointer selection feature
  42834. */
  42835. static POINTER_SELECTION: string;
  42836. /**
  42837. * The name of the teleportation feature
  42838. */
  42839. static TELEPORTATION: string;
  42840. /**
  42841. * The name of the plane detection feature
  42842. */
  42843. static PLANE_DETECTION: string;
  42844. /**
  42845. * physics impostors for xr controllers feature
  42846. */
  42847. static PHYSICS_CONTROLLERS: string;
  42848. }
  42849. /**
  42850. * Defining the constructor of a feature. Used to register the modules.
  42851. */
  42852. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42853. /**
  42854. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42855. * It is mainly used in AR sessions.
  42856. *
  42857. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42858. */
  42859. export class WebXRFeaturesManager implements IDisposable {
  42860. private _xrSessionManager;
  42861. private static readonly _AvailableFeatures;
  42862. /**
  42863. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42864. * Mainly used internally.
  42865. *
  42866. * @param featureName the name of the feature to register
  42867. * @param constructorFunction the function used to construct the module
  42868. * @param version the (babylon) version of the module
  42869. * @param stable is that a stable version of this module
  42870. */
  42871. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42872. /**
  42873. * Returns a constructor of a specific feature.
  42874. *
  42875. * @param featureName the name of the feature to construct
  42876. * @param version the version of the feature to load
  42877. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42878. * @param options optional options provided to the module.
  42879. * @returns a function that, when called, will return a new instance of this feature
  42880. */
  42881. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42882. /**
  42883. * Return the latest unstable version of this feature
  42884. * @param featureName the name of the feature to search
  42885. * @returns the version number. if not found will return -1
  42886. */
  42887. static GetLatestVersionOfFeature(featureName: string): number;
  42888. /**
  42889. * Return the latest stable version of this feature
  42890. * @param featureName the name of the feature to search
  42891. * @returns the version number. if not found will return -1
  42892. */
  42893. static GetStableVersionOfFeature(featureName: string): number;
  42894. /**
  42895. * Can be used to return the list of features currently registered
  42896. *
  42897. * @returns an Array of available features
  42898. */
  42899. static GetAvailableFeatures(): string[];
  42900. /**
  42901. * Gets the versions available for a specific feature
  42902. * @param featureName the name of the feature
  42903. * @returns an array with the available versions
  42904. */
  42905. static GetAvailableVersions(featureName: string): string[];
  42906. private _features;
  42907. /**
  42908. * constructs a new features manages.
  42909. *
  42910. * @param _xrSessionManager an instance of WebXRSessionManager
  42911. */
  42912. constructor(_xrSessionManager: WebXRSessionManager);
  42913. /**
  42914. * 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.
  42915. * 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.
  42916. *
  42917. * @param featureName the name of the feature to load or the class of the feature
  42918. * @param version optional version to load. if not provided the latest version will be enabled
  42919. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42920. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42921. * @returns a new constructed feature or throws an error if feature not found.
  42922. */
  42923. enableFeature(featureName: string | {
  42924. Name: string;
  42925. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42926. /**
  42927. * Used to disable an already-enabled feature
  42928. * The feature will be disposed and will be recreated once enabled.
  42929. * @param featureName the feature to disable
  42930. * @returns true if disable was successful
  42931. */
  42932. disableFeature(featureName: string | {
  42933. Name: string;
  42934. }): boolean;
  42935. /**
  42936. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42937. * Can be used during a session to start a feature
  42938. * @param featureName the name of feature to attach
  42939. */
  42940. attachFeature(featureName: string): void;
  42941. /**
  42942. * Can be used inside a session or when the session ends to detach a specific feature
  42943. * @param featureName the name of the feature to detach
  42944. */
  42945. detachFeature(featureName: string): void;
  42946. /**
  42947. * Get the list of enabled features
  42948. * @returns an array of enabled features
  42949. */
  42950. getEnabledFeatures(): string[];
  42951. /**
  42952. * get the implementation of an enabled feature.
  42953. * @param featureName the name of the feature to load
  42954. * @returns the feature class, if found
  42955. */
  42956. getEnabledFeature(featureName: string): IWebXRFeature;
  42957. /**
  42958. * dispose this features manager
  42959. */
  42960. dispose(): void;
  42961. }
  42962. }
  42963. declare module BABYLON {
  42964. /**
  42965. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42966. * @see https://doc.babylonjs.com/how_to/webxr
  42967. */
  42968. export class WebXRExperienceHelper implements IDisposable {
  42969. private scene;
  42970. /**
  42971. * Camera used to render xr content
  42972. */
  42973. camera: WebXRCamera;
  42974. /**
  42975. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42976. */
  42977. state: WebXRState;
  42978. private _setState;
  42979. /**
  42980. * Fires when the state of the experience helper has changed
  42981. */
  42982. onStateChangedObservable: Observable<WebXRState>;
  42983. /**
  42984. * Observers registered here will be triggered after the camera's initial transformation is set
  42985. * This can be used to set a different ground level or an extra rotation.
  42986. *
  42987. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42988. * to the position set after this observable is done executing.
  42989. */
  42990. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42991. /** Session manager used to keep track of xr session */
  42992. sessionManager: WebXRSessionManager;
  42993. /** A features manager for this xr session */
  42994. featuresManager: WebXRFeaturesManager;
  42995. private _nonVRCamera;
  42996. private _originalSceneAutoClear;
  42997. private _supported;
  42998. /**
  42999. * Creates the experience helper
  43000. * @param scene the scene to attach the experience helper to
  43001. * @returns a promise for the experience helper
  43002. */
  43003. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43004. /**
  43005. * Creates a WebXRExperienceHelper
  43006. * @param scene The scene the helper should be created in
  43007. */
  43008. private constructor();
  43009. /**
  43010. * Exits XR mode and returns the scene to its original state
  43011. * @returns promise that resolves after xr mode has exited
  43012. */
  43013. exitXRAsync(): Promise<void>;
  43014. /**
  43015. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43016. * @param sessionMode options for the XR session
  43017. * @param referenceSpaceType frame of reference of the XR session
  43018. * @param renderTarget the output canvas that will be used to enter XR mode
  43019. * @returns promise that resolves after xr mode has entered
  43020. */
  43021. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43022. /**
  43023. * Disposes of the experience helper
  43024. */
  43025. dispose(): void;
  43026. private _nonXRToXRCamera;
  43027. }
  43028. }
  43029. declare module BABYLON {
  43030. /**
  43031. * X-Y values for axes in WebXR
  43032. */
  43033. export interface IWebXRMotionControllerAxesValue {
  43034. /**
  43035. * The value of the x axis
  43036. */
  43037. x: number;
  43038. /**
  43039. * The value of the y-axis
  43040. */
  43041. y: number;
  43042. }
  43043. /**
  43044. * changed / previous values for the values of this component
  43045. */
  43046. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43047. /**
  43048. * current (this frame) value
  43049. */
  43050. current: T;
  43051. /**
  43052. * previous (last change) value
  43053. */
  43054. previous: T;
  43055. }
  43056. /**
  43057. * Represents changes in the component between current frame and last values recorded
  43058. */
  43059. export interface IWebXRMotionControllerComponentChanges {
  43060. /**
  43061. * will be populated with previous and current values if touched changed
  43062. */
  43063. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43064. /**
  43065. * will be populated with previous and current values if pressed changed
  43066. */
  43067. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43068. /**
  43069. * will be populated with previous and current values if value changed
  43070. */
  43071. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43072. /**
  43073. * will be populated with previous and current values if axes changed
  43074. */
  43075. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43076. }
  43077. /**
  43078. * This class represents a single component (for example button or thumbstick) of a motion controller
  43079. */
  43080. export class WebXRControllerComponent implements IDisposable {
  43081. /**
  43082. * the id of this component
  43083. */
  43084. id: string;
  43085. /**
  43086. * the type of the component
  43087. */
  43088. type: MotionControllerComponentType;
  43089. private _buttonIndex;
  43090. private _axesIndices;
  43091. /**
  43092. * Thumbstick component type
  43093. */
  43094. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43095. /**
  43096. * Touchpad component type
  43097. */
  43098. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43099. /**
  43100. * trigger component type
  43101. */
  43102. static TRIGGER_TYPE: MotionControllerComponentType;
  43103. /**
  43104. * squeeze component type
  43105. */
  43106. static SQUEEZE_TYPE: MotionControllerComponentType;
  43107. /**
  43108. * button component type
  43109. */
  43110. static BUTTON_TYPE: MotionControllerComponentType;
  43111. /**
  43112. * Observers registered here will be triggered when the state of a button changes
  43113. * State change is either pressed / touched / value
  43114. */
  43115. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43116. /**
  43117. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43118. * the axes data changes
  43119. */
  43120. onAxisValueChangedObservable: Observable<{
  43121. x: number;
  43122. y: number;
  43123. }>;
  43124. private _currentValue;
  43125. private _touched;
  43126. private _pressed;
  43127. private _axes;
  43128. private _changes;
  43129. private _hasChanges;
  43130. /**
  43131. * Return whether or not the component changed the last frame
  43132. */
  43133. get hasChanges(): boolean;
  43134. /**
  43135. * Creates a new component for a motion controller.
  43136. * It is created by the motion controller itself
  43137. *
  43138. * @param id the id of this component
  43139. * @param type the type of the component
  43140. * @param _buttonIndex index in the buttons array of the gamepad
  43141. * @param _axesIndices indices of the values in the axes array of the gamepad
  43142. */
  43143. constructor(
  43144. /**
  43145. * the id of this component
  43146. */
  43147. id: string,
  43148. /**
  43149. * the type of the component
  43150. */
  43151. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43152. /**
  43153. * Get the current value of this component
  43154. */
  43155. get value(): number;
  43156. /**
  43157. * is the button currently pressed
  43158. */
  43159. get pressed(): boolean;
  43160. /**
  43161. * is the button currently touched
  43162. */
  43163. get touched(): boolean;
  43164. /**
  43165. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43166. */
  43167. get axes(): IWebXRMotionControllerAxesValue;
  43168. /**
  43169. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43170. */
  43171. get changes(): IWebXRMotionControllerComponentChanges;
  43172. /**
  43173. * Is this component a button (hence - pressable)
  43174. * @returns true if can be pressed
  43175. */
  43176. isButton(): boolean;
  43177. /**
  43178. * Are there axes correlating to this component
  43179. * @return true is axes data is available
  43180. */
  43181. isAxes(): boolean;
  43182. /**
  43183. * update this component using the gamepad object it is in. Called on every frame
  43184. * @param nativeController the native gamepad controller object
  43185. */
  43186. update(nativeController: IMinimalMotionControllerObject): void;
  43187. /**
  43188. * Dispose this component
  43189. */
  43190. dispose(): void;
  43191. }
  43192. }
  43193. declare module BABYLON {
  43194. /**
  43195. * Class used to represent data loading progression
  43196. */
  43197. export class SceneLoaderProgressEvent {
  43198. /** defines if data length to load can be evaluated */
  43199. readonly lengthComputable: boolean;
  43200. /** defines the loaded data length */
  43201. readonly loaded: number;
  43202. /** defines the data length to load */
  43203. readonly total: number;
  43204. /**
  43205. * Create a new progress event
  43206. * @param lengthComputable defines if data length to load can be evaluated
  43207. * @param loaded defines the loaded data length
  43208. * @param total defines the data length to load
  43209. */
  43210. constructor(
  43211. /** defines if data length to load can be evaluated */
  43212. lengthComputable: boolean,
  43213. /** defines the loaded data length */
  43214. loaded: number,
  43215. /** defines the data length to load */
  43216. total: number);
  43217. /**
  43218. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43219. * @param event defines the source event
  43220. * @returns a new SceneLoaderProgressEvent
  43221. */
  43222. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43223. }
  43224. /**
  43225. * Interface used by SceneLoader plugins to define supported file extensions
  43226. */
  43227. export interface ISceneLoaderPluginExtensions {
  43228. /**
  43229. * Defines the list of supported extensions
  43230. */
  43231. [extension: string]: {
  43232. isBinary: boolean;
  43233. };
  43234. }
  43235. /**
  43236. * Interface used by SceneLoader plugin factory
  43237. */
  43238. export interface ISceneLoaderPluginFactory {
  43239. /**
  43240. * Defines the name of the factory
  43241. */
  43242. name: string;
  43243. /**
  43244. * Function called to create a new plugin
  43245. * @return the new plugin
  43246. */
  43247. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43248. /**
  43249. * The callback that returns true if the data can be directly loaded.
  43250. * @param data string containing the file data
  43251. * @returns if the data can be loaded directly
  43252. */
  43253. canDirectLoad?(data: string): boolean;
  43254. }
  43255. /**
  43256. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43257. */
  43258. export interface ISceneLoaderPluginBase {
  43259. /**
  43260. * The friendly name of this plugin.
  43261. */
  43262. name: string;
  43263. /**
  43264. * The file extensions supported by this plugin.
  43265. */
  43266. extensions: string | ISceneLoaderPluginExtensions;
  43267. /**
  43268. * The callback called when loading from a url.
  43269. * @param scene scene loading this url
  43270. * @param url url to load
  43271. * @param onSuccess callback called when the file successfully loads
  43272. * @param onProgress callback called while file is loading (if the server supports this mode)
  43273. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43274. * @param onError callback called when the file fails to load
  43275. * @returns a file request object
  43276. */
  43277. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43278. /**
  43279. * The callback called when loading from a file object.
  43280. * @param scene scene loading this file
  43281. * @param file defines the file to load
  43282. * @param onSuccess defines the callback to call when data is loaded
  43283. * @param onProgress defines the callback to call during loading process
  43284. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43285. * @param onError defines the callback to call when an error occurs
  43286. * @returns a file request object
  43287. */
  43288. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43289. /**
  43290. * The callback that returns true if the data can be directly loaded.
  43291. * @param data string containing the file data
  43292. * @returns if the data can be loaded directly
  43293. */
  43294. canDirectLoad?(data: string): boolean;
  43295. /**
  43296. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43297. * @param scene scene loading this data
  43298. * @param data string containing the data
  43299. * @returns data to pass to the plugin
  43300. */
  43301. directLoad?(scene: Scene, data: string): any;
  43302. /**
  43303. * The callback that allows custom handling of the root url based on the response url.
  43304. * @param rootUrl the original root url
  43305. * @param responseURL the response url if available
  43306. * @returns the new root url
  43307. */
  43308. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43309. }
  43310. /**
  43311. * Interface used to define a SceneLoader plugin
  43312. */
  43313. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43314. /**
  43315. * Import meshes into a scene.
  43316. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43317. * @param scene The scene to import into
  43318. * @param data The data to import
  43319. * @param rootUrl The root url for scene and resources
  43320. * @param meshes The meshes array to import into
  43321. * @param particleSystems The particle systems array to import into
  43322. * @param skeletons The skeletons array to import into
  43323. * @param onError The callback when import fails
  43324. * @returns True if successful or false otherwise
  43325. */
  43326. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43327. /**
  43328. * Load into a scene.
  43329. * @param scene The scene to load into
  43330. * @param data The data to import
  43331. * @param rootUrl The root url for scene and resources
  43332. * @param onError The callback when import fails
  43333. * @returns True if successful or false otherwise
  43334. */
  43335. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43336. /**
  43337. * Load into an asset container.
  43338. * @param scene The scene to load into
  43339. * @param data The data to import
  43340. * @param rootUrl The root url for scene and resources
  43341. * @param onError The callback when import fails
  43342. * @returns The loaded asset container
  43343. */
  43344. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43345. }
  43346. /**
  43347. * Interface used to define an async SceneLoader plugin
  43348. */
  43349. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43350. /**
  43351. * Import meshes into a scene.
  43352. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43353. * @param scene The scene to import into
  43354. * @param data The data to import
  43355. * @param rootUrl The root url for scene and resources
  43356. * @param onProgress The callback when the load progresses
  43357. * @param fileName Defines the name of the file to load
  43358. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43359. */
  43360. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43361. meshes: AbstractMesh[];
  43362. particleSystems: IParticleSystem[];
  43363. skeletons: Skeleton[];
  43364. animationGroups: AnimationGroup[];
  43365. }>;
  43366. /**
  43367. * Load into a scene.
  43368. * @param scene The scene to load into
  43369. * @param data The data to import
  43370. * @param rootUrl The root url for scene and resources
  43371. * @param onProgress The callback when the load progresses
  43372. * @param fileName Defines the name of the file to load
  43373. * @returns Nothing
  43374. */
  43375. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43376. /**
  43377. * Load into an asset container.
  43378. * @param scene The scene to load into
  43379. * @param data The data to import
  43380. * @param rootUrl The root url for scene and resources
  43381. * @param onProgress The callback when the load progresses
  43382. * @param fileName Defines the name of the file to load
  43383. * @returns The loaded asset container
  43384. */
  43385. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43386. }
  43387. /**
  43388. * Mode that determines how to handle old animation groups before loading new ones.
  43389. */
  43390. export enum SceneLoaderAnimationGroupLoadingMode {
  43391. /**
  43392. * Reset all old animations to initial state then dispose them.
  43393. */
  43394. Clean = 0,
  43395. /**
  43396. * Stop all old animations.
  43397. */
  43398. Stop = 1,
  43399. /**
  43400. * Restart old animations from first frame.
  43401. */
  43402. Sync = 2,
  43403. /**
  43404. * Old animations remains untouched.
  43405. */
  43406. NoSync = 3
  43407. }
  43408. /**
  43409. * Class used to load scene from various file formats using registered plugins
  43410. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43411. */
  43412. export class SceneLoader {
  43413. /**
  43414. * No logging while loading
  43415. */
  43416. static readonly NO_LOGGING: number;
  43417. /**
  43418. * Minimal logging while loading
  43419. */
  43420. static readonly MINIMAL_LOGGING: number;
  43421. /**
  43422. * Summary logging while loading
  43423. */
  43424. static readonly SUMMARY_LOGGING: number;
  43425. /**
  43426. * Detailled logging while loading
  43427. */
  43428. static readonly DETAILED_LOGGING: number;
  43429. /**
  43430. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43431. */
  43432. static get ForceFullSceneLoadingForIncremental(): boolean;
  43433. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43434. /**
  43435. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43436. */
  43437. static get ShowLoadingScreen(): boolean;
  43438. static set ShowLoadingScreen(value: boolean);
  43439. /**
  43440. * Defines the current logging level (while loading the scene)
  43441. * @ignorenaming
  43442. */
  43443. static get loggingLevel(): number;
  43444. static set loggingLevel(value: number);
  43445. /**
  43446. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43447. */
  43448. static get CleanBoneMatrixWeights(): boolean;
  43449. static set CleanBoneMatrixWeights(value: boolean);
  43450. /**
  43451. * Event raised when a plugin is used to load a scene
  43452. */
  43453. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43454. private static _registeredPlugins;
  43455. private static _getDefaultPlugin;
  43456. private static _getPluginForExtension;
  43457. private static _getPluginForDirectLoad;
  43458. private static _getPluginForFilename;
  43459. private static _getDirectLoad;
  43460. private static _loadData;
  43461. private static _getFileInfo;
  43462. /**
  43463. * Gets a plugin that can load the given extension
  43464. * @param extension defines the extension to load
  43465. * @returns a plugin or null if none works
  43466. */
  43467. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43468. /**
  43469. * Gets a boolean indicating that the given extension can be loaded
  43470. * @param extension defines the extension to load
  43471. * @returns true if the extension is supported
  43472. */
  43473. static IsPluginForExtensionAvailable(extension: string): boolean;
  43474. /**
  43475. * Adds a new plugin to the list of registered plugins
  43476. * @param plugin defines the plugin to add
  43477. */
  43478. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43479. /**
  43480. * Import meshes into a scene
  43481. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43482. * @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)
  43483. * @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)
  43484. * @param scene the instance of BABYLON.Scene to append to
  43485. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43486. * @param onProgress a callback with a progress event for each file being loaded
  43487. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43488. * @param pluginExtension the extension used to determine the plugin
  43489. * @returns The loaded plugin
  43490. */
  43491. 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>;
  43492. /**
  43493. * Import meshes into a scene
  43494. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43495. * @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)
  43496. * @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)
  43497. * @param scene the instance of BABYLON.Scene to append to
  43498. * @param onProgress a callback with a progress event for each file being loaded
  43499. * @param pluginExtension the extension used to determine the plugin
  43500. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43501. */
  43502. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43503. meshes: AbstractMesh[];
  43504. particleSystems: IParticleSystem[];
  43505. skeletons: Skeleton[];
  43506. animationGroups: AnimationGroup[];
  43507. }>;
  43508. /**
  43509. * Load a scene
  43510. * @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)
  43511. * @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)
  43512. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43513. * @param onSuccess a callback with the scene when import succeeds
  43514. * @param onProgress a callback with a progress event for each file being loaded
  43515. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43516. * @param pluginExtension the extension used to determine the plugin
  43517. * @returns The loaded plugin
  43518. */
  43519. 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>;
  43520. /**
  43521. * Load a scene
  43522. * @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)
  43523. * @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)
  43524. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43525. * @param onProgress a callback with a progress event for each file being loaded
  43526. * @param pluginExtension the extension used to determine the plugin
  43527. * @returns The loaded scene
  43528. */
  43529. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43530. /**
  43531. * Append a scene
  43532. * @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)
  43533. * @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)
  43534. * @param scene is the instance of BABYLON.Scene to append to
  43535. * @param onSuccess a callback with the scene when import succeeds
  43536. * @param onProgress a callback with a progress event for each file being loaded
  43537. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43538. * @param pluginExtension the extension used to determine the plugin
  43539. * @returns The loaded plugin
  43540. */
  43541. 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>;
  43542. /**
  43543. * Append a scene
  43544. * @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)
  43545. * @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)
  43546. * @param scene is the instance of BABYLON.Scene to append to
  43547. * @param onProgress a callback with a progress event for each file being loaded
  43548. * @param pluginExtension the extension used to determine the plugin
  43549. * @returns The given scene
  43550. */
  43551. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43552. /**
  43553. * Load a scene into an asset container
  43554. * @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)
  43555. * @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)
  43556. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43557. * @param onSuccess a callback with the scene when import succeeds
  43558. * @param onProgress a callback with a progress event for each file being loaded
  43559. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43560. * @param pluginExtension the extension used to determine the plugin
  43561. * @returns The loaded plugin
  43562. */
  43563. 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>;
  43564. /**
  43565. * Load a scene into an asset container
  43566. * @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)
  43567. * @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)
  43568. * @param scene is the instance of Scene to append to
  43569. * @param onProgress a callback with a progress event for each file being loaded
  43570. * @param pluginExtension the extension used to determine the plugin
  43571. * @returns The loaded asset container
  43572. */
  43573. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43574. /**
  43575. * Import animations from a file into a scene
  43576. * @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)
  43577. * @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)
  43578. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43579. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43580. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43581. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43582. * @param onSuccess a callback with the scene when import succeeds
  43583. * @param onProgress a callback with a progress event for each file being loaded
  43584. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43585. */
  43586. 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;
  43587. /**
  43588. * Import animations from a file into a scene
  43589. * @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)
  43590. * @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)
  43591. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43592. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43593. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43594. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43595. * @param onSuccess a callback with the scene when import succeeds
  43596. * @param onProgress a callback with a progress event for each file being loaded
  43597. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43598. * @returns the updated scene with imported animations
  43599. */
  43600. 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>;
  43601. }
  43602. }
  43603. declare module BABYLON {
  43604. /**
  43605. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43606. */
  43607. export type MotionControllerHandness = "none" | "left" | "right";
  43608. /**
  43609. * The type of components available in motion controllers.
  43610. * This is not the name of the component.
  43611. */
  43612. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43613. /**
  43614. * The state of a controller component
  43615. */
  43616. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43617. /**
  43618. * The schema of motion controller layout.
  43619. * No object will be initialized using this interface
  43620. * This is used just to define the profile.
  43621. */
  43622. export interface IMotionControllerLayout {
  43623. /**
  43624. * Defines the main button component id
  43625. */
  43626. selectComponentId: string;
  43627. /**
  43628. * Available components (unsorted)
  43629. */
  43630. components: {
  43631. /**
  43632. * A map of component Ids
  43633. */
  43634. [componentId: string]: {
  43635. /**
  43636. * The type of input the component outputs
  43637. */
  43638. type: MotionControllerComponentType;
  43639. /**
  43640. * The indices of this component in the gamepad object
  43641. */
  43642. gamepadIndices: {
  43643. /**
  43644. * Index of button
  43645. */
  43646. button?: number;
  43647. /**
  43648. * If available, index of x-axis
  43649. */
  43650. xAxis?: number;
  43651. /**
  43652. * If available, index of y-axis
  43653. */
  43654. yAxis?: number;
  43655. };
  43656. /**
  43657. * The mesh's root node name
  43658. */
  43659. rootNodeName: string;
  43660. /**
  43661. * Animation definitions for this model
  43662. */
  43663. visualResponses: {
  43664. [stateKey: string]: {
  43665. /**
  43666. * What property will be animated
  43667. */
  43668. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43669. /**
  43670. * What states influence this visual reponse
  43671. */
  43672. states: MotionControllerComponentStateType[];
  43673. /**
  43674. * Type of animation - movement or visibility
  43675. */
  43676. valueNodeProperty: "transform" | "visibility";
  43677. /**
  43678. * Base node name to move. Its position will be calculated according to the min and max nodes
  43679. */
  43680. valueNodeName?: string;
  43681. /**
  43682. * Minimum movement node
  43683. */
  43684. minNodeName?: string;
  43685. /**
  43686. * Max movement node
  43687. */
  43688. maxNodeName?: string;
  43689. };
  43690. };
  43691. /**
  43692. * If touch enabled, what is the name of node to display user feedback
  43693. */
  43694. touchPointNodeName?: string;
  43695. };
  43696. };
  43697. /**
  43698. * Is it xr standard mapping or not
  43699. */
  43700. gamepadMapping: "" | "xr-standard";
  43701. /**
  43702. * Base root node of this entire model
  43703. */
  43704. rootNodeName: string;
  43705. /**
  43706. * Path to load the assets. Usually relative to the base path
  43707. */
  43708. assetPath: string;
  43709. }
  43710. /**
  43711. * A definition for the layout map in the input profile
  43712. */
  43713. export interface IMotionControllerLayoutMap {
  43714. /**
  43715. * Layouts with handness type as a key
  43716. */
  43717. [handness: string]: IMotionControllerLayout;
  43718. }
  43719. /**
  43720. * The XR Input profile schema
  43721. * Profiles can be found here:
  43722. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43723. */
  43724. export interface IMotionControllerProfile {
  43725. /**
  43726. * The id of this profile
  43727. * correlates to the profile(s) in the xrInput.profiles array
  43728. */
  43729. profileId: string;
  43730. /**
  43731. * fallback profiles for this profileId
  43732. */
  43733. fallbackProfileIds: string[];
  43734. /**
  43735. * The layout map, with handness as key
  43736. */
  43737. layouts: IMotionControllerLayoutMap;
  43738. }
  43739. /**
  43740. * A helper-interface for the 3 meshes needed for controller button animation
  43741. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43742. */
  43743. export interface IMotionControllerButtonMeshMap {
  43744. /**
  43745. * The mesh that will be changed when value changes
  43746. */
  43747. valueMesh: AbstractMesh;
  43748. /**
  43749. * the mesh that defines the pressed value mesh position.
  43750. * This is used to find the max-position of this button
  43751. */
  43752. pressedMesh: AbstractMesh;
  43753. /**
  43754. * the mesh that defines the unpressed value mesh position.
  43755. * This is used to find the min (or initial) position of this button
  43756. */
  43757. unpressedMesh: AbstractMesh;
  43758. }
  43759. /**
  43760. * A helper-interface for the 3 meshes needed for controller axis animation.
  43761. * This will be expanded when touchpad animations are fully supported
  43762. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43763. */
  43764. export interface IMotionControllerMeshMap {
  43765. /**
  43766. * The mesh that will be changed when axis value changes
  43767. */
  43768. valueMesh: AbstractMesh;
  43769. /**
  43770. * the mesh that defines the minimum value mesh position.
  43771. */
  43772. minMesh?: AbstractMesh;
  43773. /**
  43774. * the mesh that defines the maximum value mesh position.
  43775. */
  43776. maxMesh?: AbstractMesh;
  43777. }
  43778. /**
  43779. * The elements needed for change-detection of the gamepad objects in motion controllers
  43780. */
  43781. export interface IMinimalMotionControllerObject {
  43782. /**
  43783. * An array of available buttons
  43784. */
  43785. buttons: Array<{
  43786. /**
  43787. * Value of the button/trigger
  43788. */
  43789. value: number;
  43790. /**
  43791. * If the button/trigger is currently touched
  43792. */
  43793. touched: boolean;
  43794. /**
  43795. * If the button/trigger is currently pressed
  43796. */
  43797. pressed: boolean;
  43798. }>;
  43799. /**
  43800. * Available axes of this controller
  43801. */
  43802. axes: number[];
  43803. }
  43804. /**
  43805. * An Abstract Motion controller
  43806. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43807. * Each component has an observable to check for changes in value and state
  43808. */
  43809. export abstract class WebXRAbstractMotionController implements IDisposable {
  43810. protected scene: Scene;
  43811. protected layout: IMotionControllerLayout;
  43812. /**
  43813. * The gamepad object correlating to this controller
  43814. */
  43815. gamepadObject: IMinimalMotionControllerObject;
  43816. /**
  43817. * handness (left/right/none) of this controller
  43818. */
  43819. handness: MotionControllerHandness;
  43820. /**
  43821. * The profile id of this motion controller
  43822. */
  43823. abstract profileId: string;
  43824. /**
  43825. * A map of components (WebXRControllerComponent) in this motion controller
  43826. * Components have a ComponentType and can also have both button and axis definitions
  43827. */
  43828. readonly components: {
  43829. [id: string]: WebXRControllerComponent;
  43830. };
  43831. /**
  43832. * Observers registered here will be triggered when the model of this controller is done loading
  43833. */
  43834. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43835. /**
  43836. * The root mesh of the model. It is null if the model was not yet initialized
  43837. */
  43838. rootMesh: Nullable<AbstractMesh>;
  43839. /**
  43840. * Disable the model's animation. Can be set at any time.
  43841. */
  43842. disableAnimation: boolean;
  43843. private _modelReady;
  43844. /**
  43845. * constructs a new abstract motion controller
  43846. * @param scene the scene to which the model of the controller will be added
  43847. * @param layout The profile layout to load
  43848. * @param gamepadObject The gamepad object correlating to this controller
  43849. * @param handness handness (left/right/none) of this controller
  43850. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43851. */
  43852. constructor(scene: Scene, layout: IMotionControllerLayout,
  43853. /**
  43854. * The gamepad object correlating to this controller
  43855. */
  43856. gamepadObject: IMinimalMotionControllerObject,
  43857. /**
  43858. * handness (left/right/none) of this controller
  43859. */
  43860. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43861. private _initComponent;
  43862. /**
  43863. * Update this model using the current XRFrame
  43864. * @param xrFrame the current xr frame to use and update the model
  43865. */
  43866. updateFromXRFrame(xrFrame: XRFrame): void;
  43867. /**
  43868. * Get the list of components available in this motion controller
  43869. * @returns an array of strings correlating to available components
  43870. */
  43871. getComponentIds(): string[];
  43872. /**
  43873. * Get the main (Select) component of this controller as defined in the layout
  43874. * @returns the main component of this controller
  43875. */
  43876. getMainComponent(): WebXRControllerComponent;
  43877. /**
  43878. * get a component based an its component id as defined in layout.components
  43879. * @param id the id of the component
  43880. * @returns the component correlates to the id or undefined if not found
  43881. */
  43882. getComponent(id: string): WebXRControllerComponent;
  43883. /**
  43884. * Get the first component of specific type
  43885. * @param type type of component to find
  43886. * @return a controller component or null if not found
  43887. */
  43888. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43889. /**
  43890. * Returns all components of specific type
  43891. * @param type the type to search for
  43892. * @return an array of components with this type
  43893. */
  43894. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43895. /**
  43896. * Loads the model correlating to this controller
  43897. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43898. * @returns A promise fulfilled with the result of the model loading
  43899. */
  43900. loadModel(): Promise<boolean>;
  43901. /**
  43902. * Update the model itself with the current frame data
  43903. * @param xrFrame the frame to use for updating the model mesh
  43904. */
  43905. protected updateModel(xrFrame: XRFrame): void;
  43906. /**
  43907. * Moves the axis on the controller mesh based on its current state
  43908. * @param axis the index of the axis
  43909. * @param axisValue the value of the axis which determines the meshes new position
  43910. * @hidden
  43911. */
  43912. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43913. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43914. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43915. private _getGenericFilenameAndPath;
  43916. private _getGenericParentMesh;
  43917. /**
  43918. * Get the filename and path for this controller's model
  43919. * @returns a map of filename and path
  43920. */
  43921. protected abstract _getFilenameAndPath(): {
  43922. filename: string;
  43923. path: string;
  43924. };
  43925. /**
  43926. * This function will be called after the model was successfully loaded and can be used
  43927. * for mesh transformations before it is available for the user
  43928. * @param meshes the loaded meshes
  43929. */
  43930. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43931. /**
  43932. * Set the root mesh for this controller. Important for the WebXR controller class
  43933. * @param meshes the loaded meshes
  43934. */
  43935. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43936. /**
  43937. * A function executed each frame that updates the mesh (if needed)
  43938. * @param xrFrame the current xrFrame
  43939. */
  43940. protected abstract _updateModel(xrFrame: XRFrame): void;
  43941. /**
  43942. * This function is called before the mesh is loaded. It checks for loading constraints.
  43943. * For example, this function can check if the GLB loader is available
  43944. * If this function returns false, the generic controller will be loaded instead
  43945. * @returns Is the client ready to load the mesh
  43946. */
  43947. protected abstract _getModelLoadingConstraints(): boolean;
  43948. /**
  43949. * Dispose this controller, the model mesh and all its components
  43950. */
  43951. dispose(): void;
  43952. }
  43953. }
  43954. declare module BABYLON {
  43955. /**
  43956. * A generic trigger-only motion controller for WebXR
  43957. */
  43958. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43959. /**
  43960. * Static version of the profile id of this controller
  43961. */
  43962. static ProfileId: string;
  43963. profileId: string;
  43964. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43965. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43966. protected _updateModel(): void;
  43967. protected _getFilenameAndPath(): {
  43968. filename: string;
  43969. path: string;
  43970. };
  43971. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43972. protected _getModelLoadingConstraints(): boolean;
  43973. }
  43974. }
  43975. declare module BABYLON {
  43976. /**
  43977. * Class containing static functions to help procedurally build meshes
  43978. */
  43979. export class SphereBuilder {
  43980. /**
  43981. * Creates a sphere mesh
  43982. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43983. * * 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`)
  43984. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43985. * * 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
  43986. * * 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)
  43987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43988. * * 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
  43989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43990. * @param name defines the name of the mesh
  43991. * @param options defines the options used to create the mesh
  43992. * @param scene defines the hosting scene
  43993. * @returns the sphere mesh
  43994. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43995. */
  43996. static CreateSphere(name: string, options: {
  43997. segments?: number;
  43998. diameter?: number;
  43999. diameterX?: number;
  44000. diameterY?: number;
  44001. diameterZ?: number;
  44002. arc?: number;
  44003. slice?: number;
  44004. sideOrientation?: number;
  44005. frontUVs?: Vector4;
  44006. backUVs?: Vector4;
  44007. updatable?: boolean;
  44008. }, scene?: Nullable<Scene>): Mesh;
  44009. }
  44010. }
  44011. declare module BABYLON {
  44012. /**
  44013. * A profiled motion controller has its profile loaded from an online repository.
  44014. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44015. */
  44016. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44017. private _repositoryUrl;
  44018. /**
  44019. * The profile ID of this controller. Will be populated when the controller initializes.
  44020. */
  44021. profileId: string;
  44022. private _buttonMeshMapping;
  44023. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44024. protected _getFilenameAndPath(): {
  44025. filename: string;
  44026. path: string;
  44027. };
  44028. private _touchDots;
  44029. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44030. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44031. protected _updateModel(_xrFrame: XRFrame): void;
  44032. protected _getModelLoadingConstraints(): boolean;
  44033. dispose(): void;
  44034. }
  44035. }
  44036. declare module BABYLON {
  44037. /**
  44038. * A construction function type to create a new controller based on an xrInput object
  44039. */
  44040. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44041. /**
  44042. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44043. *
  44044. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44045. * it should be replaced with auto-loaded controllers.
  44046. *
  44047. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44048. */
  44049. export class WebXRMotionControllerManager {
  44050. /**
  44051. * The base URL of the online controller repository. Can be changed at any time.
  44052. */
  44053. static BaseRepositoryUrl: string;
  44054. /**
  44055. * Use the online repository, or use only locally-defined controllers
  44056. */
  44057. static UseOnlineRepository: boolean;
  44058. /**
  44059. * Which repository gets priority - local or online
  44060. */
  44061. static PrioritizeOnlineRepository: boolean;
  44062. private static _AvailableControllers;
  44063. private static _Fallbacks;
  44064. /**
  44065. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44066. *
  44067. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44068. *
  44069. * @param type the profile type to register
  44070. * @param constructFunction the function to be called when loading this profile
  44071. */
  44072. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44073. /**
  44074. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44075. * The order of search:
  44076. *
  44077. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44078. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44079. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44080. * 4) return the generic trigger controller if none were found
  44081. *
  44082. * @param xrInput the xrInput to which a new controller is initialized
  44083. * @param scene the scene to which the model will be added
  44084. * @param forceProfile force a certain profile for this controller
  44085. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44086. */
  44087. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44088. private static _LoadProfilesFromAvailableControllers;
  44089. private static _ProfilesList;
  44090. private static _ProfileLoadingPromises;
  44091. private static _LoadProfileFromRepository;
  44092. /**
  44093. * Clear the cache used for profile loading and reload when requested again
  44094. */
  44095. static ClearProfilesCache(): void;
  44096. /**
  44097. * Will update the list of profiles available in the repository
  44098. * @return a promise that resolves to a map of profiles available online
  44099. */
  44100. static UpdateProfilesList(): Promise<{
  44101. [profile: string]: string;
  44102. }>;
  44103. /**
  44104. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44105. * @param profileId the profile to which a fallback needs to be found
  44106. * @return an array with corresponding fallback profiles
  44107. */
  44108. static FindFallbackWithProfileId(profileId: string): string[];
  44109. /**
  44110. * Register a fallback to a specific profile.
  44111. * @param profileId the profileId that will receive the fallbacks
  44112. * @param fallbacks A list of fallback profiles
  44113. */
  44114. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44115. /**
  44116. * Register the default fallbacks.
  44117. * This function is called automatically when this file is imported.
  44118. */
  44119. static DefaultFallbacks(): void;
  44120. }
  44121. }
  44122. declare module BABYLON {
  44123. /**
  44124. * Configuration options for the WebXR controller creation
  44125. */
  44126. export interface IWebXRControllerOptions {
  44127. /**
  44128. * Force a specific controller type for this controller.
  44129. * This can be used when creating your own profile or when testing different controllers
  44130. */
  44131. forceControllerProfile?: string;
  44132. /**
  44133. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44134. */
  44135. doNotLoadControllerMesh?: boolean;
  44136. /**
  44137. * Should the controller mesh be animated when a user interacts with it
  44138. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44139. */
  44140. disableMotionControllerAnimation?: boolean;
  44141. }
  44142. /**
  44143. * Represents an XR controller
  44144. */
  44145. export class WebXRInputSource {
  44146. private _scene;
  44147. /** The underlying input source for the controller */
  44148. inputSource: XRInputSource;
  44149. private _options;
  44150. /**
  44151. * 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
  44152. */
  44153. grip?: AbstractMesh;
  44154. /**
  44155. * Pointer which can be used to select objects or attach a visible laser to
  44156. */
  44157. pointer: AbstractMesh;
  44158. /**
  44159. * If available, this is the gamepad object related to this controller.
  44160. * Using this object it is possible to get click events and trackpad changes of the
  44161. * webxr controller that is currently being used.
  44162. */
  44163. motionController?: WebXRAbstractMotionController;
  44164. /**
  44165. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44166. */
  44167. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44168. /**
  44169. * Will be triggered when the mesh associated with the motion controller is done loading.
  44170. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44171. * A shortened version of controller -> motion controller -> on mesh loaded.
  44172. */
  44173. onMeshLoadedObservable: Observable<AbstractMesh>;
  44174. /**
  44175. * Event that fires when the controller is removed/disposed.
  44176. * The object provided as event data is this controller, after associated assets were disposed.
  44177. * uniqueId is still available.
  44178. */
  44179. onDisposeObservable: Observable<WebXRInputSource>;
  44180. private _tmpQuaternion;
  44181. private _tmpVector;
  44182. private _uniqueId;
  44183. /**
  44184. * Creates the controller
  44185. * @see https://doc.babylonjs.com/how_to/webxr
  44186. * @param _scene the scene which the controller should be associated to
  44187. * @param inputSource the underlying input source for the controller
  44188. * @param _options options for this controller creation
  44189. */
  44190. constructor(_scene: Scene,
  44191. /** The underlying input source for the controller */
  44192. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44193. /**
  44194. * Get this controllers unique id
  44195. */
  44196. get uniqueId(): string;
  44197. /**
  44198. * Updates the controller pose based on the given XRFrame
  44199. * @param xrFrame xr frame to update the pose with
  44200. * @param referenceSpace reference space to use
  44201. */
  44202. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44203. /**
  44204. * Gets a world space ray coming from the pointer or grip
  44205. * @param result the resulting ray
  44206. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44207. */
  44208. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44209. /**
  44210. * Disposes of the object
  44211. */
  44212. dispose(): void;
  44213. }
  44214. }
  44215. declare module BABYLON {
  44216. /**
  44217. * The schema for initialization options of the XR Input class
  44218. */
  44219. export interface IWebXRInputOptions {
  44220. /**
  44221. * If set to true no model will be automatically loaded
  44222. */
  44223. doNotLoadControllerMeshes?: boolean;
  44224. /**
  44225. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44226. * If not found, the xr input profile data will be used.
  44227. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44228. */
  44229. forceInputProfile?: string;
  44230. /**
  44231. * Do not send a request to the controlle repository to load the profile.
  44232. *
  44233. * Instead, use the controllers available in babylon itself.
  44234. */
  44235. disableOnlineControllerRepository?: boolean;
  44236. /**
  44237. * A custom URL for the controllers repository
  44238. */
  44239. customControllersRepositoryURL?: string;
  44240. /**
  44241. * Should the controller model's components not move according to the user input
  44242. */
  44243. disableControllerAnimation?: boolean;
  44244. }
  44245. /**
  44246. * XR input used to track XR inputs such as controllers/rays
  44247. */
  44248. export class WebXRInput implements IDisposable {
  44249. /**
  44250. * the xr session manager for this session
  44251. */
  44252. xrSessionManager: WebXRSessionManager;
  44253. /**
  44254. * the WebXR camera for this session. Mainly used for teleportation
  44255. */
  44256. xrCamera: WebXRCamera;
  44257. private readonly options;
  44258. /**
  44259. * XR controllers being tracked
  44260. */
  44261. controllers: Array<WebXRInputSource>;
  44262. private _frameObserver;
  44263. private _sessionEndedObserver;
  44264. private _sessionInitObserver;
  44265. /**
  44266. * Event when a controller has been connected/added
  44267. */
  44268. onControllerAddedObservable: Observable<WebXRInputSource>;
  44269. /**
  44270. * Event when a controller has been removed/disconnected
  44271. */
  44272. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44273. /**
  44274. * Initializes the WebXRInput
  44275. * @param xrSessionManager the xr session manager for this session
  44276. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44277. * @param options = initialization options for this xr input
  44278. */
  44279. constructor(
  44280. /**
  44281. * the xr session manager for this session
  44282. */
  44283. xrSessionManager: WebXRSessionManager,
  44284. /**
  44285. * the WebXR camera for this session. Mainly used for teleportation
  44286. */
  44287. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44288. private _onInputSourcesChange;
  44289. private _addAndRemoveControllers;
  44290. /**
  44291. * Disposes of the object
  44292. */
  44293. dispose(): void;
  44294. }
  44295. }
  44296. declare module BABYLON {
  44297. /**
  44298. * This is the base class for all WebXR features.
  44299. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44300. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44301. */
  44302. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44303. protected _xrSessionManager: WebXRSessionManager;
  44304. /**
  44305. * Construct a new (abstract) webxr feature
  44306. * @param _xrSessionManager the xr session manager for this feature
  44307. */
  44308. constructor(_xrSessionManager: WebXRSessionManager);
  44309. private _attached;
  44310. private _removeOnDetach;
  44311. /**
  44312. * Is this feature attached
  44313. */
  44314. get attached(): boolean;
  44315. /**
  44316. * Should auto-attach be disabled?
  44317. */
  44318. disableAutoAttach: boolean;
  44319. /**
  44320. * attach this feature
  44321. *
  44322. * @param force should attachment be forced (even when already attached)
  44323. * @returns true if successful, false is failed or already attached
  44324. */
  44325. attach(force?: boolean): boolean;
  44326. /**
  44327. * detach this feature.
  44328. *
  44329. * @returns true if successful, false if failed or already detached
  44330. */
  44331. detach(): boolean;
  44332. /**
  44333. * Dispose this feature and all of the resources attached
  44334. */
  44335. dispose(): void;
  44336. /**
  44337. * Code in this function will be executed on each xrFrame received from the browser.
  44338. * This function will not execute after the feature is detached.
  44339. * @param _xrFrame the current frame
  44340. */
  44341. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44342. /**
  44343. * This is used to register callbacks that will automatically be removed when detach is called.
  44344. * @param observable the observable to which the observer will be attached
  44345. * @param callback the callback to register
  44346. */
  44347. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44348. }
  44349. }
  44350. declare module BABYLON {
  44351. /**
  44352. * Renders a layer on top of an existing scene
  44353. */
  44354. export class UtilityLayerRenderer implements IDisposable {
  44355. /** the original scene that will be rendered on top of */
  44356. originalScene: Scene;
  44357. private _pointerCaptures;
  44358. private _lastPointerEvents;
  44359. private static _DefaultUtilityLayer;
  44360. private static _DefaultKeepDepthUtilityLayer;
  44361. private _sharedGizmoLight;
  44362. private _renderCamera;
  44363. /**
  44364. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44365. * @returns the camera that is used when rendering the utility layer
  44366. */
  44367. getRenderCamera(): Camera;
  44368. /**
  44369. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44370. * @param cam the camera that should be used when rendering the utility layer
  44371. */
  44372. setRenderCamera(cam: Nullable<Camera>): void;
  44373. /**
  44374. * @hidden
  44375. * Light which used by gizmos to get light shading
  44376. */
  44377. _getSharedGizmoLight(): HemisphericLight;
  44378. /**
  44379. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44380. */
  44381. pickUtilitySceneFirst: boolean;
  44382. /**
  44383. * 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)
  44384. */
  44385. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44386. /**
  44387. * 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)
  44388. */
  44389. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44390. /**
  44391. * The scene that is rendered on top of the original scene
  44392. */
  44393. utilityLayerScene: Scene;
  44394. /**
  44395. * If the utility layer should automatically be rendered on top of existing scene
  44396. */
  44397. shouldRender: boolean;
  44398. /**
  44399. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44400. */
  44401. onlyCheckPointerDownEvents: boolean;
  44402. /**
  44403. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44404. */
  44405. processAllEvents: boolean;
  44406. /**
  44407. * Observable raised when the pointer move from the utility layer scene to the main scene
  44408. */
  44409. onPointerOutObservable: Observable<number>;
  44410. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44411. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44412. private _afterRenderObserver;
  44413. private _sceneDisposeObserver;
  44414. private _originalPointerObserver;
  44415. /**
  44416. * Instantiates a UtilityLayerRenderer
  44417. * @param originalScene the original scene that will be rendered on top of
  44418. * @param handleEvents boolean indicating if the utility layer should handle events
  44419. */
  44420. constructor(
  44421. /** the original scene that will be rendered on top of */
  44422. originalScene: Scene, handleEvents?: boolean);
  44423. private _notifyObservers;
  44424. /**
  44425. * Renders the utility layers scene on top of the original scene
  44426. */
  44427. render(): void;
  44428. /**
  44429. * Disposes of the renderer
  44430. */
  44431. dispose(): void;
  44432. private _updateCamera;
  44433. }
  44434. }
  44435. declare module BABYLON {
  44436. /**
  44437. * Options interface for the pointer selection module
  44438. */
  44439. export interface IWebXRControllerPointerSelectionOptions {
  44440. /**
  44441. * the xr input to use with this pointer selection
  44442. */
  44443. xrInput: WebXRInput;
  44444. /**
  44445. * Different button type to use instead of the main component
  44446. */
  44447. overrideButtonId?: string;
  44448. /**
  44449. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  44450. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44451. * 3000 means 3 seconds between pointing at something and selecting it
  44452. */
  44453. timeToSelect?: number;
  44454. /**
  44455. * 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)
  44456. * If not disabled, the last picked point will be used to execute a pointer up event
  44457. * If disabled, pointer up event will be triggered right after the pointer down event.
  44458. * Used in screen and gaze target ray mode only
  44459. */
  44460. disablePointerUpOnTouchOut: boolean;
  44461. /**
  44462. * For gaze mode (time to select instead of press)
  44463. */
  44464. forceGazeMode: boolean;
  44465. /**
  44466. * 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
  44467. * to start a new countdown to the pointer down event.
  44468. * Defaults to 1.
  44469. */
  44470. gazeModePointerMovedFactor?: number;
  44471. /**
  44472. * Should meshes created here be added to a utility layer or the main scene
  44473. */
  44474. useUtilityLayer?: boolean;
  44475. /**
  44476. * if provided, this scene will be used to render meshes.
  44477. */
  44478. customUtilityLayerScene?: Scene;
  44479. /**
  44480. * use this rendering group id for the meshes (optional)
  44481. */
  44482. renderingGroupId?: number;
  44483. }
  44484. /**
  44485. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44486. */
  44487. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44488. private readonly _options;
  44489. /**
  44490. * The module's name
  44491. */
  44492. static readonly Name: string;
  44493. /**
  44494. * The (Babylon) version of this module.
  44495. * This is an integer representing the implementation version.
  44496. * This number does not correspond to the webxr specs version
  44497. */
  44498. static readonly Version: number;
  44499. /**
  44500. * This color will be set to the laser pointer when selection is triggered
  44501. */
  44502. laserPointerPickedColor: Color3;
  44503. /**
  44504. * This color will be applied to the selection ring when selection is triggered
  44505. */
  44506. selectionMeshPickedColor: Color3;
  44507. /**
  44508. * default color of the selection ring
  44509. */
  44510. selectionMeshDefaultColor: Color3;
  44511. /**
  44512. * Default color of the laser pointer
  44513. */
  44514. lasterPointerDefaultColor: Color3;
  44515. /**
  44516. * Should the laser pointer be displayed
  44517. */
  44518. displayLaserPointer: boolean;
  44519. /**
  44520. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44521. */
  44522. displaySelectionMesh: boolean;
  44523. /**
  44524. * Disable lighting on the laser pointer (so it will always be visible)
  44525. */
  44526. disablePointerLighting: boolean;
  44527. /**
  44528. * Disable lighting on the selection mesh (so it will always be visible)
  44529. */
  44530. disableSelectionMeshLighting: boolean;
  44531. private static _idCounter;
  44532. private _controllers;
  44533. private _scene;
  44534. /**
  44535. * constructs a new background remover module
  44536. * @param _xrSessionManager the session manager for this module
  44537. * @param _options read-only options to be used in this module
  44538. */
  44539. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44540. /**
  44541. * attach this feature
  44542. * Will usually be called by the features manager
  44543. *
  44544. * @returns true if successful.
  44545. */
  44546. attach(): boolean;
  44547. /**
  44548. * detach this feature.
  44549. * Will usually be called by the features manager
  44550. *
  44551. * @returns true if successful.
  44552. */
  44553. detach(): boolean;
  44554. /**
  44555. * Get the xr controller that correlates to the pointer id in the pointer event
  44556. *
  44557. * @param id the pointer id to search for
  44558. * @returns the controller that correlates to this id or null if not found
  44559. */
  44560. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44561. /**
  44562. * Will get the mesh under a specific pointer.
  44563. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44564. * @param controllerId the controllerId to check
  44565. * @returns The mesh under pointer or null if no mesh is under the pointer
  44566. */
  44567. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44568. protected _onXRFrame(_xrFrame: XRFrame): void;
  44569. private _attachController;
  44570. private _attachScreenRayMode;
  44571. private _attachGazeMode;
  44572. private _tmpVectorForPickCompare;
  44573. private _pickingMoved;
  44574. private _attachTrackedPointerRayMode;
  44575. private _detachController;
  44576. private _generateNewMeshPair;
  44577. private _convertNormalToDirectionOfRay;
  44578. private _updatePointerDistance;
  44579. }
  44580. }
  44581. declare module BABYLON {
  44582. /**
  44583. * Button which can be used to enter a different mode of XR
  44584. */
  44585. export class WebXREnterExitUIButton {
  44586. /** button element */
  44587. element: HTMLElement;
  44588. /** XR initialization options for the button */
  44589. sessionMode: XRSessionMode;
  44590. /** Reference space type */
  44591. referenceSpaceType: XRReferenceSpaceType;
  44592. /**
  44593. * Creates a WebXREnterExitUIButton
  44594. * @param element button element
  44595. * @param sessionMode XR initialization session mode
  44596. * @param referenceSpaceType the type of reference space to be used
  44597. */
  44598. constructor(
  44599. /** button element */
  44600. element: HTMLElement,
  44601. /** XR initialization options for the button */
  44602. sessionMode: XRSessionMode,
  44603. /** Reference space type */
  44604. referenceSpaceType: XRReferenceSpaceType);
  44605. /**
  44606. * Overwritable function which can be used to update the button's visuals when the state changes
  44607. * @param activeButton the current active button in the UI
  44608. */
  44609. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44610. }
  44611. /**
  44612. * Options to create the webXR UI
  44613. */
  44614. export class WebXREnterExitUIOptions {
  44615. /**
  44616. * Context to enter xr with
  44617. */
  44618. renderTarget?: Nullable<WebXRRenderTarget>;
  44619. /**
  44620. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44621. */
  44622. customButtons?: Array<WebXREnterExitUIButton>;
  44623. /**
  44624. * A session mode to use when creating the default button.
  44625. * Default is immersive-vr
  44626. */
  44627. sessionMode?: XRSessionMode;
  44628. /**
  44629. * A reference space type to use when creating the default button.
  44630. * Default is local-floor
  44631. */
  44632. referenceSpaceType?: XRReferenceSpaceType;
  44633. }
  44634. /**
  44635. * UI to allow the user to enter/exit XR mode
  44636. */
  44637. export class WebXREnterExitUI implements IDisposable {
  44638. private scene;
  44639. /** version of the options passed to this UI */
  44640. options: WebXREnterExitUIOptions;
  44641. private _overlay;
  44642. private _buttons;
  44643. private _activeButton;
  44644. /**
  44645. * Fired every time the active button is changed.
  44646. *
  44647. * When xr is entered via a button that launches xr that button will be the callback parameter
  44648. *
  44649. * When exiting xr the callback parameter will be null)
  44650. */
  44651. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44652. /**
  44653. * Creates UI to allow the user to enter/exit XR mode
  44654. * @param scene the scene to add the ui to
  44655. * @param helper the xr experience helper to enter/exit xr with
  44656. * @param options options to configure the UI
  44657. * @returns the created ui
  44658. */
  44659. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44660. /**
  44661. *
  44662. * @param scene babylon scene object to use
  44663. * @param options (read-only) version of the options passed to this UI
  44664. */
  44665. private constructor();
  44666. private _updateButtons;
  44667. /**
  44668. * Disposes of the object
  44669. */
  44670. dispose(): void;
  44671. }
  44672. }
  44673. declare module BABYLON {
  44674. /**
  44675. * Class containing static functions to help procedurally build meshes
  44676. */
  44677. export class LinesBuilder {
  44678. /**
  44679. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44680. * * 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
  44681. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44682. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44683. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44684. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44685. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44686. * * 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
  44687. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44690. * @param name defines the name of the new line system
  44691. * @param options defines the options used to create the line system
  44692. * @param scene defines the hosting scene
  44693. * @returns a new line system mesh
  44694. */
  44695. static CreateLineSystem(name: string, options: {
  44696. lines: Vector3[][];
  44697. updatable?: boolean;
  44698. instance?: Nullable<LinesMesh>;
  44699. colors?: Nullable<Color4[][]>;
  44700. useVertexAlpha?: boolean;
  44701. }, scene: Nullable<Scene>): LinesMesh;
  44702. /**
  44703. * Creates a line mesh
  44704. * 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
  44705. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44706. * * The parameter `points` is an array successive Vector3
  44707. * * 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
  44708. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44709. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44710. * * When updating an instance, remember that only point positions can change, not the number of points
  44711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44713. * @param name defines the name of the new line system
  44714. * @param options defines the options used to create the line system
  44715. * @param scene defines the hosting scene
  44716. * @returns a new line mesh
  44717. */
  44718. static CreateLines(name: string, options: {
  44719. points: Vector3[];
  44720. updatable?: boolean;
  44721. instance?: Nullable<LinesMesh>;
  44722. colors?: Color4[];
  44723. useVertexAlpha?: boolean;
  44724. }, scene?: Nullable<Scene>): LinesMesh;
  44725. /**
  44726. * Creates a dashed line mesh
  44727. * * 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
  44728. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44729. * * The parameter `points` is an array successive Vector3
  44730. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44731. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44732. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44733. * * 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
  44734. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44735. * * When updating an instance, remember that only point positions can change, not the number of points
  44736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44737. * @param name defines the name of the mesh
  44738. * @param options defines the options used to create the mesh
  44739. * @param scene defines the hosting scene
  44740. * @returns the dashed line mesh
  44741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44742. */
  44743. static CreateDashedLines(name: string, options: {
  44744. points: Vector3[];
  44745. dashSize?: number;
  44746. gapSize?: number;
  44747. dashNb?: number;
  44748. updatable?: boolean;
  44749. instance?: LinesMesh;
  44750. useVertexAlpha?: boolean;
  44751. }, scene?: Nullable<Scene>): LinesMesh;
  44752. }
  44753. }
  44754. declare module BABYLON {
  44755. /**
  44756. * The options container for the teleportation module
  44757. */
  44758. export interface IWebXRTeleportationOptions {
  44759. /**
  44760. * Babylon XR Input class for controller
  44761. */
  44762. xrInput: WebXRInput;
  44763. /**
  44764. * A list of meshes to use as floor meshes.
  44765. * Meshes can be added and removed after initializing the feature using the
  44766. * addFloorMesh and removeFloorMesh functions
  44767. * If empty, rotation will still work
  44768. */
  44769. floorMeshes?: AbstractMesh[];
  44770. /**
  44771. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44772. * If you want to support rotation, make sure your mesh has a direction indicator.
  44773. *
  44774. * When left untouched, the default mesh will be initialized.
  44775. */
  44776. teleportationTargetMesh?: AbstractMesh;
  44777. /**
  44778. * An array of points to which the teleportation will snap to.
  44779. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44780. */
  44781. snapPositions?: Vector3[];
  44782. /**
  44783. * How close should the teleportation ray be in order to snap to position.
  44784. * Default to 0.8 units (meters)
  44785. */
  44786. snapToPositionRadius?: number;
  44787. /**
  44788. * Should teleportation move only to snap points
  44789. */
  44790. snapPointsOnly?: boolean;
  44791. /**
  44792. * Values to configure the default target mesh
  44793. */
  44794. defaultTargetMeshOptions?: {
  44795. /**
  44796. * Fill color of the teleportation area
  44797. */
  44798. teleportationFillColor?: string;
  44799. /**
  44800. * Border color for the teleportation area
  44801. */
  44802. teleportationBorderColor?: string;
  44803. /**
  44804. * Disable the mesh's animation sequence
  44805. */
  44806. disableAnimation?: boolean;
  44807. /**
  44808. * Disable lighting on the material or the ring and arrow
  44809. */
  44810. disableLighting?: boolean;
  44811. /**
  44812. * Override the default material of the torus and arrow
  44813. */
  44814. torusArrowMaterial?: Material;
  44815. };
  44816. /**
  44817. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44818. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44819. */
  44820. useMainComponentOnly?: boolean;
  44821. /**
  44822. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44823. */
  44824. timeToTeleport?: number;
  44825. /**
  44826. * Should meshes created here be added to a utility layer or the main scene
  44827. */
  44828. useUtilityLayer?: boolean;
  44829. /**
  44830. * if provided, this scene will be used to render meshes.
  44831. */
  44832. customUtilityLayerScene?: Scene;
  44833. /**
  44834. * use this rendering group id for the meshes (optional)
  44835. */
  44836. renderingGroupId?: number;
  44837. }
  44838. /**
  44839. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44840. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44841. * the input of the attached controllers.
  44842. */
  44843. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44844. private _options;
  44845. /**
  44846. * The module's name
  44847. */
  44848. static readonly Name: string;
  44849. /**
  44850. * The (Babylon) version of this module.
  44851. * This is an integer representing the implementation version.
  44852. * This number does not correspond to the webxr specs version
  44853. */
  44854. static readonly Version: number;
  44855. /**
  44856. * Is rotation enabled when moving forward?
  44857. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44858. */
  44859. rotationEnabled: boolean;
  44860. /**
  44861. * Should the module support parabolic ray on top of direct ray
  44862. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44863. * Very helpful when moving between floors / different heights
  44864. */
  44865. parabolicRayEnabled: boolean;
  44866. /**
  44867. * The distance from the user to the inspection point in the direction of the controller
  44868. * A higher number will allow the user to move further
  44869. * defaults to 5 (meters, in xr units)
  44870. */
  44871. parabolicCheckRadius: number;
  44872. /**
  44873. * How much rotation should be applied when rotating right and left
  44874. */
  44875. rotationAngle: number;
  44876. /**
  44877. * Is movement backwards enabled
  44878. */
  44879. backwardsMovementEnabled: boolean;
  44880. /**
  44881. * Distance to travel when moving backwards
  44882. */
  44883. backwardsTeleportationDistance: number;
  44884. /**
  44885. * Add a new mesh to the floor meshes array
  44886. * @param mesh the mesh to use as floor mesh
  44887. */
  44888. addFloorMesh(mesh: AbstractMesh): void;
  44889. /**
  44890. * Remove a mesh from the floor meshes array
  44891. * @param mesh the mesh to remove
  44892. */
  44893. removeFloorMesh(mesh: AbstractMesh): void;
  44894. /**
  44895. * Remove a mesh from the floor meshes array using its name
  44896. * @param name the mesh name to remove
  44897. */
  44898. removeFloorMeshByName(name: string): void;
  44899. private _tmpRay;
  44900. private _tmpVector;
  44901. private _floorMeshes;
  44902. private _snapToPositions;
  44903. private _controllers;
  44904. /**
  44905. * constructs a new anchor system
  44906. * @param _xrSessionManager an instance of WebXRSessionManager
  44907. * @param _options configuration object for this feature
  44908. */
  44909. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44910. private _selectionFeature;
  44911. private _snappedToPoint;
  44912. private _teleportationRingMaterial?;
  44913. /**
  44914. * Get the snapPointsOnly flag
  44915. */
  44916. get snapPointsOnly(): boolean;
  44917. /**
  44918. * Sets the snapPointsOnly flag
  44919. * @param snapToPoints should teleportation be exclusively to snap points
  44920. */
  44921. set snapPointsOnly(snapToPoints: boolean);
  44922. /**
  44923. * Add a new snap-to point to fix teleportation to this position
  44924. * @param newSnapPoint The new Snap-To point
  44925. */
  44926. addSnapPoint(newSnapPoint: Vector3): void;
  44927. /**
  44928. * 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
  44929. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  44930. * @returns was the point found and removed or not
  44931. */
  44932. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  44933. /**
  44934. * This function sets a selection feature that will be disabled when
  44935. * the forward ray is shown and will be reattached when hidden.
  44936. * This is used to remove the selection rays when moving.
  44937. * @param selectionFeature the feature to disable when forward movement is enabled
  44938. */
  44939. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44940. attach(): boolean;
  44941. detach(): boolean;
  44942. dispose(): void;
  44943. protected _onXRFrame(_xrFrame: XRFrame): void;
  44944. private _currentTeleportationControllerId;
  44945. private _attachController;
  44946. private _teleportForward;
  44947. private _detachController;
  44948. private _createDefaultTargetMesh;
  44949. private _setTargetMeshVisibility;
  44950. private _setTargetMeshPosition;
  44951. private _quadraticBezierCurve;
  44952. private _showParabolicPath;
  44953. private _findClosestSnapPointWithRadius;
  44954. }
  44955. }
  44956. declare module BABYLON {
  44957. /**
  44958. * Options for the default xr helper
  44959. */
  44960. export class WebXRDefaultExperienceOptions {
  44961. /**
  44962. * Floor meshes that will be used for teleporting
  44963. */
  44964. floorMeshes?: Array<AbstractMesh>;
  44965. /**
  44966. * Enable or disable default UI to enter XR
  44967. */
  44968. disableDefaultUI?: boolean;
  44969. /**
  44970. * optional configuration for the output canvas
  44971. */
  44972. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44973. /**
  44974. * optional UI options. This can be used among other to change session mode and reference space type
  44975. */
  44976. uiOptions?: WebXREnterExitUIOptions;
  44977. /**
  44978. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44979. */
  44980. inputOptions?: IWebXRInputOptions;
  44981. /**
  44982. * Should teleportation not initialize. defaults to false.
  44983. */
  44984. disableTeleportation?: boolean;
  44985. /**
  44986. * If set to true, the first frame will not be used to reset position
  44987. * The first frame is mainly used when copying transformation from the old camera
  44988. * Mainly used in AR
  44989. */
  44990. ignoreNativeCameraTransformation?: boolean;
  44991. /**
  44992. * When loading teleportation and pointer select, use stable versions instead of latest.
  44993. */
  44994. useStablePlugins?: boolean;
  44995. }
  44996. /**
  44997. * Default experience which provides a similar setup to the previous webVRExperience
  44998. */
  44999. export class WebXRDefaultExperience {
  45000. /**
  45001. * Base experience
  45002. */
  45003. baseExperience: WebXRExperienceHelper;
  45004. /**
  45005. * Input experience extension
  45006. */
  45007. input: WebXRInput;
  45008. /**
  45009. * Enables laser pointer and selection
  45010. */
  45011. pointerSelection: WebXRControllerPointerSelection;
  45012. /**
  45013. * Enables teleportation
  45014. */
  45015. teleportation: WebXRMotionControllerTeleportation;
  45016. /**
  45017. * Enables ui for entering/exiting xr
  45018. */
  45019. enterExitUI: WebXREnterExitUI;
  45020. /**
  45021. * Default target xr should render to
  45022. */
  45023. renderTarget: WebXRRenderTarget;
  45024. /**
  45025. * Creates the default xr experience
  45026. * @param scene scene
  45027. * @param options options for basic configuration
  45028. * @returns resulting WebXRDefaultExperience
  45029. */
  45030. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45031. private constructor();
  45032. /**
  45033. * DIsposes of the experience helper
  45034. */
  45035. dispose(): void;
  45036. }
  45037. }
  45038. declare module BABYLON {
  45039. /**
  45040. * Options to modify the vr teleportation behavior.
  45041. */
  45042. export interface VRTeleportationOptions {
  45043. /**
  45044. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45045. */
  45046. floorMeshName?: string;
  45047. /**
  45048. * A list of meshes to be used as the teleportation floor. (default: empty)
  45049. */
  45050. floorMeshes?: Mesh[];
  45051. /**
  45052. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45053. */
  45054. teleportationMode?: number;
  45055. /**
  45056. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45057. */
  45058. teleportationTime?: number;
  45059. /**
  45060. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45061. */
  45062. teleportationSpeed?: number;
  45063. /**
  45064. * The easing function used in the animation or null for Linear. (default CircleEase)
  45065. */
  45066. easingFunction?: EasingFunction;
  45067. }
  45068. /**
  45069. * Options to modify the vr experience helper's behavior.
  45070. */
  45071. export interface VRExperienceHelperOptions extends WebVROptions {
  45072. /**
  45073. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45074. */
  45075. createDeviceOrientationCamera?: boolean;
  45076. /**
  45077. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45078. */
  45079. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45080. /**
  45081. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45082. */
  45083. laserToggle?: boolean;
  45084. /**
  45085. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45086. */
  45087. floorMeshes?: Mesh[];
  45088. /**
  45089. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45090. */
  45091. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45092. /**
  45093. * Defines if WebXR should be used instead of WebVR (if available)
  45094. */
  45095. useXR?: boolean;
  45096. }
  45097. /**
  45098. * Event containing information after VR has been entered
  45099. */
  45100. export class OnAfterEnteringVRObservableEvent {
  45101. /**
  45102. * If entering vr was successful
  45103. */
  45104. success: boolean;
  45105. }
  45106. /**
  45107. * Helps to quickly add VR support to an existing scene.
  45108. * See http://doc.babylonjs.com/how_to/webvr_helper
  45109. */
  45110. export class VRExperienceHelper {
  45111. /** Options to modify the vr experience helper's behavior. */
  45112. webVROptions: VRExperienceHelperOptions;
  45113. private _scene;
  45114. private _position;
  45115. private _btnVR;
  45116. private _btnVRDisplayed;
  45117. private _webVRsupported;
  45118. private _webVRready;
  45119. private _webVRrequesting;
  45120. private _webVRpresenting;
  45121. private _hasEnteredVR;
  45122. private _fullscreenVRpresenting;
  45123. private _inputElement;
  45124. private _webVRCamera;
  45125. private _vrDeviceOrientationCamera;
  45126. private _deviceOrientationCamera;
  45127. private _existingCamera;
  45128. private _onKeyDown;
  45129. private _onVrDisplayPresentChange;
  45130. private _onVRDisplayChanged;
  45131. private _onVRRequestPresentStart;
  45132. private _onVRRequestPresentComplete;
  45133. /**
  45134. * 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)
  45135. */
  45136. enableGazeEvenWhenNoPointerLock: boolean;
  45137. /**
  45138. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45139. */
  45140. exitVROnDoubleTap: boolean;
  45141. /**
  45142. * Observable raised right before entering VR.
  45143. */
  45144. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45145. /**
  45146. * Observable raised when entering VR has completed.
  45147. */
  45148. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45149. /**
  45150. * Observable raised when exiting VR.
  45151. */
  45152. onExitingVRObservable: Observable<VRExperienceHelper>;
  45153. /**
  45154. * Observable raised when controller mesh is loaded.
  45155. */
  45156. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45157. /** Return this.onEnteringVRObservable
  45158. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45159. */
  45160. get onEnteringVR(): Observable<VRExperienceHelper>;
  45161. /** Return this.onExitingVRObservable
  45162. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45163. */
  45164. get onExitingVR(): Observable<VRExperienceHelper>;
  45165. /** Return this.onControllerMeshLoadedObservable
  45166. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45167. */
  45168. get onControllerMeshLoaded(): Observable<WebVRController>;
  45169. private _rayLength;
  45170. private _useCustomVRButton;
  45171. private _teleportationRequested;
  45172. private _teleportActive;
  45173. private _floorMeshName;
  45174. private _floorMeshesCollection;
  45175. private _teleportationMode;
  45176. private _teleportationTime;
  45177. private _teleportationSpeed;
  45178. private _teleportationEasing;
  45179. private _rotationAllowed;
  45180. private _teleportBackwardsVector;
  45181. private _teleportationTarget;
  45182. private _isDefaultTeleportationTarget;
  45183. private _postProcessMove;
  45184. private _teleportationFillColor;
  45185. private _teleportationBorderColor;
  45186. private _rotationAngle;
  45187. private _haloCenter;
  45188. private _cameraGazer;
  45189. private _padSensibilityUp;
  45190. private _padSensibilityDown;
  45191. private _leftController;
  45192. private _rightController;
  45193. private _gazeColor;
  45194. private _laserColor;
  45195. private _pickedLaserColor;
  45196. private _pickedGazeColor;
  45197. /**
  45198. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45199. */
  45200. onNewMeshSelected: Observable<AbstractMesh>;
  45201. /**
  45202. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45203. * This observable will provide the mesh and the controller used to select the mesh
  45204. */
  45205. onMeshSelectedWithController: Observable<{
  45206. mesh: AbstractMesh;
  45207. controller: WebVRController;
  45208. }>;
  45209. /**
  45210. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45211. */
  45212. onNewMeshPicked: Observable<PickingInfo>;
  45213. private _circleEase;
  45214. /**
  45215. * Observable raised before camera teleportation
  45216. */
  45217. onBeforeCameraTeleport: Observable<Vector3>;
  45218. /**
  45219. * Observable raised after camera teleportation
  45220. */
  45221. onAfterCameraTeleport: Observable<Vector3>;
  45222. /**
  45223. * Observable raised when current selected mesh gets unselected
  45224. */
  45225. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45226. private _raySelectionPredicate;
  45227. /**
  45228. * To be optionaly changed by user to define custom ray selection
  45229. */
  45230. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45231. /**
  45232. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45233. */
  45234. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45235. /**
  45236. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45237. */
  45238. teleportationEnabled: boolean;
  45239. private _defaultHeight;
  45240. private _teleportationInitialized;
  45241. private _interactionsEnabled;
  45242. private _interactionsRequested;
  45243. private _displayGaze;
  45244. private _displayLaserPointer;
  45245. /**
  45246. * The mesh used to display where the user is going to teleport.
  45247. */
  45248. get teleportationTarget(): Mesh;
  45249. /**
  45250. * Sets the mesh to be used to display where the user is going to teleport.
  45251. */
  45252. set teleportationTarget(value: Mesh);
  45253. /**
  45254. * 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
  45255. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45256. * See http://doc.babylonjs.com/resources/baking_transformations
  45257. */
  45258. get gazeTrackerMesh(): Mesh;
  45259. set gazeTrackerMesh(value: Mesh);
  45260. /**
  45261. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45262. */
  45263. updateGazeTrackerScale: boolean;
  45264. /**
  45265. * If the gaze trackers color should be updated when selecting meshes
  45266. */
  45267. updateGazeTrackerColor: boolean;
  45268. /**
  45269. * If the controller laser color should be updated when selecting meshes
  45270. */
  45271. updateControllerLaserColor: boolean;
  45272. /**
  45273. * The gaze tracking mesh corresponding to the left controller
  45274. */
  45275. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45276. /**
  45277. * The gaze tracking mesh corresponding to the right controller
  45278. */
  45279. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45280. /**
  45281. * If the ray of the gaze should be displayed.
  45282. */
  45283. get displayGaze(): boolean;
  45284. /**
  45285. * Sets if the ray of the gaze should be displayed.
  45286. */
  45287. set displayGaze(value: boolean);
  45288. /**
  45289. * If the ray of the LaserPointer should be displayed.
  45290. */
  45291. get displayLaserPointer(): boolean;
  45292. /**
  45293. * Sets if the ray of the LaserPointer should be displayed.
  45294. */
  45295. set displayLaserPointer(value: boolean);
  45296. /**
  45297. * The deviceOrientationCamera used as the camera when not in VR.
  45298. */
  45299. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45300. /**
  45301. * Based on the current WebVR support, returns the current VR camera used.
  45302. */
  45303. get currentVRCamera(): Nullable<Camera>;
  45304. /**
  45305. * The webVRCamera which is used when in VR.
  45306. */
  45307. get webVRCamera(): WebVRFreeCamera;
  45308. /**
  45309. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45310. */
  45311. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45312. /**
  45313. * The html button that is used to trigger entering into VR.
  45314. */
  45315. get vrButton(): Nullable<HTMLButtonElement>;
  45316. private get _teleportationRequestInitiated();
  45317. /**
  45318. * Defines whether or not Pointer lock should be requested when switching to
  45319. * full screen.
  45320. */
  45321. requestPointerLockOnFullScreen: boolean;
  45322. /**
  45323. * If asking to force XR, this will be populated with the default xr experience
  45324. */
  45325. xr: WebXRDefaultExperience;
  45326. /**
  45327. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45328. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45329. */
  45330. xrTestDone: boolean;
  45331. /**
  45332. * Instantiates a VRExperienceHelper.
  45333. * Helps to quickly add VR support to an existing scene.
  45334. * @param scene The scene the VRExperienceHelper belongs to.
  45335. * @param webVROptions Options to modify the vr experience helper's behavior.
  45336. */
  45337. constructor(scene: Scene,
  45338. /** Options to modify the vr experience helper's behavior. */
  45339. webVROptions?: VRExperienceHelperOptions);
  45340. private completeVRInit;
  45341. private _onDefaultMeshLoaded;
  45342. private _onResize;
  45343. private _onFullscreenChange;
  45344. /**
  45345. * Gets a value indicating if we are currently in VR mode.
  45346. */
  45347. get isInVRMode(): boolean;
  45348. private onVrDisplayPresentChange;
  45349. private onVRDisplayChanged;
  45350. private moveButtonToBottomRight;
  45351. private displayVRButton;
  45352. private updateButtonVisibility;
  45353. private _cachedAngularSensibility;
  45354. /**
  45355. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45356. * Otherwise, will use the fullscreen API.
  45357. */
  45358. enterVR(): void;
  45359. /**
  45360. * Attempt to exit VR, or fullscreen.
  45361. */
  45362. exitVR(): void;
  45363. /**
  45364. * The position of the vr experience helper.
  45365. */
  45366. get position(): Vector3;
  45367. /**
  45368. * Sets the position of the vr experience helper.
  45369. */
  45370. set position(value: Vector3);
  45371. /**
  45372. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45373. */
  45374. enableInteractions(): void;
  45375. private get _noControllerIsActive();
  45376. private beforeRender;
  45377. private _isTeleportationFloor;
  45378. /**
  45379. * Adds a floor mesh to be used for teleportation.
  45380. * @param floorMesh the mesh to be used for teleportation.
  45381. */
  45382. addFloorMesh(floorMesh: Mesh): void;
  45383. /**
  45384. * Removes a floor mesh from being used for teleportation.
  45385. * @param floorMesh the mesh to be removed.
  45386. */
  45387. removeFloorMesh(floorMesh: Mesh): void;
  45388. /**
  45389. * Enables interactions and teleportation using the VR controllers and gaze.
  45390. * @param vrTeleportationOptions options to modify teleportation behavior.
  45391. */
  45392. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45393. private _onNewGamepadConnected;
  45394. private _tryEnableInteractionOnController;
  45395. private _onNewGamepadDisconnected;
  45396. private _enableInteractionOnController;
  45397. private _checkTeleportWithRay;
  45398. private _checkRotate;
  45399. private _checkTeleportBackwards;
  45400. private _enableTeleportationOnController;
  45401. private _createTeleportationCircles;
  45402. private _displayTeleportationTarget;
  45403. private _hideTeleportationTarget;
  45404. private _rotateCamera;
  45405. private _moveTeleportationSelectorTo;
  45406. private _workingVector;
  45407. private _workingQuaternion;
  45408. private _workingMatrix;
  45409. /**
  45410. * Time Constant Teleportation Mode
  45411. */
  45412. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45413. /**
  45414. * Speed Constant Teleportation Mode
  45415. */
  45416. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45417. /**
  45418. * Teleports the users feet to the desired location
  45419. * @param location The location where the user's feet should be placed
  45420. */
  45421. teleportCamera(location: Vector3): void;
  45422. private _convertNormalToDirectionOfRay;
  45423. private _castRayAndSelectObject;
  45424. private _notifySelectedMeshUnselected;
  45425. /**
  45426. * Permanently set new colors for the laser pointer
  45427. * @param color the new laser color
  45428. * @param pickedColor the new laser color when picked mesh detected
  45429. */
  45430. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45431. /**
  45432. * Set lighting enabled / disabled on the laser pointer of both controllers
  45433. * @param enabled should the lighting be enabled on the laser pointer
  45434. */
  45435. setLaserLightingState(enabled?: boolean): void;
  45436. /**
  45437. * Permanently set new colors for the gaze pointer
  45438. * @param color the new gaze color
  45439. * @param pickedColor the new gaze color when picked mesh detected
  45440. */
  45441. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45442. /**
  45443. * Sets the color of the laser ray from the vr controllers.
  45444. * @param color new color for the ray.
  45445. */
  45446. changeLaserColor(color: Color3): void;
  45447. /**
  45448. * Sets the color of the ray from the vr headsets gaze.
  45449. * @param color new color for the ray.
  45450. */
  45451. changeGazeColor(color: Color3): void;
  45452. /**
  45453. * Exits VR and disposes of the vr experience helper
  45454. */
  45455. dispose(): void;
  45456. /**
  45457. * Gets the name of the VRExperienceHelper class
  45458. * @returns "VRExperienceHelper"
  45459. */
  45460. getClassName(): string;
  45461. }
  45462. }
  45463. declare module BABYLON {
  45464. /**
  45465. * Contains an array of blocks representing the octree
  45466. */
  45467. export interface IOctreeContainer<T> {
  45468. /**
  45469. * Blocks within the octree
  45470. */
  45471. blocks: Array<OctreeBlock<T>>;
  45472. }
  45473. /**
  45474. * Class used to store a cell in an octree
  45475. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45476. */
  45477. export class OctreeBlock<T> {
  45478. /**
  45479. * Gets the content of the current block
  45480. */
  45481. entries: T[];
  45482. /**
  45483. * Gets the list of block children
  45484. */
  45485. blocks: Array<OctreeBlock<T>>;
  45486. private _depth;
  45487. private _maxDepth;
  45488. private _capacity;
  45489. private _minPoint;
  45490. private _maxPoint;
  45491. private _boundingVectors;
  45492. private _creationFunc;
  45493. /**
  45494. * Creates a new block
  45495. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45496. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45497. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45498. * @param depth defines the current depth of this block in the octree
  45499. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45500. * @param creationFunc defines a callback to call when an element is added to the block
  45501. */
  45502. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45503. /**
  45504. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45505. */
  45506. get capacity(): number;
  45507. /**
  45508. * Gets the minimum vector (in world space) of the block's bounding box
  45509. */
  45510. get minPoint(): Vector3;
  45511. /**
  45512. * Gets the maximum vector (in world space) of the block's bounding box
  45513. */
  45514. get maxPoint(): Vector3;
  45515. /**
  45516. * Add a new element to this block
  45517. * @param entry defines the element to add
  45518. */
  45519. addEntry(entry: T): void;
  45520. /**
  45521. * Remove an element from this block
  45522. * @param entry defines the element to remove
  45523. */
  45524. removeEntry(entry: T): void;
  45525. /**
  45526. * Add an array of elements to this block
  45527. * @param entries defines the array of elements to add
  45528. */
  45529. addEntries(entries: T[]): void;
  45530. /**
  45531. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45532. * @param frustumPlanes defines the frustum planes to test
  45533. * @param selection defines the array to store current content if selection is positive
  45534. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45535. */
  45536. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45537. /**
  45538. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45539. * @param sphereCenter defines the bounding sphere center
  45540. * @param sphereRadius defines the bounding sphere radius
  45541. * @param selection defines the array to store current content if selection is positive
  45542. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45543. */
  45544. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45545. /**
  45546. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45547. * @param ray defines the ray to test with
  45548. * @param selection defines the array to store current content if selection is positive
  45549. */
  45550. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45551. /**
  45552. * Subdivide the content into child blocks (this block will then be empty)
  45553. */
  45554. createInnerBlocks(): void;
  45555. /**
  45556. * @hidden
  45557. */
  45558. 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;
  45559. }
  45560. }
  45561. declare module BABYLON {
  45562. /**
  45563. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45564. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45565. */
  45566. export class Octree<T> {
  45567. /** 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.) */
  45568. maxDepth: number;
  45569. /**
  45570. * Blocks within the octree containing objects
  45571. */
  45572. blocks: Array<OctreeBlock<T>>;
  45573. /**
  45574. * Content stored in the octree
  45575. */
  45576. dynamicContent: T[];
  45577. private _maxBlockCapacity;
  45578. private _selectionContent;
  45579. private _creationFunc;
  45580. /**
  45581. * Creates a octree
  45582. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45583. * @param creationFunc function to be used to instatiate the octree
  45584. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45585. * @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.)
  45586. */
  45587. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45588. /** 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.) */
  45589. maxDepth?: number);
  45590. /**
  45591. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45592. * @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);
  45593. * @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);
  45594. * @param entries meshes to be added to the octree blocks
  45595. */
  45596. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45597. /**
  45598. * Adds a mesh to the octree
  45599. * @param entry Mesh to add to the octree
  45600. */
  45601. addMesh(entry: T): void;
  45602. /**
  45603. * Remove an element from the octree
  45604. * @param entry defines the element to remove
  45605. */
  45606. removeMesh(entry: T): void;
  45607. /**
  45608. * Selects an array of meshes within the frustum
  45609. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45610. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45611. * @returns array of meshes within the frustum
  45612. */
  45613. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45614. /**
  45615. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45616. * @param sphereCenter defines the bounding sphere center
  45617. * @param sphereRadius defines the bounding sphere radius
  45618. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45619. * @returns an array of objects that intersect the sphere
  45620. */
  45621. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45622. /**
  45623. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45624. * @param ray defines the ray to test with
  45625. * @returns array of intersected objects
  45626. */
  45627. intersectsRay(ray: Ray): SmartArray<T>;
  45628. /**
  45629. * Adds a mesh into the octree block if it intersects the block
  45630. */
  45631. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45632. /**
  45633. * Adds a submesh into the octree block if it intersects the block
  45634. */
  45635. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45636. }
  45637. }
  45638. declare module BABYLON {
  45639. interface Scene {
  45640. /**
  45641. * @hidden
  45642. * Backing Filed
  45643. */
  45644. _selectionOctree: Octree<AbstractMesh>;
  45645. /**
  45646. * Gets the octree used to boost mesh selection (picking)
  45647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45648. */
  45649. selectionOctree: Octree<AbstractMesh>;
  45650. /**
  45651. * Creates or updates the octree used to boost selection (picking)
  45652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45653. * @param maxCapacity defines the maximum capacity per leaf
  45654. * @param maxDepth defines the maximum depth of the octree
  45655. * @returns an octree of AbstractMesh
  45656. */
  45657. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45658. }
  45659. interface AbstractMesh {
  45660. /**
  45661. * @hidden
  45662. * Backing Field
  45663. */
  45664. _submeshesOctree: Octree<SubMesh>;
  45665. /**
  45666. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45667. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45668. * @param maxCapacity defines the maximum size of each block (64 by default)
  45669. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45670. * @returns the new octree
  45671. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45673. */
  45674. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45675. }
  45676. /**
  45677. * Defines the octree scene component responsible to manage any octrees
  45678. * in a given scene.
  45679. */
  45680. export class OctreeSceneComponent {
  45681. /**
  45682. * The component name help to identify the component in the list of scene components.
  45683. */
  45684. readonly name: string;
  45685. /**
  45686. * The scene the component belongs to.
  45687. */
  45688. scene: Scene;
  45689. /**
  45690. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45691. */
  45692. readonly checksIsEnabled: boolean;
  45693. /**
  45694. * Creates a new instance of the component for the given scene
  45695. * @param scene Defines the scene to register the component in
  45696. */
  45697. constructor(scene: Scene);
  45698. /**
  45699. * Registers the component in a given scene
  45700. */
  45701. register(): void;
  45702. /**
  45703. * Return the list of active meshes
  45704. * @returns the list of active meshes
  45705. */
  45706. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45707. /**
  45708. * Return the list of active sub meshes
  45709. * @param mesh The mesh to get the candidates sub meshes from
  45710. * @returns the list of active sub meshes
  45711. */
  45712. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45713. private _tempRay;
  45714. /**
  45715. * Return the list of sub meshes intersecting with a given local ray
  45716. * @param mesh defines the mesh to find the submesh for
  45717. * @param localRay defines the ray in local space
  45718. * @returns the list of intersecting sub meshes
  45719. */
  45720. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45721. /**
  45722. * Return the list of sub meshes colliding with a collider
  45723. * @param mesh defines the mesh to find the submesh for
  45724. * @param collider defines the collider to evaluate the collision against
  45725. * @returns the list of colliding sub meshes
  45726. */
  45727. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45728. /**
  45729. * Rebuilds the elements related to this component in case of
  45730. * context lost for instance.
  45731. */
  45732. rebuild(): void;
  45733. /**
  45734. * Disposes the component and the associated ressources.
  45735. */
  45736. dispose(): void;
  45737. }
  45738. }
  45739. declare module BABYLON {
  45740. /**
  45741. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45742. */
  45743. export class Gizmo implements IDisposable {
  45744. /** The utility layer the gizmo will be added to */
  45745. gizmoLayer: UtilityLayerRenderer;
  45746. /**
  45747. * The root mesh of the gizmo
  45748. */
  45749. _rootMesh: Mesh;
  45750. private _attachedMesh;
  45751. /**
  45752. * Ratio for the scale of the gizmo (Default: 1)
  45753. */
  45754. scaleRatio: number;
  45755. /**
  45756. * If a custom mesh has been set (Default: false)
  45757. */
  45758. protected _customMeshSet: boolean;
  45759. /**
  45760. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45761. * * When set, interactions will be enabled
  45762. */
  45763. get attachedMesh(): Nullable<AbstractMesh>;
  45764. set attachedMesh(value: Nullable<AbstractMesh>);
  45765. /**
  45766. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45767. * @param mesh The mesh to replace the default mesh of the gizmo
  45768. */
  45769. setCustomMesh(mesh: Mesh): void;
  45770. /**
  45771. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45772. */
  45773. updateGizmoRotationToMatchAttachedMesh: boolean;
  45774. /**
  45775. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45776. */
  45777. updateGizmoPositionToMatchAttachedMesh: boolean;
  45778. /**
  45779. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45780. */
  45781. updateScale: boolean;
  45782. protected _interactionsEnabled: boolean;
  45783. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45784. private _beforeRenderObserver;
  45785. private _tempVector;
  45786. /**
  45787. * Creates a gizmo
  45788. * @param gizmoLayer The utility layer the gizmo will be added to
  45789. */
  45790. constructor(
  45791. /** The utility layer the gizmo will be added to */
  45792. gizmoLayer?: UtilityLayerRenderer);
  45793. /**
  45794. * Updates the gizmo to match the attached mesh's position/rotation
  45795. */
  45796. protected _update(): void;
  45797. /**
  45798. * Disposes of the gizmo
  45799. */
  45800. dispose(): void;
  45801. }
  45802. }
  45803. declare module BABYLON {
  45804. /**
  45805. * Single plane drag gizmo
  45806. */
  45807. export class PlaneDragGizmo extends Gizmo {
  45808. /**
  45809. * Drag behavior responsible for the gizmos dragging interactions
  45810. */
  45811. dragBehavior: PointerDragBehavior;
  45812. private _pointerObserver;
  45813. /**
  45814. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45815. */
  45816. snapDistance: number;
  45817. /**
  45818. * Event that fires each time the gizmo snaps to a new location.
  45819. * * snapDistance is the the change in distance
  45820. */
  45821. onSnapObservable: Observable<{
  45822. snapDistance: number;
  45823. }>;
  45824. private _plane;
  45825. private _coloredMaterial;
  45826. private _hoverMaterial;
  45827. private _isEnabled;
  45828. private _parent;
  45829. /** @hidden */
  45830. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45831. /** @hidden */
  45832. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45833. /**
  45834. * Creates a PlaneDragGizmo
  45835. * @param gizmoLayer The utility layer the gizmo will be added to
  45836. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45837. * @param color The color of the gizmo
  45838. */
  45839. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45840. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45841. /**
  45842. * If the gizmo is enabled
  45843. */
  45844. set isEnabled(value: boolean);
  45845. get isEnabled(): boolean;
  45846. /**
  45847. * Disposes of the gizmo
  45848. */
  45849. dispose(): void;
  45850. }
  45851. }
  45852. declare module BABYLON {
  45853. /**
  45854. * Gizmo that enables dragging a mesh along 3 axis
  45855. */
  45856. export class PositionGizmo extends Gizmo {
  45857. /**
  45858. * Internal gizmo used for interactions on the x axis
  45859. */
  45860. xGizmo: AxisDragGizmo;
  45861. /**
  45862. * Internal gizmo used for interactions on the y axis
  45863. */
  45864. yGizmo: AxisDragGizmo;
  45865. /**
  45866. * Internal gizmo used for interactions on the z axis
  45867. */
  45868. zGizmo: AxisDragGizmo;
  45869. /**
  45870. * Internal gizmo used for interactions on the yz plane
  45871. */
  45872. xPlaneGizmo: PlaneDragGizmo;
  45873. /**
  45874. * Internal gizmo used for interactions on the xz plane
  45875. */
  45876. yPlaneGizmo: PlaneDragGizmo;
  45877. /**
  45878. * Internal gizmo used for interactions on the xy plane
  45879. */
  45880. zPlaneGizmo: PlaneDragGizmo;
  45881. /**
  45882. * private variables
  45883. */
  45884. private _meshAttached;
  45885. private _updateGizmoRotationToMatchAttachedMesh;
  45886. private _snapDistance;
  45887. private _scaleRatio;
  45888. /** Fires an event when any of it's sub gizmos are dragged */
  45889. onDragStartObservable: Observable<unknown>;
  45890. /** Fires an event when any of it's sub gizmos are released from dragging */
  45891. onDragEndObservable: Observable<unknown>;
  45892. /**
  45893. * If set to true, planar drag is enabled
  45894. */
  45895. private _planarGizmoEnabled;
  45896. get attachedMesh(): Nullable<AbstractMesh>;
  45897. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45898. /**
  45899. * Creates a PositionGizmo
  45900. * @param gizmoLayer The utility layer the gizmo will be added to
  45901. */
  45902. constructor(gizmoLayer?: UtilityLayerRenderer);
  45903. /**
  45904. * If the planar drag gizmo is enabled
  45905. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45906. */
  45907. set planarGizmoEnabled(value: boolean);
  45908. get planarGizmoEnabled(): boolean;
  45909. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45910. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45911. /**
  45912. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45913. */
  45914. set snapDistance(value: number);
  45915. get snapDistance(): number;
  45916. /**
  45917. * Ratio for the scale of the gizmo (Default: 1)
  45918. */
  45919. set scaleRatio(value: number);
  45920. get scaleRatio(): number;
  45921. /**
  45922. * Disposes of the gizmo
  45923. */
  45924. dispose(): void;
  45925. /**
  45926. * CustomMeshes are not supported by this gizmo
  45927. * @param mesh The mesh to replace the default mesh of the gizmo
  45928. */
  45929. setCustomMesh(mesh: Mesh): void;
  45930. }
  45931. }
  45932. declare module BABYLON {
  45933. /**
  45934. * Single axis drag gizmo
  45935. */
  45936. export class AxisDragGizmo extends Gizmo {
  45937. /**
  45938. * Drag behavior responsible for the gizmos dragging interactions
  45939. */
  45940. dragBehavior: PointerDragBehavior;
  45941. private _pointerObserver;
  45942. /**
  45943. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45944. */
  45945. snapDistance: number;
  45946. /**
  45947. * Event that fires each time the gizmo snaps to a new location.
  45948. * * snapDistance is the the change in distance
  45949. */
  45950. onSnapObservable: Observable<{
  45951. snapDistance: number;
  45952. }>;
  45953. private _isEnabled;
  45954. private _parent;
  45955. private _arrow;
  45956. private _coloredMaterial;
  45957. private _hoverMaterial;
  45958. /** @hidden */
  45959. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45960. /** @hidden */
  45961. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45962. /**
  45963. * Creates an AxisDragGizmo
  45964. * @param gizmoLayer The utility layer the gizmo will be added to
  45965. * @param dragAxis The axis which the gizmo will be able to drag on
  45966. * @param color The color of the gizmo
  45967. */
  45968. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45969. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45970. /**
  45971. * If the gizmo is enabled
  45972. */
  45973. set isEnabled(value: boolean);
  45974. get isEnabled(): boolean;
  45975. /**
  45976. * Disposes of the gizmo
  45977. */
  45978. dispose(): void;
  45979. }
  45980. }
  45981. declare module BABYLON.Debug {
  45982. /**
  45983. * The Axes viewer will show 3 axes in a specific point in space
  45984. */
  45985. export class AxesViewer {
  45986. private _xAxis;
  45987. private _yAxis;
  45988. private _zAxis;
  45989. private _scaleLinesFactor;
  45990. private _instanced;
  45991. /**
  45992. * Gets the hosting scene
  45993. */
  45994. scene: Scene;
  45995. /**
  45996. * Gets or sets a number used to scale line length
  45997. */
  45998. scaleLines: number;
  45999. /** Gets the node hierarchy used to render x-axis */
  46000. get xAxis(): TransformNode;
  46001. /** Gets the node hierarchy used to render y-axis */
  46002. get yAxis(): TransformNode;
  46003. /** Gets the node hierarchy used to render z-axis */
  46004. get zAxis(): TransformNode;
  46005. /**
  46006. * Creates a new AxesViewer
  46007. * @param scene defines the hosting scene
  46008. * @param scaleLines defines a number used to scale line length (1 by default)
  46009. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46010. * @param xAxis defines the node hierarchy used to render the x-axis
  46011. * @param yAxis defines the node hierarchy used to render the y-axis
  46012. * @param zAxis defines the node hierarchy used to render the z-axis
  46013. */
  46014. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46015. /**
  46016. * Force the viewer to update
  46017. * @param position defines the position of the viewer
  46018. * @param xaxis defines the x axis of the viewer
  46019. * @param yaxis defines the y axis of the viewer
  46020. * @param zaxis defines the z axis of the viewer
  46021. */
  46022. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46023. /**
  46024. * Creates an instance of this axes viewer.
  46025. * @returns a new axes viewer with instanced meshes
  46026. */
  46027. createInstance(): AxesViewer;
  46028. /** Releases resources */
  46029. dispose(): void;
  46030. private static _SetRenderingGroupId;
  46031. }
  46032. }
  46033. declare module BABYLON.Debug {
  46034. /**
  46035. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46036. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46037. */
  46038. export class BoneAxesViewer extends AxesViewer {
  46039. /**
  46040. * Gets or sets the target mesh where to display the axes viewer
  46041. */
  46042. mesh: Nullable<Mesh>;
  46043. /**
  46044. * Gets or sets the target bone where to display the axes viewer
  46045. */
  46046. bone: Nullable<Bone>;
  46047. /** Gets current position */
  46048. pos: Vector3;
  46049. /** Gets direction of X axis */
  46050. xaxis: Vector3;
  46051. /** Gets direction of Y axis */
  46052. yaxis: Vector3;
  46053. /** Gets direction of Z axis */
  46054. zaxis: Vector3;
  46055. /**
  46056. * Creates a new BoneAxesViewer
  46057. * @param scene defines the hosting scene
  46058. * @param bone defines the target bone
  46059. * @param mesh defines the target mesh
  46060. * @param scaleLines defines a scaling factor for line length (1 by default)
  46061. */
  46062. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46063. /**
  46064. * Force the viewer to update
  46065. */
  46066. update(): void;
  46067. /** Releases resources */
  46068. dispose(): void;
  46069. }
  46070. }
  46071. declare module BABYLON {
  46072. /**
  46073. * Interface used to define scene explorer extensibility option
  46074. */
  46075. export interface IExplorerExtensibilityOption {
  46076. /**
  46077. * Define the option label
  46078. */
  46079. label: string;
  46080. /**
  46081. * Defines the action to execute on click
  46082. */
  46083. action: (entity: any) => void;
  46084. }
  46085. /**
  46086. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46087. */
  46088. export interface IExplorerExtensibilityGroup {
  46089. /**
  46090. * Defines a predicate to test if a given type mut be extended
  46091. */
  46092. predicate: (entity: any) => boolean;
  46093. /**
  46094. * Gets the list of options added to a type
  46095. */
  46096. entries: IExplorerExtensibilityOption[];
  46097. }
  46098. /**
  46099. * Interface used to define the options to use to create the Inspector
  46100. */
  46101. export interface IInspectorOptions {
  46102. /**
  46103. * Display in overlay mode (default: false)
  46104. */
  46105. overlay?: boolean;
  46106. /**
  46107. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46108. */
  46109. globalRoot?: HTMLElement;
  46110. /**
  46111. * Display the Scene explorer
  46112. */
  46113. showExplorer?: boolean;
  46114. /**
  46115. * Display the property inspector
  46116. */
  46117. showInspector?: boolean;
  46118. /**
  46119. * Display in embed mode (both panes on the right)
  46120. */
  46121. embedMode?: boolean;
  46122. /**
  46123. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46124. */
  46125. handleResize?: boolean;
  46126. /**
  46127. * Allow the panes to popup (default: true)
  46128. */
  46129. enablePopup?: boolean;
  46130. /**
  46131. * Allow the panes to be closed by users (default: true)
  46132. */
  46133. enableClose?: boolean;
  46134. /**
  46135. * Optional list of extensibility entries
  46136. */
  46137. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46138. /**
  46139. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46140. */
  46141. inspectorURL?: string;
  46142. /**
  46143. * Optional initial tab (default to DebugLayerTab.Properties)
  46144. */
  46145. initialTab?: DebugLayerTab;
  46146. }
  46147. interface Scene {
  46148. /**
  46149. * @hidden
  46150. * Backing field
  46151. */
  46152. _debugLayer: DebugLayer;
  46153. /**
  46154. * Gets the debug layer (aka Inspector) associated with the scene
  46155. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46156. */
  46157. debugLayer: DebugLayer;
  46158. }
  46159. /**
  46160. * Enum of inspector action tab
  46161. */
  46162. export enum DebugLayerTab {
  46163. /**
  46164. * Properties tag (default)
  46165. */
  46166. Properties = 0,
  46167. /**
  46168. * Debug tab
  46169. */
  46170. Debug = 1,
  46171. /**
  46172. * Statistics tab
  46173. */
  46174. Statistics = 2,
  46175. /**
  46176. * Tools tab
  46177. */
  46178. Tools = 3,
  46179. /**
  46180. * Settings tab
  46181. */
  46182. Settings = 4
  46183. }
  46184. /**
  46185. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46186. * what is happening in your scene
  46187. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46188. */
  46189. export class DebugLayer {
  46190. /**
  46191. * Define the url to get the inspector script from.
  46192. * By default it uses the babylonjs CDN.
  46193. * @ignoreNaming
  46194. */
  46195. static InspectorURL: string;
  46196. private _scene;
  46197. private BJSINSPECTOR;
  46198. private _onPropertyChangedObservable?;
  46199. /**
  46200. * Observable triggered when a property is changed through the inspector.
  46201. */
  46202. get onPropertyChangedObservable(): any;
  46203. /**
  46204. * Instantiates a new debug layer.
  46205. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46206. * what is happening in your scene
  46207. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46208. * @param scene Defines the scene to inspect
  46209. */
  46210. constructor(scene: Scene);
  46211. /** Creates the inspector window. */
  46212. private _createInspector;
  46213. /**
  46214. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46215. * @param entity defines the entity to select
  46216. * @param lineContainerTitle defines the specific block to highlight
  46217. */
  46218. select(entity: any, lineContainerTitle?: string): void;
  46219. /** Get the inspector from bundle or global */
  46220. private _getGlobalInspector;
  46221. /**
  46222. * Get if the inspector is visible or not.
  46223. * @returns true if visible otherwise, false
  46224. */
  46225. isVisible(): boolean;
  46226. /**
  46227. * Hide the inspector and close its window.
  46228. */
  46229. hide(): void;
  46230. /**
  46231. * Launch the debugLayer.
  46232. * @param config Define the configuration of the inspector
  46233. * @return a promise fulfilled when the debug layer is visible
  46234. */
  46235. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46236. }
  46237. }
  46238. declare module BABYLON {
  46239. /**
  46240. * Class containing static functions to help procedurally build meshes
  46241. */
  46242. export class BoxBuilder {
  46243. /**
  46244. * Creates a box mesh
  46245. * * The parameter `size` sets the size (float) of each box side (default 1)
  46246. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46247. * * 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)
  46248. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46250. * * 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
  46251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46252. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46253. * @param name defines the name of the mesh
  46254. * @param options defines the options used to create the mesh
  46255. * @param scene defines the hosting scene
  46256. * @returns the box mesh
  46257. */
  46258. static CreateBox(name: string, options: {
  46259. size?: number;
  46260. width?: number;
  46261. height?: number;
  46262. depth?: number;
  46263. faceUV?: Vector4[];
  46264. faceColors?: Color4[];
  46265. sideOrientation?: number;
  46266. frontUVs?: Vector4;
  46267. backUVs?: Vector4;
  46268. wrap?: boolean;
  46269. topBaseAt?: number;
  46270. bottomBaseAt?: number;
  46271. updatable?: boolean;
  46272. }, scene?: Nullable<Scene>): Mesh;
  46273. }
  46274. }
  46275. declare module BABYLON.Debug {
  46276. /**
  46277. * Used to show the physics impostor around the specific mesh
  46278. */
  46279. export class PhysicsViewer {
  46280. /** @hidden */
  46281. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46282. /** @hidden */
  46283. protected _meshes: Array<Nullable<AbstractMesh>>;
  46284. /** @hidden */
  46285. protected _scene: Nullable<Scene>;
  46286. /** @hidden */
  46287. protected _numMeshes: number;
  46288. /** @hidden */
  46289. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46290. private _renderFunction;
  46291. private _utilityLayer;
  46292. private _debugBoxMesh;
  46293. private _debugSphereMesh;
  46294. private _debugCylinderMesh;
  46295. private _debugMaterial;
  46296. private _debugMeshMeshes;
  46297. /**
  46298. * Creates a new PhysicsViewer
  46299. * @param scene defines the hosting scene
  46300. */
  46301. constructor(scene: Scene);
  46302. /** @hidden */
  46303. protected _updateDebugMeshes(): void;
  46304. /**
  46305. * Renders a specified physic impostor
  46306. * @param impostor defines the impostor to render
  46307. * @param targetMesh defines the mesh represented by the impostor
  46308. * @returns the new debug mesh used to render the impostor
  46309. */
  46310. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46311. /**
  46312. * Hides a specified physic impostor
  46313. * @param impostor defines the impostor to hide
  46314. */
  46315. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46316. private _getDebugMaterial;
  46317. private _getDebugBoxMesh;
  46318. private _getDebugSphereMesh;
  46319. private _getDebugCylinderMesh;
  46320. private _getDebugMeshMesh;
  46321. private _getDebugMesh;
  46322. /** Releases all resources */
  46323. dispose(): void;
  46324. }
  46325. }
  46326. declare module BABYLON {
  46327. /**
  46328. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46329. * in order to better appreciate the issue one might have.
  46330. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46331. */
  46332. export class RayHelper {
  46333. /**
  46334. * Defines the ray we are currently tryin to visualize.
  46335. */
  46336. ray: Nullable<Ray>;
  46337. private _renderPoints;
  46338. private _renderLine;
  46339. private _renderFunction;
  46340. private _scene;
  46341. private _updateToMeshFunction;
  46342. private _attachedToMesh;
  46343. private _meshSpaceDirection;
  46344. private _meshSpaceOrigin;
  46345. /**
  46346. * Helper function to create a colored helper in a scene in one line.
  46347. * @param ray Defines the ray we are currently tryin to visualize
  46348. * @param scene Defines the scene the ray is used in
  46349. * @param color Defines the color we want to see the ray in
  46350. * @returns The newly created ray helper.
  46351. */
  46352. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46353. /**
  46354. * Instantiate a new ray helper.
  46355. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46356. * in order to better appreciate the issue one might have.
  46357. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46358. * @param ray Defines the ray we are currently tryin to visualize
  46359. */
  46360. constructor(ray: Ray);
  46361. /**
  46362. * Shows the ray we are willing to debug.
  46363. * @param scene Defines the scene the ray needs to be rendered in
  46364. * @param color Defines the color the ray needs to be rendered in
  46365. */
  46366. show(scene: Scene, color?: Color3): void;
  46367. /**
  46368. * Hides the ray we are debugging.
  46369. */
  46370. hide(): void;
  46371. private _render;
  46372. /**
  46373. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46374. * @param mesh Defines the mesh we want the helper attached to
  46375. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46376. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46377. * @param length Defines the length of the ray
  46378. */
  46379. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46380. /**
  46381. * Detach the ray helper from the mesh it has previously been attached to.
  46382. */
  46383. detachFromMesh(): void;
  46384. private _updateToMesh;
  46385. /**
  46386. * Dispose the helper and release its associated resources.
  46387. */
  46388. dispose(): void;
  46389. }
  46390. }
  46391. declare module BABYLON.Debug {
  46392. /**
  46393. * Class used to render a debug view of a given skeleton
  46394. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46395. */
  46396. export class SkeletonViewer {
  46397. /** defines the skeleton to render */
  46398. skeleton: Skeleton;
  46399. /** defines the mesh attached to the skeleton */
  46400. mesh: AbstractMesh;
  46401. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46402. autoUpdateBonesMatrices: boolean;
  46403. /** defines the rendering group id to use with the viewer */
  46404. renderingGroupId: number;
  46405. /** Gets or sets the color used to render the skeleton */
  46406. color: Color3;
  46407. private _scene;
  46408. private _debugLines;
  46409. private _debugMesh;
  46410. private _isEnabled;
  46411. private _renderFunction;
  46412. private _utilityLayer;
  46413. /**
  46414. * Returns the mesh used to render the bones
  46415. */
  46416. get debugMesh(): Nullable<LinesMesh>;
  46417. /**
  46418. * Creates a new SkeletonViewer
  46419. * @param skeleton defines the skeleton to render
  46420. * @param mesh defines the mesh attached to the skeleton
  46421. * @param scene defines the hosting scene
  46422. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46423. * @param renderingGroupId defines the rendering group id to use with the viewer
  46424. */
  46425. constructor(
  46426. /** defines the skeleton to render */
  46427. skeleton: Skeleton,
  46428. /** defines the mesh attached to the skeleton */
  46429. mesh: AbstractMesh, scene: Scene,
  46430. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46431. autoUpdateBonesMatrices?: boolean,
  46432. /** defines the rendering group id to use with the viewer */
  46433. renderingGroupId?: number);
  46434. /** Gets or sets a boolean indicating if the viewer is enabled */
  46435. set isEnabled(value: boolean);
  46436. get isEnabled(): boolean;
  46437. private _getBonePosition;
  46438. private _getLinesForBonesWithLength;
  46439. private _getLinesForBonesNoLength;
  46440. /** Update the viewer to sync with current skeleton state */
  46441. update(): void;
  46442. /** Release associated resources */
  46443. dispose(): void;
  46444. }
  46445. }
  46446. declare module BABYLON {
  46447. /**
  46448. * Options to create the null engine
  46449. */
  46450. export class NullEngineOptions {
  46451. /**
  46452. * Render width (Default: 512)
  46453. */
  46454. renderWidth: number;
  46455. /**
  46456. * Render height (Default: 256)
  46457. */
  46458. renderHeight: number;
  46459. /**
  46460. * Texture size (Default: 512)
  46461. */
  46462. textureSize: number;
  46463. /**
  46464. * If delta time between frames should be constant
  46465. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46466. */
  46467. deterministicLockstep: boolean;
  46468. /**
  46469. * Maximum about of steps between frames (Default: 4)
  46470. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46471. */
  46472. lockstepMaxSteps: number;
  46473. }
  46474. /**
  46475. * The null engine class provides support for headless version of babylon.js.
  46476. * This can be used in server side scenario or for testing purposes
  46477. */
  46478. export class NullEngine extends Engine {
  46479. private _options;
  46480. /**
  46481. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46482. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46483. * @returns true if engine is in deterministic lock step mode
  46484. */
  46485. isDeterministicLockStep(): boolean;
  46486. /**
  46487. * Gets the max steps when engine is running in deterministic lock step
  46488. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46489. * @returns the max steps
  46490. */
  46491. getLockstepMaxSteps(): number;
  46492. /**
  46493. * Gets the current hardware scaling level.
  46494. * By default the hardware scaling level is computed from the window device ratio.
  46495. * 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.
  46496. * @returns a number indicating the current hardware scaling level
  46497. */
  46498. getHardwareScalingLevel(): number;
  46499. constructor(options?: NullEngineOptions);
  46500. /**
  46501. * Creates a vertex buffer
  46502. * @param vertices the data for the vertex buffer
  46503. * @returns the new WebGL static buffer
  46504. */
  46505. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46506. /**
  46507. * Creates a new index buffer
  46508. * @param indices defines the content of the index buffer
  46509. * @param updatable defines if the index buffer must be updatable
  46510. * @returns a new webGL buffer
  46511. */
  46512. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46513. /**
  46514. * Clear the current render buffer or the current render target (if any is set up)
  46515. * @param color defines the color to use
  46516. * @param backBuffer defines if the back buffer must be cleared
  46517. * @param depth defines if the depth buffer must be cleared
  46518. * @param stencil defines if the stencil buffer must be cleared
  46519. */
  46520. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46521. /**
  46522. * Gets the current render width
  46523. * @param useScreen defines if screen size must be used (or the current render target if any)
  46524. * @returns a number defining the current render width
  46525. */
  46526. getRenderWidth(useScreen?: boolean): number;
  46527. /**
  46528. * Gets the current render height
  46529. * @param useScreen defines if screen size must be used (or the current render target if any)
  46530. * @returns a number defining the current render height
  46531. */
  46532. getRenderHeight(useScreen?: boolean): number;
  46533. /**
  46534. * Set the WebGL's viewport
  46535. * @param viewport defines the viewport element to be used
  46536. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46537. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46538. */
  46539. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46540. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46541. /**
  46542. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46543. * @param pipelineContext defines the pipeline context to use
  46544. * @param uniformsNames defines the list of uniform names
  46545. * @returns an array of webGL uniform locations
  46546. */
  46547. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46548. /**
  46549. * Gets the lsit of active attributes for a given webGL program
  46550. * @param pipelineContext defines the pipeline context to use
  46551. * @param attributesNames defines the list of attribute names to get
  46552. * @returns an array of indices indicating the offset of each attribute
  46553. */
  46554. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46555. /**
  46556. * Binds an effect to the webGL context
  46557. * @param effect defines the effect to bind
  46558. */
  46559. bindSamplers(effect: Effect): void;
  46560. /**
  46561. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46562. * @param effect defines the effect to activate
  46563. */
  46564. enableEffect(effect: Effect): void;
  46565. /**
  46566. * Set various states to the webGL context
  46567. * @param culling defines backface culling state
  46568. * @param zOffset defines the value to apply to zOffset (0 by default)
  46569. * @param force defines if states must be applied even if cache is up to date
  46570. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46571. */
  46572. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46573. /**
  46574. * Set the value of an uniform to an array of int32
  46575. * @param uniform defines the webGL uniform location where to store the value
  46576. * @param array defines the array of int32 to store
  46577. */
  46578. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46579. /**
  46580. * Set the value of an uniform to an array of int32 (stored as vec2)
  46581. * @param uniform defines the webGL uniform location where to store the value
  46582. * @param array defines the array of int32 to store
  46583. */
  46584. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46585. /**
  46586. * Set the value of an uniform to an array of int32 (stored as vec3)
  46587. * @param uniform defines the webGL uniform location where to store the value
  46588. * @param array defines the array of int32 to store
  46589. */
  46590. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46591. /**
  46592. * Set the value of an uniform to an array of int32 (stored as vec4)
  46593. * @param uniform defines the webGL uniform location where to store the value
  46594. * @param array defines the array of int32 to store
  46595. */
  46596. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46597. /**
  46598. * Set the value of an uniform to an array of float32
  46599. * @param uniform defines the webGL uniform location where to store the value
  46600. * @param array defines the array of float32 to store
  46601. */
  46602. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46603. /**
  46604. * Set the value of an uniform to an array of float32 (stored as vec2)
  46605. * @param uniform defines the webGL uniform location where to store the value
  46606. * @param array defines the array of float32 to store
  46607. */
  46608. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46609. /**
  46610. * Set the value of an uniform to an array of float32 (stored as vec3)
  46611. * @param uniform defines the webGL uniform location where to store the value
  46612. * @param array defines the array of float32 to store
  46613. */
  46614. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46615. /**
  46616. * Set the value of an uniform to an array of float32 (stored as vec4)
  46617. * @param uniform defines the webGL uniform location where to store the value
  46618. * @param array defines the array of float32 to store
  46619. */
  46620. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46621. /**
  46622. * Set the value of an uniform to an array of number
  46623. * @param uniform defines the webGL uniform location where to store the value
  46624. * @param array defines the array of number to store
  46625. */
  46626. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46627. /**
  46628. * Set the value of an uniform to an array of number (stored as vec2)
  46629. * @param uniform defines the webGL uniform location where to store the value
  46630. * @param array defines the array of number to store
  46631. */
  46632. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46633. /**
  46634. * Set the value of an uniform to an array of number (stored as vec3)
  46635. * @param uniform defines the webGL uniform location where to store the value
  46636. * @param array defines the array of number to store
  46637. */
  46638. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46639. /**
  46640. * Set the value of an uniform to an array of number (stored as vec4)
  46641. * @param uniform defines the webGL uniform location where to store the value
  46642. * @param array defines the array of number to store
  46643. */
  46644. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46645. /**
  46646. * Set the value of an uniform to an array of float32 (stored as matrices)
  46647. * @param uniform defines the webGL uniform location where to store the value
  46648. * @param matrices defines the array of float32 to store
  46649. */
  46650. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46651. /**
  46652. * Set the value of an uniform to a matrix (3x3)
  46653. * @param uniform defines the webGL uniform location where to store the value
  46654. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46655. */
  46656. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46657. /**
  46658. * Set the value of an uniform to a matrix (2x2)
  46659. * @param uniform defines the webGL uniform location where to store the value
  46660. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46661. */
  46662. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46663. /**
  46664. * Set the value of an uniform to a number (float)
  46665. * @param uniform defines the webGL uniform location where to store the value
  46666. * @param value defines the float number to store
  46667. */
  46668. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46669. /**
  46670. * Set the value of an uniform to a vec2
  46671. * @param uniform defines the webGL uniform location where to store the value
  46672. * @param x defines the 1st component of the value
  46673. * @param y defines the 2nd component of the value
  46674. */
  46675. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46676. /**
  46677. * Set the value of an uniform to a vec3
  46678. * @param uniform defines the webGL uniform location where to store the value
  46679. * @param x defines the 1st component of the value
  46680. * @param y defines the 2nd component of the value
  46681. * @param z defines the 3rd component of the value
  46682. */
  46683. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46684. /**
  46685. * Set the value of an uniform to a boolean
  46686. * @param uniform defines the webGL uniform location where to store the value
  46687. * @param bool defines the boolean to store
  46688. */
  46689. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46690. /**
  46691. * Set the value of an uniform to a vec4
  46692. * @param uniform defines the webGL uniform location where to store the value
  46693. * @param x defines the 1st component of the value
  46694. * @param y defines the 2nd component of the value
  46695. * @param z defines the 3rd component of the value
  46696. * @param w defines the 4th component of the value
  46697. */
  46698. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46699. /**
  46700. * Sets the current alpha mode
  46701. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46702. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46703. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46704. */
  46705. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46706. /**
  46707. * Bind webGl buffers directly to the webGL context
  46708. * @param vertexBuffers defines the vertex buffer to bind
  46709. * @param indexBuffer defines the index buffer to bind
  46710. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46711. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46712. * @param effect defines the effect associated with the vertex buffer
  46713. */
  46714. bindBuffers(vertexBuffers: {
  46715. [key: string]: VertexBuffer;
  46716. }, indexBuffer: DataBuffer, effect: Effect): void;
  46717. /**
  46718. * Force the entire cache to be cleared
  46719. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46720. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46721. */
  46722. wipeCaches(bruteForce?: boolean): void;
  46723. /**
  46724. * Send a draw order
  46725. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46726. * @param indexStart defines the starting index
  46727. * @param indexCount defines the number of index to draw
  46728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46729. */
  46730. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46731. /**
  46732. * Draw a list of indexed primitives
  46733. * @param fillMode defines the primitive to use
  46734. * @param indexStart defines the starting index
  46735. * @param indexCount defines the number of index to draw
  46736. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46737. */
  46738. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46739. /**
  46740. * Draw a list of unindexed primitives
  46741. * @param fillMode defines the primitive to use
  46742. * @param verticesStart defines the index of first vertex to draw
  46743. * @param verticesCount defines the count of vertices to draw
  46744. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46745. */
  46746. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46747. /** @hidden */
  46748. _createTexture(): WebGLTexture;
  46749. /** @hidden */
  46750. _releaseTexture(texture: InternalTexture): void;
  46751. /**
  46752. * Usually called from Texture.ts.
  46753. * Passed information to create a WebGLTexture
  46754. * @param urlArg defines a value which contains one of the following:
  46755. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46756. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46757. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46758. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46759. * @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)
  46760. * @param scene needed for loading to the correct scene
  46761. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46762. * @param onLoad optional callback to be called upon successful completion
  46763. * @param onError optional callback to be called upon failure
  46764. * @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
  46765. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46766. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46767. * @param forcedExtension defines the extension to use to pick the right loader
  46768. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46769. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46770. */
  46771. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  46772. /**
  46773. * Creates a new render target texture
  46774. * @param size defines the size of the texture
  46775. * @param options defines the options used to create the texture
  46776. * @returns a new render target texture stored in an InternalTexture
  46777. */
  46778. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46779. /**
  46780. * Update the sampling mode of a given texture
  46781. * @param samplingMode defines the required sampling mode
  46782. * @param texture defines the texture to update
  46783. */
  46784. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46785. /**
  46786. * Binds the frame buffer to the specified texture.
  46787. * @param texture The texture to render to or null for the default canvas
  46788. * @param faceIndex The face of the texture to render to in case of cube texture
  46789. * @param requiredWidth The width of the target to render to
  46790. * @param requiredHeight The height of the target to render to
  46791. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46792. * @param lodLevel defines le lod level to bind to the frame buffer
  46793. */
  46794. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46795. /**
  46796. * Unbind the current render target texture from the webGL context
  46797. * @param texture defines the render target texture to unbind
  46798. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46799. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46800. */
  46801. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46802. /**
  46803. * Creates a dynamic vertex buffer
  46804. * @param vertices the data for the dynamic vertex buffer
  46805. * @returns the new WebGL dynamic buffer
  46806. */
  46807. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46808. /**
  46809. * Update the content of a dynamic texture
  46810. * @param texture defines the texture to update
  46811. * @param canvas defines the canvas containing the source
  46812. * @param invertY defines if data must be stored with Y axis inverted
  46813. * @param premulAlpha defines if alpha is stored as premultiplied
  46814. * @param format defines the format of the data
  46815. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46816. */
  46817. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46818. /**
  46819. * Gets a boolean indicating if all created effects are ready
  46820. * @returns true if all effects are ready
  46821. */
  46822. areAllEffectsReady(): boolean;
  46823. /**
  46824. * @hidden
  46825. * Get the current error code of the webGL context
  46826. * @returns the error code
  46827. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46828. */
  46829. getError(): number;
  46830. /** @hidden */
  46831. _getUnpackAlignement(): number;
  46832. /** @hidden */
  46833. _unpackFlipY(value: boolean): void;
  46834. /**
  46835. * Update a dynamic index buffer
  46836. * @param indexBuffer defines the target index buffer
  46837. * @param indices defines the data to update
  46838. * @param offset defines the offset in the target index buffer where update should start
  46839. */
  46840. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46841. /**
  46842. * Updates a dynamic vertex buffer.
  46843. * @param vertexBuffer the vertex buffer to update
  46844. * @param vertices the data used to update the vertex buffer
  46845. * @param byteOffset the byte offset of the data (optional)
  46846. * @param byteLength the byte length of the data (optional)
  46847. */
  46848. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46849. /** @hidden */
  46850. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46851. /** @hidden */
  46852. _bindTexture(channel: number, texture: InternalTexture): void;
  46853. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46854. /**
  46855. * 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
  46856. */
  46857. releaseEffects(): void;
  46858. displayLoadingUI(): void;
  46859. hideLoadingUI(): void;
  46860. /** @hidden */
  46861. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46862. /** @hidden */
  46863. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46864. /** @hidden */
  46865. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46866. /** @hidden */
  46867. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46868. }
  46869. }
  46870. declare module BABYLON {
  46871. /**
  46872. * @hidden
  46873. **/
  46874. export class _TimeToken {
  46875. _startTimeQuery: Nullable<WebGLQuery>;
  46876. _endTimeQuery: Nullable<WebGLQuery>;
  46877. _timeElapsedQuery: Nullable<WebGLQuery>;
  46878. _timeElapsedQueryEnded: boolean;
  46879. }
  46880. }
  46881. declare module BABYLON {
  46882. /** @hidden */
  46883. export class _OcclusionDataStorage {
  46884. /** @hidden */
  46885. occlusionInternalRetryCounter: number;
  46886. /** @hidden */
  46887. isOcclusionQueryInProgress: boolean;
  46888. /** @hidden */
  46889. isOccluded: boolean;
  46890. /** @hidden */
  46891. occlusionRetryCount: number;
  46892. /** @hidden */
  46893. occlusionType: number;
  46894. /** @hidden */
  46895. occlusionQueryAlgorithmType: number;
  46896. }
  46897. interface Engine {
  46898. /**
  46899. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46900. * @return the new query
  46901. */
  46902. createQuery(): WebGLQuery;
  46903. /**
  46904. * Delete and release a webGL query
  46905. * @param query defines the query to delete
  46906. * @return the current engine
  46907. */
  46908. deleteQuery(query: WebGLQuery): Engine;
  46909. /**
  46910. * Check if a given query has resolved and got its value
  46911. * @param query defines the query to check
  46912. * @returns true if the query got its value
  46913. */
  46914. isQueryResultAvailable(query: WebGLQuery): boolean;
  46915. /**
  46916. * Gets the value of a given query
  46917. * @param query defines the query to check
  46918. * @returns the value of the query
  46919. */
  46920. getQueryResult(query: WebGLQuery): number;
  46921. /**
  46922. * Initiates an occlusion query
  46923. * @param algorithmType defines the algorithm to use
  46924. * @param query defines the query to use
  46925. * @returns the current engine
  46926. * @see http://doc.babylonjs.com/features/occlusionquery
  46927. */
  46928. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46929. /**
  46930. * Ends an occlusion query
  46931. * @see http://doc.babylonjs.com/features/occlusionquery
  46932. * @param algorithmType defines the algorithm to use
  46933. * @returns the current engine
  46934. */
  46935. endOcclusionQuery(algorithmType: number): Engine;
  46936. /**
  46937. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46938. * Please note that only one query can be issued at a time
  46939. * @returns a time token used to track the time span
  46940. */
  46941. startTimeQuery(): Nullable<_TimeToken>;
  46942. /**
  46943. * Ends a time query
  46944. * @param token defines the token used to measure the time span
  46945. * @returns the time spent (in ns)
  46946. */
  46947. endTimeQuery(token: _TimeToken): int;
  46948. /** @hidden */
  46949. _currentNonTimestampToken: Nullable<_TimeToken>;
  46950. /** @hidden */
  46951. _createTimeQuery(): WebGLQuery;
  46952. /** @hidden */
  46953. _deleteTimeQuery(query: WebGLQuery): void;
  46954. /** @hidden */
  46955. _getGlAlgorithmType(algorithmType: number): number;
  46956. /** @hidden */
  46957. _getTimeQueryResult(query: WebGLQuery): any;
  46958. /** @hidden */
  46959. _getTimeQueryAvailability(query: WebGLQuery): any;
  46960. }
  46961. interface AbstractMesh {
  46962. /**
  46963. * Backing filed
  46964. * @hidden
  46965. */
  46966. __occlusionDataStorage: _OcclusionDataStorage;
  46967. /**
  46968. * Access property
  46969. * @hidden
  46970. */
  46971. _occlusionDataStorage: _OcclusionDataStorage;
  46972. /**
  46973. * 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.
  46974. * The default value is -1 which means don't break the query and wait till the result
  46975. * @see http://doc.babylonjs.com/features/occlusionquery
  46976. */
  46977. occlusionRetryCount: number;
  46978. /**
  46979. * 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:
  46980. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46981. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46982. * * 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.
  46983. * @see http://doc.babylonjs.com/features/occlusionquery
  46984. */
  46985. occlusionType: number;
  46986. /**
  46987. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46988. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46989. * * 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.
  46990. * @see http://doc.babylonjs.com/features/occlusionquery
  46991. */
  46992. occlusionQueryAlgorithmType: number;
  46993. /**
  46994. * 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
  46995. * @see http://doc.babylonjs.com/features/occlusionquery
  46996. */
  46997. isOccluded: boolean;
  46998. /**
  46999. * Flag to check the progress status of the query
  47000. * @see http://doc.babylonjs.com/features/occlusionquery
  47001. */
  47002. isOcclusionQueryInProgress: boolean;
  47003. }
  47004. }
  47005. declare module BABYLON {
  47006. /** @hidden */
  47007. export var _forceTransformFeedbackToBundle: boolean;
  47008. interface Engine {
  47009. /**
  47010. * Creates a webGL transform feedback object
  47011. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47012. * @returns the webGL transform feedback object
  47013. */
  47014. createTransformFeedback(): WebGLTransformFeedback;
  47015. /**
  47016. * Delete a webGL transform feedback object
  47017. * @param value defines the webGL transform feedback object to delete
  47018. */
  47019. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47020. /**
  47021. * Bind a webGL transform feedback object to the webgl context
  47022. * @param value defines the webGL transform feedback object to bind
  47023. */
  47024. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47025. /**
  47026. * Begins a transform feedback operation
  47027. * @param usePoints defines if points or triangles must be used
  47028. */
  47029. beginTransformFeedback(usePoints: boolean): void;
  47030. /**
  47031. * Ends a transform feedback operation
  47032. */
  47033. endTransformFeedback(): void;
  47034. /**
  47035. * Specify the varyings to use with transform feedback
  47036. * @param program defines the associated webGL program
  47037. * @param value defines the list of strings representing the varying names
  47038. */
  47039. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47040. /**
  47041. * Bind a webGL buffer for a transform feedback operation
  47042. * @param value defines the webGL buffer to bind
  47043. */
  47044. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47045. }
  47046. }
  47047. declare module BABYLON {
  47048. /**
  47049. * Creation options of the multi render target texture.
  47050. */
  47051. export interface IMultiRenderTargetOptions {
  47052. /**
  47053. * Define if the texture needs to create mip maps after render.
  47054. */
  47055. generateMipMaps?: boolean;
  47056. /**
  47057. * Define the types of all the draw buffers we want to create
  47058. */
  47059. types?: number[];
  47060. /**
  47061. * Define the sampling modes of all the draw buffers we want to create
  47062. */
  47063. samplingModes?: number[];
  47064. /**
  47065. * Define if a depth buffer is required
  47066. */
  47067. generateDepthBuffer?: boolean;
  47068. /**
  47069. * Define if a stencil buffer is required
  47070. */
  47071. generateStencilBuffer?: boolean;
  47072. /**
  47073. * Define if a depth texture is required instead of a depth buffer
  47074. */
  47075. generateDepthTexture?: boolean;
  47076. /**
  47077. * Define the number of desired draw buffers
  47078. */
  47079. textureCount?: number;
  47080. /**
  47081. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47082. */
  47083. doNotChangeAspectRatio?: boolean;
  47084. /**
  47085. * Define the default type of the buffers we are creating
  47086. */
  47087. defaultType?: number;
  47088. }
  47089. /**
  47090. * A multi render target, like a render target provides the ability to render to a texture.
  47091. * Unlike the render target, it can render to several draw buffers in one draw.
  47092. * This is specially interesting in deferred rendering or for any effects requiring more than
  47093. * just one color from a single pass.
  47094. */
  47095. export class MultiRenderTarget extends RenderTargetTexture {
  47096. private _internalTextures;
  47097. private _textures;
  47098. private _multiRenderTargetOptions;
  47099. /**
  47100. * Get if draw buffers are currently supported by the used hardware and browser.
  47101. */
  47102. get isSupported(): boolean;
  47103. /**
  47104. * Get the list of textures generated by the multi render target.
  47105. */
  47106. get textures(): Texture[];
  47107. /**
  47108. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47109. */
  47110. get depthTexture(): Texture;
  47111. /**
  47112. * Set the wrapping mode on U of all the textures we are rendering to.
  47113. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47114. */
  47115. set wrapU(wrap: number);
  47116. /**
  47117. * Set the wrapping mode on V of all the textures we are rendering to.
  47118. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47119. */
  47120. set wrapV(wrap: number);
  47121. /**
  47122. * Instantiate a new multi render target texture.
  47123. * A multi render target, like a render target provides the ability to render to a texture.
  47124. * Unlike the render target, it can render to several draw buffers in one draw.
  47125. * This is specially interesting in deferred rendering or for any effects requiring more than
  47126. * just one color from a single pass.
  47127. * @param name Define the name of the texture
  47128. * @param size Define the size of the buffers to render to
  47129. * @param count Define the number of target we are rendering into
  47130. * @param scene Define the scene the texture belongs to
  47131. * @param options Define the options used to create the multi render target
  47132. */
  47133. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47134. /** @hidden */
  47135. _rebuild(): void;
  47136. private _createInternalTextures;
  47137. private _createTextures;
  47138. /**
  47139. * Define the number of samples used if MSAA is enabled.
  47140. */
  47141. get samples(): number;
  47142. set samples(value: number);
  47143. /**
  47144. * Resize all the textures in the multi render target.
  47145. * Be carrefull as it will recreate all the data in the new texture.
  47146. * @param size Define the new size
  47147. */
  47148. resize(size: any): void;
  47149. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47150. /**
  47151. * Dispose the render targets and their associated resources
  47152. */
  47153. dispose(): void;
  47154. /**
  47155. * Release all the underlying texture used as draw buffers.
  47156. */
  47157. releaseInternalTextures(): void;
  47158. }
  47159. }
  47160. declare module BABYLON {
  47161. interface ThinEngine {
  47162. /**
  47163. * Unbind a list of render target textures from the webGL context
  47164. * This is used only when drawBuffer extension or webGL2 are active
  47165. * @param textures defines the render target textures to unbind
  47166. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47167. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47168. */
  47169. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47170. /**
  47171. * Create a multi render target texture
  47172. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47173. * @param size defines the size of the texture
  47174. * @param options defines the creation options
  47175. * @returns the cube texture as an InternalTexture
  47176. */
  47177. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47178. /**
  47179. * Update the sample count for a given multiple render target texture
  47180. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47181. * @param textures defines the textures to update
  47182. * @param samples defines the sample count to set
  47183. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47184. */
  47185. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47186. }
  47187. }
  47188. declare module BABYLON {
  47189. /**
  47190. * Class used to define an additional view for the engine
  47191. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47192. */
  47193. export class EngineView {
  47194. /** Defines the canvas where to render the view */
  47195. target: HTMLCanvasElement;
  47196. /** Defines an optional camera used to render the view (will use active camera else) */
  47197. camera?: Camera;
  47198. }
  47199. interface Engine {
  47200. /**
  47201. * Gets or sets the HTML element to use for attaching events
  47202. */
  47203. inputElement: Nullable<HTMLElement>;
  47204. /**
  47205. * Gets the current engine view
  47206. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47207. */
  47208. activeView: Nullable<EngineView>;
  47209. /** Gets or sets the list of views */
  47210. views: EngineView[];
  47211. /**
  47212. * Register a new child canvas
  47213. * @param canvas defines the canvas to register
  47214. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47215. * @returns the associated view
  47216. */
  47217. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47218. /**
  47219. * Remove a registered child canvas
  47220. * @param canvas defines the canvas to remove
  47221. * @returns the current engine
  47222. */
  47223. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47224. }
  47225. }
  47226. declare module BABYLON {
  47227. /**
  47228. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47229. */
  47230. export interface CubeMapInfo {
  47231. /**
  47232. * The pixel array for the front face.
  47233. * This is stored in format, left to right, up to down format.
  47234. */
  47235. front: Nullable<ArrayBufferView>;
  47236. /**
  47237. * The pixel array for the back face.
  47238. * This is stored in format, left to right, up to down format.
  47239. */
  47240. back: Nullable<ArrayBufferView>;
  47241. /**
  47242. * The pixel array for the left face.
  47243. * This is stored in format, left to right, up to down format.
  47244. */
  47245. left: Nullable<ArrayBufferView>;
  47246. /**
  47247. * The pixel array for the right face.
  47248. * This is stored in format, left to right, up to down format.
  47249. */
  47250. right: Nullable<ArrayBufferView>;
  47251. /**
  47252. * The pixel array for the up face.
  47253. * This is stored in format, left to right, up to down format.
  47254. */
  47255. up: Nullable<ArrayBufferView>;
  47256. /**
  47257. * The pixel array for the down face.
  47258. * This is stored in format, left to right, up to down format.
  47259. */
  47260. down: Nullable<ArrayBufferView>;
  47261. /**
  47262. * The size of the cubemap stored.
  47263. *
  47264. * Each faces will be size * size pixels.
  47265. */
  47266. size: number;
  47267. /**
  47268. * The format of the texture.
  47269. *
  47270. * RGBA, RGB.
  47271. */
  47272. format: number;
  47273. /**
  47274. * The type of the texture data.
  47275. *
  47276. * UNSIGNED_INT, FLOAT.
  47277. */
  47278. type: number;
  47279. /**
  47280. * Specifies whether the texture is in gamma space.
  47281. */
  47282. gammaSpace: boolean;
  47283. }
  47284. /**
  47285. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47286. */
  47287. export class PanoramaToCubeMapTools {
  47288. private static FACE_FRONT;
  47289. private static FACE_BACK;
  47290. private static FACE_RIGHT;
  47291. private static FACE_LEFT;
  47292. private static FACE_DOWN;
  47293. private static FACE_UP;
  47294. /**
  47295. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47296. *
  47297. * @param float32Array The source data.
  47298. * @param inputWidth The width of the input panorama.
  47299. * @param inputHeight The height of the input panorama.
  47300. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47301. * @return The cubemap data
  47302. */
  47303. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47304. private static CreateCubemapTexture;
  47305. private static CalcProjectionSpherical;
  47306. }
  47307. }
  47308. declare module BABYLON {
  47309. /**
  47310. * Helper class dealing with the extraction of spherical polynomial dataArray
  47311. * from a cube map.
  47312. */
  47313. export class CubeMapToSphericalPolynomialTools {
  47314. private static FileFaces;
  47315. /**
  47316. * Converts a texture to the according Spherical Polynomial data.
  47317. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47318. *
  47319. * @param texture The texture to extract the information from.
  47320. * @return The Spherical Polynomial data.
  47321. */
  47322. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47323. /**
  47324. * Converts a cubemap to the according Spherical Polynomial data.
  47325. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47326. *
  47327. * @param cubeInfo The Cube map to extract the information from.
  47328. * @return The Spherical Polynomial data.
  47329. */
  47330. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47331. }
  47332. }
  47333. declare module BABYLON {
  47334. interface BaseTexture {
  47335. /**
  47336. * Get the polynomial representation of the texture data.
  47337. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47338. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47339. */
  47340. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47341. }
  47342. }
  47343. declare module BABYLON {
  47344. /** @hidden */
  47345. export var rgbdEncodePixelShader: {
  47346. name: string;
  47347. shader: string;
  47348. };
  47349. }
  47350. declare module BABYLON {
  47351. /** @hidden */
  47352. export var rgbdDecodePixelShader: {
  47353. name: string;
  47354. shader: string;
  47355. };
  47356. }
  47357. declare module BABYLON {
  47358. /**
  47359. * Raw texture data and descriptor sufficient for WebGL texture upload
  47360. */
  47361. export interface EnvironmentTextureInfo {
  47362. /**
  47363. * Version of the environment map
  47364. */
  47365. version: number;
  47366. /**
  47367. * Width of image
  47368. */
  47369. width: number;
  47370. /**
  47371. * Irradiance information stored in the file.
  47372. */
  47373. irradiance: any;
  47374. /**
  47375. * Specular information stored in the file.
  47376. */
  47377. specular: any;
  47378. }
  47379. /**
  47380. * Defines One Image in the file. It requires only the position in the file
  47381. * as well as the length.
  47382. */
  47383. interface BufferImageData {
  47384. /**
  47385. * Length of the image data.
  47386. */
  47387. length: number;
  47388. /**
  47389. * Position of the data from the null terminator delimiting the end of the JSON.
  47390. */
  47391. position: number;
  47392. }
  47393. /**
  47394. * Defines the specular data enclosed in the file.
  47395. * This corresponds to the version 1 of the data.
  47396. */
  47397. export interface EnvironmentTextureSpecularInfoV1 {
  47398. /**
  47399. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47400. */
  47401. specularDataPosition?: number;
  47402. /**
  47403. * This contains all the images data needed to reconstruct the cubemap.
  47404. */
  47405. mipmaps: Array<BufferImageData>;
  47406. /**
  47407. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47408. */
  47409. lodGenerationScale: number;
  47410. }
  47411. /**
  47412. * Sets of helpers addressing the serialization and deserialization of environment texture
  47413. * stored in a BabylonJS env file.
  47414. * Those files are usually stored as .env files.
  47415. */
  47416. export class EnvironmentTextureTools {
  47417. /**
  47418. * Magic number identifying the env file.
  47419. */
  47420. private static _MagicBytes;
  47421. /**
  47422. * Gets the environment info from an env file.
  47423. * @param data The array buffer containing the .env bytes.
  47424. * @returns the environment file info (the json header) if successfully parsed.
  47425. */
  47426. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47427. /**
  47428. * Creates an environment texture from a loaded cube texture.
  47429. * @param texture defines the cube texture to convert in env file
  47430. * @return a promise containing the environment data if succesfull.
  47431. */
  47432. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47433. /**
  47434. * Creates a JSON representation of the spherical data.
  47435. * @param texture defines the texture containing the polynomials
  47436. * @return the JSON representation of the spherical info
  47437. */
  47438. private static _CreateEnvTextureIrradiance;
  47439. /**
  47440. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47441. * @param data the image data
  47442. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47443. * @return the views described by info providing access to the underlying buffer
  47444. */
  47445. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47446. /**
  47447. * Uploads the texture info contained in the env file to the GPU.
  47448. * @param texture defines the internal texture to upload to
  47449. * @param data defines the data to load
  47450. * @param info defines the texture info retrieved through the GetEnvInfo method
  47451. * @returns a promise
  47452. */
  47453. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47454. private static _OnImageReadyAsync;
  47455. /**
  47456. * Uploads the levels of image data to the GPU.
  47457. * @param texture defines the internal texture to upload to
  47458. * @param imageData defines the array buffer views of image data [mipmap][face]
  47459. * @returns a promise
  47460. */
  47461. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47462. /**
  47463. * Uploads spherical polynomials information to the texture.
  47464. * @param texture defines the texture we are trying to upload the information to
  47465. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47466. */
  47467. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47468. /** @hidden */
  47469. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47470. }
  47471. }
  47472. declare module BABYLON {
  47473. /**
  47474. * Contains position and normal vectors for a vertex
  47475. */
  47476. export class PositionNormalVertex {
  47477. /** the position of the vertex (defaut: 0,0,0) */
  47478. position: Vector3;
  47479. /** the normal of the vertex (defaut: 0,1,0) */
  47480. normal: Vector3;
  47481. /**
  47482. * Creates a PositionNormalVertex
  47483. * @param position the position of the vertex (defaut: 0,0,0)
  47484. * @param normal the normal of the vertex (defaut: 0,1,0)
  47485. */
  47486. constructor(
  47487. /** the position of the vertex (defaut: 0,0,0) */
  47488. position?: Vector3,
  47489. /** the normal of the vertex (defaut: 0,1,0) */
  47490. normal?: Vector3);
  47491. /**
  47492. * Clones the PositionNormalVertex
  47493. * @returns the cloned PositionNormalVertex
  47494. */
  47495. clone(): PositionNormalVertex;
  47496. }
  47497. /**
  47498. * Contains position, normal and uv vectors for a vertex
  47499. */
  47500. export class PositionNormalTextureVertex {
  47501. /** the position of the vertex (defaut: 0,0,0) */
  47502. position: Vector3;
  47503. /** the normal of the vertex (defaut: 0,1,0) */
  47504. normal: Vector3;
  47505. /** the uv of the vertex (default: 0,0) */
  47506. uv: Vector2;
  47507. /**
  47508. * Creates a PositionNormalTextureVertex
  47509. * @param position the position of the vertex (defaut: 0,0,0)
  47510. * @param normal the normal of the vertex (defaut: 0,1,0)
  47511. * @param uv the uv of the vertex (default: 0,0)
  47512. */
  47513. constructor(
  47514. /** the position of the vertex (defaut: 0,0,0) */
  47515. position?: Vector3,
  47516. /** the normal of the vertex (defaut: 0,1,0) */
  47517. normal?: Vector3,
  47518. /** the uv of the vertex (default: 0,0) */
  47519. uv?: Vector2);
  47520. /**
  47521. * Clones the PositionNormalTextureVertex
  47522. * @returns the cloned PositionNormalTextureVertex
  47523. */
  47524. clone(): PositionNormalTextureVertex;
  47525. }
  47526. }
  47527. declare module BABYLON {
  47528. /** @hidden */
  47529. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47530. private _genericAttributeLocation;
  47531. private _varyingLocationCount;
  47532. private _varyingLocationMap;
  47533. private _replacements;
  47534. private _textureCount;
  47535. private _uniforms;
  47536. lineProcessor(line: string): string;
  47537. attributeProcessor(attribute: string): string;
  47538. varyingProcessor(varying: string, isFragment: boolean): string;
  47539. uniformProcessor(uniform: string): string;
  47540. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47541. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47542. }
  47543. }
  47544. declare module BABYLON {
  47545. /**
  47546. * Container for accessors for natively-stored mesh data buffers.
  47547. */
  47548. class NativeDataBuffer extends DataBuffer {
  47549. /**
  47550. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47551. */
  47552. nativeIndexBuffer?: any;
  47553. /**
  47554. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47555. */
  47556. nativeVertexBuffer?: any;
  47557. }
  47558. /** @hidden */
  47559. class NativeTexture extends InternalTexture {
  47560. getInternalTexture(): InternalTexture;
  47561. getViewCount(): number;
  47562. }
  47563. /** @hidden */
  47564. export class NativeEngine extends Engine {
  47565. private readonly _native;
  47566. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47567. private readonly INVALID_HANDLE;
  47568. getHardwareScalingLevel(): number;
  47569. constructor();
  47570. /**
  47571. * Can be used to override the current requestAnimationFrame requester.
  47572. * @hidden
  47573. */
  47574. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47575. /**
  47576. * Override default engine behavior.
  47577. * @param color
  47578. * @param backBuffer
  47579. * @param depth
  47580. * @param stencil
  47581. */
  47582. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47583. /**
  47584. * Gets host document
  47585. * @returns the host document object
  47586. */
  47587. getHostDocument(): Nullable<Document>;
  47588. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47589. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47590. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47591. recordVertexArrayObject(vertexBuffers: {
  47592. [key: string]: VertexBuffer;
  47593. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47594. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47595. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47596. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47597. /**
  47598. * Draw a list of indexed primitives
  47599. * @param fillMode defines the primitive to use
  47600. * @param indexStart defines the starting index
  47601. * @param indexCount defines the number of index to draw
  47602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47603. */
  47604. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47605. /**
  47606. * Draw a list of unindexed primitives
  47607. * @param fillMode defines the primitive to use
  47608. * @param verticesStart defines the index of first vertex to draw
  47609. * @param verticesCount defines the count of vertices to draw
  47610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47611. */
  47612. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47613. createPipelineContext(): IPipelineContext;
  47614. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47615. /** @hidden */
  47616. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47617. /** @hidden */
  47618. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47619. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47620. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47621. protected _setProgram(program: WebGLProgram): void;
  47622. _releaseEffect(effect: Effect): void;
  47623. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47624. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47625. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47626. bindSamplers(effect: Effect): void;
  47627. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47628. getRenderWidth(useScreen?: boolean): number;
  47629. getRenderHeight(useScreen?: boolean): number;
  47630. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47631. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47632. /**
  47633. * Set the z offset to apply to current rendering
  47634. * @param value defines the offset to apply
  47635. */
  47636. setZOffset(value: number): void;
  47637. /**
  47638. * Gets the current value of the zOffset
  47639. * @returns the current zOffset state
  47640. */
  47641. getZOffset(): number;
  47642. /**
  47643. * Enable or disable depth buffering
  47644. * @param enable defines the state to set
  47645. */
  47646. setDepthBuffer(enable: boolean): void;
  47647. /**
  47648. * Gets a boolean indicating if depth writing is enabled
  47649. * @returns the current depth writing state
  47650. */
  47651. getDepthWrite(): boolean;
  47652. /**
  47653. * Enable or disable depth writing
  47654. * @param enable defines the state to set
  47655. */
  47656. setDepthWrite(enable: boolean): void;
  47657. /**
  47658. * Enable or disable color writing
  47659. * @param enable defines the state to set
  47660. */
  47661. setColorWrite(enable: boolean): void;
  47662. /**
  47663. * Gets a boolean indicating if color writing is enabled
  47664. * @returns the current color writing state
  47665. */
  47666. getColorWrite(): boolean;
  47667. /**
  47668. * Sets alpha constants used by some alpha blending modes
  47669. * @param r defines the red component
  47670. * @param g defines the green component
  47671. * @param b defines the blue component
  47672. * @param a defines the alpha component
  47673. */
  47674. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47675. /**
  47676. * Sets the current alpha mode
  47677. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47678. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47679. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47680. */
  47681. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47682. /**
  47683. * Gets the current alpha mode
  47684. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47685. * @returns the current alpha mode
  47686. */
  47687. getAlphaMode(): number;
  47688. setInt(uniform: WebGLUniformLocation, int: number): void;
  47689. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47690. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47691. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47692. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47693. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47694. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47695. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47696. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47697. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47698. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47699. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47700. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47701. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47702. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47703. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47704. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47705. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47706. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47707. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47708. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47709. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47710. wipeCaches(bruteForce?: boolean): void;
  47711. _createTexture(): WebGLTexture;
  47712. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47713. /**
  47714. * Usually called from BABYLON.Texture.ts.
  47715. * Passed information to create a WebGLTexture
  47716. * @param urlArg defines a value which contains one of the following:
  47717. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47718. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47719. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47720. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47721. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47722. * @param scene needed for loading to the correct scene
  47723. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47724. * @param onLoad optional callback to be called upon successful completion
  47725. * @param onError optional callback to be called upon failure
  47726. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47727. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47728. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47729. * @param forcedExtension defines the extension to use to pick the right loader
  47730. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47731. */
  47732. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  47733. /**
  47734. * Creates a cube texture
  47735. * @param rootUrl defines the url where the files to load is located
  47736. * @param scene defines the current scene
  47737. * @param files defines the list of files to load (1 per face)
  47738. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47739. * @param onLoad defines an optional callback raised when the texture is loaded
  47740. * @param onError defines an optional callback raised if there is an issue to load the texture
  47741. * @param format defines the format of the data
  47742. * @param forcedExtension defines the extension to use to pick the right loader
  47743. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47744. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47745. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47746. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47747. * @returns the cube texture as an InternalTexture
  47748. */
  47749. 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;
  47750. private _getSamplingFilter;
  47751. private static _GetNativeTextureFormat;
  47752. createRenderTargetTexture(size: number | {
  47753. width: number;
  47754. height: number;
  47755. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47756. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47757. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47758. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47759. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47760. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47761. /**
  47762. * Updates a dynamic vertex buffer.
  47763. * @param vertexBuffer the vertex buffer to update
  47764. * @param data the data used to update the vertex buffer
  47765. * @param byteOffset the byte offset of the data (optional)
  47766. * @param byteLength the byte length of the data (optional)
  47767. */
  47768. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47769. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47770. private _updateAnisotropicLevel;
  47771. private _getAddressMode;
  47772. /** @hidden */
  47773. _bindTexture(channel: number, texture: InternalTexture): void;
  47774. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47775. releaseEffects(): void;
  47776. /** @hidden */
  47777. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47778. /** @hidden */
  47779. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47780. /** @hidden */
  47781. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47782. /** @hidden */
  47783. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47784. }
  47785. }
  47786. declare module BABYLON {
  47787. /**
  47788. * Gather the list of clipboard event types as constants.
  47789. */
  47790. export class ClipboardEventTypes {
  47791. /**
  47792. * The clipboard event is fired when a copy command is active (pressed).
  47793. */
  47794. static readonly COPY: number;
  47795. /**
  47796. * The clipboard event is fired when a cut command is active (pressed).
  47797. */
  47798. static readonly CUT: number;
  47799. /**
  47800. * The clipboard event is fired when a paste command is active (pressed).
  47801. */
  47802. static readonly PASTE: number;
  47803. }
  47804. /**
  47805. * This class is used to store clipboard related info for the onClipboardObservable event.
  47806. */
  47807. export class ClipboardInfo {
  47808. /**
  47809. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47810. */
  47811. type: number;
  47812. /**
  47813. * Defines the related dom event
  47814. */
  47815. event: ClipboardEvent;
  47816. /**
  47817. *Creates an instance of ClipboardInfo.
  47818. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47819. * @param event Defines the related dom event
  47820. */
  47821. constructor(
  47822. /**
  47823. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47824. */
  47825. type: number,
  47826. /**
  47827. * Defines the related dom event
  47828. */
  47829. event: ClipboardEvent);
  47830. /**
  47831. * Get the clipboard event's type from the keycode.
  47832. * @param keyCode Defines the keyCode for the current keyboard event.
  47833. * @return {number}
  47834. */
  47835. static GetTypeFromCharacter(keyCode: number): number;
  47836. }
  47837. }
  47838. declare module BABYLON {
  47839. /**
  47840. * Google Daydream controller
  47841. */
  47842. export class DaydreamController extends WebVRController {
  47843. /**
  47844. * Base Url for the controller model.
  47845. */
  47846. static MODEL_BASE_URL: string;
  47847. /**
  47848. * File name for the controller model.
  47849. */
  47850. static MODEL_FILENAME: string;
  47851. /**
  47852. * Gamepad Id prefix used to identify Daydream Controller.
  47853. */
  47854. static readonly GAMEPAD_ID_PREFIX: string;
  47855. /**
  47856. * Creates a new DaydreamController from a gamepad
  47857. * @param vrGamepad the gamepad that the controller should be created from
  47858. */
  47859. constructor(vrGamepad: any);
  47860. /**
  47861. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47862. * @param scene scene in which to add meshes
  47863. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47864. */
  47865. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47866. /**
  47867. * Called once for each button that changed state since the last frame
  47868. * @param buttonIdx Which button index changed
  47869. * @param state New state of the button
  47870. * @param changes Which properties on the state changed since last frame
  47871. */
  47872. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47873. }
  47874. }
  47875. declare module BABYLON {
  47876. /**
  47877. * Gear VR Controller
  47878. */
  47879. export class GearVRController extends WebVRController {
  47880. /**
  47881. * Base Url for the controller model.
  47882. */
  47883. static MODEL_BASE_URL: string;
  47884. /**
  47885. * File name for the controller model.
  47886. */
  47887. static MODEL_FILENAME: string;
  47888. /**
  47889. * Gamepad Id prefix used to identify this controller.
  47890. */
  47891. static readonly GAMEPAD_ID_PREFIX: string;
  47892. private readonly _buttonIndexToObservableNameMap;
  47893. /**
  47894. * Creates a new GearVRController from a gamepad
  47895. * @param vrGamepad the gamepad that the controller should be created from
  47896. */
  47897. constructor(vrGamepad: any);
  47898. /**
  47899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47900. * @param scene scene in which to add meshes
  47901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47902. */
  47903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47904. /**
  47905. * Called once for each button that changed state since the last frame
  47906. * @param buttonIdx Which button index changed
  47907. * @param state New state of the button
  47908. * @param changes Which properties on the state changed since last frame
  47909. */
  47910. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47911. }
  47912. }
  47913. declare module BABYLON {
  47914. /**
  47915. * Generic Controller
  47916. */
  47917. export class GenericController extends WebVRController {
  47918. /**
  47919. * Base Url for the controller model.
  47920. */
  47921. static readonly MODEL_BASE_URL: string;
  47922. /**
  47923. * File name for the controller model.
  47924. */
  47925. static readonly MODEL_FILENAME: string;
  47926. /**
  47927. * Creates a new GenericController from a gamepad
  47928. * @param vrGamepad the gamepad that the controller should be created from
  47929. */
  47930. constructor(vrGamepad: any);
  47931. /**
  47932. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47933. * @param scene scene in which to add meshes
  47934. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47935. */
  47936. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47937. /**
  47938. * Called once for each button that changed state since the last frame
  47939. * @param buttonIdx Which button index changed
  47940. * @param state New state of the button
  47941. * @param changes Which properties on the state changed since last frame
  47942. */
  47943. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47944. }
  47945. }
  47946. declare module BABYLON {
  47947. /**
  47948. * Oculus Touch Controller
  47949. */
  47950. export class OculusTouchController extends WebVRController {
  47951. /**
  47952. * Base Url for the controller model.
  47953. */
  47954. static MODEL_BASE_URL: string;
  47955. /**
  47956. * File name for the left controller model.
  47957. */
  47958. static MODEL_LEFT_FILENAME: string;
  47959. /**
  47960. * File name for the right controller model.
  47961. */
  47962. static MODEL_RIGHT_FILENAME: string;
  47963. /**
  47964. * Base Url for the Quest controller model.
  47965. */
  47966. static QUEST_MODEL_BASE_URL: string;
  47967. /**
  47968. * @hidden
  47969. * If the controllers are running on a device that needs the updated Quest controller models
  47970. */
  47971. static _IsQuest: boolean;
  47972. /**
  47973. * Fired when the secondary trigger on this controller is modified
  47974. */
  47975. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47976. /**
  47977. * Fired when the thumb rest on this controller is modified
  47978. */
  47979. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47980. /**
  47981. * Creates a new OculusTouchController from a gamepad
  47982. * @param vrGamepad the gamepad that the controller should be created from
  47983. */
  47984. constructor(vrGamepad: any);
  47985. /**
  47986. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47987. * @param scene scene in which to add meshes
  47988. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47989. */
  47990. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47991. /**
  47992. * Fired when the A button on this controller is modified
  47993. */
  47994. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47995. /**
  47996. * Fired when the B button on this controller is modified
  47997. */
  47998. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47999. /**
  48000. * Fired when the X button on this controller is modified
  48001. */
  48002. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48003. /**
  48004. * Fired when the Y button on this controller is modified
  48005. */
  48006. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48007. /**
  48008. * Called once for each button that changed state since the last frame
  48009. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48010. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48011. * 2) secondary trigger (same)
  48012. * 3) A (right) X (left), touch, pressed = value
  48013. * 4) B / Y
  48014. * 5) thumb rest
  48015. * @param buttonIdx Which button index changed
  48016. * @param state New state of the button
  48017. * @param changes Which properties on the state changed since last frame
  48018. */
  48019. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48020. }
  48021. }
  48022. declare module BABYLON {
  48023. /**
  48024. * Vive Controller
  48025. */
  48026. export class ViveController extends WebVRController {
  48027. /**
  48028. * Base Url for the controller model.
  48029. */
  48030. static MODEL_BASE_URL: string;
  48031. /**
  48032. * File name for the controller model.
  48033. */
  48034. static MODEL_FILENAME: string;
  48035. /**
  48036. * Creates a new ViveController from a gamepad
  48037. * @param vrGamepad the gamepad that the controller should be created from
  48038. */
  48039. constructor(vrGamepad: any);
  48040. /**
  48041. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48042. * @param scene scene in which to add meshes
  48043. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48044. */
  48045. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48046. /**
  48047. * Fired when the left button on this controller is modified
  48048. */
  48049. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48050. /**
  48051. * Fired when the right button on this controller is modified
  48052. */
  48053. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48054. /**
  48055. * Fired when the menu button on this controller is modified
  48056. */
  48057. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48058. /**
  48059. * Called once for each button that changed state since the last frame
  48060. * Vive mapping:
  48061. * 0: touchpad
  48062. * 1: trigger
  48063. * 2: left AND right buttons
  48064. * 3: menu button
  48065. * @param buttonIdx Which button index changed
  48066. * @param state New state of the button
  48067. * @param changes Which properties on the state changed since last frame
  48068. */
  48069. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48070. }
  48071. }
  48072. declare module BABYLON {
  48073. /**
  48074. * Defines the WindowsMotionController object that the state of the windows motion controller
  48075. */
  48076. export class WindowsMotionController extends WebVRController {
  48077. /**
  48078. * The base url used to load the left and right controller models
  48079. */
  48080. static MODEL_BASE_URL: string;
  48081. /**
  48082. * The name of the left controller model file
  48083. */
  48084. static MODEL_LEFT_FILENAME: string;
  48085. /**
  48086. * The name of the right controller model file
  48087. */
  48088. static MODEL_RIGHT_FILENAME: string;
  48089. /**
  48090. * The controller name prefix for this controller type
  48091. */
  48092. static readonly GAMEPAD_ID_PREFIX: string;
  48093. /**
  48094. * The controller id pattern for this controller type
  48095. */
  48096. private static readonly GAMEPAD_ID_PATTERN;
  48097. private _loadedMeshInfo;
  48098. protected readonly _mapping: {
  48099. buttons: string[];
  48100. buttonMeshNames: {
  48101. 'trigger': string;
  48102. 'menu': string;
  48103. 'grip': string;
  48104. 'thumbstick': string;
  48105. 'trackpad': string;
  48106. };
  48107. buttonObservableNames: {
  48108. 'trigger': string;
  48109. 'menu': string;
  48110. 'grip': string;
  48111. 'thumbstick': string;
  48112. 'trackpad': string;
  48113. };
  48114. axisMeshNames: string[];
  48115. pointingPoseMeshName: string;
  48116. };
  48117. /**
  48118. * Fired when the trackpad on this controller is clicked
  48119. */
  48120. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48121. /**
  48122. * Fired when the trackpad on this controller is modified
  48123. */
  48124. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48125. /**
  48126. * The current x and y values of this controller's trackpad
  48127. */
  48128. trackpad: StickValues;
  48129. /**
  48130. * Creates a new WindowsMotionController from a gamepad
  48131. * @param vrGamepad the gamepad that the controller should be created from
  48132. */
  48133. constructor(vrGamepad: any);
  48134. /**
  48135. * Fired when the trigger on this controller is modified
  48136. */
  48137. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48138. /**
  48139. * Fired when the menu button on this controller is modified
  48140. */
  48141. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48142. /**
  48143. * Fired when the grip button on this controller is modified
  48144. */
  48145. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48146. /**
  48147. * Fired when the thumbstick button on this controller is modified
  48148. */
  48149. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48150. /**
  48151. * Fired when the touchpad button on this controller is modified
  48152. */
  48153. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48154. /**
  48155. * Fired when the touchpad values on this controller are modified
  48156. */
  48157. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48158. protected _updateTrackpad(): void;
  48159. /**
  48160. * Called once per frame by the engine.
  48161. */
  48162. update(): void;
  48163. /**
  48164. * Called once for each button that changed state since the last frame
  48165. * @param buttonIdx Which button index changed
  48166. * @param state New state of the button
  48167. * @param changes Which properties on the state changed since last frame
  48168. */
  48169. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48170. /**
  48171. * Moves the buttons on the controller mesh based on their current state
  48172. * @param buttonName the name of the button to move
  48173. * @param buttonValue the value of the button which determines the buttons new position
  48174. */
  48175. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48176. /**
  48177. * Moves the axis on the controller mesh based on its current state
  48178. * @param axis the index of the axis
  48179. * @param axisValue the value of the axis which determines the meshes new position
  48180. * @hidden
  48181. */
  48182. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48183. /**
  48184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48185. * @param scene scene in which to add meshes
  48186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48187. */
  48188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48189. /**
  48190. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48191. * can be transformed by button presses and axes values, based on this._mapping.
  48192. *
  48193. * @param scene scene in which the meshes exist
  48194. * @param meshes list of meshes that make up the controller model to process
  48195. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48196. */
  48197. private processModel;
  48198. private createMeshInfo;
  48199. /**
  48200. * Gets the ray of the controller in the direction the controller is pointing
  48201. * @param length the length the resulting ray should be
  48202. * @returns a ray in the direction the controller is pointing
  48203. */
  48204. getForwardRay(length?: number): Ray;
  48205. /**
  48206. * Disposes of the controller
  48207. */
  48208. dispose(): void;
  48209. }
  48210. /**
  48211. * This class represents a new windows motion controller in XR.
  48212. */
  48213. export class XRWindowsMotionController extends WindowsMotionController {
  48214. /**
  48215. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48216. */
  48217. protected readonly _mapping: {
  48218. buttons: string[];
  48219. buttonMeshNames: {
  48220. 'trigger': string;
  48221. 'menu': string;
  48222. 'grip': string;
  48223. 'thumbstick': string;
  48224. 'trackpad': string;
  48225. };
  48226. buttonObservableNames: {
  48227. 'trigger': string;
  48228. 'menu': string;
  48229. 'grip': string;
  48230. 'thumbstick': string;
  48231. 'trackpad': string;
  48232. };
  48233. axisMeshNames: string[];
  48234. pointingPoseMeshName: string;
  48235. };
  48236. /**
  48237. * Construct a new XR-Based windows motion controller
  48238. *
  48239. * @param gamepadInfo the gamepad object from the browser
  48240. */
  48241. constructor(gamepadInfo: any);
  48242. /**
  48243. * holds the thumbstick values (X,Y)
  48244. */
  48245. thumbstickValues: StickValues;
  48246. /**
  48247. * Fired when the thumbstick on this controller is clicked
  48248. */
  48249. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48250. /**
  48251. * Fired when the thumbstick on this controller is modified
  48252. */
  48253. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48254. /**
  48255. * Fired when the touchpad button on this controller is modified
  48256. */
  48257. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48258. /**
  48259. * Fired when the touchpad values on this controller are modified
  48260. */
  48261. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48262. /**
  48263. * Fired when the thumbstick button on this controller is modified
  48264. * here to prevent breaking changes
  48265. */
  48266. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48267. /**
  48268. * updating the thumbstick(!) and not the trackpad.
  48269. * This is named this way due to the difference between WebVR and XR and to avoid
  48270. * changing the parent class.
  48271. */
  48272. protected _updateTrackpad(): void;
  48273. /**
  48274. * Disposes the class with joy
  48275. */
  48276. dispose(): void;
  48277. }
  48278. }
  48279. declare module BABYLON {
  48280. /**
  48281. * Class containing static functions to help procedurally build meshes
  48282. */
  48283. export class PolyhedronBuilder {
  48284. /**
  48285. * Creates a polyhedron mesh
  48286. * * 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
  48287. * * The parameter `size` (positive float, default 1) sets the polygon size
  48288. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48289. * * 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`
  48290. * * 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
  48291. * * 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)`)
  48292. * * 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
  48293. * * 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
  48294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48295. * * 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
  48296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48297. * @param name defines the name of the mesh
  48298. * @param options defines the options used to create the mesh
  48299. * @param scene defines the hosting scene
  48300. * @returns the polyhedron mesh
  48301. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48302. */
  48303. static CreatePolyhedron(name: string, options: {
  48304. type?: number;
  48305. size?: number;
  48306. sizeX?: number;
  48307. sizeY?: number;
  48308. sizeZ?: number;
  48309. custom?: any;
  48310. faceUV?: Vector4[];
  48311. faceColors?: Color4[];
  48312. flat?: boolean;
  48313. updatable?: boolean;
  48314. sideOrientation?: number;
  48315. frontUVs?: Vector4;
  48316. backUVs?: Vector4;
  48317. }, scene?: Nullable<Scene>): Mesh;
  48318. }
  48319. }
  48320. declare module BABYLON {
  48321. /**
  48322. * Gizmo that enables scaling a mesh along 3 axis
  48323. */
  48324. export class ScaleGizmo extends Gizmo {
  48325. /**
  48326. * Internal gizmo used for interactions on the x axis
  48327. */
  48328. xGizmo: AxisScaleGizmo;
  48329. /**
  48330. * Internal gizmo used for interactions on the y axis
  48331. */
  48332. yGizmo: AxisScaleGizmo;
  48333. /**
  48334. * Internal gizmo used for interactions on the z axis
  48335. */
  48336. zGizmo: AxisScaleGizmo;
  48337. /**
  48338. * Internal gizmo used to scale all axis equally
  48339. */
  48340. uniformScaleGizmo: AxisScaleGizmo;
  48341. private _meshAttached;
  48342. private _updateGizmoRotationToMatchAttachedMesh;
  48343. private _snapDistance;
  48344. private _scaleRatio;
  48345. private _uniformScalingMesh;
  48346. private _octahedron;
  48347. private _sensitivity;
  48348. /** Fires an event when any of it's sub gizmos are dragged */
  48349. onDragStartObservable: Observable<unknown>;
  48350. /** Fires an event when any of it's sub gizmos are released from dragging */
  48351. onDragEndObservable: Observable<unknown>;
  48352. get attachedMesh(): Nullable<AbstractMesh>;
  48353. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48354. /**
  48355. * Creates a ScaleGizmo
  48356. * @param gizmoLayer The utility layer the gizmo will be added to
  48357. */
  48358. constructor(gizmoLayer?: UtilityLayerRenderer);
  48359. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48360. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48361. /**
  48362. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48363. */
  48364. set snapDistance(value: number);
  48365. get snapDistance(): number;
  48366. /**
  48367. * Ratio for the scale of the gizmo (Default: 1)
  48368. */
  48369. set scaleRatio(value: number);
  48370. get scaleRatio(): number;
  48371. /**
  48372. * Sensitivity factor for dragging (Default: 1)
  48373. */
  48374. set sensitivity(value: number);
  48375. get sensitivity(): number;
  48376. /**
  48377. * Disposes of the gizmo
  48378. */
  48379. dispose(): void;
  48380. }
  48381. }
  48382. declare module BABYLON {
  48383. /**
  48384. * Single axis scale gizmo
  48385. */
  48386. export class AxisScaleGizmo extends Gizmo {
  48387. /**
  48388. * Drag behavior responsible for the gizmos dragging interactions
  48389. */
  48390. dragBehavior: PointerDragBehavior;
  48391. private _pointerObserver;
  48392. /**
  48393. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48394. */
  48395. snapDistance: number;
  48396. /**
  48397. * Event that fires each time the gizmo snaps to a new location.
  48398. * * snapDistance is the the change in distance
  48399. */
  48400. onSnapObservable: Observable<{
  48401. snapDistance: number;
  48402. }>;
  48403. /**
  48404. * If the scaling operation should be done on all axis (default: false)
  48405. */
  48406. uniformScaling: boolean;
  48407. /**
  48408. * Custom sensitivity value for the drag strength
  48409. */
  48410. sensitivity: number;
  48411. private _isEnabled;
  48412. private _parent;
  48413. private _arrow;
  48414. private _coloredMaterial;
  48415. private _hoverMaterial;
  48416. /**
  48417. * Creates an AxisScaleGizmo
  48418. * @param gizmoLayer The utility layer the gizmo will be added to
  48419. * @param dragAxis The axis which the gizmo will be able to scale on
  48420. * @param color The color of the gizmo
  48421. */
  48422. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48423. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48424. /**
  48425. * If the gizmo is enabled
  48426. */
  48427. set isEnabled(value: boolean);
  48428. get isEnabled(): boolean;
  48429. /**
  48430. * Disposes of the gizmo
  48431. */
  48432. dispose(): void;
  48433. /**
  48434. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48435. * @param mesh The mesh to replace the default mesh of the gizmo
  48436. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48437. */
  48438. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48439. }
  48440. }
  48441. declare module BABYLON {
  48442. /**
  48443. * Bounding box gizmo
  48444. */
  48445. export class BoundingBoxGizmo extends Gizmo {
  48446. private _lineBoundingBox;
  48447. private _rotateSpheresParent;
  48448. private _scaleBoxesParent;
  48449. private _boundingDimensions;
  48450. private _renderObserver;
  48451. private _pointerObserver;
  48452. private _scaleDragSpeed;
  48453. private _tmpQuaternion;
  48454. private _tmpVector;
  48455. private _tmpRotationMatrix;
  48456. /**
  48457. * 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)
  48458. */
  48459. ignoreChildren: boolean;
  48460. /**
  48461. * 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)
  48462. */
  48463. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48464. /**
  48465. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48466. */
  48467. rotationSphereSize: number;
  48468. /**
  48469. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48470. */
  48471. scaleBoxSize: number;
  48472. /**
  48473. * 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)
  48474. */
  48475. fixedDragMeshScreenSize: boolean;
  48476. /**
  48477. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48478. */
  48479. fixedDragMeshScreenSizeDistanceFactor: number;
  48480. /**
  48481. * Fired when a rotation sphere or scale box is dragged
  48482. */
  48483. onDragStartObservable: Observable<{}>;
  48484. /**
  48485. * Fired when a scale box is dragged
  48486. */
  48487. onScaleBoxDragObservable: Observable<{}>;
  48488. /**
  48489. * Fired when a scale box drag is ended
  48490. */
  48491. onScaleBoxDragEndObservable: Observable<{}>;
  48492. /**
  48493. * Fired when a rotation sphere is dragged
  48494. */
  48495. onRotationSphereDragObservable: Observable<{}>;
  48496. /**
  48497. * Fired when a rotation sphere drag is ended
  48498. */
  48499. onRotationSphereDragEndObservable: Observable<{}>;
  48500. /**
  48501. * 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)
  48502. */
  48503. scalePivot: Nullable<Vector3>;
  48504. /**
  48505. * Mesh used as a pivot to rotate the attached mesh
  48506. */
  48507. private _anchorMesh;
  48508. private _existingMeshScale;
  48509. private _dragMesh;
  48510. private pointerDragBehavior;
  48511. private coloredMaterial;
  48512. private hoverColoredMaterial;
  48513. /**
  48514. * Sets the color of the bounding box gizmo
  48515. * @param color the color to set
  48516. */
  48517. setColor(color: Color3): void;
  48518. /**
  48519. * Creates an BoundingBoxGizmo
  48520. * @param gizmoLayer The utility layer the gizmo will be added to
  48521. * @param color The color of the gizmo
  48522. */
  48523. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48524. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48525. private _selectNode;
  48526. /**
  48527. * Updates the bounding box information for the Gizmo
  48528. */
  48529. updateBoundingBox(): void;
  48530. private _updateRotationSpheres;
  48531. private _updateScaleBoxes;
  48532. /**
  48533. * Enables rotation on the specified axis and disables rotation on the others
  48534. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48535. */
  48536. setEnabledRotationAxis(axis: string): void;
  48537. /**
  48538. * Enables/disables scaling
  48539. * @param enable if scaling should be enabled
  48540. */
  48541. setEnabledScaling(enable: boolean): void;
  48542. private _updateDummy;
  48543. /**
  48544. * Enables a pointer drag behavior on the bounding box of the gizmo
  48545. */
  48546. enableDragBehavior(): void;
  48547. /**
  48548. * Disposes of the gizmo
  48549. */
  48550. dispose(): void;
  48551. /**
  48552. * 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)
  48553. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48554. * @returns the bounding box mesh with the passed in mesh as a child
  48555. */
  48556. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48557. /**
  48558. * CustomMeshes are not supported by this gizmo
  48559. * @param mesh The mesh to replace the default mesh of the gizmo
  48560. */
  48561. setCustomMesh(mesh: Mesh): void;
  48562. }
  48563. }
  48564. declare module BABYLON {
  48565. /**
  48566. * Single plane rotation gizmo
  48567. */
  48568. export class PlaneRotationGizmo extends Gizmo {
  48569. /**
  48570. * Drag behavior responsible for the gizmos dragging interactions
  48571. */
  48572. dragBehavior: PointerDragBehavior;
  48573. private _pointerObserver;
  48574. /**
  48575. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48576. */
  48577. snapDistance: number;
  48578. /**
  48579. * Event that fires each time the gizmo snaps to a new location.
  48580. * * snapDistance is the the change in distance
  48581. */
  48582. onSnapObservable: Observable<{
  48583. snapDistance: number;
  48584. }>;
  48585. private _isEnabled;
  48586. private _parent;
  48587. /**
  48588. * Creates a PlaneRotationGizmo
  48589. * @param gizmoLayer The utility layer the gizmo will be added to
  48590. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48591. * @param color The color of the gizmo
  48592. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48593. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48594. */
  48595. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48596. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48597. /**
  48598. * If the gizmo is enabled
  48599. */
  48600. set isEnabled(value: boolean);
  48601. get isEnabled(): boolean;
  48602. /**
  48603. * Disposes of the gizmo
  48604. */
  48605. dispose(): void;
  48606. }
  48607. }
  48608. declare module BABYLON {
  48609. /**
  48610. * Gizmo that enables rotating a mesh along 3 axis
  48611. */
  48612. export class RotationGizmo extends Gizmo {
  48613. /**
  48614. * Internal gizmo used for interactions on the x axis
  48615. */
  48616. xGizmo: PlaneRotationGizmo;
  48617. /**
  48618. * Internal gizmo used for interactions on the y axis
  48619. */
  48620. yGizmo: PlaneRotationGizmo;
  48621. /**
  48622. * Internal gizmo used for interactions on the z axis
  48623. */
  48624. zGizmo: PlaneRotationGizmo;
  48625. /** Fires an event when any of it's sub gizmos are dragged */
  48626. onDragStartObservable: Observable<unknown>;
  48627. /** Fires an event when any of it's sub gizmos are released from dragging */
  48628. onDragEndObservable: Observable<unknown>;
  48629. private _meshAttached;
  48630. get attachedMesh(): Nullable<AbstractMesh>;
  48631. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48632. /**
  48633. * Creates a RotationGizmo
  48634. * @param gizmoLayer The utility layer the gizmo will be added to
  48635. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48636. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48637. */
  48638. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48639. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48640. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48641. /**
  48642. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48643. */
  48644. set snapDistance(value: number);
  48645. get snapDistance(): number;
  48646. /**
  48647. * Ratio for the scale of the gizmo (Default: 1)
  48648. */
  48649. set scaleRatio(value: number);
  48650. get scaleRatio(): number;
  48651. /**
  48652. * Disposes of the gizmo
  48653. */
  48654. dispose(): void;
  48655. /**
  48656. * CustomMeshes are not supported by this gizmo
  48657. * @param mesh The mesh to replace the default mesh of the gizmo
  48658. */
  48659. setCustomMesh(mesh: Mesh): void;
  48660. }
  48661. }
  48662. declare module BABYLON {
  48663. /**
  48664. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48665. */
  48666. export class GizmoManager implements IDisposable {
  48667. private scene;
  48668. /**
  48669. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48670. */
  48671. gizmos: {
  48672. positionGizmo: Nullable<PositionGizmo>;
  48673. rotationGizmo: Nullable<RotationGizmo>;
  48674. scaleGizmo: Nullable<ScaleGizmo>;
  48675. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48676. };
  48677. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48678. clearGizmoOnEmptyPointerEvent: boolean;
  48679. /** Fires an event when the manager is attached to a mesh */
  48680. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48681. private _gizmosEnabled;
  48682. private _pointerObserver;
  48683. private _attachedMesh;
  48684. private _boundingBoxColor;
  48685. private _defaultUtilityLayer;
  48686. private _defaultKeepDepthUtilityLayer;
  48687. /**
  48688. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48689. */
  48690. boundingBoxDragBehavior: SixDofDragBehavior;
  48691. /**
  48692. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48693. */
  48694. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48695. /**
  48696. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48697. */
  48698. usePointerToAttachGizmos: boolean;
  48699. /**
  48700. * Utility layer that the bounding box gizmo belongs to
  48701. */
  48702. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48703. /**
  48704. * Utility layer that all gizmos besides bounding box belong to
  48705. */
  48706. get utilityLayer(): UtilityLayerRenderer;
  48707. /**
  48708. * Instatiates a gizmo manager
  48709. * @param scene the scene to overlay the gizmos on top of
  48710. */
  48711. constructor(scene: Scene);
  48712. /**
  48713. * Attaches a set of gizmos to the specified mesh
  48714. * @param mesh The mesh the gizmo's should be attached to
  48715. */
  48716. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48717. /**
  48718. * If the position gizmo is enabled
  48719. */
  48720. set positionGizmoEnabled(value: boolean);
  48721. get positionGizmoEnabled(): boolean;
  48722. /**
  48723. * If the rotation gizmo is enabled
  48724. */
  48725. set rotationGizmoEnabled(value: boolean);
  48726. get rotationGizmoEnabled(): boolean;
  48727. /**
  48728. * If the scale gizmo is enabled
  48729. */
  48730. set scaleGizmoEnabled(value: boolean);
  48731. get scaleGizmoEnabled(): boolean;
  48732. /**
  48733. * If the boundingBox gizmo is enabled
  48734. */
  48735. set boundingBoxGizmoEnabled(value: boolean);
  48736. get boundingBoxGizmoEnabled(): boolean;
  48737. /**
  48738. * Disposes of the gizmo manager
  48739. */
  48740. dispose(): void;
  48741. }
  48742. }
  48743. declare module BABYLON {
  48744. /**
  48745. * A directional light is defined by a direction (what a surprise!).
  48746. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48747. * 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.
  48748. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48749. */
  48750. export class DirectionalLight extends ShadowLight {
  48751. private _shadowFrustumSize;
  48752. /**
  48753. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48754. */
  48755. get shadowFrustumSize(): number;
  48756. /**
  48757. * Specifies a fix frustum size for the shadow generation.
  48758. */
  48759. set shadowFrustumSize(value: number);
  48760. private _shadowOrthoScale;
  48761. /**
  48762. * Gets the shadow projection scale against the optimal computed one.
  48763. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48764. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48765. */
  48766. get shadowOrthoScale(): number;
  48767. /**
  48768. * Sets the shadow projection scale against the optimal computed one.
  48769. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48770. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48771. */
  48772. set shadowOrthoScale(value: number);
  48773. /**
  48774. * Automatically compute the projection matrix to best fit (including all the casters)
  48775. * on each frame.
  48776. */
  48777. autoUpdateExtends: boolean;
  48778. /**
  48779. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48780. * on each frame. autoUpdateExtends must be set to true for this to work
  48781. */
  48782. autoCalcShadowZBounds: boolean;
  48783. private _orthoLeft;
  48784. private _orthoRight;
  48785. private _orthoTop;
  48786. private _orthoBottom;
  48787. /**
  48788. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48789. * The directional light is emitted from everywhere in the given direction.
  48790. * It can cast shadows.
  48791. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48792. * @param name The friendly name of the light
  48793. * @param direction The direction of the light
  48794. * @param scene The scene the light belongs to
  48795. */
  48796. constructor(name: string, direction: Vector3, scene: Scene);
  48797. /**
  48798. * Returns the string "DirectionalLight".
  48799. * @return The class name
  48800. */
  48801. getClassName(): string;
  48802. /**
  48803. * Returns the integer 1.
  48804. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48805. */
  48806. getTypeID(): number;
  48807. /**
  48808. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48809. * Returns the DirectionalLight Shadow projection matrix.
  48810. */
  48811. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48812. /**
  48813. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48814. * Returns the DirectionalLight Shadow projection matrix.
  48815. */
  48816. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48817. /**
  48818. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48819. * Returns the DirectionalLight Shadow projection matrix.
  48820. */
  48821. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48822. protected _buildUniformLayout(): void;
  48823. /**
  48824. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48825. * @param effect The effect to update
  48826. * @param lightIndex The index of the light in the effect to update
  48827. * @returns The directional light
  48828. */
  48829. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48830. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48831. /**
  48832. * Gets the minZ used for shadow according to both the scene and the light.
  48833. *
  48834. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48835. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48836. * @param activeCamera The camera we are returning the min for
  48837. * @returns the depth min z
  48838. */
  48839. getDepthMinZ(activeCamera: Camera): number;
  48840. /**
  48841. * Gets the maxZ used for shadow according to both the scene and the light.
  48842. *
  48843. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48844. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48845. * @param activeCamera The camera we are returning the max for
  48846. * @returns the depth max z
  48847. */
  48848. getDepthMaxZ(activeCamera: Camera): number;
  48849. /**
  48850. * Prepares the list of defines specific to the light type.
  48851. * @param defines the list of defines
  48852. * @param lightIndex defines the index of the light for the effect
  48853. */
  48854. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48855. }
  48856. }
  48857. declare module BABYLON {
  48858. /**
  48859. * Class containing static functions to help procedurally build meshes
  48860. */
  48861. export class HemisphereBuilder {
  48862. /**
  48863. * Creates a hemisphere mesh
  48864. * @param name defines the name of the mesh
  48865. * @param options defines the options used to create the mesh
  48866. * @param scene defines the hosting scene
  48867. * @returns the hemisphere mesh
  48868. */
  48869. static CreateHemisphere(name: string, options: {
  48870. segments?: number;
  48871. diameter?: number;
  48872. sideOrientation?: number;
  48873. }, scene: any): Mesh;
  48874. }
  48875. }
  48876. declare module BABYLON {
  48877. /**
  48878. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48879. * These values define a cone of light starting from the position, emitting toward the direction.
  48880. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48881. * and the exponent defines the speed of the decay of the light with distance (reach).
  48882. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48883. */
  48884. export class SpotLight extends ShadowLight {
  48885. private _angle;
  48886. private _innerAngle;
  48887. private _cosHalfAngle;
  48888. private _lightAngleScale;
  48889. private _lightAngleOffset;
  48890. /**
  48891. * Gets the cone angle of the spot light in Radians.
  48892. */
  48893. get angle(): number;
  48894. /**
  48895. * Sets the cone angle of the spot light in Radians.
  48896. */
  48897. set angle(value: number);
  48898. /**
  48899. * Only used in gltf falloff mode, this defines the angle where
  48900. * the directional falloff will start before cutting at angle which could be seen
  48901. * as outer angle.
  48902. */
  48903. get innerAngle(): number;
  48904. /**
  48905. * Only used in gltf falloff mode, this defines the angle where
  48906. * the directional falloff will start before cutting at angle which could be seen
  48907. * as outer angle.
  48908. */
  48909. set innerAngle(value: number);
  48910. private _shadowAngleScale;
  48911. /**
  48912. * Allows scaling the angle of the light for shadow generation only.
  48913. */
  48914. get shadowAngleScale(): number;
  48915. /**
  48916. * Allows scaling the angle of the light for shadow generation only.
  48917. */
  48918. set shadowAngleScale(value: number);
  48919. /**
  48920. * The light decay speed with the distance from the emission spot.
  48921. */
  48922. exponent: number;
  48923. private _projectionTextureMatrix;
  48924. /**
  48925. * Allows reading the projecton texture
  48926. */
  48927. get projectionTextureMatrix(): Matrix;
  48928. protected _projectionTextureLightNear: number;
  48929. /**
  48930. * Gets the near clip of the Spotlight for texture projection.
  48931. */
  48932. get projectionTextureLightNear(): number;
  48933. /**
  48934. * Sets the near clip of the Spotlight for texture projection.
  48935. */
  48936. set projectionTextureLightNear(value: number);
  48937. protected _projectionTextureLightFar: number;
  48938. /**
  48939. * Gets the far clip of the Spotlight for texture projection.
  48940. */
  48941. get projectionTextureLightFar(): number;
  48942. /**
  48943. * Sets the far clip of the Spotlight for texture projection.
  48944. */
  48945. set projectionTextureLightFar(value: number);
  48946. protected _projectionTextureUpDirection: Vector3;
  48947. /**
  48948. * Gets the Up vector of the Spotlight for texture projection.
  48949. */
  48950. get projectionTextureUpDirection(): Vector3;
  48951. /**
  48952. * Sets the Up vector of the Spotlight for texture projection.
  48953. */
  48954. set projectionTextureUpDirection(value: Vector3);
  48955. private _projectionTexture;
  48956. /**
  48957. * Gets the projection texture of the light.
  48958. */
  48959. get projectionTexture(): Nullable<BaseTexture>;
  48960. /**
  48961. * Sets the projection texture of the light.
  48962. */
  48963. set projectionTexture(value: Nullable<BaseTexture>);
  48964. private _projectionTextureViewLightDirty;
  48965. private _projectionTextureProjectionLightDirty;
  48966. private _projectionTextureDirty;
  48967. private _projectionTextureViewTargetVector;
  48968. private _projectionTextureViewLightMatrix;
  48969. private _projectionTextureProjectionLightMatrix;
  48970. private _projectionTextureScalingMatrix;
  48971. /**
  48972. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48973. * It can cast shadows.
  48974. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48975. * @param name The light friendly name
  48976. * @param position The position of the spot light in the scene
  48977. * @param direction The direction of the light in the scene
  48978. * @param angle The cone angle of the light in Radians
  48979. * @param exponent The light decay speed with the distance from the emission spot
  48980. * @param scene The scene the lights belongs to
  48981. */
  48982. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48983. /**
  48984. * Returns the string "SpotLight".
  48985. * @returns the class name
  48986. */
  48987. getClassName(): string;
  48988. /**
  48989. * Returns the integer 2.
  48990. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48991. */
  48992. getTypeID(): number;
  48993. /**
  48994. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48995. */
  48996. protected _setDirection(value: Vector3): void;
  48997. /**
  48998. * Overrides the position setter to recompute the projection texture view light Matrix.
  48999. */
  49000. protected _setPosition(value: Vector3): void;
  49001. /**
  49002. * 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.
  49003. * Returns the SpotLight.
  49004. */
  49005. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49006. protected _computeProjectionTextureViewLightMatrix(): void;
  49007. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49008. /**
  49009. * Main function for light texture projection matrix computing.
  49010. */
  49011. protected _computeProjectionTextureMatrix(): void;
  49012. protected _buildUniformLayout(): void;
  49013. private _computeAngleValues;
  49014. /**
  49015. * Sets the passed Effect "effect" with the Light textures.
  49016. * @param effect The effect to update
  49017. * @param lightIndex The index of the light in the effect to update
  49018. * @returns The light
  49019. */
  49020. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49021. /**
  49022. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49023. * @param effect The effect to update
  49024. * @param lightIndex The index of the light in the effect to update
  49025. * @returns The spot light
  49026. */
  49027. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49028. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49029. /**
  49030. * Disposes the light and the associated resources.
  49031. */
  49032. dispose(): void;
  49033. /**
  49034. * Prepares the list of defines specific to the light type.
  49035. * @param defines the list of defines
  49036. * @param lightIndex defines the index of the light for the effect
  49037. */
  49038. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49039. }
  49040. }
  49041. declare module BABYLON {
  49042. /**
  49043. * Gizmo that enables viewing a light
  49044. */
  49045. export class LightGizmo extends Gizmo {
  49046. private _lightMesh;
  49047. private _material;
  49048. private _cachedPosition;
  49049. private _cachedForward;
  49050. private _attachedMeshParent;
  49051. /**
  49052. * Creates a LightGizmo
  49053. * @param gizmoLayer The utility layer the gizmo will be added to
  49054. */
  49055. constructor(gizmoLayer?: UtilityLayerRenderer);
  49056. private _light;
  49057. /**
  49058. * The light that the gizmo is attached to
  49059. */
  49060. set light(light: Nullable<Light>);
  49061. get light(): Nullable<Light>;
  49062. /**
  49063. * Gets the material used to render the light gizmo
  49064. */
  49065. get material(): StandardMaterial;
  49066. /**
  49067. * @hidden
  49068. * Updates the gizmo to match the attached mesh's position/rotation
  49069. */
  49070. protected _update(): void;
  49071. private static _Scale;
  49072. /**
  49073. * Creates the lines for a light mesh
  49074. */
  49075. private static _CreateLightLines;
  49076. /**
  49077. * Disposes of the light gizmo
  49078. */
  49079. dispose(): void;
  49080. private static _CreateHemisphericLightMesh;
  49081. private static _CreatePointLightMesh;
  49082. private static _CreateSpotLightMesh;
  49083. private static _CreateDirectionalLightMesh;
  49084. }
  49085. }
  49086. declare module BABYLON {
  49087. /** @hidden */
  49088. export var backgroundFragmentDeclaration: {
  49089. name: string;
  49090. shader: string;
  49091. };
  49092. }
  49093. declare module BABYLON {
  49094. /** @hidden */
  49095. export var backgroundUboDeclaration: {
  49096. name: string;
  49097. shader: string;
  49098. };
  49099. }
  49100. declare module BABYLON {
  49101. /** @hidden */
  49102. export var backgroundPixelShader: {
  49103. name: string;
  49104. shader: string;
  49105. };
  49106. }
  49107. declare module BABYLON {
  49108. /** @hidden */
  49109. export var backgroundVertexDeclaration: {
  49110. name: string;
  49111. shader: string;
  49112. };
  49113. }
  49114. declare module BABYLON {
  49115. /** @hidden */
  49116. export var backgroundVertexShader: {
  49117. name: string;
  49118. shader: string;
  49119. };
  49120. }
  49121. declare module BABYLON {
  49122. /**
  49123. * Background material used to create an efficient environement around your scene.
  49124. */
  49125. export class BackgroundMaterial extends PushMaterial {
  49126. /**
  49127. * Standard reflectance value at parallel view angle.
  49128. */
  49129. static StandardReflectance0: number;
  49130. /**
  49131. * Standard reflectance value at grazing angle.
  49132. */
  49133. static StandardReflectance90: number;
  49134. protected _primaryColor: Color3;
  49135. /**
  49136. * Key light Color (multiply against the environement texture)
  49137. */
  49138. primaryColor: Color3;
  49139. protected __perceptualColor: Nullable<Color3>;
  49140. /**
  49141. * Experimental Internal Use Only.
  49142. *
  49143. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49144. * This acts as a helper to set the primary color to a more "human friendly" value.
  49145. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49146. * output color as close as possible from the chosen value.
  49147. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49148. * part of lighting setup.)
  49149. */
  49150. get _perceptualColor(): Nullable<Color3>;
  49151. set _perceptualColor(value: Nullable<Color3>);
  49152. protected _primaryColorShadowLevel: float;
  49153. /**
  49154. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49155. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49156. */
  49157. get primaryColorShadowLevel(): float;
  49158. set primaryColorShadowLevel(value: float);
  49159. protected _primaryColorHighlightLevel: float;
  49160. /**
  49161. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49162. * The primary color is used at the level chosen to define what the white area would look.
  49163. */
  49164. get primaryColorHighlightLevel(): float;
  49165. set primaryColorHighlightLevel(value: float);
  49166. protected _reflectionTexture: Nullable<BaseTexture>;
  49167. /**
  49168. * Reflection Texture used in the material.
  49169. * Should be author in a specific way for the best result (refer to the documentation).
  49170. */
  49171. reflectionTexture: Nullable<BaseTexture>;
  49172. protected _reflectionBlur: float;
  49173. /**
  49174. * Reflection Texture level of blur.
  49175. *
  49176. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49177. * texture twice.
  49178. */
  49179. reflectionBlur: float;
  49180. protected _diffuseTexture: Nullable<BaseTexture>;
  49181. /**
  49182. * Diffuse Texture used in the material.
  49183. * Should be author in a specific way for the best result (refer to the documentation).
  49184. */
  49185. diffuseTexture: Nullable<BaseTexture>;
  49186. protected _shadowLights: Nullable<IShadowLight[]>;
  49187. /**
  49188. * Specify the list of lights casting shadow on the material.
  49189. * All scene shadow lights will be included if null.
  49190. */
  49191. shadowLights: Nullable<IShadowLight[]>;
  49192. protected _shadowLevel: float;
  49193. /**
  49194. * Helps adjusting the shadow to a softer level if required.
  49195. * 0 means black shadows and 1 means no shadows.
  49196. */
  49197. shadowLevel: float;
  49198. protected _sceneCenter: Vector3;
  49199. /**
  49200. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49201. * It is usually zero but might be interesting to modify according to your setup.
  49202. */
  49203. sceneCenter: Vector3;
  49204. protected _opacityFresnel: boolean;
  49205. /**
  49206. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49207. * This helps ensuring a nice transition when the camera goes under the ground.
  49208. */
  49209. opacityFresnel: boolean;
  49210. protected _reflectionFresnel: boolean;
  49211. /**
  49212. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49213. * This helps adding a mirror texture on the ground.
  49214. */
  49215. reflectionFresnel: boolean;
  49216. protected _reflectionFalloffDistance: number;
  49217. /**
  49218. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49219. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49220. */
  49221. reflectionFalloffDistance: number;
  49222. protected _reflectionAmount: number;
  49223. /**
  49224. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49225. */
  49226. reflectionAmount: number;
  49227. protected _reflectionReflectance0: number;
  49228. /**
  49229. * This specifies the weight of the reflection at grazing angle.
  49230. */
  49231. reflectionReflectance0: number;
  49232. protected _reflectionReflectance90: number;
  49233. /**
  49234. * This specifies the weight of the reflection at a perpendicular point of view.
  49235. */
  49236. reflectionReflectance90: number;
  49237. /**
  49238. * Sets the reflection reflectance fresnel values according to the default standard
  49239. * empirically know to work well :-)
  49240. */
  49241. set reflectionStandardFresnelWeight(value: number);
  49242. protected _useRGBColor: boolean;
  49243. /**
  49244. * Helps to directly use the maps channels instead of their level.
  49245. */
  49246. useRGBColor: boolean;
  49247. protected _enableNoise: boolean;
  49248. /**
  49249. * This helps reducing the banding effect that could occur on the background.
  49250. */
  49251. enableNoise: boolean;
  49252. /**
  49253. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49254. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49255. * Recommended to be keep at 1.0 except for special cases.
  49256. */
  49257. get fovMultiplier(): number;
  49258. set fovMultiplier(value: number);
  49259. private _fovMultiplier;
  49260. /**
  49261. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49262. */
  49263. useEquirectangularFOV: boolean;
  49264. private _maxSimultaneousLights;
  49265. /**
  49266. * Number of Simultaneous lights allowed on the material.
  49267. */
  49268. maxSimultaneousLights: int;
  49269. /**
  49270. * Default configuration related to image processing available in the Background Material.
  49271. */
  49272. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49273. /**
  49274. * Keep track of the image processing observer to allow dispose and replace.
  49275. */
  49276. private _imageProcessingObserver;
  49277. /**
  49278. * Attaches a new image processing configuration to the PBR Material.
  49279. * @param configuration (if null the scene configuration will be use)
  49280. */
  49281. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49282. /**
  49283. * Gets the image processing configuration used either in this material.
  49284. */
  49285. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49286. /**
  49287. * Sets the Default image processing configuration used either in the this material.
  49288. *
  49289. * If sets to null, the scene one is in use.
  49290. */
  49291. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49292. /**
  49293. * Gets wether the color curves effect is enabled.
  49294. */
  49295. get cameraColorCurvesEnabled(): boolean;
  49296. /**
  49297. * Sets wether the color curves effect is enabled.
  49298. */
  49299. set cameraColorCurvesEnabled(value: boolean);
  49300. /**
  49301. * Gets wether the color grading effect is enabled.
  49302. */
  49303. get cameraColorGradingEnabled(): boolean;
  49304. /**
  49305. * Gets wether the color grading effect is enabled.
  49306. */
  49307. set cameraColorGradingEnabled(value: boolean);
  49308. /**
  49309. * Gets wether tonemapping is enabled or not.
  49310. */
  49311. get cameraToneMappingEnabled(): boolean;
  49312. /**
  49313. * Sets wether tonemapping is enabled or not
  49314. */
  49315. set cameraToneMappingEnabled(value: boolean);
  49316. /**
  49317. * The camera exposure used on this material.
  49318. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49319. * This corresponds to a photographic exposure.
  49320. */
  49321. get cameraExposure(): float;
  49322. /**
  49323. * The camera exposure used on this material.
  49324. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49325. * This corresponds to a photographic exposure.
  49326. */
  49327. set cameraExposure(value: float);
  49328. /**
  49329. * Gets The camera contrast used on this material.
  49330. */
  49331. get cameraContrast(): float;
  49332. /**
  49333. * Sets The camera contrast used on this material.
  49334. */
  49335. set cameraContrast(value: float);
  49336. /**
  49337. * Gets the Color Grading 2D Lookup Texture.
  49338. */
  49339. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49340. /**
  49341. * Sets the Color Grading 2D Lookup Texture.
  49342. */
  49343. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49344. /**
  49345. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49346. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49347. * 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;
  49348. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49349. */
  49350. get cameraColorCurves(): Nullable<ColorCurves>;
  49351. /**
  49352. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49353. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49354. * 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;
  49355. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49356. */
  49357. set cameraColorCurves(value: Nullable<ColorCurves>);
  49358. /**
  49359. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49360. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49361. */
  49362. switchToBGR: boolean;
  49363. private _renderTargets;
  49364. private _reflectionControls;
  49365. private _white;
  49366. private _primaryShadowColor;
  49367. private _primaryHighlightColor;
  49368. /**
  49369. * Instantiates a Background Material in the given scene
  49370. * @param name The friendly name of the material
  49371. * @param scene The scene to add the material to
  49372. */
  49373. constructor(name: string, scene: Scene);
  49374. /**
  49375. * Gets a boolean indicating that current material needs to register RTT
  49376. */
  49377. get hasRenderTargetTextures(): boolean;
  49378. /**
  49379. * The entire material has been created in order to prevent overdraw.
  49380. * @returns false
  49381. */
  49382. needAlphaTesting(): boolean;
  49383. /**
  49384. * The entire material has been created in order to prevent overdraw.
  49385. * @returns true if blending is enable
  49386. */
  49387. needAlphaBlending(): boolean;
  49388. /**
  49389. * Checks wether the material is ready to be rendered for a given mesh.
  49390. * @param mesh The mesh to render
  49391. * @param subMesh The submesh to check against
  49392. * @param useInstances Specify wether or not the material is used with instances
  49393. * @returns true if all the dependencies are ready (Textures, Effects...)
  49394. */
  49395. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49396. /**
  49397. * Compute the primary color according to the chosen perceptual color.
  49398. */
  49399. private _computePrimaryColorFromPerceptualColor;
  49400. /**
  49401. * Compute the highlights and shadow colors according to their chosen levels.
  49402. */
  49403. private _computePrimaryColors;
  49404. /**
  49405. * Build the uniform buffer used in the material.
  49406. */
  49407. buildUniformLayout(): void;
  49408. /**
  49409. * Unbind the material.
  49410. */
  49411. unbind(): void;
  49412. /**
  49413. * Bind only the world matrix to the material.
  49414. * @param world The world matrix to bind.
  49415. */
  49416. bindOnlyWorldMatrix(world: Matrix): void;
  49417. /**
  49418. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49419. * @param world The world matrix to bind.
  49420. * @param subMesh The submesh to bind for.
  49421. */
  49422. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49423. /**
  49424. * Checks to see if a texture is used in the material.
  49425. * @param texture - Base texture to use.
  49426. * @returns - Boolean specifying if a texture is used in the material.
  49427. */
  49428. hasTexture(texture: BaseTexture): boolean;
  49429. /**
  49430. * Dispose the material.
  49431. * @param forceDisposeEffect Force disposal of the associated effect.
  49432. * @param forceDisposeTextures Force disposal of the associated textures.
  49433. */
  49434. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49435. /**
  49436. * Clones the material.
  49437. * @param name The cloned name.
  49438. * @returns The cloned material.
  49439. */
  49440. clone(name: string): BackgroundMaterial;
  49441. /**
  49442. * Serializes the current material to its JSON representation.
  49443. * @returns The JSON representation.
  49444. */
  49445. serialize(): any;
  49446. /**
  49447. * Gets the class name of the material
  49448. * @returns "BackgroundMaterial"
  49449. */
  49450. getClassName(): string;
  49451. /**
  49452. * Parse a JSON input to create back a background material.
  49453. * @param source The JSON data to parse
  49454. * @param scene The scene to create the parsed material in
  49455. * @param rootUrl The root url of the assets the material depends upon
  49456. * @returns the instantiated BackgroundMaterial.
  49457. */
  49458. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49459. }
  49460. }
  49461. declare module BABYLON {
  49462. /**
  49463. * Represents the different options available during the creation of
  49464. * a Environment helper.
  49465. *
  49466. * This can control the default ground, skybox and image processing setup of your scene.
  49467. */
  49468. export interface IEnvironmentHelperOptions {
  49469. /**
  49470. * Specifies whether or not to create a ground.
  49471. * True by default.
  49472. */
  49473. createGround: boolean;
  49474. /**
  49475. * Specifies the ground size.
  49476. * 15 by default.
  49477. */
  49478. groundSize: number;
  49479. /**
  49480. * The texture used on the ground for the main color.
  49481. * Comes from the BabylonJS CDN by default.
  49482. *
  49483. * Remarks: Can be either a texture or a url.
  49484. */
  49485. groundTexture: string | BaseTexture;
  49486. /**
  49487. * The color mixed in the ground texture by default.
  49488. * BabylonJS clearColor by default.
  49489. */
  49490. groundColor: Color3;
  49491. /**
  49492. * Specifies the ground opacity.
  49493. * 1 by default.
  49494. */
  49495. groundOpacity: number;
  49496. /**
  49497. * Enables the ground to receive shadows.
  49498. * True by default.
  49499. */
  49500. enableGroundShadow: boolean;
  49501. /**
  49502. * Helps preventing the shadow to be fully black on the ground.
  49503. * 0.5 by default.
  49504. */
  49505. groundShadowLevel: number;
  49506. /**
  49507. * Creates a mirror texture attach to the ground.
  49508. * false by default.
  49509. */
  49510. enableGroundMirror: boolean;
  49511. /**
  49512. * Specifies the ground mirror size ratio.
  49513. * 0.3 by default as the default kernel is 64.
  49514. */
  49515. groundMirrorSizeRatio: number;
  49516. /**
  49517. * Specifies the ground mirror blur kernel size.
  49518. * 64 by default.
  49519. */
  49520. groundMirrorBlurKernel: number;
  49521. /**
  49522. * Specifies the ground mirror visibility amount.
  49523. * 1 by default
  49524. */
  49525. groundMirrorAmount: number;
  49526. /**
  49527. * Specifies the ground mirror reflectance weight.
  49528. * This uses the standard weight of the background material to setup the fresnel effect
  49529. * of the mirror.
  49530. * 1 by default.
  49531. */
  49532. groundMirrorFresnelWeight: number;
  49533. /**
  49534. * Specifies the ground mirror Falloff distance.
  49535. * This can helps reducing the size of the reflection.
  49536. * 0 by Default.
  49537. */
  49538. groundMirrorFallOffDistance: number;
  49539. /**
  49540. * Specifies the ground mirror texture type.
  49541. * Unsigned Int by Default.
  49542. */
  49543. groundMirrorTextureType: number;
  49544. /**
  49545. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49546. * the shown objects.
  49547. */
  49548. groundYBias: number;
  49549. /**
  49550. * Specifies whether or not to create a skybox.
  49551. * True by default.
  49552. */
  49553. createSkybox: boolean;
  49554. /**
  49555. * Specifies the skybox size.
  49556. * 20 by default.
  49557. */
  49558. skyboxSize: number;
  49559. /**
  49560. * The texture used on the skybox for the main color.
  49561. * Comes from the BabylonJS CDN by default.
  49562. *
  49563. * Remarks: Can be either a texture or a url.
  49564. */
  49565. skyboxTexture: string | BaseTexture;
  49566. /**
  49567. * The color mixed in the skybox texture by default.
  49568. * BabylonJS clearColor by default.
  49569. */
  49570. skyboxColor: Color3;
  49571. /**
  49572. * The background rotation around the Y axis of the scene.
  49573. * This helps aligning the key lights of your scene with the background.
  49574. * 0 by default.
  49575. */
  49576. backgroundYRotation: number;
  49577. /**
  49578. * Compute automatically the size of the elements to best fit with the scene.
  49579. */
  49580. sizeAuto: boolean;
  49581. /**
  49582. * Default position of the rootMesh if autoSize is not true.
  49583. */
  49584. rootPosition: Vector3;
  49585. /**
  49586. * Sets up the image processing in the scene.
  49587. * true by default.
  49588. */
  49589. setupImageProcessing: boolean;
  49590. /**
  49591. * The texture used as your environment texture in the scene.
  49592. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49593. *
  49594. * Remarks: Can be either a texture or a url.
  49595. */
  49596. environmentTexture: string | BaseTexture;
  49597. /**
  49598. * The value of the exposure to apply to the scene.
  49599. * 0.6 by default if setupImageProcessing is true.
  49600. */
  49601. cameraExposure: number;
  49602. /**
  49603. * The value of the contrast to apply to the scene.
  49604. * 1.6 by default if setupImageProcessing is true.
  49605. */
  49606. cameraContrast: number;
  49607. /**
  49608. * Specifies whether or not tonemapping should be enabled in the scene.
  49609. * true by default if setupImageProcessing is true.
  49610. */
  49611. toneMappingEnabled: boolean;
  49612. }
  49613. /**
  49614. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49615. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49616. * It also helps with the default setup of your imageProcessing configuration.
  49617. */
  49618. export class EnvironmentHelper {
  49619. /**
  49620. * Default ground texture URL.
  49621. */
  49622. private static _groundTextureCDNUrl;
  49623. /**
  49624. * Default skybox texture URL.
  49625. */
  49626. private static _skyboxTextureCDNUrl;
  49627. /**
  49628. * Default environment texture URL.
  49629. */
  49630. private static _environmentTextureCDNUrl;
  49631. /**
  49632. * Creates the default options for the helper.
  49633. */
  49634. private static _getDefaultOptions;
  49635. private _rootMesh;
  49636. /**
  49637. * Gets the root mesh created by the helper.
  49638. */
  49639. get rootMesh(): Mesh;
  49640. private _skybox;
  49641. /**
  49642. * Gets the skybox created by the helper.
  49643. */
  49644. get skybox(): Nullable<Mesh>;
  49645. private _skyboxTexture;
  49646. /**
  49647. * Gets the skybox texture created by the helper.
  49648. */
  49649. get skyboxTexture(): Nullable<BaseTexture>;
  49650. private _skyboxMaterial;
  49651. /**
  49652. * Gets the skybox material created by the helper.
  49653. */
  49654. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49655. private _ground;
  49656. /**
  49657. * Gets the ground mesh created by the helper.
  49658. */
  49659. get ground(): Nullable<Mesh>;
  49660. private _groundTexture;
  49661. /**
  49662. * Gets the ground texture created by the helper.
  49663. */
  49664. get groundTexture(): Nullable<BaseTexture>;
  49665. private _groundMirror;
  49666. /**
  49667. * Gets the ground mirror created by the helper.
  49668. */
  49669. get groundMirror(): Nullable<MirrorTexture>;
  49670. /**
  49671. * Gets the ground mirror render list to helps pushing the meshes
  49672. * you wish in the ground reflection.
  49673. */
  49674. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49675. private _groundMaterial;
  49676. /**
  49677. * Gets the ground material created by the helper.
  49678. */
  49679. get groundMaterial(): Nullable<BackgroundMaterial>;
  49680. /**
  49681. * Stores the creation options.
  49682. */
  49683. private readonly _scene;
  49684. private _options;
  49685. /**
  49686. * This observable will be notified with any error during the creation of the environment,
  49687. * mainly texture creation errors.
  49688. */
  49689. onErrorObservable: Observable<{
  49690. message?: string;
  49691. exception?: any;
  49692. }>;
  49693. /**
  49694. * constructor
  49695. * @param options Defines the options we want to customize the helper
  49696. * @param scene The scene to add the material to
  49697. */
  49698. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49699. /**
  49700. * Updates the background according to the new options
  49701. * @param options
  49702. */
  49703. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49704. /**
  49705. * Sets the primary color of all the available elements.
  49706. * @param color the main color to affect to the ground and the background
  49707. */
  49708. setMainColor(color: Color3): void;
  49709. /**
  49710. * Setup the image processing according to the specified options.
  49711. */
  49712. private _setupImageProcessing;
  49713. /**
  49714. * Setup the environment texture according to the specified options.
  49715. */
  49716. private _setupEnvironmentTexture;
  49717. /**
  49718. * Setup the background according to the specified options.
  49719. */
  49720. private _setupBackground;
  49721. /**
  49722. * Get the scene sizes according to the setup.
  49723. */
  49724. private _getSceneSize;
  49725. /**
  49726. * Setup the ground according to the specified options.
  49727. */
  49728. private _setupGround;
  49729. /**
  49730. * Setup the ground material according to the specified options.
  49731. */
  49732. private _setupGroundMaterial;
  49733. /**
  49734. * Setup the ground diffuse texture according to the specified options.
  49735. */
  49736. private _setupGroundDiffuseTexture;
  49737. /**
  49738. * Setup the ground mirror texture according to the specified options.
  49739. */
  49740. private _setupGroundMirrorTexture;
  49741. /**
  49742. * Setup the ground to receive the mirror texture.
  49743. */
  49744. private _setupMirrorInGroundMaterial;
  49745. /**
  49746. * Setup the skybox according to the specified options.
  49747. */
  49748. private _setupSkybox;
  49749. /**
  49750. * Setup the skybox material according to the specified options.
  49751. */
  49752. private _setupSkyboxMaterial;
  49753. /**
  49754. * Setup the skybox reflection texture according to the specified options.
  49755. */
  49756. private _setupSkyboxReflectionTexture;
  49757. private _errorHandler;
  49758. /**
  49759. * Dispose all the elements created by the Helper.
  49760. */
  49761. dispose(): void;
  49762. }
  49763. }
  49764. declare module BABYLON {
  49765. /**
  49766. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49767. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49768. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49769. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49770. */
  49771. export class PhotoDome extends TransformNode {
  49772. /**
  49773. * Define the image as a Monoscopic panoramic 360 image.
  49774. */
  49775. static readonly MODE_MONOSCOPIC: number;
  49776. /**
  49777. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49778. */
  49779. static readonly MODE_TOPBOTTOM: number;
  49780. /**
  49781. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49782. */
  49783. static readonly MODE_SIDEBYSIDE: number;
  49784. private _useDirectMapping;
  49785. /**
  49786. * The texture being displayed on the sphere
  49787. */
  49788. protected _photoTexture: Texture;
  49789. /**
  49790. * Gets or sets the texture being displayed on the sphere
  49791. */
  49792. get photoTexture(): Texture;
  49793. set photoTexture(value: Texture);
  49794. /**
  49795. * Observable raised when an error occured while loading the 360 image
  49796. */
  49797. onLoadErrorObservable: Observable<string>;
  49798. /**
  49799. * The skybox material
  49800. */
  49801. protected _material: BackgroundMaterial;
  49802. /**
  49803. * The surface used for the skybox
  49804. */
  49805. protected _mesh: Mesh;
  49806. /**
  49807. * Gets the mesh used for the skybox.
  49808. */
  49809. get mesh(): Mesh;
  49810. /**
  49811. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49812. * Also see the options.resolution property.
  49813. */
  49814. get fovMultiplier(): number;
  49815. set fovMultiplier(value: number);
  49816. private _imageMode;
  49817. /**
  49818. * Gets or set the current video mode for the video. It can be:
  49819. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49820. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49821. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49822. */
  49823. get imageMode(): number;
  49824. set imageMode(value: number);
  49825. /**
  49826. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49827. * @param name Element's name, child elements will append suffixes for their own names.
  49828. * @param urlsOfPhoto defines the url of the photo to display
  49829. * @param options defines an object containing optional or exposed sub element properties
  49830. * @param onError defines a callback called when an error occured while loading the texture
  49831. */
  49832. constructor(name: string, urlOfPhoto: string, options: {
  49833. resolution?: number;
  49834. size?: number;
  49835. useDirectMapping?: boolean;
  49836. faceForward?: boolean;
  49837. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49838. private _onBeforeCameraRenderObserver;
  49839. private _changeImageMode;
  49840. /**
  49841. * Releases resources associated with this node.
  49842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49844. */
  49845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49846. }
  49847. }
  49848. declare module BABYLON {
  49849. /**
  49850. * Class used to host RGBD texture specific utilities
  49851. */
  49852. export class RGBDTextureTools {
  49853. /**
  49854. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49855. * @param texture the texture to expand.
  49856. */
  49857. static ExpandRGBDTexture(texture: Texture): void;
  49858. }
  49859. }
  49860. declare module BABYLON {
  49861. /**
  49862. * Class used to host texture specific utilities
  49863. */
  49864. export class BRDFTextureTools {
  49865. /**
  49866. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49867. * @param scene defines the hosting scene
  49868. * @returns the environment BRDF texture
  49869. */
  49870. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49871. private static _environmentBRDFBase64Texture;
  49872. }
  49873. }
  49874. declare module BABYLON {
  49875. /**
  49876. * @hidden
  49877. */
  49878. export interface IMaterialClearCoatDefines {
  49879. CLEARCOAT: boolean;
  49880. CLEARCOAT_DEFAULTIOR: boolean;
  49881. CLEARCOAT_TEXTURE: boolean;
  49882. CLEARCOAT_TEXTUREDIRECTUV: number;
  49883. CLEARCOAT_BUMP: boolean;
  49884. CLEARCOAT_BUMPDIRECTUV: number;
  49885. CLEARCOAT_TINT: boolean;
  49886. CLEARCOAT_TINT_TEXTURE: boolean;
  49887. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49888. /** @hidden */
  49889. _areTexturesDirty: boolean;
  49890. }
  49891. /**
  49892. * Define the code related to the clear coat parameters of the pbr material.
  49893. */
  49894. export class PBRClearCoatConfiguration {
  49895. /**
  49896. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49897. * The default fits with a polyurethane material.
  49898. */
  49899. private static readonly _DefaultIndexOfRefraction;
  49900. private _isEnabled;
  49901. /**
  49902. * Defines if the clear coat is enabled in the material.
  49903. */
  49904. isEnabled: boolean;
  49905. /**
  49906. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49907. */
  49908. intensity: number;
  49909. /**
  49910. * Defines the clear coat layer roughness.
  49911. */
  49912. roughness: number;
  49913. private _indexOfRefraction;
  49914. /**
  49915. * Defines the index of refraction of the clear coat.
  49916. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49917. * The default fits with a polyurethane material.
  49918. * Changing the default value is more performance intensive.
  49919. */
  49920. indexOfRefraction: number;
  49921. private _texture;
  49922. /**
  49923. * Stores the clear coat values in a texture.
  49924. */
  49925. texture: Nullable<BaseTexture>;
  49926. private _bumpTexture;
  49927. /**
  49928. * Define the clear coat specific bump texture.
  49929. */
  49930. bumpTexture: Nullable<BaseTexture>;
  49931. private _isTintEnabled;
  49932. /**
  49933. * Defines if the clear coat tint is enabled in the material.
  49934. */
  49935. isTintEnabled: boolean;
  49936. /**
  49937. * Defines the clear coat tint of the material.
  49938. * This is only use if tint is enabled
  49939. */
  49940. tintColor: Color3;
  49941. /**
  49942. * Defines the distance at which the tint color should be found in the
  49943. * clear coat media.
  49944. * This is only use if tint is enabled
  49945. */
  49946. tintColorAtDistance: number;
  49947. /**
  49948. * Defines the clear coat layer thickness.
  49949. * This is only use if tint is enabled
  49950. */
  49951. tintThickness: number;
  49952. private _tintTexture;
  49953. /**
  49954. * Stores the clear tint values in a texture.
  49955. * rgb is tint
  49956. * a is a thickness factor
  49957. */
  49958. tintTexture: Nullable<BaseTexture>;
  49959. /** @hidden */
  49960. private _internalMarkAllSubMeshesAsTexturesDirty;
  49961. /** @hidden */
  49962. _markAllSubMeshesAsTexturesDirty(): void;
  49963. /**
  49964. * Instantiate a new istance of clear coat configuration.
  49965. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49966. */
  49967. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49968. /**
  49969. * Gets wehter the submesh is ready to be used or not.
  49970. * @param defines the list of "defines" to update.
  49971. * @param scene defines the scene the material belongs to.
  49972. * @param engine defines the engine the material belongs to.
  49973. * @param disableBumpMap defines wether the material disables bump or not.
  49974. * @returns - boolean indicating that the submesh is ready or not.
  49975. */
  49976. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49977. /**
  49978. * Checks to see if a texture is used in the material.
  49979. * @param defines the list of "defines" to update.
  49980. * @param scene defines the scene to the material belongs to.
  49981. */
  49982. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49983. /**
  49984. * Binds the material data.
  49985. * @param uniformBuffer defines the Uniform buffer to fill in.
  49986. * @param scene defines the scene the material belongs to.
  49987. * @param engine defines the engine the material belongs to.
  49988. * @param disableBumpMap defines wether the material disables bump or not.
  49989. * @param isFrozen defines wether the material is frozen or not.
  49990. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49991. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49992. */
  49993. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49994. /**
  49995. * Checks to see if a texture is used in the material.
  49996. * @param texture - Base texture to use.
  49997. * @returns - Boolean specifying if a texture is used in the material.
  49998. */
  49999. hasTexture(texture: BaseTexture): boolean;
  50000. /**
  50001. * Returns an array of the actively used textures.
  50002. * @param activeTextures Array of BaseTextures
  50003. */
  50004. getActiveTextures(activeTextures: BaseTexture[]): void;
  50005. /**
  50006. * Returns the animatable textures.
  50007. * @param animatables Array of animatable textures.
  50008. */
  50009. getAnimatables(animatables: IAnimatable[]): void;
  50010. /**
  50011. * Disposes the resources of the material.
  50012. * @param forceDisposeTextures - Forces the disposal of all textures.
  50013. */
  50014. dispose(forceDisposeTextures?: boolean): void;
  50015. /**
  50016. * Get the current class name of the texture useful for serialization or dynamic coding.
  50017. * @returns "PBRClearCoatConfiguration"
  50018. */
  50019. getClassName(): string;
  50020. /**
  50021. * Add fallbacks to the effect fallbacks list.
  50022. * @param defines defines the Base texture to use.
  50023. * @param fallbacks defines the current fallback list.
  50024. * @param currentRank defines the current fallback rank.
  50025. * @returns the new fallback rank.
  50026. */
  50027. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50028. /**
  50029. * Add the required uniforms to the current list.
  50030. * @param uniforms defines the current uniform list.
  50031. */
  50032. static AddUniforms(uniforms: string[]): void;
  50033. /**
  50034. * Add the required samplers to the current list.
  50035. * @param samplers defines the current sampler list.
  50036. */
  50037. static AddSamplers(samplers: string[]): void;
  50038. /**
  50039. * Add the required uniforms to the current buffer.
  50040. * @param uniformBuffer defines the current uniform buffer.
  50041. */
  50042. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50043. /**
  50044. * Makes a duplicate of the current configuration into another one.
  50045. * @param clearCoatConfiguration define the config where to copy the info
  50046. */
  50047. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50048. /**
  50049. * Serializes this clear coat configuration.
  50050. * @returns - An object with the serialized config.
  50051. */
  50052. serialize(): any;
  50053. /**
  50054. * Parses a anisotropy Configuration from a serialized object.
  50055. * @param source - Serialized object.
  50056. * @param scene Defines the scene we are parsing for
  50057. * @param rootUrl Defines the rootUrl to load from
  50058. */
  50059. parse(source: any, scene: Scene, rootUrl: string): void;
  50060. }
  50061. }
  50062. declare module BABYLON {
  50063. /**
  50064. * @hidden
  50065. */
  50066. export interface IMaterialAnisotropicDefines {
  50067. ANISOTROPIC: boolean;
  50068. ANISOTROPIC_TEXTURE: boolean;
  50069. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50070. MAINUV1: boolean;
  50071. _areTexturesDirty: boolean;
  50072. _needUVs: boolean;
  50073. }
  50074. /**
  50075. * Define the code related to the anisotropic parameters of the pbr material.
  50076. */
  50077. export class PBRAnisotropicConfiguration {
  50078. private _isEnabled;
  50079. /**
  50080. * Defines if the anisotropy is enabled in the material.
  50081. */
  50082. isEnabled: boolean;
  50083. /**
  50084. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50085. */
  50086. intensity: number;
  50087. /**
  50088. * Defines if the effect is along the tangents, bitangents or in between.
  50089. * By default, the effect is "strectching" the highlights along the tangents.
  50090. */
  50091. direction: Vector2;
  50092. private _texture;
  50093. /**
  50094. * Stores the anisotropy values in a texture.
  50095. * rg is direction (like normal from -1 to 1)
  50096. * b is a intensity
  50097. */
  50098. texture: Nullable<BaseTexture>;
  50099. /** @hidden */
  50100. private _internalMarkAllSubMeshesAsTexturesDirty;
  50101. /** @hidden */
  50102. _markAllSubMeshesAsTexturesDirty(): void;
  50103. /**
  50104. * Instantiate a new istance of anisotropy configuration.
  50105. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50106. */
  50107. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50108. /**
  50109. * Specifies that the submesh is ready to be used.
  50110. * @param defines the list of "defines" to update.
  50111. * @param scene defines the scene the material belongs to.
  50112. * @returns - boolean indicating that the submesh is ready or not.
  50113. */
  50114. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50115. /**
  50116. * Checks to see if a texture is used in the material.
  50117. * @param defines the list of "defines" to update.
  50118. * @param mesh the mesh we are preparing the defines for.
  50119. * @param scene defines the scene the material belongs to.
  50120. */
  50121. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50122. /**
  50123. * Binds the material data.
  50124. * @param uniformBuffer defines the Uniform buffer to fill in.
  50125. * @param scene defines the scene the material belongs to.
  50126. * @param isFrozen defines wether the material is frozen or not.
  50127. */
  50128. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50129. /**
  50130. * Checks to see if a texture is used in the material.
  50131. * @param texture - Base texture to use.
  50132. * @returns - Boolean specifying if a texture is used in the material.
  50133. */
  50134. hasTexture(texture: BaseTexture): boolean;
  50135. /**
  50136. * Returns an array of the actively used textures.
  50137. * @param activeTextures Array of BaseTextures
  50138. */
  50139. getActiveTextures(activeTextures: BaseTexture[]): void;
  50140. /**
  50141. * Returns the animatable textures.
  50142. * @param animatables Array of animatable textures.
  50143. */
  50144. getAnimatables(animatables: IAnimatable[]): void;
  50145. /**
  50146. * Disposes the resources of the material.
  50147. * @param forceDisposeTextures - Forces the disposal of all textures.
  50148. */
  50149. dispose(forceDisposeTextures?: boolean): void;
  50150. /**
  50151. * Get the current class name of the texture useful for serialization or dynamic coding.
  50152. * @returns "PBRAnisotropicConfiguration"
  50153. */
  50154. getClassName(): string;
  50155. /**
  50156. * Add fallbacks to the effect fallbacks list.
  50157. * @param defines defines the Base texture to use.
  50158. * @param fallbacks defines the current fallback list.
  50159. * @param currentRank defines the current fallback rank.
  50160. * @returns the new fallback rank.
  50161. */
  50162. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50163. /**
  50164. * Add the required uniforms to the current list.
  50165. * @param uniforms defines the current uniform list.
  50166. */
  50167. static AddUniforms(uniforms: string[]): void;
  50168. /**
  50169. * Add the required uniforms to the current buffer.
  50170. * @param uniformBuffer defines the current uniform buffer.
  50171. */
  50172. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50173. /**
  50174. * Add the required samplers to the current list.
  50175. * @param samplers defines the current sampler list.
  50176. */
  50177. static AddSamplers(samplers: string[]): void;
  50178. /**
  50179. * Makes a duplicate of the current configuration into another one.
  50180. * @param anisotropicConfiguration define the config where to copy the info
  50181. */
  50182. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50183. /**
  50184. * Serializes this anisotropy configuration.
  50185. * @returns - An object with the serialized config.
  50186. */
  50187. serialize(): any;
  50188. /**
  50189. * Parses a anisotropy Configuration from a serialized object.
  50190. * @param source - Serialized object.
  50191. * @param scene Defines the scene we are parsing for
  50192. * @param rootUrl Defines the rootUrl to load from
  50193. */
  50194. parse(source: any, scene: Scene, rootUrl: string): void;
  50195. }
  50196. }
  50197. declare module BABYLON {
  50198. /**
  50199. * @hidden
  50200. */
  50201. export interface IMaterialBRDFDefines {
  50202. BRDF_V_HEIGHT_CORRELATED: boolean;
  50203. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50204. SPHERICAL_HARMONICS: boolean;
  50205. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50206. /** @hidden */
  50207. _areMiscDirty: boolean;
  50208. }
  50209. /**
  50210. * Define the code related to the BRDF parameters of the pbr material.
  50211. */
  50212. export class PBRBRDFConfiguration {
  50213. /**
  50214. * Default value used for the energy conservation.
  50215. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50216. */
  50217. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50218. /**
  50219. * Default value used for the Smith Visibility Height Correlated mode.
  50220. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50221. */
  50222. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50223. /**
  50224. * Default value used for the IBL diffuse part.
  50225. * This can help switching back to the polynomials mode globally which is a tiny bit
  50226. * less GPU intensive at the drawback of a lower quality.
  50227. */
  50228. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50229. /**
  50230. * Default value used for activating energy conservation for the specular workflow.
  50231. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50232. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50233. */
  50234. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50235. private _useEnergyConservation;
  50236. /**
  50237. * Defines if the material uses energy conservation.
  50238. */
  50239. useEnergyConservation: boolean;
  50240. private _useSmithVisibilityHeightCorrelated;
  50241. /**
  50242. * LEGACY Mode set to false
  50243. * Defines if the material uses height smith correlated visibility term.
  50244. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50245. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50246. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50247. * Not relying on height correlated will also disable energy conservation.
  50248. */
  50249. useSmithVisibilityHeightCorrelated: boolean;
  50250. private _useSphericalHarmonics;
  50251. /**
  50252. * LEGACY Mode set to false
  50253. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50254. * diffuse part of the IBL.
  50255. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50256. * to the ground truth.
  50257. */
  50258. useSphericalHarmonics: boolean;
  50259. private _useSpecularGlossinessInputEnergyConservation;
  50260. /**
  50261. * Defines if the material uses energy conservation, when the specular workflow is active.
  50262. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50263. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50264. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50265. */
  50266. useSpecularGlossinessInputEnergyConservation: boolean;
  50267. /** @hidden */
  50268. private _internalMarkAllSubMeshesAsMiscDirty;
  50269. /** @hidden */
  50270. _markAllSubMeshesAsMiscDirty(): void;
  50271. /**
  50272. * Instantiate a new istance of clear coat configuration.
  50273. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50274. */
  50275. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50276. /**
  50277. * Checks to see if a texture is used in the material.
  50278. * @param defines the list of "defines" to update.
  50279. */
  50280. prepareDefines(defines: IMaterialBRDFDefines): void;
  50281. /**
  50282. * Get the current class name of the texture useful for serialization or dynamic coding.
  50283. * @returns "PBRClearCoatConfiguration"
  50284. */
  50285. getClassName(): string;
  50286. /**
  50287. * Makes a duplicate of the current configuration into another one.
  50288. * @param brdfConfiguration define the config where to copy the info
  50289. */
  50290. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50291. /**
  50292. * Serializes this BRDF configuration.
  50293. * @returns - An object with the serialized config.
  50294. */
  50295. serialize(): any;
  50296. /**
  50297. * Parses a anisotropy Configuration from a serialized object.
  50298. * @param source - Serialized object.
  50299. * @param scene Defines the scene we are parsing for
  50300. * @param rootUrl Defines the rootUrl to load from
  50301. */
  50302. parse(source: any, scene: Scene, rootUrl: string): void;
  50303. }
  50304. }
  50305. declare module BABYLON {
  50306. /**
  50307. * @hidden
  50308. */
  50309. export interface IMaterialSheenDefines {
  50310. SHEEN: boolean;
  50311. SHEEN_TEXTURE: boolean;
  50312. SHEEN_TEXTUREDIRECTUV: number;
  50313. SHEEN_LINKWITHALBEDO: boolean;
  50314. /** @hidden */
  50315. _areTexturesDirty: boolean;
  50316. }
  50317. /**
  50318. * Define the code related to the Sheen parameters of the pbr material.
  50319. */
  50320. export class PBRSheenConfiguration {
  50321. private _isEnabled;
  50322. /**
  50323. * Defines if the material uses sheen.
  50324. */
  50325. isEnabled: boolean;
  50326. private _linkSheenWithAlbedo;
  50327. /**
  50328. * Defines if the sheen is linked to the sheen color.
  50329. */
  50330. linkSheenWithAlbedo: boolean;
  50331. /**
  50332. * Defines the sheen intensity.
  50333. */
  50334. intensity: number;
  50335. /**
  50336. * Defines the sheen color.
  50337. */
  50338. color: Color3;
  50339. private _texture;
  50340. /**
  50341. * Stores the sheen tint values in a texture.
  50342. * rgb is tint
  50343. * a is a intensity
  50344. */
  50345. texture: Nullable<BaseTexture>;
  50346. /** @hidden */
  50347. private _internalMarkAllSubMeshesAsTexturesDirty;
  50348. /** @hidden */
  50349. _markAllSubMeshesAsTexturesDirty(): void;
  50350. /**
  50351. * Instantiate a new istance of clear coat configuration.
  50352. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50353. */
  50354. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50355. /**
  50356. * Specifies that the submesh is ready to be used.
  50357. * @param defines the list of "defines" to update.
  50358. * @param scene defines the scene the material belongs to.
  50359. * @returns - boolean indicating that the submesh is ready or not.
  50360. */
  50361. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50362. /**
  50363. * Checks to see if a texture is used in the material.
  50364. * @param defines the list of "defines" to update.
  50365. * @param scene defines the scene the material belongs to.
  50366. */
  50367. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50368. /**
  50369. * Binds the material data.
  50370. * @param uniformBuffer defines the Uniform buffer to fill in.
  50371. * @param scene defines the scene the material belongs to.
  50372. * @param isFrozen defines wether the material is frozen or not.
  50373. */
  50374. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50375. /**
  50376. * Checks to see if a texture is used in the material.
  50377. * @param texture - Base texture to use.
  50378. * @returns - Boolean specifying if a texture is used in the material.
  50379. */
  50380. hasTexture(texture: BaseTexture): boolean;
  50381. /**
  50382. * Returns an array of the actively used textures.
  50383. * @param activeTextures Array of BaseTextures
  50384. */
  50385. getActiveTextures(activeTextures: BaseTexture[]): void;
  50386. /**
  50387. * Returns the animatable textures.
  50388. * @param animatables Array of animatable textures.
  50389. */
  50390. getAnimatables(animatables: IAnimatable[]): void;
  50391. /**
  50392. * Disposes the resources of the material.
  50393. * @param forceDisposeTextures - Forces the disposal of all textures.
  50394. */
  50395. dispose(forceDisposeTextures?: boolean): void;
  50396. /**
  50397. * Get the current class name of the texture useful for serialization or dynamic coding.
  50398. * @returns "PBRSheenConfiguration"
  50399. */
  50400. getClassName(): string;
  50401. /**
  50402. * Add fallbacks to the effect fallbacks list.
  50403. * @param defines defines the Base texture to use.
  50404. * @param fallbacks defines the current fallback list.
  50405. * @param currentRank defines the current fallback rank.
  50406. * @returns the new fallback rank.
  50407. */
  50408. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50409. /**
  50410. * Add the required uniforms to the current list.
  50411. * @param uniforms defines the current uniform list.
  50412. */
  50413. static AddUniforms(uniforms: string[]): void;
  50414. /**
  50415. * Add the required uniforms to the current buffer.
  50416. * @param uniformBuffer defines the current uniform buffer.
  50417. */
  50418. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50419. /**
  50420. * Add the required samplers to the current list.
  50421. * @param samplers defines the current sampler list.
  50422. */
  50423. static AddSamplers(samplers: string[]): void;
  50424. /**
  50425. * Makes a duplicate of the current configuration into another one.
  50426. * @param sheenConfiguration define the config where to copy the info
  50427. */
  50428. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50429. /**
  50430. * Serializes this BRDF configuration.
  50431. * @returns - An object with the serialized config.
  50432. */
  50433. serialize(): any;
  50434. /**
  50435. * Parses a anisotropy Configuration from a serialized object.
  50436. * @param source - Serialized object.
  50437. * @param scene Defines the scene we are parsing for
  50438. * @param rootUrl Defines the rootUrl to load from
  50439. */
  50440. parse(source: any, scene: Scene, rootUrl: string): void;
  50441. }
  50442. }
  50443. declare module BABYLON {
  50444. /**
  50445. * @hidden
  50446. */
  50447. export interface IMaterialSubSurfaceDefines {
  50448. SUBSURFACE: boolean;
  50449. SS_REFRACTION: boolean;
  50450. SS_TRANSLUCENCY: boolean;
  50451. SS_SCATERRING: boolean;
  50452. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50453. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50454. SS_REFRACTIONMAP_3D: boolean;
  50455. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50456. SS_LODINREFRACTIONALPHA: boolean;
  50457. SS_GAMMAREFRACTION: boolean;
  50458. SS_RGBDREFRACTION: boolean;
  50459. SS_LINEARSPECULARREFRACTION: boolean;
  50460. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50461. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50462. /** @hidden */
  50463. _areTexturesDirty: boolean;
  50464. }
  50465. /**
  50466. * Define the code related to the sub surface parameters of the pbr material.
  50467. */
  50468. export class PBRSubSurfaceConfiguration {
  50469. private _isRefractionEnabled;
  50470. /**
  50471. * Defines if the refraction is enabled in the material.
  50472. */
  50473. isRefractionEnabled: boolean;
  50474. private _isTranslucencyEnabled;
  50475. /**
  50476. * Defines if the translucency is enabled in the material.
  50477. */
  50478. isTranslucencyEnabled: boolean;
  50479. private _isScatteringEnabled;
  50480. /**
  50481. * Defines the refraction intensity of the material.
  50482. * The refraction when enabled replaces the Diffuse part of the material.
  50483. * The intensity helps transitionning between diffuse and refraction.
  50484. */
  50485. refractionIntensity: number;
  50486. /**
  50487. * Defines the translucency intensity of the material.
  50488. * When translucency has been enabled, this defines how much of the "translucency"
  50489. * is addded to the diffuse part of the material.
  50490. */
  50491. translucencyIntensity: number;
  50492. /**
  50493. * Defines the scattering intensity of the material.
  50494. * When scattering has been enabled, this defines how much of the "scattered light"
  50495. * is addded to the diffuse part of the material.
  50496. */
  50497. scatteringIntensity: number;
  50498. private _thicknessTexture;
  50499. /**
  50500. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50501. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50502. * 0 would mean minimumThickness
  50503. * 1 would mean maximumThickness
  50504. * The other channels might be use as a mask to vary the different effects intensity.
  50505. */
  50506. thicknessTexture: Nullable<BaseTexture>;
  50507. private _refractionTexture;
  50508. /**
  50509. * Defines the texture to use for refraction.
  50510. */
  50511. refractionTexture: Nullable<BaseTexture>;
  50512. private _indexOfRefraction;
  50513. /**
  50514. * Defines the index of refraction used in the material.
  50515. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50516. */
  50517. indexOfRefraction: number;
  50518. private _invertRefractionY;
  50519. /**
  50520. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50521. */
  50522. invertRefractionY: boolean;
  50523. private _linkRefractionWithTransparency;
  50524. /**
  50525. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50526. * Materials half opaque for instance using refraction could benefit from this control.
  50527. */
  50528. linkRefractionWithTransparency: boolean;
  50529. /**
  50530. * Defines the minimum thickness stored in the thickness map.
  50531. * If no thickness map is defined, this value will be used to simulate thickness.
  50532. */
  50533. minimumThickness: number;
  50534. /**
  50535. * Defines the maximum thickness stored in the thickness map.
  50536. */
  50537. maximumThickness: number;
  50538. /**
  50539. * Defines the volume tint of the material.
  50540. * This is used for both translucency and scattering.
  50541. */
  50542. tintColor: Color3;
  50543. /**
  50544. * Defines the distance at which the tint color should be found in the media.
  50545. * This is used for refraction only.
  50546. */
  50547. tintColorAtDistance: number;
  50548. /**
  50549. * Defines how far each channel transmit through the media.
  50550. * It is defined as a color to simplify it selection.
  50551. */
  50552. diffusionDistance: Color3;
  50553. private _useMaskFromThicknessTexture;
  50554. /**
  50555. * Stores the intensity of the different subsurface effects in the thickness texture.
  50556. * * the green channel is the translucency intensity.
  50557. * * the blue channel is the scattering intensity.
  50558. * * the alpha channel is the refraction intensity.
  50559. */
  50560. useMaskFromThicknessTexture: boolean;
  50561. /** @hidden */
  50562. private _internalMarkAllSubMeshesAsTexturesDirty;
  50563. /** @hidden */
  50564. _markAllSubMeshesAsTexturesDirty(): void;
  50565. /**
  50566. * Instantiate a new istance of sub surface configuration.
  50567. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50568. */
  50569. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50570. /**
  50571. * Gets wehter the submesh is ready to be used or not.
  50572. * @param defines the list of "defines" to update.
  50573. * @param scene defines the scene the material belongs to.
  50574. * @returns - boolean indicating that the submesh is ready or not.
  50575. */
  50576. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50577. /**
  50578. * Checks to see if a texture is used in the material.
  50579. * @param defines the list of "defines" to update.
  50580. * @param scene defines the scene to the material belongs to.
  50581. */
  50582. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50583. /**
  50584. * Binds the material data.
  50585. * @param uniformBuffer defines the Uniform buffer to fill in.
  50586. * @param scene defines the scene the material belongs to.
  50587. * @param engine defines the engine the material belongs to.
  50588. * @param isFrozen defines wether the material is frozen or not.
  50589. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50590. */
  50591. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50592. /**
  50593. * Unbinds the material from the mesh.
  50594. * @param activeEffect defines the effect that should be unbound from.
  50595. * @returns true if unbound, otherwise false
  50596. */
  50597. unbind(activeEffect: Effect): boolean;
  50598. /**
  50599. * Returns the texture used for refraction or null if none is used.
  50600. * @param scene defines the scene the material belongs to.
  50601. * @returns - Refraction texture if present. If no refraction texture and refraction
  50602. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50603. */
  50604. private _getRefractionTexture;
  50605. /**
  50606. * Returns true if alpha blending should be disabled.
  50607. */
  50608. get disableAlphaBlending(): boolean;
  50609. /**
  50610. * Fills the list of render target textures.
  50611. * @param renderTargets the list of render targets to update
  50612. */
  50613. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50614. /**
  50615. * Checks to see if a texture is used in the material.
  50616. * @param texture - Base texture to use.
  50617. * @returns - Boolean specifying if a texture is used in the material.
  50618. */
  50619. hasTexture(texture: BaseTexture): boolean;
  50620. /**
  50621. * Gets a boolean indicating that current material needs to register RTT
  50622. * @returns true if this uses a render target otherwise false.
  50623. */
  50624. hasRenderTargetTextures(): boolean;
  50625. /**
  50626. * Returns an array of the actively used textures.
  50627. * @param activeTextures Array of BaseTextures
  50628. */
  50629. getActiveTextures(activeTextures: BaseTexture[]): void;
  50630. /**
  50631. * Returns the animatable textures.
  50632. * @param animatables Array of animatable textures.
  50633. */
  50634. getAnimatables(animatables: IAnimatable[]): void;
  50635. /**
  50636. * Disposes the resources of the material.
  50637. * @param forceDisposeTextures - Forces the disposal of all textures.
  50638. */
  50639. dispose(forceDisposeTextures?: boolean): void;
  50640. /**
  50641. * Get the current class name of the texture useful for serialization or dynamic coding.
  50642. * @returns "PBRSubSurfaceConfiguration"
  50643. */
  50644. getClassName(): string;
  50645. /**
  50646. * Add fallbacks to the effect fallbacks list.
  50647. * @param defines defines the Base texture to use.
  50648. * @param fallbacks defines the current fallback list.
  50649. * @param currentRank defines the current fallback rank.
  50650. * @returns the new fallback rank.
  50651. */
  50652. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50653. /**
  50654. * Add the required uniforms to the current list.
  50655. * @param uniforms defines the current uniform list.
  50656. */
  50657. static AddUniforms(uniforms: string[]): void;
  50658. /**
  50659. * Add the required samplers to the current list.
  50660. * @param samplers defines the current sampler list.
  50661. */
  50662. static AddSamplers(samplers: string[]): void;
  50663. /**
  50664. * Add the required uniforms to the current buffer.
  50665. * @param uniformBuffer defines the current uniform buffer.
  50666. */
  50667. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50668. /**
  50669. * Makes a duplicate of the current configuration into another one.
  50670. * @param configuration define the config where to copy the info
  50671. */
  50672. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50673. /**
  50674. * Serializes this Sub Surface configuration.
  50675. * @returns - An object with the serialized config.
  50676. */
  50677. serialize(): any;
  50678. /**
  50679. * Parses a anisotropy Configuration from a serialized object.
  50680. * @param source - Serialized object.
  50681. * @param scene Defines the scene we are parsing for
  50682. * @param rootUrl Defines the rootUrl to load from
  50683. */
  50684. parse(source: any, scene: Scene, rootUrl: string): void;
  50685. }
  50686. }
  50687. declare module BABYLON {
  50688. /** @hidden */
  50689. export var pbrFragmentDeclaration: {
  50690. name: string;
  50691. shader: string;
  50692. };
  50693. }
  50694. declare module BABYLON {
  50695. /** @hidden */
  50696. export var pbrUboDeclaration: {
  50697. name: string;
  50698. shader: string;
  50699. };
  50700. }
  50701. declare module BABYLON {
  50702. /** @hidden */
  50703. export var pbrFragmentExtraDeclaration: {
  50704. name: string;
  50705. shader: string;
  50706. };
  50707. }
  50708. declare module BABYLON {
  50709. /** @hidden */
  50710. export var pbrFragmentSamplersDeclaration: {
  50711. name: string;
  50712. shader: string;
  50713. };
  50714. }
  50715. declare module BABYLON {
  50716. /** @hidden */
  50717. export var pbrHelperFunctions: {
  50718. name: string;
  50719. shader: string;
  50720. };
  50721. }
  50722. declare module BABYLON {
  50723. /** @hidden */
  50724. export var harmonicsFunctions: {
  50725. name: string;
  50726. shader: string;
  50727. };
  50728. }
  50729. declare module BABYLON {
  50730. /** @hidden */
  50731. export var pbrDirectLightingSetupFunctions: {
  50732. name: string;
  50733. shader: string;
  50734. };
  50735. }
  50736. declare module BABYLON {
  50737. /** @hidden */
  50738. export var pbrDirectLightingFalloffFunctions: {
  50739. name: string;
  50740. shader: string;
  50741. };
  50742. }
  50743. declare module BABYLON {
  50744. /** @hidden */
  50745. export var pbrBRDFFunctions: {
  50746. name: string;
  50747. shader: string;
  50748. };
  50749. }
  50750. declare module BABYLON {
  50751. /** @hidden */
  50752. export var pbrDirectLightingFunctions: {
  50753. name: string;
  50754. shader: string;
  50755. };
  50756. }
  50757. declare module BABYLON {
  50758. /** @hidden */
  50759. export var pbrIBLFunctions: {
  50760. name: string;
  50761. shader: string;
  50762. };
  50763. }
  50764. declare module BABYLON {
  50765. /** @hidden */
  50766. export var pbrDebug: {
  50767. name: string;
  50768. shader: string;
  50769. };
  50770. }
  50771. declare module BABYLON {
  50772. /** @hidden */
  50773. export var pbrPixelShader: {
  50774. name: string;
  50775. shader: string;
  50776. };
  50777. }
  50778. declare module BABYLON {
  50779. /** @hidden */
  50780. export var pbrVertexDeclaration: {
  50781. name: string;
  50782. shader: string;
  50783. };
  50784. }
  50785. declare module BABYLON {
  50786. /** @hidden */
  50787. export var pbrVertexShader: {
  50788. name: string;
  50789. shader: string;
  50790. };
  50791. }
  50792. declare module BABYLON {
  50793. /**
  50794. * Manages the defines for the PBR Material.
  50795. * @hidden
  50796. */
  50797. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50798. PBR: boolean;
  50799. MAINUV1: boolean;
  50800. MAINUV2: boolean;
  50801. UV1: boolean;
  50802. UV2: boolean;
  50803. ALBEDO: boolean;
  50804. ALBEDODIRECTUV: number;
  50805. VERTEXCOLOR: boolean;
  50806. AMBIENT: boolean;
  50807. AMBIENTDIRECTUV: number;
  50808. AMBIENTINGRAYSCALE: boolean;
  50809. OPACITY: boolean;
  50810. VERTEXALPHA: boolean;
  50811. OPACITYDIRECTUV: number;
  50812. OPACITYRGB: boolean;
  50813. ALPHATEST: boolean;
  50814. DEPTHPREPASS: boolean;
  50815. ALPHABLEND: boolean;
  50816. ALPHAFROMALBEDO: boolean;
  50817. ALPHATESTVALUE: string;
  50818. SPECULAROVERALPHA: boolean;
  50819. RADIANCEOVERALPHA: boolean;
  50820. ALPHAFRESNEL: boolean;
  50821. LINEARALPHAFRESNEL: boolean;
  50822. PREMULTIPLYALPHA: boolean;
  50823. EMISSIVE: boolean;
  50824. EMISSIVEDIRECTUV: number;
  50825. REFLECTIVITY: boolean;
  50826. REFLECTIVITYDIRECTUV: number;
  50827. SPECULARTERM: boolean;
  50828. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50829. MICROSURFACEAUTOMATIC: boolean;
  50830. LODBASEDMICROSFURACE: boolean;
  50831. MICROSURFACEMAP: boolean;
  50832. MICROSURFACEMAPDIRECTUV: number;
  50833. METALLICWORKFLOW: boolean;
  50834. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50835. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50836. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50837. AOSTOREINMETALMAPRED: boolean;
  50838. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50839. ENVIRONMENTBRDF: boolean;
  50840. ENVIRONMENTBRDF_RGBD: boolean;
  50841. NORMAL: boolean;
  50842. TANGENT: boolean;
  50843. BUMP: boolean;
  50844. BUMPDIRECTUV: number;
  50845. OBJECTSPACE_NORMALMAP: boolean;
  50846. PARALLAX: boolean;
  50847. PARALLAXOCCLUSION: boolean;
  50848. NORMALXYSCALE: boolean;
  50849. LIGHTMAP: boolean;
  50850. LIGHTMAPDIRECTUV: number;
  50851. USELIGHTMAPASSHADOWMAP: boolean;
  50852. GAMMALIGHTMAP: boolean;
  50853. RGBDLIGHTMAP: boolean;
  50854. REFLECTION: boolean;
  50855. REFLECTIONMAP_3D: boolean;
  50856. REFLECTIONMAP_SPHERICAL: boolean;
  50857. REFLECTIONMAP_PLANAR: boolean;
  50858. REFLECTIONMAP_CUBIC: boolean;
  50859. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50860. REFLECTIONMAP_PROJECTION: boolean;
  50861. REFLECTIONMAP_SKYBOX: boolean;
  50862. REFLECTIONMAP_EXPLICIT: boolean;
  50863. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50864. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50865. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50866. INVERTCUBICMAP: boolean;
  50867. USESPHERICALFROMREFLECTIONMAP: boolean;
  50868. USEIRRADIANCEMAP: boolean;
  50869. SPHERICAL_HARMONICS: boolean;
  50870. USESPHERICALINVERTEX: boolean;
  50871. REFLECTIONMAP_OPPOSITEZ: boolean;
  50872. LODINREFLECTIONALPHA: boolean;
  50873. GAMMAREFLECTION: boolean;
  50874. RGBDREFLECTION: boolean;
  50875. LINEARSPECULARREFLECTION: boolean;
  50876. RADIANCEOCCLUSION: boolean;
  50877. HORIZONOCCLUSION: boolean;
  50878. INSTANCES: boolean;
  50879. NUM_BONE_INFLUENCERS: number;
  50880. BonesPerMesh: number;
  50881. BONETEXTURE: boolean;
  50882. NONUNIFORMSCALING: boolean;
  50883. MORPHTARGETS: boolean;
  50884. MORPHTARGETS_NORMAL: boolean;
  50885. MORPHTARGETS_TANGENT: boolean;
  50886. MORPHTARGETS_UV: boolean;
  50887. NUM_MORPH_INFLUENCERS: number;
  50888. IMAGEPROCESSING: boolean;
  50889. VIGNETTE: boolean;
  50890. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50891. VIGNETTEBLENDMODEOPAQUE: boolean;
  50892. TONEMAPPING: boolean;
  50893. TONEMAPPING_ACES: boolean;
  50894. CONTRAST: boolean;
  50895. COLORCURVES: boolean;
  50896. COLORGRADING: boolean;
  50897. COLORGRADING3D: boolean;
  50898. SAMPLER3DGREENDEPTH: boolean;
  50899. SAMPLER3DBGRMAP: boolean;
  50900. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50901. EXPOSURE: boolean;
  50902. MULTIVIEW: boolean;
  50903. USEPHYSICALLIGHTFALLOFF: boolean;
  50904. USEGLTFLIGHTFALLOFF: boolean;
  50905. TWOSIDEDLIGHTING: boolean;
  50906. SHADOWFLOAT: boolean;
  50907. CLIPPLANE: boolean;
  50908. CLIPPLANE2: boolean;
  50909. CLIPPLANE3: boolean;
  50910. CLIPPLANE4: boolean;
  50911. CLIPPLANE5: boolean;
  50912. CLIPPLANE6: boolean;
  50913. POINTSIZE: boolean;
  50914. FOG: boolean;
  50915. LOGARITHMICDEPTH: boolean;
  50916. FORCENORMALFORWARD: boolean;
  50917. SPECULARAA: boolean;
  50918. CLEARCOAT: boolean;
  50919. CLEARCOAT_DEFAULTIOR: boolean;
  50920. CLEARCOAT_TEXTURE: boolean;
  50921. CLEARCOAT_TEXTUREDIRECTUV: number;
  50922. CLEARCOAT_BUMP: boolean;
  50923. CLEARCOAT_BUMPDIRECTUV: number;
  50924. CLEARCOAT_TINT: boolean;
  50925. CLEARCOAT_TINT_TEXTURE: boolean;
  50926. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50927. ANISOTROPIC: boolean;
  50928. ANISOTROPIC_TEXTURE: boolean;
  50929. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50930. BRDF_V_HEIGHT_CORRELATED: boolean;
  50931. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50932. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50933. SHEEN: boolean;
  50934. SHEEN_TEXTURE: boolean;
  50935. SHEEN_TEXTUREDIRECTUV: number;
  50936. SHEEN_LINKWITHALBEDO: boolean;
  50937. SUBSURFACE: boolean;
  50938. SS_REFRACTION: boolean;
  50939. SS_TRANSLUCENCY: boolean;
  50940. SS_SCATERRING: boolean;
  50941. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50942. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50943. SS_REFRACTIONMAP_3D: boolean;
  50944. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50945. SS_LODINREFRACTIONALPHA: boolean;
  50946. SS_GAMMAREFRACTION: boolean;
  50947. SS_RGBDREFRACTION: boolean;
  50948. SS_LINEARSPECULARREFRACTION: boolean;
  50949. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50950. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50951. UNLIT: boolean;
  50952. DEBUGMODE: number;
  50953. /**
  50954. * Initializes the PBR Material defines.
  50955. */
  50956. constructor();
  50957. /**
  50958. * Resets the PBR Material defines.
  50959. */
  50960. reset(): void;
  50961. }
  50962. /**
  50963. * The Physically based material base class of BJS.
  50964. *
  50965. * This offers the main features of a standard PBR material.
  50966. * For more information, please refer to the documentation :
  50967. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50968. */
  50969. export abstract class PBRBaseMaterial extends PushMaterial {
  50970. /**
  50971. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50972. */
  50973. static readonly PBRMATERIAL_OPAQUE: number;
  50974. /**
  50975. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50976. */
  50977. static readonly PBRMATERIAL_ALPHATEST: number;
  50978. /**
  50979. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50980. */
  50981. static readonly PBRMATERIAL_ALPHABLEND: number;
  50982. /**
  50983. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50984. * They are also discarded below the alpha cutoff threshold to improve performances.
  50985. */
  50986. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50987. /**
  50988. * Defines the default value of how much AO map is occluding the analytical lights
  50989. * (point spot...).
  50990. */
  50991. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50992. /**
  50993. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50994. */
  50995. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50996. /**
  50997. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50998. * to enhance interoperability with other engines.
  50999. */
  51000. static readonly LIGHTFALLOFF_GLTF: number;
  51001. /**
  51002. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51003. * to enhance interoperability with other materials.
  51004. */
  51005. static readonly LIGHTFALLOFF_STANDARD: number;
  51006. /**
  51007. * Intensity of the direct lights e.g. the four lights available in your scene.
  51008. * This impacts both the direct diffuse and specular highlights.
  51009. */
  51010. protected _directIntensity: number;
  51011. /**
  51012. * Intensity of the emissive part of the material.
  51013. * This helps controlling the emissive effect without modifying the emissive color.
  51014. */
  51015. protected _emissiveIntensity: number;
  51016. /**
  51017. * Intensity of the environment e.g. how much the environment will light the object
  51018. * either through harmonics for rough material or through the refelction for shiny ones.
  51019. */
  51020. protected _environmentIntensity: number;
  51021. /**
  51022. * This is a special control allowing the reduction of the specular highlights coming from the
  51023. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51024. */
  51025. protected _specularIntensity: number;
  51026. /**
  51027. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51028. */
  51029. private _lightingInfos;
  51030. /**
  51031. * Debug Control allowing disabling the bump map on this material.
  51032. */
  51033. protected _disableBumpMap: boolean;
  51034. /**
  51035. * AKA Diffuse Texture in standard nomenclature.
  51036. */
  51037. protected _albedoTexture: Nullable<BaseTexture>;
  51038. /**
  51039. * AKA Occlusion Texture in other nomenclature.
  51040. */
  51041. protected _ambientTexture: Nullable<BaseTexture>;
  51042. /**
  51043. * AKA Occlusion Texture Intensity in other nomenclature.
  51044. */
  51045. protected _ambientTextureStrength: number;
  51046. /**
  51047. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51048. * 1 means it completely occludes it
  51049. * 0 mean it has no impact
  51050. */
  51051. protected _ambientTextureImpactOnAnalyticalLights: number;
  51052. /**
  51053. * Stores the alpha values in a texture.
  51054. */
  51055. protected _opacityTexture: Nullable<BaseTexture>;
  51056. /**
  51057. * Stores the reflection values in a texture.
  51058. */
  51059. protected _reflectionTexture: Nullable<BaseTexture>;
  51060. /**
  51061. * Stores the emissive values in a texture.
  51062. */
  51063. protected _emissiveTexture: Nullable<BaseTexture>;
  51064. /**
  51065. * AKA Specular texture in other nomenclature.
  51066. */
  51067. protected _reflectivityTexture: Nullable<BaseTexture>;
  51068. /**
  51069. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51070. */
  51071. protected _metallicTexture: Nullable<BaseTexture>;
  51072. /**
  51073. * Specifies the metallic scalar of the metallic/roughness workflow.
  51074. * Can also be used to scale the metalness values of the metallic texture.
  51075. */
  51076. protected _metallic: Nullable<number>;
  51077. /**
  51078. * Specifies the roughness scalar of the metallic/roughness workflow.
  51079. * Can also be used to scale the roughness values of the metallic texture.
  51080. */
  51081. protected _roughness: Nullable<number>;
  51082. /**
  51083. * Specifies the an F0 factor to help configuring the material F0.
  51084. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51085. * to 0.5 the previously hard coded value stays the same.
  51086. * Can also be used to scale the F0 values of the metallic texture.
  51087. */
  51088. protected _metallicF0Factor: number;
  51089. /**
  51090. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51091. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51092. * your expectation as it multiplies with the texture data.
  51093. */
  51094. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51095. /**
  51096. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51097. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51098. */
  51099. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51100. /**
  51101. * Stores surface normal data used to displace a mesh in a texture.
  51102. */
  51103. protected _bumpTexture: Nullable<BaseTexture>;
  51104. /**
  51105. * Stores the pre-calculated light information of a mesh in a texture.
  51106. */
  51107. protected _lightmapTexture: Nullable<BaseTexture>;
  51108. /**
  51109. * The color of a material in ambient lighting.
  51110. */
  51111. protected _ambientColor: Color3;
  51112. /**
  51113. * AKA Diffuse Color in other nomenclature.
  51114. */
  51115. protected _albedoColor: Color3;
  51116. /**
  51117. * AKA Specular Color in other nomenclature.
  51118. */
  51119. protected _reflectivityColor: Color3;
  51120. /**
  51121. * The color applied when light is reflected from a material.
  51122. */
  51123. protected _reflectionColor: Color3;
  51124. /**
  51125. * The color applied when light is emitted from a material.
  51126. */
  51127. protected _emissiveColor: Color3;
  51128. /**
  51129. * AKA Glossiness in other nomenclature.
  51130. */
  51131. protected _microSurface: number;
  51132. /**
  51133. * Specifies that the material will use the light map as a show map.
  51134. */
  51135. protected _useLightmapAsShadowmap: boolean;
  51136. /**
  51137. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51138. * makes the reflect vector face the model (under horizon).
  51139. */
  51140. protected _useHorizonOcclusion: boolean;
  51141. /**
  51142. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51143. * too much the area relying on ambient texture to define their ambient occlusion.
  51144. */
  51145. protected _useRadianceOcclusion: boolean;
  51146. /**
  51147. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51148. */
  51149. protected _useAlphaFromAlbedoTexture: boolean;
  51150. /**
  51151. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51152. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51153. */
  51154. protected _useSpecularOverAlpha: boolean;
  51155. /**
  51156. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51157. */
  51158. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51159. /**
  51160. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51161. */
  51162. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51163. /**
  51164. * Specifies if the metallic texture contains the roughness information in its green channel.
  51165. */
  51166. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51167. /**
  51168. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51169. */
  51170. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51171. /**
  51172. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51173. */
  51174. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51175. /**
  51176. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51177. */
  51178. protected _useAmbientInGrayScale: boolean;
  51179. /**
  51180. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51181. * The material will try to infer what glossiness each pixel should be.
  51182. */
  51183. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51184. /**
  51185. * Defines the falloff type used in this material.
  51186. * It by default is Physical.
  51187. */
  51188. protected _lightFalloff: number;
  51189. /**
  51190. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51191. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51192. */
  51193. protected _useRadianceOverAlpha: boolean;
  51194. /**
  51195. * Allows using an object space normal map (instead of tangent space).
  51196. */
  51197. protected _useObjectSpaceNormalMap: boolean;
  51198. /**
  51199. * Allows using the bump map in parallax mode.
  51200. */
  51201. protected _useParallax: boolean;
  51202. /**
  51203. * Allows using the bump map in parallax occlusion mode.
  51204. */
  51205. protected _useParallaxOcclusion: boolean;
  51206. /**
  51207. * Controls the scale bias of the parallax mode.
  51208. */
  51209. protected _parallaxScaleBias: number;
  51210. /**
  51211. * If sets to true, disables all the lights affecting the material.
  51212. */
  51213. protected _disableLighting: boolean;
  51214. /**
  51215. * Number of Simultaneous lights allowed on the material.
  51216. */
  51217. protected _maxSimultaneousLights: number;
  51218. /**
  51219. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51220. */
  51221. protected _invertNormalMapX: boolean;
  51222. /**
  51223. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51224. */
  51225. protected _invertNormalMapY: boolean;
  51226. /**
  51227. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51228. */
  51229. protected _twoSidedLighting: boolean;
  51230. /**
  51231. * Defines the alpha limits in alpha test mode.
  51232. */
  51233. protected _alphaCutOff: number;
  51234. /**
  51235. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51236. */
  51237. protected _forceAlphaTest: boolean;
  51238. /**
  51239. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51240. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51241. */
  51242. protected _useAlphaFresnel: boolean;
  51243. /**
  51244. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51245. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51246. */
  51247. protected _useLinearAlphaFresnel: boolean;
  51248. /**
  51249. * The transparency mode of the material.
  51250. */
  51251. protected _transparencyMode: Nullable<number>;
  51252. /**
  51253. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51254. * from cos thetav and roughness:
  51255. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51256. */
  51257. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51258. /**
  51259. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51260. */
  51261. protected _forceIrradianceInFragment: boolean;
  51262. /**
  51263. * Force normal to face away from face.
  51264. */
  51265. protected _forceNormalForward: boolean;
  51266. /**
  51267. * Enables specular anti aliasing in the PBR shader.
  51268. * It will both interacts on the Geometry for analytical and IBL lighting.
  51269. * It also prefilter the roughness map based on the bump values.
  51270. */
  51271. protected _enableSpecularAntiAliasing: boolean;
  51272. /**
  51273. * Default configuration related to image processing available in the PBR Material.
  51274. */
  51275. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51276. /**
  51277. * Keep track of the image processing observer to allow dispose and replace.
  51278. */
  51279. private _imageProcessingObserver;
  51280. /**
  51281. * Attaches a new image processing configuration to the PBR Material.
  51282. * @param configuration
  51283. */
  51284. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51285. /**
  51286. * Stores the available render targets.
  51287. */
  51288. private _renderTargets;
  51289. /**
  51290. * Sets the global ambient color for the material used in lighting calculations.
  51291. */
  51292. private _globalAmbientColor;
  51293. /**
  51294. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51295. */
  51296. private _useLogarithmicDepth;
  51297. /**
  51298. * If set to true, no lighting calculations will be applied.
  51299. */
  51300. private _unlit;
  51301. private _debugMode;
  51302. /**
  51303. * @hidden
  51304. * This is reserved for the inspector.
  51305. * Defines the material debug mode.
  51306. * It helps seeing only some components of the material while troubleshooting.
  51307. */
  51308. debugMode: number;
  51309. /**
  51310. * @hidden
  51311. * This is reserved for the inspector.
  51312. * Specify from where on screen the debug mode should start.
  51313. * The value goes from -1 (full screen) to 1 (not visible)
  51314. * It helps with side by side comparison against the final render
  51315. * This defaults to -1
  51316. */
  51317. private debugLimit;
  51318. /**
  51319. * @hidden
  51320. * This is reserved for the inspector.
  51321. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51322. * You can use the factor to better multiply the final value.
  51323. */
  51324. private debugFactor;
  51325. /**
  51326. * Defines the clear coat layer parameters for the material.
  51327. */
  51328. readonly clearCoat: PBRClearCoatConfiguration;
  51329. /**
  51330. * Defines the anisotropic parameters for the material.
  51331. */
  51332. readonly anisotropy: PBRAnisotropicConfiguration;
  51333. /**
  51334. * Defines the BRDF parameters for the material.
  51335. */
  51336. readonly brdf: PBRBRDFConfiguration;
  51337. /**
  51338. * Defines the Sheen parameters for the material.
  51339. */
  51340. readonly sheen: PBRSheenConfiguration;
  51341. /**
  51342. * Defines the SubSurface parameters for the material.
  51343. */
  51344. readonly subSurface: PBRSubSurfaceConfiguration;
  51345. /**
  51346. * Custom callback helping to override the default shader used in the material.
  51347. */
  51348. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51349. protected _rebuildInParallel: boolean;
  51350. /**
  51351. * Instantiates a new PBRMaterial instance.
  51352. *
  51353. * @param name The material name
  51354. * @param scene The scene the material will be use in.
  51355. */
  51356. constructor(name: string, scene: Scene);
  51357. /**
  51358. * Gets a boolean indicating that current material needs to register RTT
  51359. */
  51360. get hasRenderTargetTextures(): boolean;
  51361. /**
  51362. * Gets the name of the material class.
  51363. */
  51364. getClassName(): string;
  51365. /**
  51366. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51367. */
  51368. get useLogarithmicDepth(): boolean;
  51369. /**
  51370. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51371. */
  51372. set useLogarithmicDepth(value: boolean);
  51373. /**
  51374. * Gets the current transparency mode.
  51375. */
  51376. get transparencyMode(): Nullable<number>;
  51377. /**
  51378. * Sets the transparency mode of the material.
  51379. *
  51380. * | Value | Type | Description |
  51381. * | ----- | ----------------------------------- | ----------- |
  51382. * | 0 | OPAQUE | |
  51383. * | 1 | ALPHATEST | |
  51384. * | 2 | ALPHABLEND | |
  51385. * | 3 | ALPHATESTANDBLEND | |
  51386. *
  51387. */
  51388. set transparencyMode(value: Nullable<number>);
  51389. /**
  51390. * Returns true if alpha blending should be disabled.
  51391. */
  51392. private get _disableAlphaBlending();
  51393. /**
  51394. * Specifies whether or not this material should be rendered in alpha blend mode.
  51395. */
  51396. needAlphaBlending(): boolean;
  51397. /**
  51398. * Specifies if the mesh will require alpha blending.
  51399. * @param mesh - BJS mesh.
  51400. */
  51401. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51402. /**
  51403. * Specifies whether or not this material should be rendered in alpha test mode.
  51404. */
  51405. needAlphaTesting(): boolean;
  51406. /**
  51407. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51408. */
  51409. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51410. /**
  51411. * Gets the texture used for the alpha test.
  51412. */
  51413. getAlphaTestTexture(): Nullable<BaseTexture>;
  51414. /**
  51415. * Specifies that the submesh is ready to be used.
  51416. * @param mesh - BJS mesh.
  51417. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51418. * @param useInstances - Specifies that instances should be used.
  51419. * @returns - boolean indicating that the submesh is ready or not.
  51420. */
  51421. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51422. /**
  51423. * Specifies if the material uses metallic roughness workflow.
  51424. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51425. */
  51426. isMetallicWorkflow(): boolean;
  51427. private _prepareEffect;
  51428. private _prepareDefines;
  51429. /**
  51430. * Force shader compilation
  51431. */
  51432. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51433. /**
  51434. * Initializes the uniform buffer layout for the shader.
  51435. */
  51436. buildUniformLayout(): void;
  51437. /**
  51438. * Unbinds the material from the mesh
  51439. */
  51440. unbind(): void;
  51441. /**
  51442. * Binds the submesh data.
  51443. * @param world - The world matrix.
  51444. * @param mesh - The BJS mesh.
  51445. * @param subMesh - A submesh of the BJS mesh.
  51446. */
  51447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51448. /**
  51449. * Returns the animatable textures.
  51450. * @returns - Array of animatable textures.
  51451. */
  51452. getAnimatables(): IAnimatable[];
  51453. /**
  51454. * Returns the texture used for reflections.
  51455. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51456. */
  51457. private _getReflectionTexture;
  51458. /**
  51459. * Returns an array of the actively used textures.
  51460. * @returns - Array of BaseTextures
  51461. */
  51462. getActiveTextures(): BaseTexture[];
  51463. /**
  51464. * Checks to see if a texture is used in the material.
  51465. * @param texture - Base texture to use.
  51466. * @returns - Boolean specifying if a texture is used in the material.
  51467. */
  51468. hasTexture(texture: BaseTexture): boolean;
  51469. /**
  51470. * Disposes the resources of the material.
  51471. * @param forceDisposeEffect - Forces the disposal of effects.
  51472. * @param forceDisposeTextures - Forces the disposal of all textures.
  51473. */
  51474. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51475. }
  51476. }
  51477. declare module BABYLON {
  51478. /**
  51479. * The Physically based material of BJS.
  51480. *
  51481. * This offers the main features of a standard PBR material.
  51482. * For more information, please refer to the documentation :
  51483. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51484. */
  51485. export class PBRMaterial extends PBRBaseMaterial {
  51486. /**
  51487. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51488. */
  51489. static readonly PBRMATERIAL_OPAQUE: number;
  51490. /**
  51491. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51492. */
  51493. static readonly PBRMATERIAL_ALPHATEST: number;
  51494. /**
  51495. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51496. */
  51497. static readonly PBRMATERIAL_ALPHABLEND: number;
  51498. /**
  51499. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51500. * They are also discarded below the alpha cutoff threshold to improve performances.
  51501. */
  51502. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51503. /**
  51504. * Defines the default value of how much AO map is occluding the analytical lights
  51505. * (point spot...).
  51506. */
  51507. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51508. /**
  51509. * Intensity of the direct lights e.g. the four lights available in your scene.
  51510. * This impacts both the direct diffuse and specular highlights.
  51511. */
  51512. directIntensity: number;
  51513. /**
  51514. * Intensity of the emissive part of the material.
  51515. * This helps controlling the emissive effect without modifying the emissive color.
  51516. */
  51517. emissiveIntensity: number;
  51518. /**
  51519. * Intensity of the environment e.g. how much the environment will light the object
  51520. * either through harmonics for rough material or through the refelction for shiny ones.
  51521. */
  51522. environmentIntensity: number;
  51523. /**
  51524. * This is a special control allowing the reduction of the specular highlights coming from the
  51525. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51526. */
  51527. specularIntensity: number;
  51528. /**
  51529. * Debug Control allowing disabling the bump map on this material.
  51530. */
  51531. disableBumpMap: boolean;
  51532. /**
  51533. * AKA Diffuse Texture in standard nomenclature.
  51534. */
  51535. albedoTexture: BaseTexture;
  51536. /**
  51537. * AKA Occlusion Texture in other nomenclature.
  51538. */
  51539. ambientTexture: BaseTexture;
  51540. /**
  51541. * AKA Occlusion Texture Intensity in other nomenclature.
  51542. */
  51543. ambientTextureStrength: number;
  51544. /**
  51545. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51546. * 1 means it completely occludes it
  51547. * 0 mean it has no impact
  51548. */
  51549. ambientTextureImpactOnAnalyticalLights: number;
  51550. /**
  51551. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51552. */
  51553. opacityTexture: BaseTexture;
  51554. /**
  51555. * Stores the reflection values in a texture.
  51556. */
  51557. reflectionTexture: Nullable<BaseTexture>;
  51558. /**
  51559. * Stores the emissive values in a texture.
  51560. */
  51561. emissiveTexture: BaseTexture;
  51562. /**
  51563. * AKA Specular texture in other nomenclature.
  51564. */
  51565. reflectivityTexture: BaseTexture;
  51566. /**
  51567. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51568. */
  51569. metallicTexture: BaseTexture;
  51570. /**
  51571. * Specifies the metallic scalar of the metallic/roughness workflow.
  51572. * Can also be used to scale the metalness values of the metallic texture.
  51573. */
  51574. metallic: Nullable<number>;
  51575. /**
  51576. * Specifies the roughness scalar of the metallic/roughness workflow.
  51577. * Can also be used to scale the roughness values of the metallic texture.
  51578. */
  51579. roughness: Nullable<number>;
  51580. /**
  51581. * Specifies the an F0 factor to help configuring the material F0.
  51582. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51583. * to 0.5 the previously hard coded value stays the same.
  51584. * Can also be used to scale the F0 values of the metallic texture.
  51585. */
  51586. metallicF0Factor: number;
  51587. /**
  51588. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51589. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51590. * your expectation as it multiplies with the texture data.
  51591. */
  51592. useMetallicF0FactorFromMetallicTexture: boolean;
  51593. /**
  51594. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51595. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51596. */
  51597. microSurfaceTexture: BaseTexture;
  51598. /**
  51599. * Stores surface normal data used to displace a mesh in a texture.
  51600. */
  51601. bumpTexture: BaseTexture;
  51602. /**
  51603. * Stores the pre-calculated light information of a mesh in a texture.
  51604. */
  51605. lightmapTexture: BaseTexture;
  51606. /**
  51607. * Stores the refracted light information in a texture.
  51608. */
  51609. get refractionTexture(): Nullable<BaseTexture>;
  51610. set refractionTexture(value: Nullable<BaseTexture>);
  51611. /**
  51612. * The color of a material in ambient lighting.
  51613. */
  51614. ambientColor: Color3;
  51615. /**
  51616. * AKA Diffuse Color in other nomenclature.
  51617. */
  51618. albedoColor: Color3;
  51619. /**
  51620. * AKA Specular Color in other nomenclature.
  51621. */
  51622. reflectivityColor: Color3;
  51623. /**
  51624. * The color reflected from the material.
  51625. */
  51626. reflectionColor: Color3;
  51627. /**
  51628. * The color emitted from the material.
  51629. */
  51630. emissiveColor: Color3;
  51631. /**
  51632. * AKA Glossiness in other nomenclature.
  51633. */
  51634. microSurface: number;
  51635. /**
  51636. * source material index of refraction (IOR)' / 'destination material IOR.
  51637. */
  51638. get indexOfRefraction(): number;
  51639. set indexOfRefraction(value: number);
  51640. /**
  51641. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51642. */
  51643. get invertRefractionY(): boolean;
  51644. set invertRefractionY(value: boolean);
  51645. /**
  51646. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51647. * Materials half opaque for instance using refraction could benefit from this control.
  51648. */
  51649. get linkRefractionWithTransparency(): boolean;
  51650. set linkRefractionWithTransparency(value: boolean);
  51651. /**
  51652. * If true, the light map contains occlusion information instead of lighting info.
  51653. */
  51654. useLightmapAsShadowmap: boolean;
  51655. /**
  51656. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51657. */
  51658. useAlphaFromAlbedoTexture: boolean;
  51659. /**
  51660. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51661. */
  51662. forceAlphaTest: boolean;
  51663. /**
  51664. * Defines the alpha limits in alpha test mode.
  51665. */
  51666. alphaCutOff: number;
  51667. /**
  51668. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51669. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51670. */
  51671. useSpecularOverAlpha: boolean;
  51672. /**
  51673. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51674. */
  51675. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51676. /**
  51677. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51678. */
  51679. useRoughnessFromMetallicTextureAlpha: boolean;
  51680. /**
  51681. * Specifies if the metallic texture contains the roughness information in its green channel.
  51682. */
  51683. useRoughnessFromMetallicTextureGreen: boolean;
  51684. /**
  51685. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51686. */
  51687. useMetallnessFromMetallicTextureBlue: boolean;
  51688. /**
  51689. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51690. */
  51691. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51692. /**
  51693. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51694. */
  51695. useAmbientInGrayScale: boolean;
  51696. /**
  51697. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51698. * The material will try to infer what glossiness each pixel should be.
  51699. */
  51700. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51701. /**
  51702. * BJS is using an harcoded light falloff based on a manually sets up range.
  51703. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51704. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51705. */
  51706. get usePhysicalLightFalloff(): boolean;
  51707. /**
  51708. * BJS is using an harcoded light falloff based on a manually sets up range.
  51709. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51710. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51711. */
  51712. set usePhysicalLightFalloff(value: boolean);
  51713. /**
  51714. * In order to support the falloff compatibility with gltf, a special mode has been added
  51715. * to reproduce the gltf light falloff.
  51716. */
  51717. get useGLTFLightFalloff(): boolean;
  51718. /**
  51719. * In order to support the falloff compatibility with gltf, a special mode has been added
  51720. * to reproduce the gltf light falloff.
  51721. */
  51722. set useGLTFLightFalloff(value: boolean);
  51723. /**
  51724. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51725. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51726. */
  51727. useRadianceOverAlpha: boolean;
  51728. /**
  51729. * Allows using an object space normal map (instead of tangent space).
  51730. */
  51731. useObjectSpaceNormalMap: boolean;
  51732. /**
  51733. * Allows using the bump map in parallax mode.
  51734. */
  51735. useParallax: boolean;
  51736. /**
  51737. * Allows using the bump map in parallax occlusion mode.
  51738. */
  51739. useParallaxOcclusion: boolean;
  51740. /**
  51741. * Controls the scale bias of the parallax mode.
  51742. */
  51743. parallaxScaleBias: number;
  51744. /**
  51745. * If sets to true, disables all the lights affecting the material.
  51746. */
  51747. disableLighting: boolean;
  51748. /**
  51749. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51750. */
  51751. forceIrradianceInFragment: boolean;
  51752. /**
  51753. * Number of Simultaneous lights allowed on the material.
  51754. */
  51755. maxSimultaneousLights: number;
  51756. /**
  51757. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51758. */
  51759. invertNormalMapX: boolean;
  51760. /**
  51761. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51762. */
  51763. invertNormalMapY: boolean;
  51764. /**
  51765. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51766. */
  51767. twoSidedLighting: boolean;
  51768. /**
  51769. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51770. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51771. */
  51772. useAlphaFresnel: boolean;
  51773. /**
  51774. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51775. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51776. */
  51777. useLinearAlphaFresnel: boolean;
  51778. /**
  51779. * Let user defines the brdf lookup texture used for IBL.
  51780. * A default 8bit version is embedded but you could point at :
  51781. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51782. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51783. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51784. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51785. */
  51786. environmentBRDFTexture: Nullable<BaseTexture>;
  51787. /**
  51788. * Force normal to face away from face.
  51789. */
  51790. forceNormalForward: boolean;
  51791. /**
  51792. * Enables specular anti aliasing in the PBR shader.
  51793. * It will both interacts on the Geometry for analytical and IBL lighting.
  51794. * It also prefilter the roughness map based on the bump values.
  51795. */
  51796. enableSpecularAntiAliasing: boolean;
  51797. /**
  51798. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51799. * makes the reflect vector face the model (under horizon).
  51800. */
  51801. useHorizonOcclusion: boolean;
  51802. /**
  51803. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51804. * too much the area relying on ambient texture to define their ambient occlusion.
  51805. */
  51806. useRadianceOcclusion: boolean;
  51807. /**
  51808. * If set to true, no lighting calculations will be applied.
  51809. */
  51810. unlit: boolean;
  51811. /**
  51812. * Gets the image processing configuration used either in this material.
  51813. */
  51814. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51815. /**
  51816. * Sets the Default image processing configuration used either in the this material.
  51817. *
  51818. * If sets to null, the scene one is in use.
  51819. */
  51820. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51821. /**
  51822. * Gets wether the color curves effect is enabled.
  51823. */
  51824. get cameraColorCurvesEnabled(): boolean;
  51825. /**
  51826. * Sets wether the color curves effect is enabled.
  51827. */
  51828. set cameraColorCurvesEnabled(value: boolean);
  51829. /**
  51830. * Gets wether the color grading effect is enabled.
  51831. */
  51832. get cameraColorGradingEnabled(): boolean;
  51833. /**
  51834. * Gets wether the color grading effect is enabled.
  51835. */
  51836. set cameraColorGradingEnabled(value: boolean);
  51837. /**
  51838. * Gets wether tonemapping is enabled or not.
  51839. */
  51840. get cameraToneMappingEnabled(): boolean;
  51841. /**
  51842. * Sets wether tonemapping is enabled or not
  51843. */
  51844. set cameraToneMappingEnabled(value: boolean);
  51845. /**
  51846. * The camera exposure used on this material.
  51847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51848. * This corresponds to a photographic exposure.
  51849. */
  51850. get cameraExposure(): number;
  51851. /**
  51852. * The camera exposure used on this material.
  51853. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51854. * This corresponds to a photographic exposure.
  51855. */
  51856. set cameraExposure(value: number);
  51857. /**
  51858. * Gets The camera contrast used on this material.
  51859. */
  51860. get cameraContrast(): number;
  51861. /**
  51862. * Sets The camera contrast used on this material.
  51863. */
  51864. set cameraContrast(value: number);
  51865. /**
  51866. * Gets the Color Grading 2D Lookup Texture.
  51867. */
  51868. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51869. /**
  51870. * Sets the Color Grading 2D Lookup Texture.
  51871. */
  51872. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51873. /**
  51874. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51875. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51876. * 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;
  51877. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51878. */
  51879. get cameraColorCurves(): Nullable<ColorCurves>;
  51880. /**
  51881. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51882. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51883. * 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;
  51884. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51885. */
  51886. set cameraColorCurves(value: Nullable<ColorCurves>);
  51887. /**
  51888. * Instantiates a new PBRMaterial instance.
  51889. *
  51890. * @param name The material name
  51891. * @param scene The scene the material will be use in.
  51892. */
  51893. constructor(name: string, scene: Scene);
  51894. /**
  51895. * Returns the name of this material class.
  51896. */
  51897. getClassName(): string;
  51898. /**
  51899. * Makes a duplicate of the current material.
  51900. * @param name - name to use for the new material.
  51901. */
  51902. clone(name: string): PBRMaterial;
  51903. /**
  51904. * Serializes this PBR Material.
  51905. * @returns - An object with the serialized material.
  51906. */
  51907. serialize(): any;
  51908. /**
  51909. * Parses a PBR Material from a serialized object.
  51910. * @param source - Serialized object.
  51911. * @param scene - BJS scene instance.
  51912. * @param rootUrl - url for the scene object
  51913. * @returns - PBRMaterial
  51914. */
  51915. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51916. }
  51917. }
  51918. declare module BABYLON {
  51919. /**
  51920. * Direct draw surface info
  51921. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51922. */
  51923. export interface DDSInfo {
  51924. /**
  51925. * Width of the texture
  51926. */
  51927. width: number;
  51928. /**
  51929. * Width of the texture
  51930. */
  51931. height: number;
  51932. /**
  51933. * Number of Mipmaps for the texture
  51934. * @see https://en.wikipedia.org/wiki/Mipmap
  51935. */
  51936. mipmapCount: number;
  51937. /**
  51938. * If the textures format is a known fourCC format
  51939. * @see https://www.fourcc.org/
  51940. */
  51941. isFourCC: boolean;
  51942. /**
  51943. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51944. */
  51945. isRGB: boolean;
  51946. /**
  51947. * If the texture is a lumincance format
  51948. */
  51949. isLuminance: boolean;
  51950. /**
  51951. * If this is a cube texture
  51952. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51953. */
  51954. isCube: boolean;
  51955. /**
  51956. * If the texture is a compressed format eg. FOURCC_DXT1
  51957. */
  51958. isCompressed: boolean;
  51959. /**
  51960. * The dxgiFormat of the texture
  51961. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51962. */
  51963. dxgiFormat: number;
  51964. /**
  51965. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51966. */
  51967. textureType: number;
  51968. /**
  51969. * Sphericle polynomial created for the dds texture
  51970. */
  51971. sphericalPolynomial?: SphericalPolynomial;
  51972. }
  51973. /**
  51974. * Class used to provide DDS decompression tools
  51975. */
  51976. export class DDSTools {
  51977. /**
  51978. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51979. */
  51980. static StoreLODInAlphaChannel: boolean;
  51981. /**
  51982. * Gets DDS information from an array buffer
  51983. * @param data defines the array buffer view to read data from
  51984. * @returns the DDS information
  51985. */
  51986. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  51987. private static _FloatView;
  51988. private static _Int32View;
  51989. private static _ToHalfFloat;
  51990. private static _FromHalfFloat;
  51991. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51992. private static _GetHalfFloatRGBAArrayBuffer;
  51993. private static _GetFloatRGBAArrayBuffer;
  51994. private static _GetFloatAsUIntRGBAArrayBuffer;
  51995. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51996. private static _GetRGBAArrayBuffer;
  51997. private static _ExtractLongWordOrder;
  51998. private static _GetRGBArrayBuffer;
  51999. private static _GetLuminanceArrayBuffer;
  52000. /**
  52001. * Uploads DDS Levels to a Babylon Texture
  52002. * @hidden
  52003. */
  52004. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52005. }
  52006. interface ThinEngine {
  52007. /**
  52008. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52009. * @param rootUrl defines the url where the file to load is located
  52010. * @param scene defines the current scene
  52011. * @param lodScale defines scale to apply to the mip map selection
  52012. * @param lodOffset defines offset to apply to the mip map selection
  52013. * @param onLoad defines an optional callback raised when the texture is loaded
  52014. * @param onError defines an optional callback raised if there is an issue to load the texture
  52015. * @param format defines the format of the data
  52016. * @param forcedExtension defines the extension to use to pick the right loader
  52017. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52018. * @returns the cube texture as an InternalTexture
  52019. */
  52020. 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;
  52021. }
  52022. }
  52023. declare module BABYLON {
  52024. /**
  52025. * Implementation of the DDS Texture Loader.
  52026. * @hidden
  52027. */
  52028. export class _DDSTextureLoader implements IInternalTextureLoader {
  52029. /**
  52030. * Defines wether the loader supports cascade loading the different faces.
  52031. */
  52032. readonly supportCascades: boolean;
  52033. /**
  52034. * This returns if the loader support the current file information.
  52035. * @param extension defines the file extension of the file being loaded
  52036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52037. * @param fallback defines the fallback internal texture if any
  52038. * @param isBase64 defines whether the texture is encoded as a base64
  52039. * @param isBuffer defines whether the texture data are stored as a buffer
  52040. * @returns true if the loader can load the specified file
  52041. */
  52042. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52043. /**
  52044. * Transform the url before loading if required.
  52045. * @param rootUrl the url of the texture
  52046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52047. * @returns the transformed texture
  52048. */
  52049. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52050. /**
  52051. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52052. * @param rootUrl the url of the texture
  52053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52054. * @returns the fallback texture
  52055. */
  52056. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52057. /**
  52058. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52059. * @param data contains the texture data
  52060. * @param texture defines the BabylonJS internal texture
  52061. * @param createPolynomials will be true if polynomials have been requested
  52062. * @param onLoad defines the callback to trigger once the texture is ready
  52063. * @param onError defines the callback to trigger in case of error
  52064. */
  52065. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52066. /**
  52067. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52068. * @param data contains the texture data
  52069. * @param texture defines the BabylonJS internal texture
  52070. * @param callback defines the method to call once ready to upload
  52071. */
  52072. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52073. }
  52074. }
  52075. declare module BABYLON {
  52076. /**
  52077. * Implementation of the ENV Texture Loader.
  52078. * @hidden
  52079. */
  52080. export class _ENVTextureLoader implements IInternalTextureLoader {
  52081. /**
  52082. * Defines wether the loader supports cascade loading the different faces.
  52083. */
  52084. readonly supportCascades: boolean;
  52085. /**
  52086. * This returns if the loader support the current file information.
  52087. * @param extension defines the file extension of the file being loaded
  52088. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52089. * @param fallback defines the fallback internal texture if any
  52090. * @param isBase64 defines whether the texture is encoded as a base64
  52091. * @param isBuffer defines whether the texture data are stored as a buffer
  52092. * @returns true if the loader can load the specified file
  52093. */
  52094. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52095. /**
  52096. * Transform the url before loading if required.
  52097. * @param rootUrl the url of the texture
  52098. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52099. * @returns the transformed texture
  52100. */
  52101. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52102. /**
  52103. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52104. * @param rootUrl the url of the texture
  52105. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52106. * @returns the fallback texture
  52107. */
  52108. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52109. /**
  52110. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52111. * @param data contains the texture data
  52112. * @param texture defines the BabylonJS internal texture
  52113. * @param createPolynomials will be true if polynomials have been requested
  52114. * @param onLoad defines the callback to trigger once the texture is ready
  52115. * @param onError defines the callback to trigger in case of error
  52116. */
  52117. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52118. /**
  52119. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52120. * @param data contains the texture data
  52121. * @param texture defines the BabylonJS internal texture
  52122. * @param callback defines the method to call once ready to upload
  52123. */
  52124. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52125. }
  52126. }
  52127. declare module BABYLON {
  52128. /**
  52129. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52130. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52131. */
  52132. export class KhronosTextureContainer {
  52133. /** contents of the KTX container file */
  52134. data: ArrayBufferView;
  52135. private static HEADER_LEN;
  52136. private static COMPRESSED_2D;
  52137. private static COMPRESSED_3D;
  52138. private static TEX_2D;
  52139. private static TEX_3D;
  52140. /**
  52141. * Gets the openGL type
  52142. */
  52143. glType: number;
  52144. /**
  52145. * Gets the openGL type size
  52146. */
  52147. glTypeSize: number;
  52148. /**
  52149. * Gets the openGL format
  52150. */
  52151. glFormat: number;
  52152. /**
  52153. * Gets the openGL internal format
  52154. */
  52155. glInternalFormat: number;
  52156. /**
  52157. * Gets the base internal format
  52158. */
  52159. glBaseInternalFormat: number;
  52160. /**
  52161. * Gets image width in pixel
  52162. */
  52163. pixelWidth: number;
  52164. /**
  52165. * Gets image height in pixel
  52166. */
  52167. pixelHeight: number;
  52168. /**
  52169. * Gets image depth in pixels
  52170. */
  52171. pixelDepth: number;
  52172. /**
  52173. * Gets the number of array elements
  52174. */
  52175. numberOfArrayElements: number;
  52176. /**
  52177. * Gets the number of faces
  52178. */
  52179. numberOfFaces: number;
  52180. /**
  52181. * Gets the number of mipmap levels
  52182. */
  52183. numberOfMipmapLevels: number;
  52184. /**
  52185. * Gets the bytes of key value data
  52186. */
  52187. bytesOfKeyValueData: number;
  52188. /**
  52189. * Gets the load type
  52190. */
  52191. loadType: number;
  52192. /**
  52193. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52194. */
  52195. isInvalid: boolean;
  52196. /**
  52197. * Creates a new KhronosTextureContainer
  52198. * @param data contents of the KTX container file
  52199. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52200. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52201. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52202. */
  52203. constructor(
  52204. /** contents of the KTX container file */
  52205. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52206. /**
  52207. * Uploads KTX content to a Babylon Texture.
  52208. * It is assumed that the texture has already been created & is currently bound
  52209. * @hidden
  52210. */
  52211. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52212. private _upload2DCompressedLevels;
  52213. }
  52214. }
  52215. declare module BABYLON {
  52216. /**
  52217. * Implementation of the KTX Texture Loader.
  52218. * @hidden
  52219. */
  52220. export class _KTXTextureLoader implements IInternalTextureLoader {
  52221. /**
  52222. * Defines wether the loader supports cascade loading the different faces.
  52223. */
  52224. readonly supportCascades: boolean;
  52225. /**
  52226. * This returns if the loader support the current file information.
  52227. * @param extension defines the file extension of the file being loaded
  52228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52229. * @param fallback defines the fallback internal texture if any
  52230. * @param isBase64 defines whether the texture is encoded as a base64
  52231. * @param isBuffer defines whether the texture data are stored as a buffer
  52232. * @returns true if the loader can load the specified file
  52233. */
  52234. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52235. /**
  52236. * Transform the url before loading if required.
  52237. * @param rootUrl the url of the texture
  52238. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52239. * @returns the transformed texture
  52240. */
  52241. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52242. /**
  52243. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52244. * @param rootUrl the url of the texture
  52245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52246. * @returns the fallback texture
  52247. */
  52248. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52249. /**
  52250. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52251. * @param data contains the texture data
  52252. * @param texture defines the BabylonJS internal texture
  52253. * @param createPolynomials will be true if polynomials have been requested
  52254. * @param onLoad defines the callback to trigger once the texture is ready
  52255. * @param onError defines the callback to trigger in case of error
  52256. */
  52257. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52258. /**
  52259. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52260. * @param data contains the texture data
  52261. * @param texture defines the BabylonJS internal texture
  52262. * @param callback defines the method to call once ready to upload
  52263. */
  52264. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52265. }
  52266. }
  52267. declare module BABYLON {
  52268. /** @hidden */
  52269. export var _forceSceneHelpersToBundle: boolean;
  52270. interface Scene {
  52271. /**
  52272. * Creates a default light for the scene.
  52273. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52274. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52275. */
  52276. createDefaultLight(replace?: boolean): void;
  52277. /**
  52278. * Creates a default camera for the scene.
  52279. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52280. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52281. * @param replace has default false, when true replaces the active camera in the scene
  52282. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52283. */
  52284. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52285. /**
  52286. * Creates a default camera and a default light.
  52287. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52288. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52289. * @param replace has the default false, when true replaces the active camera/light in the scene
  52290. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52291. */
  52292. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52293. /**
  52294. * Creates a new sky box
  52295. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52296. * @param environmentTexture defines the texture to use as environment texture
  52297. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52298. * @param scale defines the overall scale of the skybox
  52299. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52300. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52301. * @returns a new mesh holding the sky box
  52302. */
  52303. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52304. /**
  52305. * Creates a new environment
  52306. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52307. * @param options defines the options you can use to configure the environment
  52308. * @returns the new EnvironmentHelper
  52309. */
  52310. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52311. /**
  52312. * Creates a new VREXperienceHelper
  52313. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52314. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52315. * @returns a new VREXperienceHelper
  52316. */
  52317. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52318. /**
  52319. * Creates a new WebXRDefaultExperience
  52320. * @see http://doc.babylonjs.com/how_to/webxr
  52321. * @param options experience options
  52322. * @returns a promise for a new WebXRDefaultExperience
  52323. */
  52324. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52325. }
  52326. }
  52327. declare module BABYLON {
  52328. /**
  52329. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52330. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52331. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52332. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52333. */
  52334. export class VideoDome extends TransformNode {
  52335. /**
  52336. * Define the video source as a Monoscopic panoramic 360 video.
  52337. */
  52338. static readonly MODE_MONOSCOPIC: number;
  52339. /**
  52340. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52341. */
  52342. static readonly MODE_TOPBOTTOM: number;
  52343. /**
  52344. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52345. */
  52346. static readonly MODE_SIDEBYSIDE: number;
  52347. private _halfDome;
  52348. private _useDirectMapping;
  52349. /**
  52350. * The video texture being displayed on the sphere
  52351. */
  52352. protected _videoTexture: VideoTexture;
  52353. /**
  52354. * Gets the video texture being displayed on the sphere
  52355. */
  52356. get videoTexture(): VideoTexture;
  52357. /**
  52358. * The skybox material
  52359. */
  52360. protected _material: BackgroundMaterial;
  52361. /**
  52362. * The surface used for the skybox
  52363. */
  52364. protected _mesh: Mesh;
  52365. /**
  52366. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52367. */
  52368. private _halfDomeMask;
  52369. /**
  52370. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52371. * Also see the options.resolution property.
  52372. */
  52373. get fovMultiplier(): number;
  52374. set fovMultiplier(value: number);
  52375. private _videoMode;
  52376. /**
  52377. * Gets or set the current video mode for the video. It can be:
  52378. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52379. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52380. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52381. */
  52382. get videoMode(): number;
  52383. set videoMode(value: number);
  52384. /**
  52385. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52386. *
  52387. */
  52388. get halfDome(): boolean;
  52389. /**
  52390. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52391. */
  52392. set halfDome(enabled: boolean);
  52393. /**
  52394. * Oberserver used in Stereoscopic VR Mode.
  52395. */
  52396. private _onBeforeCameraRenderObserver;
  52397. /**
  52398. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52399. * @param name Element's name, child elements will append suffixes for their own names.
  52400. * @param urlsOrVideo defines the url(s) or the video element to use
  52401. * @param options An object containing optional or exposed sub element properties
  52402. */
  52403. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52404. resolution?: number;
  52405. clickToPlay?: boolean;
  52406. autoPlay?: boolean;
  52407. loop?: boolean;
  52408. size?: number;
  52409. poster?: string;
  52410. faceForward?: boolean;
  52411. useDirectMapping?: boolean;
  52412. halfDomeMode?: boolean;
  52413. }, scene: Scene);
  52414. private _changeVideoMode;
  52415. /**
  52416. * Releases resources associated with this node.
  52417. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52418. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52419. */
  52420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52421. }
  52422. }
  52423. declare module BABYLON {
  52424. /**
  52425. * This class can be used to get instrumentation data from a Babylon engine
  52426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52427. */
  52428. export class EngineInstrumentation implements IDisposable {
  52429. /**
  52430. * Define the instrumented engine.
  52431. */
  52432. engine: Engine;
  52433. private _captureGPUFrameTime;
  52434. private _gpuFrameTimeToken;
  52435. private _gpuFrameTime;
  52436. private _captureShaderCompilationTime;
  52437. private _shaderCompilationTime;
  52438. private _onBeginFrameObserver;
  52439. private _onEndFrameObserver;
  52440. private _onBeforeShaderCompilationObserver;
  52441. private _onAfterShaderCompilationObserver;
  52442. /**
  52443. * Gets the perf counter used for GPU frame time
  52444. */
  52445. get gpuFrameTimeCounter(): PerfCounter;
  52446. /**
  52447. * Gets the GPU frame time capture status
  52448. */
  52449. get captureGPUFrameTime(): boolean;
  52450. /**
  52451. * Enable or disable the GPU frame time capture
  52452. */
  52453. set captureGPUFrameTime(value: boolean);
  52454. /**
  52455. * Gets the perf counter used for shader compilation time
  52456. */
  52457. get shaderCompilationTimeCounter(): PerfCounter;
  52458. /**
  52459. * Gets the shader compilation time capture status
  52460. */
  52461. get captureShaderCompilationTime(): boolean;
  52462. /**
  52463. * Enable or disable the shader compilation time capture
  52464. */
  52465. set captureShaderCompilationTime(value: boolean);
  52466. /**
  52467. * Instantiates a new engine instrumentation.
  52468. * This class can be used to get instrumentation data from a Babylon engine
  52469. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52470. * @param engine Defines the engine to instrument
  52471. */
  52472. constructor(
  52473. /**
  52474. * Define the instrumented engine.
  52475. */
  52476. engine: Engine);
  52477. /**
  52478. * Dispose and release associated resources.
  52479. */
  52480. dispose(): void;
  52481. }
  52482. }
  52483. declare module BABYLON {
  52484. /**
  52485. * This class can be used to get instrumentation data from a Babylon engine
  52486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52487. */
  52488. export class SceneInstrumentation implements IDisposable {
  52489. /**
  52490. * Defines the scene to instrument
  52491. */
  52492. scene: Scene;
  52493. private _captureActiveMeshesEvaluationTime;
  52494. private _activeMeshesEvaluationTime;
  52495. private _captureRenderTargetsRenderTime;
  52496. private _renderTargetsRenderTime;
  52497. private _captureFrameTime;
  52498. private _frameTime;
  52499. private _captureRenderTime;
  52500. private _renderTime;
  52501. private _captureInterFrameTime;
  52502. private _interFrameTime;
  52503. private _captureParticlesRenderTime;
  52504. private _particlesRenderTime;
  52505. private _captureSpritesRenderTime;
  52506. private _spritesRenderTime;
  52507. private _capturePhysicsTime;
  52508. private _physicsTime;
  52509. private _captureAnimationsTime;
  52510. private _animationsTime;
  52511. private _captureCameraRenderTime;
  52512. private _cameraRenderTime;
  52513. private _onBeforeActiveMeshesEvaluationObserver;
  52514. private _onAfterActiveMeshesEvaluationObserver;
  52515. private _onBeforeRenderTargetsRenderObserver;
  52516. private _onAfterRenderTargetsRenderObserver;
  52517. private _onAfterRenderObserver;
  52518. private _onBeforeDrawPhaseObserver;
  52519. private _onAfterDrawPhaseObserver;
  52520. private _onBeforeAnimationsObserver;
  52521. private _onBeforeParticlesRenderingObserver;
  52522. private _onAfterParticlesRenderingObserver;
  52523. private _onBeforeSpritesRenderingObserver;
  52524. private _onAfterSpritesRenderingObserver;
  52525. private _onBeforePhysicsObserver;
  52526. private _onAfterPhysicsObserver;
  52527. private _onAfterAnimationsObserver;
  52528. private _onBeforeCameraRenderObserver;
  52529. private _onAfterCameraRenderObserver;
  52530. /**
  52531. * Gets the perf counter used for active meshes evaluation time
  52532. */
  52533. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52534. /**
  52535. * Gets the active meshes evaluation time capture status
  52536. */
  52537. get captureActiveMeshesEvaluationTime(): boolean;
  52538. /**
  52539. * Enable or disable the active meshes evaluation time capture
  52540. */
  52541. set captureActiveMeshesEvaluationTime(value: boolean);
  52542. /**
  52543. * Gets the perf counter used for render targets render time
  52544. */
  52545. get renderTargetsRenderTimeCounter(): PerfCounter;
  52546. /**
  52547. * Gets the render targets render time capture status
  52548. */
  52549. get captureRenderTargetsRenderTime(): boolean;
  52550. /**
  52551. * Enable or disable the render targets render time capture
  52552. */
  52553. set captureRenderTargetsRenderTime(value: boolean);
  52554. /**
  52555. * Gets the perf counter used for particles render time
  52556. */
  52557. get particlesRenderTimeCounter(): PerfCounter;
  52558. /**
  52559. * Gets the particles render time capture status
  52560. */
  52561. get captureParticlesRenderTime(): boolean;
  52562. /**
  52563. * Enable or disable the particles render time capture
  52564. */
  52565. set captureParticlesRenderTime(value: boolean);
  52566. /**
  52567. * Gets the perf counter used for sprites render time
  52568. */
  52569. get spritesRenderTimeCounter(): PerfCounter;
  52570. /**
  52571. * Gets the sprites render time capture status
  52572. */
  52573. get captureSpritesRenderTime(): boolean;
  52574. /**
  52575. * Enable or disable the sprites render time capture
  52576. */
  52577. set captureSpritesRenderTime(value: boolean);
  52578. /**
  52579. * Gets the perf counter used for physics time
  52580. */
  52581. get physicsTimeCounter(): PerfCounter;
  52582. /**
  52583. * Gets the physics time capture status
  52584. */
  52585. get capturePhysicsTime(): boolean;
  52586. /**
  52587. * Enable or disable the physics time capture
  52588. */
  52589. set capturePhysicsTime(value: boolean);
  52590. /**
  52591. * Gets the perf counter used for animations time
  52592. */
  52593. get animationsTimeCounter(): PerfCounter;
  52594. /**
  52595. * Gets the animations time capture status
  52596. */
  52597. get captureAnimationsTime(): boolean;
  52598. /**
  52599. * Enable or disable the animations time capture
  52600. */
  52601. set captureAnimationsTime(value: boolean);
  52602. /**
  52603. * Gets the perf counter used for frame time capture
  52604. */
  52605. get frameTimeCounter(): PerfCounter;
  52606. /**
  52607. * Gets the frame time capture status
  52608. */
  52609. get captureFrameTime(): boolean;
  52610. /**
  52611. * Enable or disable the frame time capture
  52612. */
  52613. set captureFrameTime(value: boolean);
  52614. /**
  52615. * Gets the perf counter used for inter-frames time capture
  52616. */
  52617. get interFrameTimeCounter(): PerfCounter;
  52618. /**
  52619. * Gets the inter-frames time capture status
  52620. */
  52621. get captureInterFrameTime(): boolean;
  52622. /**
  52623. * Enable or disable the inter-frames time capture
  52624. */
  52625. set captureInterFrameTime(value: boolean);
  52626. /**
  52627. * Gets the perf counter used for render time capture
  52628. */
  52629. get renderTimeCounter(): PerfCounter;
  52630. /**
  52631. * Gets the render time capture status
  52632. */
  52633. get captureRenderTime(): boolean;
  52634. /**
  52635. * Enable or disable the render time capture
  52636. */
  52637. set captureRenderTime(value: boolean);
  52638. /**
  52639. * Gets the perf counter used for camera render time capture
  52640. */
  52641. get cameraRenderTimeCounter(): PerfCounter;
  52642. /**
  52643. * Gets the camera render time capture status
  52644. */
  52645. get captureCameraRenderTime(): boolean;
  52646. /**
  52647. * Enable or disable the camera render time capture
  52648. */
  52649. set captureCameraRenderTime(value: boolean);
  52650. /**
  52651. * Gets the perf counter used for draw calls
  52652. */
  52653. get drawCallsCounter(): PerfCounter;
  52654. /**
  52655. * Instantiates a new scene instrumentation.
  52656. * This class can be used to get instrumentation data from a Babylon engine
  52657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52658. * @param scene Defines the scene to instrument
  52659. */
  52660. constructor(
  52661. /**
  52662. * Defines the scene to instrument
  52663. */
  52664. scene: Scene);
  52665. /**
  52666. * Dispose and release associated resources.
  52667. */
  52668. dispose(): void;
  52669. }
  52670. }
  52671. declare module BABYLON {
  52672. /** @hidden */
  52673. export var glowMapGenerationPixelShader: {
  52674. name: string;
  52675. shader: string;
  52676. };
  52677. }
  52678. declare module BABYLON {
  52679. /** @hidden */
  52680. export var glowMapGenerationVertexShader: {
  52681. name: string;
  52682. shader: string;
  52683. };
  52684. }
  52685. declare module BABYLON {
  52686. /**
  52687. * Effect layer options. This helps customizing the behaviour
  52688. * of the effect layer.
  52689. */
  52690. export interface IEffectLayerOptions {
  52691. /**
  52692. * Multiplication factor apply to the canvas size to compute the render target size
  52693. * used to generated the objects (the smaller the faster).
  52694. */
  52695. mainTextureRatio: number;
  52696. /**
  52697. * Enforces a fixed size texture to ensure effect stability across devices.
  52698. */
  52699. mainTextureFixedSize?: number;
  52700. /**
  52701. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52702. */
  52703. alphaBlendingMode: number;
  52704. /**
  52705. * The camera attached to the layer.
  52706. */
  52707. camera: Nullable<Camera>;
  52708. /**
  52709. * The rendering group to draw the layer in.
  52710. */
  52711. renderingGroupId: number;
  52712. }
  52713. /**
  52714. * The effect layer Helps adding post process effect blended with the main pass.
  52715. *
  52716. * This can be for instance use to generate glow or higlight effects on the scene.
  52717. *
  52718. * The effect layer class can not be used directly and is intented to inherited from to be
  52719. * customized per effects.
  52720. */
  52721. export abstract class EffectLayer {
  52722. private _vertexBuffers;
  52723. private _indexBuffer;
  52724. private _cachedDefines;
  52725. private _effectLayerMapGenerationEffect;
  52726. private _effectLayerOptions;
  52727. private _mergeEffect;
  52728. protected _scene: Scene;
  52729. protected _engine: Engine;
  52730. protected _maxSize: number;
  52731. protected _mainTextureDesiredSize: ISize;
  52732. protected _mainTexture: RenderTargetTexture;
  52733. protected _shouldRender: boolean;
  52734. protected _postProcesses: PostProcess[];
  52735. protected _textures: BaseTexture[];
  52736. protected _emissiveTextureAndColor: {
  52737. texture: Nullable<BaseTexture>;
  52738. color: Color4;
  52739. };
  52740. /**
  52741. * The name of the layer
  52742. */
  52743. name: string;
  52744. /**
  52745. * The clear color of the texture used to generate the glow map.
  52746. */
  52747. neutralColor: Color4;
  52748. /**
  52749. * Specifies whether the highlight layer is enabled or not.
  52750. */
  52751. isEnabled: boolean;
  52752. /**
  52753. * Gets the camera attached to the layer.
  52754. */
  52755. get camera(): Nullable<Camera>;
  52756. /**
  52757. * Gets the rendering group id the layer should render in.
  52758. */
  52759. get renderingGroupId(): number;
  52760. set renderingGroupId(renderingGroupId: number);
  52761. /**
  52762. * An event triggered when the effect layer has been disposed.
  52763. */
  52764. onDisposeObservable: Observable<EffectLayer>;
  52765. /**
  52766. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52767. */
  52768. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52769. /**
  52770. * An event triggered when the generated texture is being merged in the scene.
  52771. */
  52772. onBeforeComposeObservable: Observable<EffectLayer>;
  52773. /**
  52774. * An event triggered when the mesh is rendered into the effect render target.
  52775. */
  52776. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52777. /**
  52778. * An event triggered after the mesh has been rendered into the effect render target.
  52779. */
  52780. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52781. /**
  52782. * An event triggered when the generated texture has been merged in the scene.
  52783. */
  52784. onAfterComposeObservable: Observable<EffectLayer>;
  52785. /**
  52786. * An event triggered when the efffect layer changes its size.
  52787. */
  52788. onSizeChangedObservable: Observable<EffectLayer>;
  52789. /** @hidden */
  52790. static _SceneComponentInitialization: (scene: Scene) => void;
  52791. /**
  52792. * Instantiates a new effect Layer and references it in the scene.
  52793. * @param name The name of the layer
  52794. * @param scene The scene to use the layer in
  52795. */
  52796. constructor(
  52797. /** The Friendly of the effect in the scene */
  52798. name: string, scene: Scene);
  52799. /**
  52800. * Get the effect name of the layer.
  52801. * @return The effect name
  52802. */
  52803. abstract getEffectName(): string;
  52804. /**
  52805. * Checks for the readiness of the element composing the layer.
  52806. * @param subMesh the mesh to check for
  52807. * @param useInstances specify whether or not to use instances to render the mesh
  52808. * @return true if ready otherwise, false
  52809. */
  52810. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52811. /**
  52812. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52813. * @returns true if the effect requires stencil during the main canvas render pass.
  52814. */
  52815. abstract needStencil(): boolean;
  52816. /**
  52817. * Create the merge effect. This is the shader use to blit the information back
  52818. * to the main canvas at the end of the scene rendering.
  52819. * @returns The effect containing the shader used to merge the effect on the main canvas
  52820. */
  52821. protected abstract _createMergeEffect(): Effect;
  52822. /**
  52823. * Creates the render target textures and post processes used in the effect layer.
  52824. */
  52825. protected abstract _createTextureAndPostProcesses(): void;
  52826. /**
  52827. * Implementation specific of rendering the generating effect on the main canvas.
  52828. * @param effect The effect used to render through
  52829. */
  52830. protected abstract _internalRender(effect: Effect): void;
  52831. /**
  52832. * Sets the required values for both the emissive texture and and the main color.
  52833. */
  52834. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52835. /**
  52836. * Free any resources and references associated to a mesh.
  52837. * Internal use
  52838. * @param mesh The mesh to free.
  52839. */
  52840. abstract _disposeMesh(mesh: Mesh): void;
  52841. /**
  52842. * Serializes this layer (Glow or Highlight for example)
  52843. * @returns a serialized layer object
  52844. */
  52845. abstract serialize?(): any;
  52846. /**
  52847. * Initializes the effect layer with the required options.
  52848. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52849. */
  52850. protected _init(options: Partial<IEffectLayerOptions>): void;
  52851. /**
  52852. * Generates the index buffer of the full screen quad blending to the main canvas.
  52853. */
  52854. private _generateIndexBuffer;
  52855. /**
  52856. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52857. */
  52858. private _generateVertexBuffer;
  52859. /**
  52860. * Sets the main texture desired size which is the closest power of two
  52861. * of the engine canvas size.
  52862. */
  52863. private _setMainTextureSize;
  52864. /**
  52865. * Creates the main texture for the effect layer.
  52866. */
  52867. protected _createMainTexture(): void;
  52868. /**
  52869. * Adds specific effects defines.
  52870. * @param defines The defines to add specifics to.
  52871. */
  52872. protected _addCustomEffectDefines(defines: string[]): void;
  52873. /**
  52874. * Checks for the readiness of the element composing the layer.
  52875. * @param subMesh the mesh to check for
  52876. * @param useInstances specify whether or not to use instances to render the mesh
  52877. * @param emissiveTexture the associated emissive texture used to generate the glow
  52878. * @return true if ready otherwise, false
  52879. */
  52880. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52881. /**
  52882. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52883. */
  52884. render(): void;
  52885. /**
  52886. * Determine if a given mesh will be used in the current effect.
  52887. * @param mesh mesh to test
  52888. * @returns true if the mesh will be used
  52889. */
  52890. hasMesh(mesh: AbstractMesh): boolean;
  52891. /**
  52892. * Returns true if the layer contains information to display, otherwise false.
  52893. * @returns true if the glow layer should be rendered
  52894. */
  52895. shouldRender(): boolean;
  52896. /**
  52897. * Returns true if the mesh should render, otherwise false.
  52898. * @param mesh The mesh to render
  52899. * @returns true if it should render otherwise false
  52900. */
  52901. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52902. /**
  52903. * Returns true if the mesh can be rendered, otherwise false.
  52904. * @param mesh The mesh to render
  52905. * @param material The material used on the mesh
  52906. * @returns true if it can be rendered otherwise false
  52907. */
  52908. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52909. /**
  52910. * Returns true if the mesh should render, otherwise false.
  52911. * @param mesh The mesh to render
  52912. * @returns true if it should render otherwise false
  52913. */
  52914. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52915. /**
  52916. * Renders the submesh passed in parameter to the generation map.
  52917. */
  52918. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52919. /**
  52920. * Defines whether the current material of the mesh should be use to render the effect.
  52921. * @param mesh defines the current mesh to render
  52922. */
  52923. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52924. /**
  52925. * Rebuild the required buffers.
  52926. * @hidden Internal use only.
  52927. */
  52928. _rebuild(): void;
  52929. /**
  52930. * Dispose only the render target textures and post process.
  52931. */
  52932. private _disposeTextureAndPostProcesses;
  52933. /**
  52934. * Dispose the highlight layer and free resources.
  52935. */
  52936. dispose(): void;
  52937. /**
  52938. * Gets the class name of the effect layer
  52939. * @returns the string with the class name of the effect layer
  52940. */
  52941. getClassName(): string;
  52942. /**
  52943. * Creates an effect layer from parsed effect layer data
  52944. * @param parsedEffectLayer defines effect layer data
  52945. * @param scene defines the current scene
  52946. * @param rootUrl defines the root URL containing the effect layer information
  52947. * @returns a parsed effect Layer
  52948. */
  52949. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52950. }
  52951. }
  52952. declare module BABYLON {
  52953. interface AbstractScene {
  52954. /**
  52955. * The list of effect layers (highlights/glow) added to the scene
  52956. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52957. * @see http://doc.babylonjs.com/how_to/glow_layer
  52958. */
  52959. effectLayers: Array<EffectLayer>;
  52960. /**
  52961. * Removes the given effect layer from this scene.
  52962. * @param toRemove defines the effect layer to remove
  52963. * @returns the index of the removed effect layer
  52964. */
  52965. removeEffectLayer(toRemove: EffectLayer): number;
  52966. /**
  52967. * Adds the given effect layer to this scene
  52968. * @param newEffectLayer defines the effect layer to add
  52969. */
  52970. addEffectLayer(newEffectLayer: EffectLayer): void;
  52971. }
  52972. /**
  52973. * Defines the layer scene component responsible to manage any effect layers
  52974. * in a given scene.
  52975. */
  52976. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52977. /**
  52978. * The component name helpfull to identify the component in the list of scene components.
  52979. */
  52980. readonly name: string;
  52981. /**
  52982. * The scene the component belongs to.
  52983. */
  52984. scene: Scene;
  52985. private _engine;
  52986. private _renderEffects;
  52987. private _needStencil;
  52988. private _previousStencilState;
  52989. /**
  52990. * Creates a new instance of the component for the given scene
  52991. * @param scene Defines the scene to register the component in
  52992. */
  52993. constructor(scene: Scene);
  52994. /**
  52995. * Registers the component in a given scene
  52996. */
  52997. register(): void;
  52998. /**
  52999. * Rebuilds the elements related to this component in case of
  53000. * context lost for instance.
  53001. */
  53002. rebuild(): void;
  53003. /**
  53004. * Serializes the component data to the specified json object
  53005. * @param serializationObject The object to serialize to
  53006. */
  53007. serialize(serializationObject: any): void;
  53008. /**
  53009. * Adds all the elements from the container to the scene
  53010. * @param container the container holding the elements
  53011. */
  53012. addFromContainer(container: AbstractScene): void;
  53013. /**
  53014. * Removes all the elements in the container from the scene
  53015. * @param container contains the elements to remove
  53016. * @param dispose if the removed element should be disposed (default: false)
  53017. */
  53018. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53019. /**
  53020. * Disposes the component and the associated ressources.
  53021. */
  53022. dispose(): void;
  53023. private _isReadyForMesh;
  53024. private _renderMainTexture;
  53025. private _setStencil;
  53026. private _setStencilBack;
  53027. private _draw;
  53028. private _drawCamera;
  53029. private _drawRenderingGroup;
  53030. }
  53031. }
  53032. declare module BABYLON {
  53033. /** @hidden */
  53034. export var glowMapMergePixelShader: {
  53035. name: string;
  53036. shader: string;
  53037. };
  53038. }
  53039. declare module BABYLON {
  53040. /** @hidden */
  53041. export var glowMapMergeVertexShader: {
  53042. name: string;
  53043. shader: string;
  53044. };
  53045. }
  53046. declare module BABYLON {
  53047. interface AbstractScene {
  53048. /**
  53049. * Return a the first highlight layer of the scene with a given name.
  53050. * @param name The name of the highlight layer to look for.
  53051. * @return The highlight layer if found otherwise null.
  53052. */
  53053. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53054. }
  53055. /**
  53056. * Glow layer options. This helps customizing the behaviour
  53057. * of the glow layer.
  53058. */
  53059. export interface IGlowLayerOptions {
  53060. /**
  53061. * Multiplication factor apply to the canvas size to compute the render target size
  53062. * used to generated the glowing objects (the smaller the faster).
  53063. */
  53064. mainTextureRatio: number;
  53065. /**
  53066. * Enforces a fixed size texture to ensure resize independant blur.
  53067. */
  53068. mainTextureFixedSize?: number;
  53069. /**
  53070. * How big is the kernel of the blur texture.
  53071. */
  53072. blurKernelSize: number;
  53073. /**
  53074. * The camera attached to the layer.
  53075. */
  53076. camera: Nullable<Camera>;
  53077. /**
  53078. * Enable MSAA by chosing the number of samples.
  53079. */
  53080. mainTextureSamples?: number;
  53081. /**
  53082. * The rendering group to draw the layer in.
  53083. */
  53084. renderingGroupId: number;
  53085. }
  53086. /**
  53087. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53088. *
  53089. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53090. *
  53091. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53092. */
  53093. export class GlowLayer extends EffectLayer {
  53094. /**
  53095. * Effect Name of the layer.
  53096. */
  53097. static readonly EffectName: string;
  53098. /**
  53099. * The default blur kernel size used for the glow.
  53100. */
  53101. static DefaultBlurKernelSize: number;
  53102. /**
  53103. * The default texture size ratio used for the glow.
  53104. */
  53105. static DefaultTextureRatio: number;
  53106. /**
  53107. * Sets the kernel size of the blur.
  53108. */
  53109. set blurKernelSize(value: number);
  53110. /**
  53111. * Gets the kernel size of the blur.
  53112. */
  53113. get blurKernelSize(): number;
  53114. /**
  53115. * Sets the glow intensity.
  53116. */
  53117. set intensity(value: number);
  53118. /**
  53119. * Gets the glow intensity.
  53120. */
  53121. get intensity(): number;
  53122. private _options;
  53123. private _intensity;
  53124. private _horizontalBlurPostprocess1;
  53125. private _verticalBlurPostprocess1;
  53126. private _horizontalBlurPostprocess2;
  53127. private _verticalBlurPostprocess2;
  53128. private _blurTexture1;
  53129. private _blurTexture2;
  53130. private _postProcesses1;
  53131. private _postProcesses2;
  53132. private _includedOnlyMeshes;
  53133. private _excludedMeshes;
  53134. private _meshesUsingTheirOwnMaterials;
  53135. /**
  53136. * Callback used to let the user override the color selection on a per mesh basis
  53137. */
  53138. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53139. /**
  53140. * Callback used to let the user override the texture selection on a per mesh basis
  53141. */
  53142. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53143. /**
  53144. * Instantiates a new glow Layer and references it to the scene.
  53145. * @param name The name of the layer
  53146. * @param scene The scene to use the layer in
  53147. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53148. */
  53149. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53150. /**
  53151. * Get the effect name of the layer.
  53152. * @return The effect name
  53153. */
  53154. getEffectName(): string;
  53155. /**
  53156. * Create the merge effect. This is the shader use to blit the information back
  53157. * to the main canvas at the end of the scene rendering.
  53158. */
  53159. protected _createMergeEffect(): Effect;
  53160. /**
  53161. * Creates the render target textures and post processes used in the glow layer.
  53162. */
  53163. protected _createTextureAndPostProcesses(): void;
  53164. /**
  53165. * Checks for the readiness of the element composing the layer.
  53166. * @param subMesh the mesh to check for
  53167. * @param useInstances specify wether or not to use instances to render the mesh
  53168. * @param emissiveTexture the associated emissive texture used to generate the glow
  53169. * @return true if ready otherwise, false
  53170. */
  53171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53172. /**
  53173. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53174. */
  53175. needStencil(): boolean;
  53176. /**
  53177. * Returns true if the mesh can be rendered, otherwise false.
  53178. * @param mesh The mesh to render
  53179. * @param material The material used on the mesh
  53180. * @returns true if it can be rendered otherwise false
  53181. */
  53182. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53183. /**
  53184. * Implementation specific of rendering the generating effect on the main canvas.
  53185. * @param effect The effect used to render through
  53186. */
  53187. protected _internalRender(effect: Effect): void;
  53188. /**
  53189. * Sets the required values for both the emissive texture and and the main color.
  53190. */
  53191. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53192. /**
  53193. * Returns true if the mesh should render, otherwise false.
  53194. * @param mesh The mesh to render
  53195. * @returns true if it should render otherwise false
  53196. */
  53197. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53198. /**
  53199. * Adds specific effects defines.
  53200. * @param defines The defines to add specifics to.
  53201. */
  53202. protected _addCustomEffectDefines(defines: string[]): void;
  53203. /**
  53204. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53205. * @param mesh The mesh to exclude from the glow layer
  53206. */
  53207. addExcludedMesh(mesh: Mesh): void;
  53208. /**
  53209. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53210. * @param mesh The mesh to remove
  53211. */
  53212. removeExcludedMesh(mesh: Mesh): void;
  53213. /**
  53214. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53215. * @param mesh The mesh to include in the glow layer
  53216. */
  53217. addIncludedOnlyMesh(mesh: Mesh): void;
  53218. /**
  53219. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53220. * @param mesh The mesh to remove
  53221. */
  53222. removeIncludedOnlyMesh(mesh: Mesh): void;
  53223. /**
  53224. * Determine if a given mesh will be used in the glow layer
  53225. * @param mesh The mesh to test
  53226. * @returns true if the mesh will be highlighted by the current glow layer
  53227. */
  53228. hasMesh(mesh: AbstractMesh): boolean;
  53229. /**
  53230. * Defines whether the current material of the mesh should be use to render the effect.
  53231. * @param mesh defines the current mesh to render
  53232. */
  53233. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53234. /**
  53235. * Add a mesh to be rendered through its own material and not with emissive only.
  53236. * @param mesh The mesh for which we need to use its material
  53237. */
  53238. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53239. /**
  53240. * Remove a mesh from being rendered through its own material and not with emissive only.
  53241. * @param mesh The mesh for which we need to not use its material
  53242. */
  53243. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53244. /**
  53245. * Free any resources and references associated to a mesh.
  53246. * Internal use
  53247. * @param mesh The mesh to free.
  53248. * @hidden
  53249. */
  53250. _disposeMesh(mesh: Mesh): void;
  53251. /**
  53252. * Gets the class name of the effect layer
  53253. * @returns the string with the class name of the effect layer
  53254. */
  53255. getClassName(): string;
  53256. /**
  53257. * Serializes this glow layer
  53258. * @returns a serialized glow layer object
  53259. */
  53260. serialize(): any;
  53261. /**
  53262. * Creates a Glow Layer from parsed glow layer data
  53263. * @param parsedGlowLayer defines glow layer data
  53264. * @param scene defines the current scene
  53265. * @param rootUrl defines the root URL containing the glow layer information
  53266. * @returns a parsed Glow Layer
  53267. */
  53268. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53269. }
  53270. }
  53271. declare module BABYLON {
  53272. /** @hidden */
  53273. export var glowBlurPostProcessPixelShader: {
  53274. name: string;
  53275. shader: string;
  53276. };
  53277. }
  53278. declare module BABYLON {
  53279. interface AbstractScene {
  53280. /**
  53281. * Return a the first highlight layer of the scene with a given name.
  53282. * @param name The name of the highlight layer to look for.
  53283. * @return The highlight layer if found otherwise null.
  53284. */
  53285. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53286. }
  53287. /**
  53288. * Highlight layer options. This helps customizing the behaviour
  53289. * of the highlight layer.
  53290. */
  53291. export interface IHighlightLayerOptions {
  53292. /**
  53293. * Multiplication factor apply to the canvas size to compute the render target size
  53294. * used to generated the glowing objects (the smaller the faster).
  53295. */
  53296. mainTextureRatio: number;
  53297. /**
  53298. * Enforces a fixed size texture to ensure resize independant blur.
  53299. */
  53300. mainTextureFixedSize?: number;
  53301. /**
  53302. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53303. * of the picture to blur (the smaller the faster).
  53304. */
  53305. blurTextureSizeRatio: number;
  53306. /**
  53307. * How big in texel of the blur texture is the vertical blur.
  53308. */
  53309. blurVerticalSize: number;
  53310. /**
  53311. * How big in texel of the blur texture is the horizontal blur.
  53312. */
  53313. blurHorizontalSize: number;
  53314. /**
  53315. * Alpha blending mode used to apply the blur. Default is combine.
  53316. */
  53317. alphaBlendingMode: number;
  53318. /**
  53319. * The camera attached to the layer.
  53320. */
  53321. camera: Nullable<Camera>;
  53322. /**
  53323. * Should we display highlight as a solid stroke?
  53324. */
  53325. isStroke?: boolean;
  53326. /**
  53327. * The rendering group to draw the layer in.
  53328. */
  53329. renderingGroupId: number;
  53330. }
  53331. /**
  53332. * The highlight layer Helps adding a glow effect around a mesh.
  53333. *
  53334. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53335. * glowy meshes to your scene.
  53336. *
  53337. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53338. */
  53339. export class HighlightLayer extends EffectLayer {
  53340. name: string;
  53341. /**
  53342. * Effect Name of the highlight layer.
  53343. */
  53344. static readonly EffectName: string;
  53345. /**
  53346. * The neutral color used during the preparation of the glow effect.
  53347. * This is black by default as the blend operation is a blend operation.
  53348. */
  53349. static NeutralColor: Color4;
  53350. /**
  53351. * Stencil value used for glowing meshes.
  53352. */
  53353. static GlowingMeshStencilReference: number;
  53354. /**
  53355. * Stencil value used for the other meshes in the scene.
  53356. */
  53357. static NormalMeshStencilReference: number;
  53358. /**
  53359. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53360. */
  53361. innerGlow: boolean;
  53362. /**
  53363. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53364. */
  53365. outerGlow: boolean;
  53366. /**
  53367. * Specifies the horizontal size of the blur.
  53368. */
  53369. set blurHorizontalSize(value: number);
  53370. /**
  53371. * Specifies the vertical size of the blur.
  53372. */
  53373. set blurVerticalSize(value: number);
  53374. /**
  53375. * Gets the horizontal size of the blur.
  53376. */
  53377. get blurHorizontalSize(): number;
  53378. /**
  53379. * Gets the vertical size of the blur.
  53380. */
  53381. get blurVerticalSize(): number;
  53382. /**
  53383. * An event triggered when the highlight layer is being blurred.
  53384. */
  53385. onBeforeBlurObservable: Observable<HighlightLayer>;
  53386. /**
  53387. * An event triggered when the highlight layer has been blurred.
  53388. */
  53389. onAfterBlurObservable: Observable<HighlightLayer>;
  53390. private _instanceGlowingMeshStencilReference;
  53391. private _options;
  53392. private _downSamplePostprocess;
  53393. private _horizontalBlurPostprocess;
  53394. private _verticalBlurPostprocess;
  53395. private _blurTexture;
  53396. private _meshes;
  53397. private _excludedMeshes;
  53398. /**
  53399. * Instantiates a new highlight Layer and references it to the scene..
  53400. * @param name The name of the layer
  53401. * @param scene The scene to use the layer in
  53402. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53403. */
  53404. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53405. /**
  53406. * Get the effect name of the layer.
  53407. * @return The effect name
  53408. */
  53409. getEffectName(): string;
  53410. /**
  53411. * Create the merge effect. This is the shader use to blit the information back
  53412. * to the main canvas at the end of the scene rendering.
  53413. */
  53414. protected _createMergeEffect(): Effect;
  53415. /**
  53416. * Creates the render target textures and post processes used in the highlight layer.
  53417. */
  53418. protected _createTextureAndPostProcesses(): void;
  53419. /**
  53420. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53421. */
  53422. needStencil(): boolean;
  53423. /**
  53424. * Checks for the readiness of the element composing the layer.
  53425. * @param subMesh the mesh to check for
  53426. * @param useInstances specify wether or not to use instances to render the mesh
  53427. * @param emissiveTexture the associated emissive texture used to generate the glow
  53428. * @return true if ready otherwise, false
  53429. */
  53430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53431. /**
  53432. * Implementation specific of rendering the generating effect on the main canvas.
  53433. * @param effect The effect used to render through
  53434. */
  53435. protected _internalRender(effect: Effect): void;
  53436. /**
  53437. * Returns true if the layer contains information to display, otherwise false.
  53438. */
  53439. shouldRender(): boolean;
  53440. /**
  53441. * Returns true if the mesh should render, otherwise false.
  53442. * @param mesh The mesh to render
  53443. * @returns true if it should render otherwise false
  53444. */
  53445. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53446. /**
  53447. * Sets the required values for both the emissive texture and and the main color.
  53448. */
  53449. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53450. /**
  53451. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53452. * @param mesh The mesh to exclude from the highlight layer
  53453. */
  53454. addExcludedMesh(mesh: Mesh): void;
  53455. /**
  53456. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53457. * @param mesh The mesh to highlight
  53458. */
  53459. removeExcludedMesh(mesh: Mesh): void;
  53460. /**
  53461. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53462. * @param mesh mesh to test
  53463. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53464. */
  53465. hasMesh(mesh: AbstractMesh): boolean;
  53466. /**
  53467. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53468. * @param mesh The mesh to highlight
  53469. * @param color The color of the highlight
  53470. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53471. */
  53472. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53473. /**
  53474. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53475. * @param mesh The mesh to highlight
  53476. */
  53477. removeMesh(mesh: Mesh): void;
  53478. /**
  53479. * Force the stencil to the normal expected value for none glowing parts
  53480. */
  53481. private _defaultStencilReference;
  53482. /**
  53483. * Free any resources and references associated to a mesh.
  53484. * Internal use
  53485. * @param mesh The mesh to free.
  53486. * @hidden
  53487. */
  53488. _disposeMesh(mesh: Mesh): void;
  53489. /**
  53490. * Dispose the highlight layer and free resources.
  53491. */
  53492. dispose(): void;
  53493. /**
  53494. * Gets the class name of the effect layer
  53495. * @returns the string with the class name of the effect layer
  53496. */
  53497. getClassName(): string;
  53498. /**
  53499. * Serializes this Highlight layer
  53500. * @returns a serialized Highlight layer object
  53501. */
  53502. serialize(): any;
  53503. /**
  53504. * Creates a Highlight layer from parsed Highlight layer data
  53505. * @param parsedHightlightLayer defines the Highlight layer data
  53506. * @param scene defines the current scene
  53507. * @param rootUrl defines the root URL containing the Highlight layer information
  53508. * @returns a parsed Highlight layer
  53509. */
  53510. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53511. }
  53512. }
  53513. declare module BABYLON {
  53514. interface AbstractScene {
  53515. /**
  53516. * The list of layers (background and foreground) of the scene
  53517. */
  53518. layers: Array<Layer>;
  53519. }
  53520. /**
  53521. * Defines the layer scene component responsible to manage any layers
  53522. * in a given scene.
  53523. */
  53524. export class LayerSceneComponent implements ISceneComponent {
  53525. /**
  53526. * The component name helpfull to identify the component in the list of scene components.
  53527. */
  53528. readonly name: string;
  53529. /**
  53530. * The scene the component belongs to.
  53531. */
  53532. scene: Scene;
  53533. private _engine;
  53534. /**
  53535. * Creates a new instance of the component for the given scene
  53536. * @param scene Defines the scene to register the component in
  53537. */
  53538. constructor(scene: Scene);
  53539. /**
  53540. * Registers the component in a given scene
  53541. */
  53542. register(): void;
  53543. /**
  53544. * Rebuilds the elements related to this component in case of
  53545. * context lost for instance.
  53546. */
  53547. rebuild(): void;
  53548. /**
  53549. * Disposes the component and the associated ressources.
  53550. */
  53551. dispose(): void;
  53552. private _draw;
  53553. private _drawCameraPredicate;
  53554. private _drawCameraBackground;
  53555. private _drawCameraForeground;
  53556. private _drawRenderTargetPredicate;
  53557. private _drawRenderTargetBackground;
  53558. private _drawRenderTargetForeground;
  53559. /**
  53560. * Adds all the elements from the container to the scene
  53561. * @param container the container holding the elements
  53562. */
  53563. addFromContainer(container: AbstractScene): void;
  53564. /**
  53565. * Removes all the elements in the container from the scene
  53566. * @param container contains the elements to remove
  53567. * @param dispose if the removed element should be disposed (default: false)
  53568. */
  53569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53570. }
  53571. }
  53572. declare module BABYLON {
  53573. /** @hidden */
  53574. export var layerPixelShader: {
  53575. name: string;
  53576. shader: string;
  53577. };
  53578. }
  53579. declare module BABYLON {
  53580. /** @hidden */
  53581. export var layerVertexShader: {
  53582. name: string;
  53583. shader: string;
  53584. };
  53585. }
  53586. declare module BABYLON {
  53587. /**
  53588. * This represents a full screen 2d layer.
  53589. * This can be useful to display a picture in the background of your scene for instance.
  53590. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53591. */
  53592. export class Layer {
  53593. /**
  53594. * Define the name of the layer.
  53595. */
  53596. name: string;
  53597. /**
  53598. * Define the texture the layer should display.
  53599. */
  53600. texture: Nullable<Texture>;
  53601. /**
  53602. * Is the layer in background or foreground.
  53603. */
  53604. isBackground: boolean;
  53605. /**
  53606. * Define the color of the layer (instead of texture).
  53607. */
  53608. color: Color4;
  53609. /**
  53610. * Define the scale of the layer in order to zoom in out of the texture.
  53611. */
  53612. scale: Vector2;
  53613. /**
  53614. * Define an offset for the layer in order to shift the texture.
  53615. */
  53616. offset: Vector2;
  53617. /**
  53618. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53619. */
  53620. alphaBlendingMode: number;
  53621. /**
  53622. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53623. * Alpha test will not mix with the background color in case of transparency.
  53624. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53625. */
  53626. alphaTest: boolean;
  53627. /**
  53628. * Define a mask to restrict the layer to only some of the scene cameras.
  53629. */
  53630. layerMask: number;
  53631. /**
  53632. * Define the list of render target the layer is visible into.
  53633. */
  53634. renderTargetTextures: RenderTargetTexture[];
  53635. /**
  53636. * Define if the layer is only used in renderTarget or if it also
  53637. * renders in the main frame buffer of the canvas.
  53638. */
  53639. renderOnlyInRenderTargetTextures: boolean;
  53640. private _scene;
  53641. private _vertexBuffers;
  53642. private _indexBuffer;
  53643. private _effect;
  53644. private _previousDefines;
  53645. /**
  53646. * An event triggered when the layer is disposed.
  53647. */
  53648. onDisposeObservable: Observable<Layer>;
  53649. private _onDisposeObserver;
  53650. /**
  53651. * Back compatibility with callback before the onDisposeObservable existed.
  53652. * The set callback will be triggered when the layer has been disposed.
  53653. */
  53654. set onDispose(callback: () => void);
  53655. /**
  53656. * An event triggered before rendering the scene
  53657. */
  53658. onBeforeRenderObservable: Observable<Layer>;
  53659. private _onBeforeRenderObserver;
  53660. /**
  53661. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53662. * The set callback will be triggered just before rendering the layer.
  53663. */
  53664. set onBeforeRender(callback: () => void);
  53665. /**
  53666. * An event triggered after rendering the scene
  53667. */
  53668. onAfterRenderObservable: Observable<Layer>;
  53669. private _onAfterRenderObserver;
  53670. /**
  53671. * Back compatibility with callback before the onAfterRenderObservable existed.
  53672. * The set callback will be triggered just after rendering the layer.
  53673. */
  53674. set onAfterRender(callback: () => void);
  53675. /**
  53676. * Instantiates a new layer.
  53677. * This represents a full screen 2d layer.
  53678. * This can be useful to display a picture in the background of your scene for instance.
  53679. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53680. * @param name Define the name of the layer in the scene
  53681. * @param imgUrl Define the url of the texture to display in the layer
  53682. * @param scene Define the scene the layer belongs to
  53683. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53684. * @param color Defines a color for the layer
  53685. */
  53686. constructor(
  53687. /**
  53688. * Define the name of the layer.
  53689. */
  53690. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53691. private _createIndexBuffer;
  53692. /** @hidden */
  53693. _rebuild(): void;
  53694. /**
  53695. * Renders the layer in the scene.
  53696. */
  53697. render(): void;
  53698. /**
  53699. * Disposes and releases the associated ressources.
  53700. */
  53701. dispose(): void;
  53702. }
  53703. }
  53704. declare module BABYLON {
  53705. /** @hidden */
  53706. export var lensFlarePixelShader: {
  53707. name: string;
  53708. shader: string;
  53709. };
  53710. }
  53711. declare module BABYLON {
  53712. /** @hidden */
  53713. export var lensFlareVertexShader: {
  53714. name: string;
  53715. shader: string;
  53716. };
  53717. }
  53718. declare module BABYLON {
  53719. /**
  53720. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53721. * It is usually composed of several `lensFlare`.
  53722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53723. */
  53724. export class LensFlareSystem {
  53725. /**
  53726. * Define the name of the lens flare system
  53727. */
  53728. name: string;
  53729. /**
  53730. * List of lens flares used in this system.
  53731. */
  53732. lensFlares: LensFlare[];
  53733. /**
  53734. * Define a limit from the border the lens flare can be visible.
  53735. */
  53736. borderLimit: number;
  53737. /**
  53738. * Define a viewport border we do not want to see the lens flare in.
  53739. */
  53740. viewportBorder: number;
  53741. /**
  53742. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53743. */
  53744. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53745. /**
  53746. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53747. */
  53748. layerMask: number;
  53749. /**
  53750. * Define the id of the lens flare system in the scene.
  53751. * (equal to name by default)
  53752. */
  53753. id: string;
  53754. private _scene;
  53755. private _emitter;
  53756. private _vertexBuffers;
  53757. private _indexBuffer;
  53758. private _effect;
  53759. private _positionX;
  53760. private _positionY;
  53761. private _isEnabled;
  53762. /** @hidden */
  53763. static _SceneComponentInitialization: (scene: Scene) => void;
  53764. /**
  53765. * Instantiates a lens flare system.
  53766. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53767. * It is usually composed of several `lensFlare`.
  53768. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53769. * @param name Define the name of the lens flare system in the scene
  53770. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53771. * @param scene Define the scene the lens flare system belongs to
  53772. */
  53773. constructor(
  53774. /**
  53775. * Define the name of the lens flare system
  53776. */
  53777. name: string, emitter: any, scene: Scene);
  53778. /**
  53779. * Define if the lens flare system is enabled.
  53780. */
  53781. get isEnabled(): boolean;
  53782. set isEnabled(value: boolean);
  53783. /**
  53784. * Get the scene the effects belongs to.
  53785. * @returns the scene holding the lens flare system
  53786. */
  53787. getScene(): Scene;
  53788. /**
  53789. * Get the emitter of the lens flare system.
  53790. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53791. * @returns the emitter of the lens flare system
  53792. */
  53793. getEmitter(): any;
  53794. /**
  53795. * Set the emitter of the lens flare system.
  53796. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53797. * @param newEmitter Define the new emitter of the system
  53798. */
  53799. setEmitter(newEmitter: any): void;
  53800. /**
  53801. * Get the lens flare system emitter position.
  53802. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53803. * @returns the position
  53804. */
  53805. getEmitterPosition(): Vector3;
  53806. /**
  53807. * @hidden
  53808. */
  53809. computeEffectivePosition(globalViewport: Viewport): boolean;
  53810. /** @hidden */
  53811. _isVisible(): boolean;
  53812. /**
  53813. * @hidden
  53814. */
  53815. render(): boolean;
  53816. /**
  53817. * Dispose and release the lens flare with its associated resources.
  53818. */
  53819. dispose(): void;
  53820. /**
  53821. * Parse a lens flare system from a JSON repressentation
  53822. * @param parsedLensFlareSystem Define the JSON to parse
  53823. * @param scene Define the scene the parsed system should be instantiated in
  53824. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53825. * @returns the parsed system
  53826. */
  53827. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53828. /**
  53829. * Serialize the current Lens Flare System into a JSON representation.
  53830. * @returns the serialized JSON
  53831. */
  53832. serialize(): any;
  53833. }
  53834. }
  53835. declare module BABYLON {
  53836. /**
  53837. * This represents one of the lens effect in a `lensFlareSystem`.
  53838. * It controls one of the indiviual texture used in the effect.
  53839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53840. */
  53841. export class LensFlare {
  53842. /**
  53843. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53844. */
  53845. size: number;
  53846. /**
  53847. * 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.
  53848. */
  53849. position: number;
  53850. /**
  53851. * Define the lens color.
  53852. */
  53853. color: Color3;
  53854. /**
  53855. * Define the lens texture.
  53856. */
  53857. texture: Nullable<Texture>;
  53858. /**
  53859. * Define the alpha mode to render this particular lens.
  53860. */
  53861. alphaMode: number;
  53862. private _system;
  53863. /**
  53864. * Creates a new Lens Flare.
  53865. * This represents one of the lens effect in a `lensFlareSystem`.
  53866. * It controls one of the indiviual texture used in the effect.
  53867. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53868. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53869. * @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.
  53870. * @param color Define the lens color
  53871. * @param imgUrl Define the lens texture url
  53872. * @param system Define the `lensFlareSystem` this flare is part of
  53873. * @returns The newly created Lens Flare
  53874. */
  53875. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53876. /**
  53877. * Instantiates a new Lens Flare.
  53878. * This represents one of the lens effect in a `lensFlareSystem`.
  53879. * It controls one of the indiviual texture used in the effect.
  53880. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53881. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53882. * @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.
  53883. * @param color Define the lens color
  53884. * @param imgUrl Define the lens texture url
  53885. * @param system Define the `lensFlareSystem` this flare is part of
  53886. */
  53887. constructor(
  53888. /**
  53889. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53890. */
  53891. size: number,
  53892. /**
  53893. * 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.
  53894. */
  53895. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53896. /**
  53897. * Dispose and release the lens flare with its associated resources.
  53898. */
  53899. dispose(): void;
  53900. }
  53901. }
  53902. declare module BABYLON {
  53903. interface AbstractScene {
  53904. /**
  53905. * The list of lens flare system added to the scene
  53906. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53907. */
  53908. lensFlareSystems: Array<LensFlareSystem>;
  53909. /**
  53910. * Removes the given lens flare system from this scene.
  53911. * @param toRemove The lens flare system to remove
  53912. * @returns The index of the removed lens flare system
  53913. */
  53914. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53915. /**
  53916. * Adds the given lens flare system to this scene
  53917. * @param newLensFlareSystem The lens flare system to add
  53918. */
  53919. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53920. /**
  53921. * Gets a lens flare system using its name
  53922. * @param name defines the name to look for
  53923. * @returns the lens flare system or null if not found
  53924. */
  53925. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53926. /**
  53927. * Gets a lens flare system using its id
  53928. * @param id defines the id to look for
  53929. * @returns the lens flare system or null if not found
  53930. */
  53931. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53932. }
  53933. /**
  53934. * Defines the lens flare scene component responsible to manage any lens flares
  53935. * in a given scene.
  53936. */
  53937. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53938. /**
  53939. * The component name helpfull to identify the component in the list of scene components.
  53940. */
  53941. readonly name: string;
  53942. /**
  53943. * The scene the component belongs to.
  53944. */
  53945. scene: Scene;
  53946. /**
  53947. * Creates a new instance of the component for the given scene
  53948. * @param scene Defines the scene to register the component in
  53949. */
  53950. constructor(scene: Scene);
  53951. /**
  53952. * Registers the component in a given scene
  53953. */
  53954. register(): void;
  53955. /**
  53956. * Rebuilds the elements related to this component in case of
  53957. * context lost for instance.
  53958. */
  53959. rebuild(): void;
  53960. /**
  53961. * Adds all the elements from the container to the scene
  53962. * @param container the container holding the elements
  53963. */
  53964. addFromContainer(container: AbstractScene): void;
  53965. /**
  53966. * Removes all the elements in the container from the scene
  53967. * @param container contains the elements to remove
  53968. * @param dispose if the removed element should be disposed (default: false)
  53969. */
  53970. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53971. /**
  53972. * Serializes the component data to the specified json object
  53973. * @param serializationObject The object to serialize to
  53974. */
  53975. serialize(serializationObject: any): void;
  53976. /**
  53977. * Disposes the component and the associated ressources.
  53978. */
  53979. dispose(): void;
  53980. private _draw;
  53981. }
  53982. }
  53983. declare module BABYLON {
  53984. /** @hidden */
  53985. export var depthPixelShader: {
  53986. name: string;
  53987. shader: string;
  53988. };
  53989. }
  53990. declare module BABYLON {
  53991. /** @hidden */
  53992. export var depthVertexShader: {
  53993. name: string;
  53994. shader: string;
  53995. };
  53996. }
  53997. declare module BABYLON {
  53998. /**
  53999. * This represents a depth renderer in Babylon.
  54000. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54001. */
  54002. export class DepthRenderer {
  54003. private _scene;
  54004. private _depthMap;
  54005. private _effect;
  54006. private readonly _storeNonLinearDepth;
  54007. private readonly _clearColor;
  54008. /** Get if the depth renderer is using packed depth or not */
  54009. readonly isPacked: boolean;
  54010. private _cachedDefines;
  54011. private _camera;
  54012. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54013. enabled: boolean;
  54014. /**
  54015. * Specifiess that the depth renderer will only be used within
  54016. * the camera it is created for.
  54017. * This can help forcing its rendering during the camera processing.
  54018. */
  54019. useOnlyInActiveCamera: boolean;
  54020. /** @hidden */
  54021. static _SceneComponentInitialization: (scene: Scene) => void;
  54022. /**
  54023. * Instantiates a depth renderer
  54024. * @param scene The scene the renderer belongs to
  54025. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54026. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54027. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54028. */
  54029. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54030. /**
  54031. * Creates the depth rendering effect and checks if the effect is ready.
  54032. * @param subMesh The submesh to be used to render the depth map of
  54033. * @param useInstances If multiple world instances should be used
  54034. * @returns if the depth renderer is ready to render the depth map
  54035. */
  54036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54037. /**
  54038. * Gets the texture which the depth map will be written to.
  54039. * @returns The depth map texture
  54040. */
  54041. getDepthMap(): RenderTargetTexture;
  54042. /**
  54043. * Disposes of the depth renderer.
  54044. */
  54045. dispose(): void;
  54046. }
  54047. }
  54048. declare module BABYLON {
  54049. /** @hidden */
  54050. export var minmaxReduxPixelShader: {
  54051. name: string;
  54052. shader: string;
  54053. };
  54054. }
  54055. declare module BABYLON {
  54056. /**
  54057. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54058. * and maximum values from all values of the texture.
  54059. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54060. * The source values are read from the red channel of the texture.
  54061. */
  54062. export class MinMaxReducer {
  54063. /**
  54064. * Observable triggered when the computation has been performed
  54065. */
  54066. onAfterReductionPerformed: Observable<{
  54067. min: number;
  54068. max: number;
  54069. }>;
  54070. protected _camera: Camera;
  54071. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54072. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54073. protected _postProcessManager: PostProcessManager;
  54074. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54075. protected _forceFullscreenViewport: boolean;
  54076. /**
  54077. * Creates a min/max reducer
  54078. * @param camera The camera to use for the post processes
  54079. */
  54080. constructor(camera: Camera);
  54081. /**
  54082. * Gets the texture used to read the values from.
  54083. */
  54084. get sourceTexture(): Nullable<RenderTargetTexture>;
  54085. /**
  54086. * Sets the source texture to read the values from.
  54087. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54088. * because in such textures '1' value must not be taken into account to compute the maximum
  54089. * as this value is used to clear the texture.
  54090. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54091. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54092. * @param depthRedux Indicates if the texture is a depth texture or not
  54093. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54094. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54095. */
  54096. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54097. /**
  54098. * Defines the refresh rate of the computation.
  54099. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54100. */
  54101. get refreshRate(): number;
  54102. set refreshRate(value: number);
  54103. protected _activated: boolean;
  54104. /**
  54105. * Gets the activation status of the reducer
  54106. */
  54107. get activated(): boolean;
  54108. /**
  54109. * Activates the reduction computation.
  54110. * When activated, the observers registered in onAfterReductionPerformed are
  54111. * called after the compuation is performed
  54112. */
  54113. activate(): void;
  54114. /**
  54115. * Deactivates the reduction computation.
  54116. */
  54117. deactivate(): void;
  54118. /**
  54119. * Disposes the min/max reducer
  54120. * @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.
  54121. */
  54122. dispose(disposeAll?: boolean): void;
  54123. }
  54124. }
  54125. declare module BABYLON {
  54126. /**
  54127. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54128. */
  54129. export class DepthReducer extends MinMaxReducer {
  54130. private _depthRenderer;
  54131. private _depthRendererId;
  54132. /**
  54133. * Gets the depth renderer used for the computation.
  54134. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54135. */
  54136. get depthRenderer(): Nullable<DepthRenderer>;
  54137. /**
  54138. * Creates a depth reducer
  54139. * @param camera The camera used to render the depth texture
  54140. */
  54141. constructor(camera: Camera);
  54142. /**
  54143. * Sets the depth renderer to use to generate the depth map
  54144. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54145. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54146. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54147. */
  54148. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54149. /** @hidden */
  54150. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54151. /**
  54152. * Activates the reduction computation.
  54153. * When activated, the observers registered in onAfterReductionPerformed are
  54154. * called after the compuation is performed
  54155. */
  54156. activate(): void;
  54157. /**
  54158. * Deactivates the reduction computation.
  54159. */
  54160. deactivate(): void;
  54161. /**
  54162. * Disposes the depth reducer
  54163. * @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.
  54164. */
  54165. dispose(disposeAll?: boolean): void;
  54166. }
  54167. }
  54168. declare module BABYLON {
  54169. /**
  54170. * A CSM implementation allowing casting shadows on large scenes.
  54171. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54172. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54173. */
  54174. export class CascadedShadowGenerator extends ShadowGenerator {
  54175. private static readonly frustumCornersNDCSpace;
  54176. /**
  54177. * Name of the CSM class
  54178. */
  54179. static CLASSNAME: string;
  54180. /**
  54181. * Defines the default number of cascades used by the CSM.
  54182. */
  54183. static readonly DEFAULT_CASCADES_COUNT: number;
  54184. /**
  54185. * Defines the minimum number of cascades used by the CSM.
  54186. */
  54187. static readonly MIN_CASCADES_COUNT: number;
  54188. /**
  54189. * Defines the maximum number of cascades used by the CSM.
  54190. */
  54191. static readonly MAX_CASCADES_COUNT: number;
  54192. protected _validateFilter(filter: number): number;
  54193. /**
  54194. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54195. */
  54196. penumbraDarkness: number;
  54197. private _numCascades;
  54198. /**
  54199. * Gets or set the number of cascades used by the CSM.
  54200. */
  54201. get numCascades(): number;
  54202. set numCascades(value: number);
  54203. /**
  54204. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54205. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54206. */
  54207. stabilizeCascades: boolean;
  54208. private _freezeShadowCastersBoundingInfo;
  54209. private _freezeShadowCastersBoundingInfoObservable;
  54210. /**
  54211. * Enables or disables the shadow casters bounding info computation.
  54212. * If your shadow casters don't move, you can disable this feature.
  54213. * If it is enabled, the bounding box computation is done every frame.
  54214. */
  54215. get freezeShadowCastersBoundingInfo(): boolean;
  54216. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54217. private _scbiMin;
  54218. private _scbiMax;
  54219. protected _computeShadowCastersBoundingInfo(): void;
  54220. protected _shadowCastersBoundingInfo: BoundingInfo;
  54221. /**
  54222. * Gets or sets the shadow casters bounding info.
  54223. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54224. * so that the system won't overwrite the bounds you provide
  54225. */
  54226. get shadowCastersBoundingInfo(): BoundingInfo;
  54227. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54228. protected _breaksAreDirty: boolean;
  54229. protected _minDistance: number;
  54230. protected _maxDistance: number;
  54231. /**
  54232. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54233. *
  54234. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54235. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54236. * @param min minimal distance for the breaks (default to 0.)
  54237. * @param max maximal distance for the breaks (default to 1.)
  54238. */
  54239. setMinMaxDistance(min: number, max: number): void;
  54240. /** Gets the minimal distance used in the cascade break computation */
  54241. get minDistance(): number;
  54242. /** Gets the maximal distance used in the cascade break computation */
  54243. get maxDistance(): number;
  54244. /**
  54245. * Gets the class name of that object
  54246. * @returns "CascadedShadowGenerator"
  54247. */
  54248. getClassName(): string;
  54249. private _cascadeMinExtents;
  54250. private _cascadeMaxExtents;
  54251. /**
  54252. * Gets a cascade minimum extents
  54253. * @param cascadeIndex index of the cascade
  54254. * @returns the minimum cascade extents
  54255. */
  54256. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54257. /**
  54258. * Gets a cascade maximum extents
  54259. * @param cascadeIndex index of the cascade
  54260. * @returns the maximum cascade extents
  54261. */
  54262. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54263. private _cascades;
  54264. private _currentLayer;
  54265. private _viewSpaceFrustumsZ;
  54266. private _viewMatrices;
  54267. private _projectionMatrices;
  54268. private _transformMatrices;
  54269. private _transformMatricesAsArray;
  54270. private _frustumLengths;
  54271. private _lightSizeUVCorrection;
  54272. private _depthCorrection;
  54273. private _frustumCornersWorldSpace;
  54274. private _frustumCenter;
  54275. private _shadowCameraPos;
  54276. private _shadowMaxZ;
  54277. /**
  54278. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54279. * It defaults to camera.maxZ
  54280. */
  54281. get shadowMaxZ(): number;
  54282. /**
  54283. * Sets the shadow max z distance.
  54284. */
  54285. set shadowMaxZ(value: number);
  54286. protected _debug: boolean;
  54287. /**
  54288. * Gets or sets the debug flag.
  54289. * When enabled, the cascades are materialized by different colors on the screen.
  54290. */
  54291. get debug(): boolean;
  54292. set debug(dbg: boolean);
  54293. private _depthClamp;
  54294. /**
  54295. * Gets or sets the depth clamping value.
  54296. *
  54297. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54298. * to account for the shadow casters far away.
  54299. *
  54300. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54301. */
  54302. get depthClamp(): boolean;
  54303. set depthClamp(value: boolean);
  54304. private _cascadeBlendPercentage;
  54305. /**
  54306. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54307. * It defaults to 0.1 (10% blending).
  54308. */
  54309. get cascadeBlendPercentage(): number;
  54310. set cascadeBlendPercentage(value: number);
  54311. private _lambda;
  54312. /**
  54313. * Gets or set the lambda parameter.
  54314. * This parameter is used to split the camera frustum and create the cascades.
  54315. * 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.
  54316. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54317. */
  54318. get lambda(): number;
  54319. set lambda(value: number);
  54320. /**
  54321. * Gets the view matrix corresponding to a given cascade
  54322. * @param cascadeNum cascade to retrieve the view matrix from
  54323. * @returns the cascade view matrix
  54324. */
  54325. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54326. /**
  54327. * Gets the projection matrix corresponding to a given cascade
  54328. * @param cascadeNum cascade to retrieve the projection matrix from
  54329. * @returns the cascade projection matrix
  54330. */
  54331. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54332. /**
  54333. * Gets the transformation matrix corresponding to a given cascade
  54334. * @param cascadeNum cascade to retrieve the transformation matrix from
  54335. * @returns the cascade transformation matrix
  54336. */
  54337. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54338. private _depthRenderer;
  54339. /**
  54340. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54341. *
  54342. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54343. *
  54344. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54345. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54346. * @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
  54347. */
  54348. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54349. private _depthReducer;
  54350. private _autoCalcDepthBounds;
  54351. /**
  54352. * Gets or sets the autoCalcDepthBounds property.
  54353. *
  54354. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54355. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54356. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54357. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54358. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54359. */
  54360. get autoCalcDepthBounds(): boolean;
  54361. set autoCalcDepthBounds(value: boolean);
  54362. /**
  54363. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54364. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54365. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54366. * for setting the refresh rate on the renderer yourself!
  54367. */
  54368. get autoCalcDepthBoundsRefreshRate(): number;
  54369. set autoCalcDepthBoundsRefreshRate(value: number);
  54370. /**
  54371. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54372. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54373. * you change the camera near/far planes!
  54374. */
  54375. splitFrustum(): void;
  54376. private _splitFrustum;
  54377. private _computeMatrices;
  54378. private _computeFrustumInWorldSpace;
  54379. private _computeCascadeFrustum;
  54380. /** @hidden */
  54381. static _SceneComponentInitialization: (scene: Scene) => void;
  54382. /**
  54383. * Creates a Cascaded Shadow Generator object.
  54384. * A ShadowGenerator is the required tool to use the shadows.
  54385. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54386. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54387. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54388. * @param light The directional light object generating the shadows.
  54389. * @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.
  54390. */
  54391. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54392. protected _initializeGenerator(): void;
  54393. protected _createTargetRenderTexture(): void;
  54394. protected _initializeShadowMap(): void;
  54395. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54396. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54397. /**
  54398. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54399. * @param defines Defines of the material we want to update
  54400. * @param lightIndex Index of the light in the enabled light list of the material
  54401. */
  54402. prepareDefines(defines: any, lightIndex: number): void;
  54403. /**
  54404. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54405. * defined in the generator but impacting the effect).
  54406. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54407. * @param effect The effect we are binfing the information for
  54408. */
  54409. bindShadowLight(lightIndex: string, effect: Effect): void;
  54410. /**
  54411. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54412. * (eq to view projection * shadow projection matrices)
  54413. * @returns The transform matrix used to create the shadow map
  54414. */
  54415. getTransformMatrix(): Matrix;
  54416. /**
  54417. * Disposes the ShadowGenerator.
  54418. * Returns nothing.
  54419. */
  54420. dispose(): void;
  54421. /**
  54422. * Serializes the shadow generator setup to a json object.
  54423. * @returns The serialized JSON object
  54424. */
  54425. serialize(): any;
  54426. /**
  54427. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54428. * @param parsedShadowGenerator The JSON object to parse
  54429. * @param scene The scene to create the shadow map for
  54430. * @returns The parsed shadow generator
  54431. */
  54432. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54433. }
  54434. }
  54435. declare module BABYLON {
  54436. /**
  54437. * Defines the shadow generator component responsible to manage any shadow generators
  54438. * in a given scene.
  54439. */
  54440. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54441. /**
  54442. * The component name helpfull to identify the component in the list of scene components.
  54443. */
  54444. readonly name: string;
  54445. /**
  54446. * The scene the component belongs to.
  54447. */
  54448. scene: Scene;
  54449. /**
  54450. * Creates a new instance of the component for the given scene
  54451. * @param scene Defines the scene to register the component in
  54452. */
  54453. constructor(scene: Scene);
  54454. /**
  54455. * Registers the component in a given scene
  54456. */
  54457. register(): void;
  54458. /**
  54459. * Rebuilds the elements related to this component in case of
  54460. * context lost for instance.
  54461. */
  54462. rebuild(): void;
  54463. /**
  54464. * Serializes the component data to the specified json object
  54465. * @param serializationObject The object to serialize to
  54466. */
  54467. serialize(serializationObject: any): void;
  54468. /**
  54469. * Adds all the elements from the container to the scene
  54470. * @param container the container holding the elements
  54471. */
  54472. addFromContainer(container: AbstractScene): void;
  54473. /**
  54474. * Removes all the elements in the container from the scene
  54475. * @param container contains the elements to remove
  54476. * @param dispose if the removed element should be disposed (default: false)
  54477. */
  54478. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54479. /**
  54480. * Rebuilds the elements related to this component in case of
  54481. * context lost for instance.
  54482. */
  54483. dispose(): void;
  54484. private _gatherRenderTargets;
  54485. }
  54486. }
  54487. declare module BABYLON {
  54488. /**
  54489. * A point light is a light defined by an unique point in world space.
  54490. * The light is emitted in every direction from this point.
  54491. * A good example of a point light is a standard light bulb.
  54492. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54493. */
  54494. export class PointLight extends ShadowLight {
  54495. private _shadowAngle;
  54496. /**
  54497. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54498. * This specifies what angle the shadow will use to be created.
  54499. *
  54500. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54501. */
  54502. get shadowAngle(): number;
  54503. /**
  54504. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54505. * This specifies what angle the shadow will use to be created.
  54506. *
  54507. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54508. */
  54509. set shadowAngle(value: number);
  54510. /**
  54511. * Gets the direction if it has been set.
  54512. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54513. */
  54514. get direction(): Vector3;
  54515. /**
  54516. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54517. */
  54518. set direction(value: Vector3);
  54519. /**
  54520. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54521. * A PointLight emits the light in every direction.
  54522. * It can cast shadows.
  54523. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54524. * ```javascript
  54525. * var pointLight = new PointLight("pl", camera.position, scene);
  54526. * ```
  54527. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54528. * @param name The light friendly name
  54529. * @param position The position of the point light in the scene
  54530. * @param scene The scene the lights belongs to
  54531. */
  54532. constructor(name: string, position: Vector3, scene: Scene);
  54533. /**
  54534. * Returns the string "PointLight"
  54535. * @returns the class name
  54536. */
  54537. getClassName(): string;
  54538. /**
  54539. * Returns the integer 0.
  54540. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54541. */
  54542. getTypeID(): number;
  54543. /**
  54544. * Specifies wether or not the shadowmap should be a cube texture.
  54545. * @returns true if the shadowmap needs to be a cube texture.
  54546. */
  54547. needCube(): boolean;
  54548. /**
  54549. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54550. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54551. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54552. */
  54553. getShadowDirection(faceIndex?: number): Vector3;
  54554. /**
  54555. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54556. * - fov = PI / 2
  54557. * - aspect ratio : 1.0
  54558. * - z-near and far equal to the active camera minZ and maxZ.
  54559. * Returns the PointLight.
  54560. */
  54561. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54562. protected _buildUniformLayout(): void;
  54563. /**
  54564. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54565. * @param effect The effect to update
  54566. * @param lightIndex The index of the light in the effect to update
  54567. * @returns The point light
  54568. */
  54569. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54570. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54571. /**
  54572. * Prepares the list of defines specific to the light type.
  54573. * @param defines the list of defines
  54574. * @param lightIndex defines the index of the light for the effect
  54575. */
  54576. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54577. }
  54578. }
  54579. declare module BABYLON {
  54580. /**
  54581. * Header information of HDR texture files.
  54582. */
  54583. export interface HDRInfo {
  54584. /**
  54585. * The height of the texture in pixels.
  54586. */
  54587. height: number;
  54588. /**
  54589. * The width of the texture in pixels.
  54590. */
  54591. width: number;
  54592. /**
  54593. * The index of the beginning of the data in the binary file.
  54594. */
  54595. dataPosition: number;
  54596. }
  54597. /**
  54598. * This groups tools to convert HDR texture to native colors array.
  54599. */
  54600. export class HDRTools {
  54601. private static Ldexp;
  54602. private static Rgbe2float;
  54603. private static readStringLine;
  54604. /**
  54605. * Reads header information from an RGBE texture stored in a native array.
  54606. * More information on this format are available here:
  54607. * https://en.wikipedia.org/wiki/RGBE_image_format
  54608. *
  54609. * @param uint8array The binary file stored in native array.
  54610. * @return The header information.
  54611. */
  54612. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54613. /**
  54614. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54615. * This RGBE texture needs to store the information as a panorama.
  54616. *
  54617. * More information on this format are available here:
  54618. * https://en.wikipedia.org/wiki/RGBE_image_format
  54619. *
  54620. * @param buffer The binary file stored in an array buffer.
  54621. * @param size The expected size of the extracted cubemap.
  54622. * @return The Cube Map information.
  54623. */
  54624. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54625. /**
  54626. * Returns the pixels data extracted from an RGBE texture.
  54627. * This pixels will be stored left to right up to down in the R G B order in one array.
  54628. *
  54629. * More information on this format are available here:
  54630. * https://en.wikipedia.org/wiki/RGBE_image_format
  54631. *
  54632. * @param uint8array The binary file stored in an array buffer.
  54633. * @param hdrInfo The header information of the file.
  54634. * @return The pixels data in RGB right to left up to down order.
  54635. */
  54636. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54637. private static RGBE_ReadPixels_RLE;
  54638. }
  54639. }
  54640. declare module BABYLON {
  54641. /**
  54642. * This represents a texture coming from an HDR input.
  54643. *
  54644. * The only supported format is currently panorama picture stored in RGBE format.
  54645. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54646. */
  54647. export class HDRCubeTexture extends BaseTexture {
  54648. private static _facesMapping;
  54649. private _generateHarmonics;
  54650. private _noMipmap;
  54651. private _textureMatrix;
  54652. private _size;
  54653. private _onLoad;
  54654. private _onError;
  54655. /**
  54656. * The texture URL.
  54657. */
  54658. url: string;
  54659. /**
  54660. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54661. */
  54662. coordinatesMode: number;
  54663. protected _isBlocking: boolean;
  54664. /**
  54665. * Sets wether or not the texture is blocking during loading.
  54666. */
  54667. set isBlocking(value: boolean);
  54668. /**
  54669. * Gets wether or not the texture is blocking during loading.
  54670. */
  54671. get isBlocking(): boolean;
  54672. protected _rotationY: number;
  54673. /**
  54674. * Sets texture matrix rotation angle around Y axis in radians.
  54675. */
  54676. set rotationY(value: number);
  54677. /**
  54678. * Gets texture matrix rotation angle around Y axis radians.
  54679. */
  54680. get rotationY(): number;
  54681. /**
  54682. * Gets or sets the center of the bounding box associated with the cube texture
  54683. * It must define where the camera used to render the texture was set
  54684. */
  54685. boundingBoxPosition: Vector3;
  54686. private _boundingBoxSize;
  54687. /**
  54688. * Gets or sets the size of the bounding box associated with the cube texture
  54689. * When defined, the cubemap will switch to local mode
  54690. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54691. * @example https://www.babylonjs-playground.com/#RNASML
  54692. */
  54693. set boundingBoxSize(value: Vector3);
  54694. get boundingBoxSize(): Vector3;
  54695. /**
  54696. * Instantiates an HDRTexture from the following parameters.
  54697. *
  54698. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54699. * @param scene The scene the texture will be used in
  54700. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54701. * @param noMipmap Forces to not generate the mipmap if true
  54702. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54703. * @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)
  54704. * @param reserved Reserved flag for internal use.
  54705. */
  54706. 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>);
  54707. /**
  54708. * Get the current class name of the texture useful for serialization or dynamic coding.
  54709. * @returns "HDRCubeTexture"
  54710. */
  54711. getClassName(): string;
  54712. /**
  54713. * Occurs when the file is raw .hdr file.
  54714. */
  54715. private loadTexture;
  54716. clone(): HDRCubeTexture;
  54717. delayLoad(): void;
  54718. /**
  54719. * Get the texture reflection matrix used to rotate/transform the reflection.
  54720. * @returns the reflection matrix
  54721. */
  54722. getReflectionTextureMatrix(): Matrix;
  54723. /**
  54724. * Set the texture reflection matrix used to rotate/transform the reflection.
  54725. * @param value Define the reflection matrix to set
  54726. */
  54727. setReflectionTextureMatrix(value: Matrix): void;
  54728. /**
  54729. * Parses a JSON representation of an HDR Texture in order to create the texture
  54730. * @param parsedTexture Define the JSON representation
  54731. * @param scene Define the scene the texture should be created in
  54732. * @param rootUrl Define the root url in case we need to load relative dependencies
  54733. * @returns the newly created texture after parsing
  54734. */
  54735. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54736. serialize(): any;
  54737. }
  54738. }
  54739. declare module BABYLON {
  54740. /**
  54741. * Class used to control physics engine
  54742. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54743. */
  54744. export class PhysicsEngine implements IPhysicsEngine {
  54745. private _physicsPlugin;
  54746. /**
  54747. * Global value used to control the smallest number supported by the simulation
  54748. */
  54749. static Epsilon: number;
  54750. private _impostors;
  54751. private _joints;
  54752. private _subTimeStep;
  54753. /**
  54754. * Gets the gravity vector used by the simulation
  54755. */
  54756. gravity: Vector3;
  54757. /**
  54758. * Factory used to create the default physics plugin.
  54759. * @returns The default physics plugin
  54760. */
  54761. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54762. /**
  54763. * Creates a new Physics Engine
  54764. * @param gravity defines the gravity vector used by the simulation
  54765. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54766. */
  54767. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54768. /**
  54769. * Sets the gravity vector used by the simulation
  54770. * @param gravity defines the gravity vector to use
  54771. */
  54772. setGravity(gravity: Vector3): void;
  54773. /**
  54774. * Set the time step of the physics engine.
  54775. * Default is 1/60.
  54776. * To slow it down, enter 1/600 for example.
  54777. * To speed it up, 1/30
  54778. * @param newTimeStep defines the new timestep to apply to this world.
  54779. */
  54780. setTimeStep(newTimeStep?: number): void;
  54781. /**
  54782. * Get the time step of the physics engine.
  54783. * @returns the current time step
  54784. */
  54785. getTimeStep(): number;
  54786. /**
  54787. * Set the sub time step of the physics engine.
  54788. * Default is 0 meaning there is no sub steps
  54789. * To increase physics resolution precision, set a small value (like 1 ms)
  54790. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54791. */
  54792. setSubTimeStep(subTimeStep?: number): void;
  54793. /**
  54794. * Get the sub time step of the physics engine.
  54795. * @returns the current sub time step
  54796. */
  54797. getSubTimeStep(): number;
  54798. /**
  54799. * Release all resources
  54800. */
  54801. dispose(): void;
  54802. /**
  54803. * Gets the name of the current physics plugin
  54804. * @returns the name of the plugin
  54805. */
  54806. getPhysicsPluginName(): string;
  54807. /**
  54808. * Adding a new impostor for the impostor tracking.
  54809. * This will be done by the impostor itself.
  54810. * @param impostor the impostor to add
  54811. */
  54812. addImpostor(impostor: PhysicsImpostor): void;
  54813. /**
  54814. * Remove an impostor from the engine.
  54815. * This impostor and its mesh will not longer be updated by the physics engine.
  54816. * @param impostor the impostor to remove
  54817. */
  54818. removeImpostor(impostor: PhysicsImpostor): void;
  54819. /**
  54820. * Add a joint to the physics engine
  54821. * @param mainImpostor defines the main impostor to which the joint is added.
  54822. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54823. * @param joint defines the joint that will connect both impostors.
  54824. */
  54825. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54826. /**
  54827. * Removes a joint from the simulation
  54828. * @param mainImpostor defines the impostor used with the joint
  54829. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54830. * @param joint defines the joint to remove
  54831. */
  54832. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54833. /**
  54834. * Called by the scene. No need to call it.
  54835. * @param delta defines the timespam between frames
  54836. */
  54837. _step(delta: number): void;
  54838. /**
  54839. * Gets the current plugin used to run the simulation
  54840. * @returns current plugin
  54841. */
  54842. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54843. /**
  54844. * Gets the list of physic impostors
  54845. * @returns an array of PhysicsImpostor
  54846. */
  54847. getImpostors(): Array<PhysicsImpostor>;
  54848. /**
  54849. * Gets the impostor for a physics enabled object
  54850. * @param object defines the object impersonated by the impostor
  54851. * @returns the PhysicsImpostor or null if not found
  54852. */
  54853. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54854. /**
  54855. * Gets the impostor for a physics body object
  54856. * @param body defines physics body used by the impostor
  54857. * @returns the PhysicsImpostor or null if not found
  54858. */
  54859. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54860. /**
  54861. * Does a raycast in the physics world
  54862. * @param from when should the ray start?
  54863. * @param to when should the ray end?
  54864. * @returns PhysicsRaycastResult
  54865. */
  54866. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54867. }
  54868. }
  54869. declare module BABYLON {
  54870. /** @hidden */
  54871. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54872. private _useDeltaForWorldStep;
  54873. world: any;
  54874. name: string;
  54875. private _physicsMaterials;
  54876. private _fixedTimeStep;
  54877. private _cannonRaycastResult;
  54878. private _raycastResult;
  54879. private _physicsBodysToRemoveAfterStep;
  54880. BJSCANNON: any;
  54881. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54882. setGravity(gravity: Vector3): void;
  54883. setTimeStep(timeStep: number): void;
  54884. getTimeStep(): number;
  54885. executeStep(delta: number): void;
  54886. private _removeMarkedPhysicsBodiesFromWorld;
  54887. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54888. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54889. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54890. private _processChildMeshes;
  54891. removePhysicsBody(impostor: PhysicsImpostor): void;
  54892. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54893. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54894. private _addMaterial;
  54895. private _checkWithEpsilon;
  54896. private _createShape;
  54897. private _createHeightmap;
  54898. private _minus90X;
  54899. private _plus90X;
  54900. private _tmpPosition;
  54901. private _tmpDeltaPosition;
  54902. private _tmpUnityRotation;
  54903. private _updatePhysicsBodyTransformation;
  54904. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54905. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54906. isSupported(): boolean;
  54907. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54908. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54909. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54910. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54911. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54912. getBodyMass(impostor: PhysicsImpostor): number;
  54913. getBodyFriction(impostor: PhysicsImpostor): number;
  54914. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54915. getBodyRestitution(impostor: PhysicsImpostor): number;
  54916. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54917. sleepBody(impostor: PhysicsImpostor): void;
  54918. wakeUpBody(impostor: PhysicsImpostor): void;
  54919. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54920. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54921. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54922. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54923. getRadius(impostor: PhysicsImpostor): number;
  54924. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54925. dispose(): void;
  54926. private _extendNamespace;
  54927. /**
  54928. * Does a raycast in the physics world
  54929. * @param from when should the ray start?
  54930. * @param to when should the ray end?
  54931. * @returns PhysicsRaycastResult
  54932. */
  54933. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54934. }
  54935. }
  54936. declare module BABYLON {
  54937. /** @hidden */
  54938. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54939. world: any;
  54940. name: string;
  54941. BJSOIMO: any;
  54942. private _raycastResult;
  54943. constructor(iterations?: number, oimoInjection?: any);
  54944. setGravity(gravity: Vector3): void;
  54945. setTimeStep(timeStep: number): void;
  54946. getTimeStep(): number;
  54947. private _tmpImpostorsArray;
  54948. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54949. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54950. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54951. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54952. private _tmpPositionVector;
  54953. removePhysicsBody(impostor: PhysicsImpostor): void;
  54954. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54955. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54956. isSupported(): boolean;
  54957. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54958. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54959. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54960. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54961. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54962. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54963. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54964. getBodyMass(impostor: PhysicsImpostor): number;
  54965. getBodyFriction(impostor: PhysicsImpostor): number;
  54966. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54967. getBodyRestitution(impostor: PhysicsImpostor): number;
  54968. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54969. sleepBody(impostor: PhysicsImpostor): void;
  54970. wakeUpBody(impostor: PhysicsImpostor): void;
  54971. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54972. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54973. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54974. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54975. getRadius(impostor: PhysicsImpostor): number;
  54976. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54977. dispose(): void;
  54978. /**
  54979. * Does a raycast in the physics world
  54980. * @param from when should the ray start?
  54981. * @param to when should the ray end?
  54982. * @returns PhysicsRaycastResult
  54983. */
  54984. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54985. }
  54986. }
  54987. declare module BABYLON {
  54988. /**
  54989. * Class containing static functions to help procedurally build meshes
  54990. */
  54991. export class RibbonBuilder {
  54992. /**
  54993. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54994. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54995. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54996. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54997. * * 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
  54998. * * 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
  54999. * * 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
  55000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55001. * * 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
  55002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55003. * * 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
  55004. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55005. * * 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
  55006. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55008. * @param name defines the name of the mesh
  55009. * @param options defines the options used to create the mesh
  55010. * @param scene defines the hosting scene
  55011. * @returns the ribbon mesh
  55012. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55013. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55014. */
  55015. static CreateRibbon(name: string, options: {
  55016. pathArray: Vector3[][];
  55017. closeArray?: boolean;
  55018. closePath?: boolean;
  55019. offset?: number;
  55020. updatable?: boolean;
  55021. sideOrientation?: number;
  55022. frontUVs?: Vector4;
  55023. backUVs?: Vector4;
  55024. instance?: Mesh;
  55025. invertUV?: boolean;
  55026. uvs?: Vector2[];
  55027. colors?: Color4[];
  55028. }, scene?: Nullable<Scene>): Mesh;
  55029. }
  55030. }
  55031. declare module BABYLON {
  55032. /**
  55033. * Class containing static functions to help procedurally build meshes
  55034. */
  55035. export class ShapeBuilder {
  55036. /**
  55037. * 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.
  55038. * * 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.
  55039. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55040. * * 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.
  55041. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55042. * * 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
  55043. * * 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
  55044. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55046. * * 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
  55047. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55049. * @param name defines the name of the mesh
  55050. * @param options defines the options used to create the mesh
  55051. * @param scene defines the hosting scene
  55052. * @returns the extruded shape mesh
  55053. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55055. */
  55056. static ExtrudeShape(name: string, options: {
  55057. shape: Vector3[];
  55058. path: Vector3[];
  55059. scale?: number;
  55060. rotation?: number;
  55061. cap?: number;
  55062. updatable?: boolean;
  55063. sideOrientation?: number;
  55064. frontUVs?: Vector4;
  55065. backUVs?: Vector4;
  55066. instance?: Mesh;
  55067. invertUV?: boolean;
  55068. }, scene?: Nullable<Scene>): Mesh;
  55069. /**
  55070. * Creates an custom extruded shape mesh.
  55071. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55072. * * 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.
  55073. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55074. * * 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
  55075. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55076. * * 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
  55077. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55078. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55079. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55080. * * 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
  55081. * * 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
  55082. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55084. * * 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
  55085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55087. * @param name defines the name of the mesh
  55088. * @param options defines the options used to create the mesh
  55089. * @param scene defines the hosting scene
  55090. * @returns the custom extruded shape mesh
  55091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55092. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55094. */
  55095. static ExtrudeShapeCustom(name: string, options: {
  55096. shape: Vector3[];
  55097. path: Vector3[];
  55098. scaleFunction?: any;
  55099. rotationFunction?: any;
  55100. ribbonCloseArray?: boolean;
  55101. ribbonClosePath?: boolean;
  55102. cap?: number;
  55103. updatable?: boolean;
  55104. sideOrientation?: number;
  55105. frontUVs?: Vector4;
  55106. backUVs?: Vector4;
  55107. instance?: Mesh;
  55108. invertUV?: boolean;
  55109. }, scene?: Nullable<Scene>): Mesh;
  55110. private static _ExtrudeShapeGeneric;
  55111. }
  55112. }
  55113. declare module BABYLON {
  55114. /**
  55115. * AmmoJS Physics plugin
  55116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55117. * @see https://github.com/kripken/ammo.js/
  55118. */
  55119. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55120. private _useDeltaForWorldStep;
  55121. /**
  55122. * Reference to the Ammo library
  55123. */
  55124. bjsAMMO: any;
  55125. /**
  55126. * Created ammoJS world which physics bodies are added to
  55127. */
  55128. world: any;
  55129. /**
  55130. * Name of the plugin
  55131. */
  55132. name: string;
  55133. private _timeStep;
  55134. private _fixedTimeStep;
  55135. private _maxSteps;
  55136. private _tmpQuaternion;
  55137. private _tmpAmmoTransform;
  55138. private _tmpAmmoQuaternion;
  55139. private _tmpAmmoConcreteContactResultCallback;
  55140. private _collisionConfiguration;
  55141. private _dispatcher;
  55142. private _overlappingPairCache;
  55143. private _solver;
  55144. private _softBodySolver;
  55145. private _tmpAmmoVectorA;
  55146. private _tmpAmmoVectorB;
  55147. private _tmpAmmoVectorC;
  55148. private _tmpAmmoVectorD;
  55149. private _tmpContactCallbackResult;
  55150. private _tmpAmmoVectorRCA;
  55151. private _tmpAmmoVectorRCB;
  55152. private _raycastResult;
  55153. private static readonly DISABLE_COLLISION_FLAG;
  55154. private static readonly KINEMATIC_FLAG;
  55155. private static readonly DISABLE_DEACTIVATION_FLAG;
  55156. /**
  55157. * Initializes the ammoJS plugin
  55158. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55159. * @param ammoInjection can be used to inject your own ammo reference
  55160. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55161. */
  55162. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55163. /**
  55164. * Sets the gravity of the physics world (m/(s^2))
  55165. * @param gravity Gravity to set
  55166. */
  55167. setGravity(gravity: Vector3): void;
  55168. /**
  55169. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55170. * @param timeStep timestep to use in seconds
  55171. */
  55172. setTimeStep(timeStep: number): void;
  55173. /**
  55174. * 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)
  55175. * @param fixedTimeStep fixedTimeStep to use in seconds
  55176. */
  55177. setFixedTimeStep(fixedTimeStep: number): void;
  55178. /**
  55179. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55180. * @param maxSteps the maximum number of steps by the physics engine per frame
  55181. */
  55182. setMaxSteps(maxSteps: number): void;
  55183. /**
  55184. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55185. * @returns the current timestep in seconds
  55186. */
  55187. getTimeStep(): number;
  55188. /**
  55189. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55190. */
  55191. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55192. private _isImpostorInContact;
  55193. private _isImpostorPairInContact;
  55194. private _stepSimulation;
  55195. /**
  55196. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55197. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55198. * After the step the babylon meshes are set to the position of the physics imposters
  55199. * @param delta amount of time to step forward
  55200. * @param impostors array of imposters to update before/after the step
  55201. */
  55202. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55203. /**
  55204. * Update babylon mesh to match physics world object
  55205. * @param impostor imposter to match
  55206. */
  55207. private _afterSoftStep;
  55208. /**
  55209. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55210. * @param impostor imposter to match
  55211. */
  55212. private _ropeStep;
  55213. /**
  55214. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55215. * @param impostor imposter to match
  55216. */
  55217. private _softbodyOrClothStep;
  55218. private _tmpVector;
  55219. private _tmpMatrix;
  55220. /**
  55221. * Applies an impulse on the imposter
  55222. * @param impostor imposter to apply impulse to
  55223. * @param force amount of force to be applied to the imposter
  55224. * @param contactPoint the location to apply the impulse on the imposter
  55225. */
  55226. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55227. /**
  55228. * Applies a force on the imposter
  55229. * @param impostor imposter to apply force
  55230. * @param force amount of force to be applied to the imposter
  55231. * @param contactPoint the location to apply the force on the imposter
  55232. */
  55233. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55234. /**
  55235. * Creates a physics body using the plugin
  55236. * @param impostor the imposter to create the physics body on
  55237. */
  55238. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55239. /**
  55240. * Removes the physics body from the imposter and disposes of the body's memory
  55241. * @param impostor imposter to remove the physics body from
  55242. */
  55243. removePhysicsBody(impostor: PhysicsImpostor): void;
  55244. /**
  55245. * Generates a joint
  55246. * @param impostorJoint the imposter joint to create the joint with
  55247. */
  55248. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55249. /**
  55250. * Removes a joint
  55251. * @param impostorJoint the imposter joint to remove the joint from
  55252. */
  55253. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55254. private _addMeshVerts;
  55255. /**
  55256. * Initialise the soft body vertices to match its object's (mesh) vertices
  55257. * Softbody vertices (nodes) are in world space and to match this
  55258. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55259. * @param impostor to create the softbody for
  55260. */
  55261. private _softVertexData;
  55262. /**
  55263. * Create an impostor's soft body
  55264. * @param impostor to create the softbody for
  55265. */
  55266. private _createSoftbody;
  55267. /**
  55268. * Create cloth for an impostor
  55269. * @param impostor to create the softbody for
  55270. */
  55271. private _createCloth;
  55272. /**
  55273. * Create rope for an impostor
  55274. * @param impostor to create the softbody for
  55275. */
  55276. private _createRope;
  55277. /**
  55278. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55279. * @param impostor to create the custom physics shape for
  55280. */
  55281. private _createCustom;
  55282. private _addHullVerts;
  55283. private _createShape;
  55284. /**
  55285. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55286. * @param impostor imposter containing the physics body and babylon object
  55287. */
  55288. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55289. /**
  55290. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55291. * @param impostor imposter containing the physics body and babylon object
  55292. * @param newPosition new position
  55293. * @param newRotation new rotation
  55294. */
  55295. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55296. /**
  55297. * If this plugin is supported
  55298. * @returns true if its supported
  55299. */
  55300. isSupported(): boolean;
  55301. /**
  55302. * Sets the linear velocity of the physics body
  55303. * @param impostor imposter to set the velocity on
  55304. * @param velocity velocity to set
  55305. */
  55306. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55307. /**
  55308. * Sets the angular velocity of the physics body
  55309. * @param impostor imposter to set the velocity on
  55310. * @param velocity velocity to set
  55311. */
  55312. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55313. /**
  55314. * gets the linear velocity
  55315. * @param impostor imposter to get linear velocity from
  55316. * @returns linear velocity
  55317. */
  55318. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55319. /**
  55320. * gets the angular velocity
  55321. * @param impostor imposter to get angular velocity from
  55322. * @returns angular velocity
  55323. */
  55324. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55325. /**
  55326. * Sets the mass of physics body
  55327. * @param impostor imposter to set the mass on
  55328. * @param mass mass to set
  55329. */
  55330. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55331. /**
  55332. * Gets the mass of the physics body
  55333. * @param impostor imposter to get the mass from
  55334. * @returns mass
  55335. */
  55336. getBodyMass(impostor: PhysicsImpostor): number;
  55337. /**
  55338. * Gets friction of the impostor
  55339. * @param impostor impostor to get friction from
  55340. * @returns friction value
  55341. */
  55342. getBodyFriction(impostor: PhysicsImpostor): number;
  55343. /**
  55344. * Sets friction of the impostor
  55345. * @param impostor impostor to set friction on
  55346. * @param friction friction value
  55347. */
  55348. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55349. /**
  55350. * Gets restitution of the impostor
  55351. * @param impostor impostor to get restitution from
  55352. * @returns restitution value
  55353. */
  55354. getBodyRestitution(impostor: PhysicsImpostor): number;
  55355. /**
  55356. * Sets resitution of the impostor
  55357. * @param impostor impostor to set resitution on
  55358. * @param restitution resitution value
  55359. */
  55360. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55361. /**
  55362. * Gets pressure inside the impostor
  55363. * @param impostor impostor to get pressure from
  55364. * @returns pressure value
  55365. */
  55366. getBodyPressure(impostor: PhysicsImpostor): number;
  55367. /**
  55368. * Sets pressure inside a soft body impostor
  55369. * Cloth and rope must remain 0 pressure
  55370. * @param impostor impostor to set pressure on
  55371. * @param pressure pressure value
  55372. */
  55373. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55374. /**
  55375. * Gets stiffness of the impostor
  55376. * @param impostor impostor to get stiffness from
  55377. * @returns pressure value
  55378. */
  55379. getBodyStiffness(impostor: PhysicsImpostor): number;
  55380. /**
  55381. * Sets stiffness of the impostor
  55382. * @param impostor impostor to set stiffness on
  55383. * @param stiffness stiffness value from 0 to 1
  55384. */
  55385. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55386. /**
  55387. * Gets velocityIterations of the impostor
  55388. * @param impostor impostor to get velocity iterations from
  55389. * @returns velocityIterations value
  55390. */
  55391. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55392. /**
  55393. * Sets velocityIterations of the impostor
  55394. * @param impostor impostor to set velocity iterations on
  55395. * @param velocityIterations velocityIterations value
  55396. */
  55397. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55398. /**
  55399. * Gets positionIterations of the impostor
  55400. * @param impostor impostor to get position iterations from
  55401. * @returns positionIterations value
  55402. */
  55403. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55404. /**
  55405. * Sets positionIterations of the impostor
  55406. * @param impostor impostor to set position on
  55407. * @param positionIterations positionIterations value
  55408. */
  55409. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55410. /**
  55411. * Append an anchor to a cloth object
  55412. * @param impostor is the cloth impostor to add anchor to
  55413. * @param otherImpostor is the rigid impostor to anchor to
  55414. * @param width ratio across width from 0 to 1
  55415. * @param height ratio up height from 0 to 1
  55416. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55417. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55418. */
  55419. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55420. /**
  55421. * Append an hook to a rope object
  55422. * @param impostor is the rope impostor to add hook to
  55423. * @param otherImpostor is the rigid impostor to hook to
  55424. * @param length ratio along the rope from 0 to 1
  55425. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55426. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55427. */
  55428. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55429. /**
  55430. * Sleeps the physics body and stops it from being active
  55431. * @param impostor impostor to sleep
  55432. */
  55433. sleepBody(impostor: PhysicsImpostor): void;
  55434. /**
  55435. * Activates the physics body
  55436. * @param impostor impostor to activate
  55437. */
  55438. wakeUpBody(impostor: PhysicsImpostor): void;
  55439. /**
  55440. * Updates the distance parameters of the joint
  55441. * @param joint joint to update
  55442. * @param maxDistance maximum distance of the joint
  55443. * @param minDistance minimum distance of the joint
  55444. */
  55445. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55446. /**
  55447. * Sets a motor on the joint
  55448. * @param joint joint to set motor on
  55449. * @param speed speed of the motor
  55450. * @param maxForce maximum force of the motor
  55451. * @param motorIndex index of the motor
  55452. */
  55453. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55454. /**
  55455. * Sets the motors limit
  55456. * @param joint joint to set limit on
  55457. * @param upperLimit upper limit
  55458. * @param lowerLimit lower limit
  55459. */
  55460. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55461. /**
  55462. * Syncs the position and rotation of a mesh with the impostor
  55463. * @param mesh mesh to sync
  55464. * @param impostor impostor to update the mesh with
  55465. */
  55466. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55467. /**
  55468. * Gets the radius of the impostor
  55469. * @param impostor impostor to get radius from
  55470. * @returns the radius
  55471. */
  55472. getRadius(impostor: PhysicsImpostor): number;
  55473. /**
  55474. * Gets the box size of the impostor
  55475. * @param impostor impostor to get box size from
  55476. * @param result the resulting box size
  55477. */
  55478. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55479. /**
  55480. * Disposes of the impostor
  55481. */
  55482. dispose(): void;
  55483. /**
  55484. * Does a raycast in the physics world
  55485. * @param from when should the ray start?
  55486. * @param to when should the ray end?
  55487. * @returns PhysicsRaycastResult
  55488. */
  55489. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55490. }
  55491. }
  55492. declare module BABYLON {
  55493. interface AbstractScene {
  55494. /**
  55495. * The list of reflection probes added to the scene
  55496. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55497. */
  55498. reflectionProbes: Array<ReflectionProbe>;
  55499. /**
  55500. * Removes the given reflection probe from this scene.
  55501. * @param toRemove The reflection probe to remove
  55502. * @returns The index of the removed reflection probe
  55503. */
  55504. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55505. /**
  55506. * Adds the given reflection probe to this scene.
  55507. * @param newReflectionProbe The reflection probe to add
  55508. */
  55509. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55510. }
  55511. /**
  55512. * Class used to generate realtime reflection / refraction cube textures
  55513. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55514. */
  55515. export class ReflectionProbe {
  55516. /** defines the name of the probe */
  55517. name: string;
  55518. private _scene;
  55519. private _renderTargetTexture;
  55520. private _projectionMatrix;
  55521. private _viewMatrix;
  55522. private _target;
  55523. private _add;
  55524. private _attachedMesh;
  55525. private _invertYAxis;
  55526. /** Gets or sets probe position (center of the cube map) */
  55527. position: Vector3;
  55528. /**
  55529. * Creates a new reflection probe
  55530. * @param name defines the name of the probe
  55531. * @param size defines the texture resolution (for each face)
  55532. * @param scene defines the hosting scene
  55533. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55534. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55535. */
  55536. constructor(
  55537. /** defines the name of the probe */
  55538. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55539. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55540. get samples(): number;
  55541. set samples(value: number);
  55542. /** Gets or sets the refresh rate to use (on every frame by default) */
  55543. get refreshRate(): number;
  55544. set refreshRate(value: number);
  55545. /**
  55546. * Gets the hosting scene
  55547. * @returns a Scene
  55548. */
  55549. getScene(): Scene;
  55550. /** Gets the internal CubeTexture used to render to */
  55551. get cubeTexture(): RenderTargetTexture;
  55552. /** Gets the list of meshes to render */
  55553. get renderList(): Nullable<AbstractMesh[]>;
  55554. /**
  55555. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55556. * @param mesh defines the mesh to attach to
  55557. */
  55558. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55559. /**
  55560. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55561. * @param renderingGroupId The rendering group id corresponding to its index
  55562. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55563. */
  55564. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55565. /**
  55566. * Clean all associated resources
  55567. */
  55568. dispose(): void;
  55569. /**
  55570. * Converts the reflection probe information to a readable string for debug purpose.
  55571. * @param fullDetails Supports for multiple levels of logging within scene loading
  55572. * @returns the human readable reflection probe info
  55573. */
  55574. toString(fullDetails?: boolean): string;
  55575. /**
  55576. * Get the class name of the relfection probe.
  55577. * @returns "ReflectionProbe"
  55578. */
  55579. getClassName(): string;
  55580. /**
  55581. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55582. * @returns The JSON representation of the texture
  55583. */
  55584. serialize(): any;
  55585. /**
  55586. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55587. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55588. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55589. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55590. * @returns The parsed reflection probe if successful
  55591. */
  55592. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55593. }
  55594. }
  55595. declare module BABYLON {
  55596. /** @hidden */
  55597. export var _BabylonLoaderRegistered: boolean;
  55598. /**
  55599. * Helps setting up some configuration for the babylon file loader.
  55600. */
  55601. export class BabylonFileLoaderConfiguration {
  55602. /**
  55603. * The loader does not allow injecting custom physix engine into the plugins.
  55604. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55605. * So you could set this variable to your engine import to make it work.
  55606. */
  55607. static LoaderInjectedPhysicsEngine: any;
  55608. }
  55609. }
  55610. declare module BABYLON {
  55611. /**
  55612. * The Physically based simple base material of BJS.
  55613. *
  55614. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55615. * It is used as the base class for both the specGloss and metalRough conventions.
  55616. */
  55617. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55618. /**
  55619. * Number of Simultaneous lights allowed on the material.
  55620. */
  55621. maxSimultaneousLights: number;
  55622. /**
  55623. * If sets to true, disables all the lights affecting the material.
  55624. */
  55625. disableLighting: boolean;
  55626. /**
  55627. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55628. */
  55629. environmentTexture: BaseTexture;
  55630. /**
  55631. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55632. */
  55633. invertNormalMapX: boolean;
  55634. /**
  55635. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55636. */
  55637. invertNormalMapY: boolean;
  55638. /**
  55639. * Normal map used in the model.
  55640. */
  55641. normalTexture: BaseTexture;
  55642. /**
  55643. * Emissivie color used to self-illuminate the model.
  55644. */
  55645. emissiveColor: Color3;
  55646. /**
  55647. * Emissivie texture used to self-illuminate the model.
  55648. */
  55649. emissiveTexture: BaseTexture;
  55650. /**
  55651. * Occlusion Channel Strenght.
  55652. */
  55653. occlusionStrength: number;
  55654. /**
  55655. * Occlusion Texture of the material (adding extra occlusion effects).
  55656. */
  55657. occlusionTexture: BaseTexture;
  55658. /**
  55659. * Defines the alpha limits in alpha test mode.
  55660. */
  55661. alphaCutOff: number;
  55662. /**
  55663. * Gets the current double sided mode.
  55664. */
  55665. get doubleSided(): boolean;
  55666. /**
  55667. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55668. */
  55669. set doubleSided(value: boolean);
  55670. /**
  55671. * Stores the pre-calculated light information of a mesh in a texture.
  55672. */
  55673. lightmapTexture: BaseTexture;
  55674. /**
  55675. * If true, the light map contains occlusion information instead of lighting info.
  55676. */
  55677. useLightmapAsShadowmap: boolean;
  55678. /**
  55679. * Instantiates a new PBRMaterial instance.
  55680. *
  55681. * @param name The material name
  55682. * @param scene The scene the material will be use in.
  55683. */
  55684. constructor(name: string, scene: Scene);
  55685. getClassName(): string;
  55686. }
  55687. }
  55688. declare module BABYLON {
  55689. /**
  55690. * The PBR material of BJS following the metal roughness convention.
  55691. *
  55692. * This fits to the PBR convention in the GLTF definition:
  55693. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55694. */
  55695. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55696. /**
  55697. * The base color has two different interpretations depending on the value of metalness.
  55698. * When the material is a metal, the base color is the specific measured reflectance value
  55699. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55700. * of the material.
  55701. */
  55702. baseColor: Color3;
  55703. /**
  55704. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55705. * well as opacity information in the alpha channel.
  55706. */
  55707. baseTexture: BaseTexture;
  55708. /**
  55709. * Specifies the metallic scalar value of the material.
  55710. * Can also be used to scale the metalness values of the metallic texture.
  55711. */
  55712. metallic: number;
  55713. /**
  55714. * Specifies the roughness scalar value of the material.
  55715. * Can also be used to scale the roughness values of the metallic texture.
  55716. */
  55717. roughness: number;
  55718. /**
  55719. * Texture containing both the metallic value in the B channel and the
  55720. * roughness value in the G channel to keep better precision.
  55721. */
  55722. metallicRoughnessTexture: BaseTexture;
  55723. /**
  55724. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55725. *
  55726. * @param name The material name
  55727. * @param scene The scene the material will be use in.
  55728. */
  55729. constructor(name: string, scene: Scene);
  55730. /**
  55731. * Return the currrent class name of the material.
  55732. */
  55733. getClassName(): string;
  55734. /**
  55735. * Makes a duplicate of the current material.
  55736. * @param name - name to use for the new material.
  55737. */
  55738. clone(name: string): PBRMetallicRoughnessMaterial;
  55739. /**
  55740. * Serialize the material to a parsable JSON object.
  55741. */
  55742. serialize(): any;
  55743. /**
  55744. * Parses a JSON object correponding to the serialize function.
  55745. */
  55746. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55747. }
  55748. }
  55749. declare module BABYLON {
  55750. /**
  55751. * The PBR material of BJS following the specular glossiness convention.
  55752. *
  55753. * This fits to the PBR convention in the GLTF definition:
  55754. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55755. */
  55756. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55757. /**
  55758. * Specifies the diffuse color of the material.
  55759. */
  55760. diffuseColor: Color3;
  55761. /**
  55762. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55763. * channel.
  55764. */
  55765. diffuseTexture: BaseTexture;
  55766. /**
  55767. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55768. */
  55769. specularColor: Color3;
  55770. /**
  55771. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55772. */
  55773. glossiness: number;
  55774. /**
  55775. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55776. */
  55777. specularGlossinessTexture: BaseTexture;
  55778. /**
  55779. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55780. *
  55781. * @param name The material name
  55782. * @param scene The scene the material will be use in.
  55783. */
  55784. constructor(name: string, scene: Scene);
  55785. /**
  55786. * Return the currrent class name of the material.
  55787. */
  55788. getClassName(): string;
  55789. /**
  55790. * Makes a duplicate of the current material.
  55791. * @param name - name to use for the new material.
  55792. */
  55793. clone(name: string): PBRSpecularGlossinessMaterial;
  55794. /**
  55795. * Serialize the material to a parsable JSON object.
  55796. */
  55797. serialize(): any;
  55798. /**
  55799. * Parses a JSON object correponding to the serialize function.
  55800. */
  55801. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55802. }
  55803. }
  55804. declare module BABYLON {
  55805. /**
  55806. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55807. * It can help converting any input color in a desired output one. This can then be used to create effects
  55808. * from sepia, black and white to sixties or futuristic rendering...
  55809. *
  55810. * The only supported format is currently 3dl.
  55811. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55812. */
  55813. export class ColorGradingTexture extends BaseTexture {
  55814. /**
  55815. * The current texture matrix. (will always be identity in color grading texture)
  55816. */
  55817. private _textureMatrix;
  55818. /**
  55819. * The texture URL.
  55820. */
  55821. url: string;
  55822. /**
  55823. * Empty line regex stored for GC.
  55824. */
  55825. private static _noneEmptyLineRegex;
  55826. private _engine;
  55827. /**
  55828. * Instantiates a ColorGradingTexture from the following parameters.
  55829. *
  55830. * @param url The location of the color gradind data (currently only supporting 3dl)
  55831. * @param scene The scene the texture will be used in
  55832. */
  55833. constructor(url: string, scene: Scene);
  55834. /**
  55835. * Returns the texture matrix used in most of the material.
  55836. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55837. */
  55838. getTextureMatrix(): Matrix;
  55839. /**
  55840. * Occurs when the file being loaded is a .3dl LUT file.
  55841. */
  55842. private load3dlTexture;
  55843. /**
  55844. * Starts the loading process of the texture.
  55845. */
  55846. private loadTexture;
  55847. /**
  55848. * Clones the color gradind texture.
  55849. */
  55850. clone(): ColorGradingTexture;
  55851. /**
  55852. * Called during delayed load for textures.
  55853. */
  55854. delayLoad(): void;
  55855. /**
  55856. * Parses a color grading texture serialized by Babylon.
  55857. * @param parsedTexture The texture information being parsedTexture
  55858. * @param scene The scene to load the texture in
  55859. * @param rootUrl The root url of the data assets to load
  55860. * @return A color gradind texture
  55861. */
  55862. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55863. /**
  55864. * Serializes the LUT texture to json format.
  55865. */
  55866. serialize(): any;
  55867. }
  55868. }
  55869. declare module BABYLON {
  55870. /**
  55871. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55872. */
  55873. export class EquiRectangularCubeTexture extends BaseTexture {
  55874. /** The six faces of the cube. */
  55875. private static _FacesMapping;
  55876. private _noMipmap;
  55877. private _onLoad;
  55878. private _onError;
  55879. /** The size of the cubemap. */
  55880. private _size;
  55881. /** The buffer of the image. */
  55882. private _buffer;
  55883. /** The width of the input image. */
  55884. private _width;
  55885. /** The height of the input image. */
  55886. private _height;
  55887. /** The URL to the image. */
  55888. url: string;
  55889. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55890. coordinatesMode: number;
  55891. /**
  55892. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55893. * @param url The location of the image
  55894. * @param scene The scene the texture will be used in
  55895. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55896. * @param noMipmap Forces to not generate the mipmap if true
  55897. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55898. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55899. * @param onLoad — defines a callback called when texture is loaded
  55900. * @param onError — defines a callback called if there is an error
  55901. */
  55902. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55903. /**
  55904. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55905. */
  55906. private loadImage;
  55907. /**
  55908. * Convert the image buffer into a cubemap and create a CubeTexture.
  55909. */
  55910. private loadTexture;
  55911. /**
  55912. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55913. * @param buffer The ArrayBuffer that should be converted.
  55914. * @returns The buffer as Float32Array.
  55915. */
  55916. private getFloat32ArrayFromArrayBuffer;
  55917. /**
  55918. * Get the current class name of the texture useful for serialization or dynamic coding.
  55919. * @returns "EquiRectangularCubeTexture"
  55920. */
  55921. getClassName(): string;
  55922. /**
  55923. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55924. * @returns A clone of the current EquiRectangularCubeTexture.
  55925. */
  55926. clone(): EquiRectangularCubeTexture;
  55927. }
  55928. }
  55929. declare module BABYLON {
  55930. /**
  55931. * Based on jsTGALoader - Javascript loader for TGA file
  55932. * By Vincent Thibault
  55933. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55934. */
  55935. export class TGATools {
  55936. private static _TYPE_INDEXED;
  55937. private static _TYPE_RGB;
  55938. private static _TYPE_GREY;
  55939. private static _TYPE_RLE_INDEXED;
  55940. private static _TYPE_RLE_RGB;
  55941. private static _TYPE_RLE_GREY;
  55942. private static _ORIGIN_MASK;
  55943. private static _ORIGIN_SHIFT;
  55944. private static _ORIGIN_BL;
  55945. private static _ORIGIN_BR;
  55946. private static _ORIGIN_UL;
  55947. private static _ORIGIN_UR;
  55948. /**
  55949. * Gets the header of a TGA file
  55950. * @param data defines the TGA data
  55951. * @returns the header
  55952. */
  55953. static GetTGAHeader(data: Uint8Array): any;
  55954. /**
  55955. * Uploads TGA content to a Babylon Texture
  55956. * @hidden
  55957. */
  55958. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55959. /** @hidden */
  55960. 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;
  55961. /** @hidden */
  55962. 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;
  55963. /** @hidden */
  55964. 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;
  55965. /** @hidden */
  55966. 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;
  55967. /** @hidden */
  55968. 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;
  55969. /** @hidden */
  55970. 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;
  55971. }
  55972. }
  55973. declare module BABYLON {
  55974. /**
  55975. * Implementation of the TGA Texture Loader.
  55976. * @hidden
  55977. */
  55978. export class _TGATextureLoader implements IInternalTextureLoader {
  55979. /**
  55980. * Defines wether the loader supports cascade loading the different faces.
  55981. */
  55982. readonly supportCascades: boolean;
  55983. /**
  55984. * This returns if the loader support the current file information.
  55985. * @param extension defines the file extension of the file being loaded
  55986. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55987. * @param fallback defines the fallback internal texture if any
  55988. * @param isBase64 defines whether the texture is encoded as a base64
  55989. * @param isBuffer defines whether the texture data are stored as a buffer
  55990. * @returns true if the loader can load the specified file
  55991. */
  55992. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55993. /**
  55994. * Transform the url before loading if required.
  55995. * @param rootUrl the url of the texture
  55996. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55997. * @returns the transformed texture
  55998. */
  55999. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56000. /**
  56001. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56002. * @param rootUrl the url of the texture
  56003. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56004. * @returns the fallback texture
  56005. */
  56006. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56007. /**
  56008. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56009. * @param data contains the texture data
  56010. * @param texture defines the BabylonJS internal texture
  56011. * @param createPolynomials will be true if polynomials have been requested
  56012. * @param onLoad defines the callback to trigger once the texture is ready
  56013. * @param onError defines the callback to trigger in case of error
  56014. */
  56015. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56016. /**
  56017. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56018. * @param data contains the texture data
  56019. * @param texture defines the BabylonJS internal texture
  56020. * @param callback defines the method to call once ready to upload
  56021. */
  56022. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56023. }
  56024. }
  56025. declare module BABYLON {
  56026. /**
  56027. * Info about the .basis files
  56028. */
  56029. class BasisFileInfo {
  56030. /**
  56031. * If the file has alpha
  56032. */
  56033. hasAlpha: boolean;
  56034. /**
  56035. * Info about each image of the basis file
  56036. */
  56037. images: Array<{
  56038. levels: Array<{
  56039. width: number;
  56040. height: number;
  56041. transcodedPixels: ArrayBufferView;
  56042. }>;
  56043. }>;
  56044. }
  56045. /**
  56046. * Result of transcoding a basis file
  56047. */
  56048. class TranscodeResult {
  56049. /**
  56050. * Info about the .basis file
  56051. */
  56052. fileInfo: BasisFileInfo;
  56053. /**
  56054. * Format to use when loading the file
  56055. */
  56056. format: number;
  56057. }
  56058. /**
  56059. * Configuration options for the Basis transcoder
  56060. */
  56061. export class BasisTranscodeConfiguration {
  56062. /**
  56063. * Supported compression formats used to determine the supported output format of the transcoder
  56064. */
  56065. supportedCompressionFormats?: {
  56066. /**
  56067. * etc1 compression format
  56068. */
  56069. etc1?: boolean;
  56070. /**
  56071. * s3tc compression format
  56072. */
  56073. s3tc?: boolean;
  56074. /**
  56075. * pvrtc compression format
  56076. */
  56077. pvrtc?: boolean;
  56078. /**
  56079. * etc2 compression format
  56080. */
  56081. etc2?: boolean;
  56082. };
  56083. /**
  56084. * If mipmap levels should be loaded for transcoded images (Default: true)
  56085. */
  56086. loadMipmapLevels?: boolean;
  56087. /**
  56088. * Index of a single image to load (Default: all images)
  56089. */
  56090. loadSingleImage?: number;
  56091. }
  56092. /**
  56093. * Used to load .Basis files
  56094. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56095. */
  56096. export class BasisTools {
  56097. private static _IgnoreSupportedFormats;
  56098. /**
  56099. * URL to use when loading the basis transcoder
  56100. */
  56101. static JSModuleURL: string;
  56102. /**
  56103. * URL to use when loading the wasm module for the transcoder
  56104. */
  56105. static WasmModuleURL: string;
  56106. /**
  56107. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56108. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56109. * @returns internal format corresponding to the Basis format
  56110. */
  56111. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56112. private static _WorkerPromise;
  56113. private static _Worker;
  56114. private static _actionId;
  56115. private static _CreateWorkerAsync;
  56116. /**
  56117. * Transcodes a loaded image file to compressed pixel data
  56118. * @param data image data to transcode
  56119. * @param config configuration options for the transcoding
  56120. * @returns a promise resulting in the transcoded image
  56121. */
  56122. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56123. /**
  56124. * Loads a texture from the transcode result
  56125. * @param texture texture load to
  56126. * @param transcodeResult the result of transcoding the basis file to load from
  56127. */
  56128. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56129. }
  56130. }
  56131. declare module BABYLON {
  56132. /**
  56133. * Loader for .basis file format
  56134. */
  56135. export class _BasisTextureLoader implements IInternalTextureLoader {
  56136. /**
  56137. * Defines whether the loader supports cascade loading the different faces.
  56138. */
  56139. readonly supportCascades: boolean;
  56140. /**
  56141. * This returns if the loader support the current file information.
  56142. * @param extension defines the file extension of the file being loaded
  56143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56144. * @param fallback defines the fallback internal texture if any
  56145. * @param isBase64 defines whether the texture is encoded as a base64
  56146. * @param isBuffer defines whether the texture data are stored as a buffer
  56147. * @returns true if the loader can load the specified file
  56148. */
  56149. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56150. /**
  56151. * Transform the url before loading if required.
  56152. * @param rootUrl the url of the texture
  56153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56154. * @returns the transformed texture
  56155. */
  56156. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56157. /**
  56158. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56159. * @param rootUrl the url of the texture
  56160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56161. * @returns the fallback texture
  56162. */
  56163. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56164. /**
  56165. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56166. * @param data contains the texture data
  56167. * @param texture defines the BabylonJS internal texture
  56168. * @param createPolynomials will be true if polynomials have been requested
  56169. * @param onLoad defines the callback to trigger once the texture is ready
  56170. * @param onError defines the callback to trigger in case of error
  56171. */
  56172. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56173. /**
  56174. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56175. * @param data contains the texture data
  56176. * @param texture defines the BabylonJS internal texture
  56177. * @param callback defines the method to call once ready to upload
  56178. */
  56179. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56180. }
  56181. }
  56182. declare module BABYLON {
  56183. /**
  56184. * 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.
  56185. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56186. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56187. */
  56188. export class CustomProceduralTexture extends ProceduralTexture {
  56189. private _animate;
  56190. private _time;
  56191. private _config;
  56192. private _texturePath;
  56193. /**
  56194. * Instantiates a new Custom Procedural Texture.
  56195. * 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.
  56196. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56197. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56198. * @param name Define the name of the texture
  56199. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56200. * @param size Define the size of the texture to create
  56201. * @param scene Define the scene the texture belongs to
  56202. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56203. * @param generateMipMaps Define if the texture should creates mip maps or not
  56204. */
  56205. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56206. private _loadJson;
  56207. /**
  56208. * Is the texture ready to be used ? (rendered at least once)
  56209. * @returns true if ready, otherwise, false.
  56210. */
  56211. isReady(): boolean;
  56212. /**
  56213. * Render the texture to its associated render target.
  56214. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56215. */
  56216. render(useCameraPostProcess?: boolean): void;
  56217. /**
  56218. * Update the list of dependant textures samplers in the shader.
  56219. */
  56220. updateTextures(): void;
  56221. /**
  56222. * Update the uniform values of the procedural texture in the shader.
  56223. */
  56224. updateShaderUniforms(): void;
  56225. /**
  56226. * Define if the texture animates or not.
  56227. */
  56228. get animate(): boolean;
  56229. set animate(value: boolean);
  56230. }
  56231. }
  56232. declare module BABYLON {
  56233. /** @hidden */
  56234. export var noisePixelShader: {
  56235. name: string;
  56236. shader: string;
  56237. };
  56238. }
  56239. declare module BABYLON {
  56240. /**
  56241. * Class used to generate noise procedural textures
  56242. */
  56243. export class NoiseProceduralTexture extends ProceduralTexture {
  56244. private _time;
  56245. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56246. brightness: number;
  56247. /** Defines the number of octaves to process */
  56248. octaves: number;
  56249. /** Defines the level of persistence (0.8 by default) */
  56250. persistence: number;
  56251. /** Gets or sets animation speed factor (default is 1) */
  56252. animationSpeedFactor: number;
  56253. /**
  56254. * Creates a new NoiseProceduralTexture
  56255. * @param name defines the name fo the texture
  56256. * @param size defines the size of the texture (default is 256)
  56257. * @param scene defines the hosting scene
  56258. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56259. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56260. */
  56261. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56262. private _updateShaderUniforms;
  56263. protected _getDefines(): string;
  56264. /** Generate the current state of the procedural texture */
  56265. render(useCameraPostProcess?: boolean): void;
  56266. /**
  56267. * Serializes this noise procedural texture
  56268. * @returns a serialized noise procedural texture object
  56269. */
  56270. serialize(): any;
  56271. /**
  56272. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56273. * @param parsedTexture defines parsed texture data
  56274. * @param scene defines the current scene
  56275. * @param rootUrl defines the root URL containing noise procedural texture information
  56276. * @returns a parsed NoiseProceduralTexture
  56277. */
  56278. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56279. }
  56280. }
  56281. declare module BABYLON {
  56282. /**
  56283. * Raw cube texture where the raw buffers are passed in
  56284. */
  56285. export class RawCubeTexture extends CubeTexture {
  56286. /**
  56287. * Creates a cube texture where the raw buffers are passed in.
  56288. * @param scene defines the scene the texture is attached to
  56289. * @param data defines the array of data to use to create each face
  56290. * @param size defines the size of the textures
  56291. * @param format defines the format of the data
  56292. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56293. * @param generateMipMaps defines if the engine should generate the mip levels
  56294. * @param invertY defines if data must be stored with Y axis inverted
  56295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56296. * @param compression defines the compression used (null by default)
  56297. */
  56298. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56299. /**
  56300. * Updates the raw cube texture.
  56301. * @param data defines the data to store
  56302. * @param format defines the data format
  56303. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56304. * @param invertY defines if data must be stored with Y axis inverted
  56305. * @param compression defines the compression used (null by default)
  56306. * @param level defines which level of the texture to update
  56307. */
  56308. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56309. /**
  56310. * Updates a raw cube texture with RGBD encoded data.
  56311. * @param data defines the array of data [mipmap][face] to use to create each face
  56312. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56313. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56314. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56315. * @returns a promsie that resolves when the operation is complete
  56316. */
  56317. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56318. /**
  56319. * Clones the raw cube texture.
  56320. * @return a new cube texture
  56321. */
  56322. clone(): CubeTexture;
  56323. /** @hidden */
  56324. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56325. }
  56326. }
  56327. declare module BABYLON {
  56328. /**
  56329. * Class used to store 3D textures containing user data
  56330. */
  56331. export class RawTexture3D extends Texture {
  56332. /** Gets or sets the texture format to use */
  56333. format: number;
  56334. private _engine;
  56335. /**
  56336. * Create a new RawTexture3D
  56337. * @param data defines the data of the texture
  56338. * @param width defines the width of the texture
  56339. * @param height defines the height of the texture
  56340. * @param depth defines the depth of the texture
  56341. * @param format defines the texture format to use
  56342. * @param scene defines the hosting scene
  56343. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56344. * @param invertY defines if texture must be stored with Y axis inverted
  56345. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56346. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56347. */
  56348. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56349. /** Gets or sets the texture format to use */
  56350. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56351. /**
  56352. * Update the texture with new data
  56353. * @param data defines the data to store in the texture
  56354. */
  56355. update(data: ArrayBufferView): void;
  56356. }
  56357. }
  56358. declare module BABYLON {
  56359. /**
  56360. * Class used to store 2D array textures containing user data
  56361. */
  56362. export class RawTexture2DArray extends Texture {
  56363. /** Gets or sets the texture format to use */
  56364. format: number;
  56365. private _engine;
  56366. /**
  56367. * Create a new RawTexture2DArray
  56368. * @param data defines the data of the texture
  56369. * @param width defines the width of the texture
  56370. * @param height defines the height of the texture
  56371. * @param depth defines the number of layers of the texture
  56372. * @param format defines the texture format to use
  56373. * @param scene defines the hosting scene
  56374. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56375. * @param invertY defines if texture must be stored with Y axis inverted
  56376. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56377. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56378. */
  56379. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56380. /** Gets or sets the texture format to use */
  56381. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56382. /**
  56383. * Update the texture with new data
  56384. * @param data defines the data to store in the texture
  56385. */
  56386. update(data: ArrayBufferView): void;
  56387. }
  56388. }
  56389. declare module BABYLON {
  56390. /**
  56391. * Creates a refraction texture used by refraction channel of the standard material.
  56392. * It is like a mirror but to see through a material.
  56393. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56394. */
  56395. export class RefractionTexture extends RenderTargetTexture {
  56396. /**
  56397. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56398. * 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.
  56399. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56400. */
  56401. refractionPlane: Plane;
  56402. /**
  56403. * Define how deep under the surface we should see.
  56404. */
  56405. depth: number;
  56406. /**
  56407. * Creates a refraction texture used by refraction channel of the standard material.
  56408. * It is like a mirror but to see through a material.
  56409. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56410. * @param name Define the texture name
  56411. * @param size Define the size of the underlying texture
  56412. * @param scene Define the scene the refraction belongs to
  56413. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56414. */
  56415. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56416. /**
  56417. * Clone the refraction texture.
  56418. * @returns the cloned texture
  56419. */
  56420. clone(): RefractionTexture;
  56421. /**
  56422. * Serialize the texture to a JSON representation you could use in Parse later on
  56423. * @returns the serialized JSON representation
  56424. */
  56425. serialize(): any;
  56426. }
  56427. }
  56428. declare module BABYLON {
  56429. /**
  56430. * Defines the options related to the creation of an HtmlElementTexture
  56431. */
  56432. export interface IHtmlElementTextureOptions {
  56433. /**
  56434. * Defines wether mip maps should be created or not.
  56435. */
  56436. generateMipMaps?: boolean;
  56437. /**
  56438. * Defines the sampling mode of the texture.
  56439. */
  56440. samplingMode?: number;
  56441. /**
  56442. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56443. */
  56444. engine: Nullable<ThinEngine>;
  56445. /**
  56446. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56447. */
  56448. scene: Nullable<Scene>;
  56449. }
  56450. /**
  56451. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56452. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56453. * is automatically managed.
  56454. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56455. * in your application.
  56456. *
  56457. * As the update is not automatic, you need to call them manually.
  56458. */
  56459. export class HtmlElementTexture extends BaseTexture {
  56460. /**
  56461. * The texture URL.
  56462. */
  56463. element: HTMLVideoElement | HTMLCanvasElement;
  56464. private static readonly DefaultOptions;
  56465. private _textureMatrix;
  56466. private _engine;
  56467. private _isVideo;
  56468. private _generateMipMaps;
  56469. private _samplingMode;
  56470. /**
  56471. * Instantiates a HtmlElementTexture from the following parameters.
  56472. *
  56473. * @param name Defines the name of the texture
  56474. * @param element Defines the video or canvas the texture is filled with
  56475. * @param options Defines the other none mandatory texture creation options
  56476. */
  56477. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56478. private _createInternalTexture;
  56479. /**
  56480. * Returns the texture matrix used in most of the material.
  56481. */
  56482. getTextureMatrix(): Matrix;
  56483. /**
  56484. * Updates the content of the texture.
  56485. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56486. */
  56487. update(invertY?: Nullable<boolean>): void;
  56488. }
  56489. }
  56490. declare module BABYLON {
  56491. /**
  56492. * Defines the basic options interface of a TexturePacker Frame
  56493. */
  56494. export interface ITexturePackerFrame {
  56495. /**
  56496. * The frame ID
  56497. */
  56498. id: number;
  56499. /**
  56500. * The frames Scale
  56501. */
  56502. scale: Vector2;
  56503. /**
  56504. * The Frames offset
  56505. */
  56506. offset: Vector2;
  56507. }
  56508. /**
  56509. * This is a support class for frame Data on texture packer sets.
  56510. */
  56511. export class TexturePackerFrame implements ITexturePackerFrame {
  56512. /**
  56513. * The frame ID
  56514. */
  56515. id: number;
  56516. /**
  56517. * The frames Scale
  56518. */
  56519. scale: Vector2;
  56520. /**
  56521. * The Frames offset
  56522. */
  56523. offset: Vector2;
  56524. /**
  56525. * Initializes a texture package frame.
  56526. * @param id The numerical frame identifier
  56527. * @param scale Scalar Vector2 for UV frame
  56528. * @param offset Vector2 for the frame position in UV units.
  56529. * @returns TexturePackerFrame
  56530. */
  56531. constructor(id: number, scale: Vector2, offset: Vector2);
  56532. }
  56533. }
  56534. declare module BABYLON {
  56535. /**
  56536. * Defines the basic options interface of a TexturePacker
  56537. */
  56538. export interface ITexturePackerOptions {
  56539. /**
  56540. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56541. */
  56542. map?: string[];
  56543. /**
  56544. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56545. */
  56546. uvsIn?: string;
  56547. /**
  56548. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56549. */
  56550. uvsOut?: string;
  56551. /**
  56552. * number representing the layout style. Defaults to LAYOUT_STRIP
  56553. */
  56554. layout?: number;
  56555. /**
  56556. * number of columns if using custom column count layout(2). This defaults to 4.
  56557. */
  56558. colnum?: number;
  56559. /**
  56560. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56561. */
  56562. updateInputMeshes?: boolean;
  56563. /**
  56564. * boolean flag to dispose all the source textures. Defaults to true.
  56565. */
  56566. disposeSources?: boolean;
  56567. /**
  56568. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56569. */
  56570. fillBlanks?: boolean;
  56571. /**
  56572. * string value representing the context fill style color. Defaults to 'black'.
  56573. */
  56574. customFillColor?: string;
  56575. /**
  56576. * Width and Height Value of each Frame in the TexturePacker Sets
  56577. */
  56578. frameSize?: number;
  56579. /**
  56580. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56581. */
  56582. paddingRatio?: number;
  56583. /**
  56584. * Number that declares the fill method for the padding gutter.
  56585. */
  56586. paddingMode?: number;
  56587. /**
  56588. * If in SUBUV_COLOR padding mode what color to use.
  56589. */
  56590. paddingColor?: Color3 | Color4;
  56591. }
  56592. /**
  56593. * Defines the basic interface of a TexturePacker JSON File
  56594. */
  56595. export interface ITexturePackerJSON {
  56596. /**
  56597. * The frame ID
  56598. */
  56599. name: string;
  56600. /**
  56601. * The base64 channel data
  56602. */
  56603. sets: any;
  56604. /**
  56605. * The options of the Packer
  56606. */
  56607. options: ITexturePackerOptions;
  56608. /**
  56609. * The frame data of the Packer
  56610. */
  56611. frames: Array<number>;
  56612. }
  56613. /**
  56614. * This is a support class that generates a series of packed texture sets.
  56615. * @see https://doc.babylonjs.com/babylon101/materials
  56616. */
  56617. export class TexturePacker {
  56618. /** Packer Layout Constant 0 */
  56619. static readonly LAYOUT_STRIP: number;
  56620. /** Packer Layout Constant 1 */
  56621. static readonly LAYOUT_POWER2: number;
  56622. /** Packer Layout Constant 2 */
  56623. static readonly LAYOUT_COLNUM: number;
  56624. /** Packer Layout Constant 0 */
  56625. static readonly SUBUV_WRAP: number;
  56626. /** Packer Layout Constant 1 */
  56627. static readonly SUBUV_EXTEND: number;
  56628. /** Packer Layout Constant 2 */
  56629. static readonly SUBUV_COLOR: number;
  56630. /** The Name of the Texture Package */
  56631. name: string;
  56632. /** The scene scope of the TexturePacker */
  56633. scene: Scene;
  56634. /** The Meshes to target */
  56635. meshes: AbstractMesh[];
  56636. /** Arguments passed with the Constructor */
  56637. options: ITexturePackerOptions;
  56638. /** The promise that is started upon initialization */
  56639. promise: Nullable<Promise<TexturePacker | string>>;
  56640. /** The Container object for the channel sets that are generated */
  56641. sets: object;
  56642. /** The Container array for the frames that are generated */
  56643. frames: TexturePackerFrame[];
  56644. /** The expected number of textures the system is parsing. */
  56645. private _expecting;
  56646. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56647. private _paddingValue;
  56648. /**
  56649. * Initializes a texture package series from an array of meshes or a single mesh.
  56650. * @param name The name of the package
  56651. * @param meshes The target meshes to compose the package from
  56652. * @param options The arguments that texture packer should follow while building.
  56653. * @param scene The scene which the textures are scoped to.
  56654. * @returns TexturePacker
  56655. */
  56656. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56657. /**
  56658. * Starts the package process
  56659. * @param resolve The promises resolution function
  56660. * @returns TexturePacker
  56661. */
  56662. private _createFrames;
  56663. /**
  56664. * Calculates the Size of the Channel Sets
  56665. * @returns Vector2
  56666. */
  56667. private _calculateSize;
  56668. /**
  56669. * Calculates the UV data for the frames.
  56670. * @param baseSize the base frameSize
  56671. * @param padding the base frame padding
  56672. * @param dtSize size of the Dynamic Texture for that channel
  56673. * @param dtUnits is 1/dtSize
  56674. * @param update flag to update the input meshes
  56675. */
  56676. private _calculateMeshUVFrames;
  56677. /**
  56678. * Calculates the frames Offset.
  56679. * @param index of the frame
  56680. * @returns Vector2
  56681. */
  56682. private _getFrameOffset;
  56683. /**
  56684. * Updates a Mesh to the frame data
  56685. * @param mesh that is the target
  56686. * @param frameID or the frame index
  56687. */
  56688. private _updateMeshUV;
  56689. /**
  56690. * Updates a Meshes materials to use the texture packer channels
  56691. * @param m is the mesh to target
  56692. * @param force all channels on the packer to be set.
  56693. */
  56694. private _updateTextureReferences;
  56695. /**
  56696. * Public method to set a Mesh to a frame
  56697. * @param m that is the target
  56698. * @param frameID or the frame index
  56699. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56700. */
  56701. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56702. /**
  56703. * Starts the async promise to compile the texture packer.
  56704. * @returns Promise<void>
  56705. */
  56706. processAsync(): Promise<void>;
  56707. /**
  56708. * Disposes all textures associated with this packer
  56709. */
  56710. dispose(): void;
  56711. /**
  56712. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56713. * @param imageType is the image type to use.
  56714. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56715. */
  56716. download(imageType?: string, quality?: number): void;
  56717. /**
  56718. * Public method to load a texturePacker JSON file.
  56719. * @param data of the JSON file in string format.
  56720. */
  56721. updateFromJSON(data: string): void;
  56722. }
  56723. }
  56724. declare module BABYLON {
  56725. /**
  56726. * Enum used to define the target of a block
  56727. */
  56728. export enum NodeMaterialBlockTargets {
  56729. /** Vertex shader */
  56730. Vertex = 1,
  56731. /** Fragment shader */
  56732. Fragment = 2,
  56733. /** Neutral */
  56734. Neutral = 4,
  56735. /** Vertex and Fragment */
  56736. VertexAndFragment = 3
  56737. }
  56738. }
  56739. declare module BABYLON {
  56740. /**
  56741. * Defines the kind of connection point for node based material
  56742. */
  56743. export enum NodeMaterialBlockConnectionPointTypes {
  56744. /** Float */
  56745. Float = 1,
  56746. /** Int */
  56747. Int = 2,
  56748. /** Vector2 */
  56749. Vector2 = 4,
  56750. /** Vector3 */
  56751. Vector3 = 8,
  56752. /** Vector4 */
  56753. Vector4 = 16,
  56754. /** Color3 */
  56755. Color3 = 32,
  56756. /** Color4 */
  56757. Color4 = 64,
  56758. /** Matrix */
  56759. Matrix = 128,
  56760. /** Detect type based on connection */
  56761. AutoDetect = 1024,
  56762. /** Output type that will be defined by input type */
  56763. BasedOnInput = 2048
  56764. }
  56765. }
  56766. declare module BABYLON {
  56767. /**
  56768. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56769. */
  56770. export enum NodeMaterialBlockConnectionPointMode {
  56771. /** Value is an uniform */
  56772. Uniform = 0,
  56773. /** Value is a mesh attribute */
  56774. Attribute = 1,
  56775. /** Value is a varying between vertex and fragment shaders */
  56776. Varying = 2,
  56777. /** Mode is undefined */
  56778. Undefined = 3
  56779. }
  56780. }
  56781. declare module BABYLON {
  56782. /**
  56783. * Enum used to define system values e.g. values automatically provided by the system
  56784. */
  56785. export enum NodeMaterialSystemValues {
  56786. /** World */
  56787. World = 1,
  56788. /** View */
  56789. View = 2,
  56790. /** Projection */
  56791. Projection = 3,
  56792. /** ViewProjection */
  56793. ViewProjection = 4,
  56794. /** WorldView */
  56795. WorldView = 5,
  56796. /** WorldViewProjection */
  56797. WorldViewProjection = 6,
  56798. /** CameraPosition */
  56799. CameraPosition = 7,
  56800. /** Fog Color */
  56801. FogColor = 8,
  56802. /** Delta time */
  56803. DeltaTime = 9
  56804. }
  56805. }
  56806. declare module BABYLON {
  56807. /**
  56808. * Root class for all node material optimizers
  56809. */
  56810. export class NodeMaterialOptimizer {
  56811. /**
  56812. * Function used to optimize a NodeMaterial graph
  56813. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56814. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56815. */
  56816. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56817. }
  56818. }
  56819. declare module BABYLON {
  56820. /**
  56821. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56822. */
  56823. export class TransformBlock extends NodeMaterialBlock {
  56824. /**
  56825. * Defines the value to use to complement W value to transform it to a Vector4
  56826. */
  56827. complementW: number;
  56828. /**
  56829. * Defines the value to use to complement z value to transform it to a Vector4
  56830. */
  56831. complementZ: number;
  56832. /**
  56833. * Creates a new TransformBlock
  56834. * @param name defines the block name
  56835. */
  56836. constructor(name: string);
  56837. /**
  56838. * Gets the current class name
  56839. * @returns the class name
  56840. */
  56841. getClassName(): string;
  56842. /**
  56843. * Gets the vector input
  56844. */
  56845. get vector(): NodeMaterialConnectionPoint;
  56846. /**
  56847. * Gets the output component
  56848. */
  56849. get output(): NodeMaterialConnectionPoint;
  56850. /**
  56851. * Gets the matrix transform input
  56852. */
  56853. get transform(): NodeMaterialConnectionPoint;
  56854. protected _buildBlock(state: NodeMaterialBuildState): this;
  56855. serialize(): any;
  56856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56857. protected _dumpPropertiesCode(): string;
  56858. }
  56859. }
  56860. declare module BABYLON {
  56861. /**
  56862. * Block used to output the vertex position
  56863. */
  56864. export class VertexOutputBlock extends NodeMaterialBlock {
  56865. /**
  56866. * Creates a new VertexOutputBlock
  56867. * @param name defines the block name
  56868. */
  56869. constructor(name: string);
  56870. /**
  56871. * Gets the current class name
  56872. * @returns the class name
  56873. */
  56874. getClassName(): string;
  56875. /**
  56876. * Gets the vector input component
  56877. */
  56878. get vector(): NodeMaterialConnectionPoint;
  56879. protected _buildBlock(state: NodeMaterialBuildState): this;
  56880. }
  56881. }
  56882. declare module BABYLON {
  56883. /**
  56884. * Block used to output the final color
  56885. */
  56886. export class FragmentOutputBlock extends NodeMaterialBlock {
  56887. /**
  56888. * Create a new FragmentOutputBlock
  56889. * @param name defines the block name
  56890. */
  56891. constructor(name: string);
  56892. /**
  56893. * Gets the current class name
  56894. * @returns the class name
  56895. */
  56896. getClassName(): string;
  56897. /**
  56898. * Gets the rgba input component
  56899. */
  56900. get rgba(): NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the rgb input component
  56903. */
  56904. get rgb(): NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the a input component
  56907. */
  56908. get a(): NodeMaterialConnectionPoint;
  56909. protected _buildBlock(state: NodeMaterialBuildState): this;
  56910. }
  56911. }
  56912. declare module BABYLON {
  56913. /**
  56914. * Block used to read a reflection texture from a sampler
  56915. */
  56916. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56917. private _define3DName;
  56918. private _defineCubicName;
  56919. private _defineExplicitName;
  56920. private _defineProjectionName;
  56921. private _defineLocalCubicName;
  56922. private _defineSphericalName;
  56923. private _definePlanarName;
  56924. private _defineEquirectangularName;
  56925. private _defineMirroredEquirectangularFixedName;
  56926. private _defineEquirectangularFixedName;
  56927. private _defineSkyboxName;
  56928. private _cubeSamplerName;
  56929. private _2DSamplerName;
  56930. private _positionUVWName;
  56931. private _directionWName;
  56932. private _reflectionCoordsName;
  56933. private _reflection2DCoordsName;
  56934. private _reflectionColorName;
  56935. private _reflectionMatrixName;
  56936. /**
  56937. * Gets or sets the texture associated with the node
  56938. */
  56939. texture: Nullable<BaseTexture>;
  56940. /**
  56941. * Create a new TextureBlock
  56942. * @param name defines the block name
  56943. */
  56944. constructor(name: string);
  56945. /**
  56946. * Gets the current class name
  56947. * @returns the class name
  56948. */
  56949. getClassName(): string;
  56950. /**
  56951. * Gets the world position input component
  56952. */
  56953. get position(): NodeMaterialConnectionPoint;
  56954. /**
  56955. * Gets the world position input component
  56956. */
  56957. get worldPosition(): NodeMaterialConnectionPoint;
  56958. /**
  56959. * Gets the world normal input component
  56960. */
  56961. get worldNormal(): NodeMaterialConnectionPoint;
  56962. /**
  56963. * Gets the world input component
  56964. */
  56965. get world(): NodeMaterialConnectionPoint;
  56966. /**
  56967. * Gets the camera (or eye) position component
  56968. */
  56969. get cameraPosition(): NodeMaterialConnectionPoint;
  56970. /**
  56971. * Gets the view input component
  56972. */
  56973. get view(): NodeMaterialConnectionPoint;
  56974. /**
  56975. * Gets the rgb output component
  56976. */
  56977. get rgb(): NodeMaterialConnectionPoint;
  56978. /**
  56979. * Gets the r output component
  56980. */
  56981. get r(): NodeMaterialConnectionPoint;
  56982. /**
  56983. * Gets the g output component
  56984. */
  56985. get g(): NodeMaterialConnectionPoint;
  56986. /**
  56987. * Gets the b output component
  56988. */
  56989. get b(): NodeMaterialConnectionPoint;
  56990. autoConfigure(material: NodeMaterial): void;
  56991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56992. isReady(): boolean;
  56993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56994. private _injectVertexCode;
  56995. private _writeOutput;
  56996. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56997. protected _dumpPropertiesCode(): string;
  56998. serialize(): any;
  56999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57000. }
  57001. }
  57002. declare module BABYLON {
  57003. /**
  57004. * Interface used to configure the node material editor
  57005. */
  57006. export interface INodeMaterialEditorOptions {
  57007. /** Define the URl to load node editor script */
  57008. editorURL?: string;
  57009. }
  57010. /** @hidden */
  57011. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57012. NORMAL: boolean;
  57013. TANGENT: boolean;
  57014. UV1: boolean;
  57015. /** BONES */
  57016. NUM_BONE_INFLUENCERS: number;
  57017. BonesPerMesh: number;
  57018. BONETEXTURE: boolean;
  57019. /** MORPH TARGETS */
  57020. MORPHTARGETS: boolean;
  57021. MORPHTARGETS_NORMAL: boolean;
  57022. MORPHTARGETS_TANGENT: boolean;
  57023. MORPHTARGETS_UV: boolean;
  57024. NUM_MORPH_INFLUENCERS: number;
  57025. /** IMAGE PROCESSING */
  57026. IMAGEPROCESSING: boolean;
  57027. VIGNETTE: boolean;
  57028. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57029. VIGNETTEBLENDMODEOPAQUE: boolean;
  57030. TONEMAPPING: boolean;
  57031. TONEMAPPING_ACES: boolean;
  57032. CONTRAST: boolean;
  57033. EXPOSURE: boolean;
  57034. COLORCURVES: boolean;
  57035. COLORGRADING: boolean;
  57036. COLORGRADING3D: boolean;
  57037. SAMPLER3DGREENDEPTH: boolean;
  57038. SAMPLER3DBGRMAP: boolean;
  57039. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57040. /** MISC. */
  57041. BUMPDIRECTUV: number;
  57042. constructor();
  57043. setValue(name: string, value: boolean): void;
  57044. }
  57045. /**
  57046. * Class used to configure NodeMaterial
  57047. */
  57048. export interface INodeMaterialOptions {
  57049. /**
  57050. * Defines if blocks should emit comments
  57051. */
  57052. emitComments: boolean;
  57053. }
  57054. /**
  57055. * Class used to create a node based material built by assembling shader blocks
  57056. */
  57057. export class NodeMaterial extends PushMaterial {
  57058. private static _BuildIdGenerator;
  57059. private _options;
  57060. private _vertexCompilationState;
  57061. private _fragmentCompilationState;
  57062. private _sharedData;
  57063. private _buildId;
  57064. private _buildWasSuccessful;
  57065. private _cachedWorldViewMatrix;
  57066. private _cachedWorldViewProjectionMatrix;
  57067. private _optimizers;
  57068. private _animationFrame;
  57069. /** Define the Url to load node editor script */
  57070. static EditorURL: string;
  57071. /** Define the Url to load snippets */
  57072. static SnippetUrl: string;
  57073. private BJSNODEMATERIALEDITOR;
  57074. /** Get the inspector from bundle or global */
  57075. private _getGlobalNodeMaterialEditor;
  57076. /**
  57077. * Gets or sets data used by visual editor
  57078. * @see https://nme.babylonjs.com
  57079. */
  57080. editorData: any;
  57081. /**
  57082. * 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)
  57083. */
  57084. ignoreAlpha: boolean;
  57085. /**
  57086. * Defines the maximum number of lights that can be used in the material
  57087. */
  57088. maxSimultaneousLights: number;
  57089. /**
  57090. * Observable raised when the material is built
  57091. */
  57092. onBuildObservable: Observable<NodeMaterial>;
  57093. /**
  57094. * Gets or sets the root nodes of the material vertex shader
  57095. */
  57096. _vertexOutputNodes: NodeMaterialBlock[];
  57097. /**
  57098. * Gets or sets the root nodes of the material fragment (pixel) shader
  57099. */
  57100. _fragmentOutputNodes: NodeMaterialBlock[];
  57101. /** Gets or sets options to control the node material overall behavior */
  57102. get options(): INodeMaterialOptions;
  57103. set options(options: INodeMaterialOptions);
  57104. /**
  57105. * Default configuration related to image processing available in the standard Material.
  57106. */
  57107. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57108. /**
  57109. * Gets the image processing configuration used either in this material.
  57110. */
  57111. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57112. /**
  57113. * Sets the Default image processing configuration used either in the this material.
  57114. *
  57115. * If sets to null, the scene one is in use.
  57116. */
  57117. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57118. /**
  57119. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57120. */
  57121. attachedBlocks: NodeMaterialBlock[];
  57122. /**
  57123. * Create a new node based material
  57124. * @param name defines the material name
  57125. * @param scene defines the hosting scene
  57126. * @param options defines creation option
  57127. */
  57128. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57129. /**
  57130. * Gets the current class name of the material e.g. "NodeMaterial"
  57131. * @returns the class name
  57132. */
  57133. getClassName(): string;
  57134. /**
  57135. * Keep track of the image processing observer to allow dispose and replace.
  57136. */
  57137. private _imageProcessingObserver;
  57138. /**
  57139. * Attaches a new image processing configuration to the Standard Material.
  57140. * @param configuration
  57141. */
  57142. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57143. /**
  57144. * Get a block by its name
  57145. * @param name defines the name of the block to retrieve
  57146. * @returns the required block or null if not found
  57147. */
  57148. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57149. /**
  57150. * Get a block by its name
  57151. * @param predicate defines the predicate used to find the good candidate
  57152. * @returns the required block or null if not found
  57153. */
  57154. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57155. /**
  57156. * Get an input block by its name
  57157. * @param predicate defines the predicate used to find the good candidate
  57158. * @returns the required input block or null if not found
  57159. */
  57160. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57161. /**
  57162. * Gets the list of input blocks attached to this material
  57163. * @returns an array of InputBlocks
  57164. */
  57165. getInputBlocks(): InputBlock[];
  57166. /**
  57167. * Adds a new optimizer to the list of optimizers
  57168. * @param optimizer defines the optimizers to add
  57169. * @returns the current material
  57170. */
  57171. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57172. /**
  57173. * Remove an optimizer from the list of optimizers
  57174. * @param optimizer defines the optimizers to remove
  57175. * @returns the current material
  57176. */
  57177. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57178. /**
  57179. * Add a new block to the list of output nodes
  57180. * @param node defines the node to add
  57181. * @returns the current material
  57182. */
  57183. addOutputNode(node: NodeMaterialBlock): this;
  57184. /**
  57185. * Remove a block from the list of root nodes
  57186. * @param node defines the node to remove
  57187. * @returns the current material
  57188. */
  57189. removeOutputNode(node: NodeMaterialBlock): this;
  57190. private _addVertexOutputNode;
  57191. private _removeVertexOutputNode;
  57192. private _addFragmentOutputNode;
  57193. private _removeFragmentOutputNode;
  57194. /**
  57195. * Specifies if the material will require alpha blending
  57196. * @returns a boolean specifying if alpha blending is needed
  57197. */
  57198. needAlphaBlending(): boolean;
  57199. /**
  57200. * Specifies if this material should be rendered in alpha test mode
  57201. * @returns a boolean specifying if an alpha test is needed.
  57202. */
  57203. needAlphaTesting(): boolean;
  57204. private _initializeBlock;
  57205. private _resetDualBlocks;
  57206. /**
  57207. * Remove a block from the current node material
  57208. * @param block defines the block to remove
  57209. */
  57210. removeBlock(block: NodeMaterialBlock): void;
  57211. /**
  57212. * Build the material and generates the inner effect
  57213. * @param verbose defines if the build should log activity
  57214. */
  57215. build(verbose?: boolean): void;
  57216. /**
  57217. * Runs an otpimization phase to try to improve the shader code
  57218. */
  57219. optimize(): void;
  57220. private _prepareDefinesForAttributes;
  57221. /**
  57222. * Get if the submesh is ready to be used and all its information available.
  57223. * Child classes can use it to update shaders
  57224. * @param mesh defines the mesh to check
  57225. * @param subMesh defines which submesh to check
  57226. * @param useInstances specifies that instances should be used
  57227. * @returns a boolean indicating that the submesh is ready or not
  57228. */
  57229. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57230. /**
  57231. * Get a string representing the shaders built by the current node graph
  57232. */
  57233. get compiledShaders(): string;
  57234. /**
  57235. * Binds the world matrix to the material
  57236. * @param world defines the world transformation matrix
  57237. */
  57238. bindOnlyWorldMatrix(world: Matrix): void;
  57239. /**
  57240. * Binds the submesh to this material by preparing the effect and shader to draw
  57241. * @param world defines the world transformation matrix
  57242. * @param mesh defines the mesh containing the submesh
  57243. * @param subMesh defines the submesh to bind the material to
  57244. */
  57245. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57246. /**
  57247. * Gets the active textures from the material
  57248. * @returns an array of textures
  57249. */
  57250. getActiveTextures(): BaseTexture[];
  57251. /**
  57252. * Gets the list of texture blocks
  57253. * @returns an array of texture blocks
  57254. */
  57255. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57256. /**
  57257. * Specifies if the material uses a texture
  57258. * @param texture defines the texture to check against the material
  57259. * @returns a boolean specifying if the material uses the texture
  57260. */
  57261. hasTexture(texture: BaseTexture): boolean;
  57262. /**
  57263. * Disposes the material
  57264. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57265. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57266. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57267. */
  57268. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57269. /** Creates the node editor window. */
  57270. private _createNodeEditor;
  57271. /**
  57272. * Launch the node material editor
  57273. * @param config Define the configuration of the editor
  57274. * @return a promise fulfilled when the node editor is visible
  57275. */
  57276. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57277. /**
  57278. * Clear the current material
  57279. */
  57280. clear(): void;
  57281. /**
  57282. * Clear the current material and set it to a default state
  57283. */
  57284. setToDefault(): void;
  57285. /**
  57286. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57287. * @param url defines the url to load from
  57288. * @returns a promise that will fullfil when the material is fully loaded
  57289. */
  57290. loadAsync(url: string): Promise<void>;
  57291. private _gatherBlocks;
  57292. /**
  57293. * Generate a string containing the code declaration required to create an equivalent of this material
  57294. * @returns a string
  57295. */
  57296. generateCode(): string;
  57297. /**
  57298. * Serializes this material in a JSON representation
  57299. * @returns the serialized material object
  57300. */
  57301. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57302. private _restoreConnections;
  57303. /**
  57304. * Clear the current graph and load a new one from a serialization object
  57305. * @param source defines the JSON representation of the material
  57306. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57307. */
  57308. loadFromSerialization(source: any, rootUrl?: string): void;
  57309. /**
  57310. * Creates a node material from parsed material data
  57311. * @param source defines the JSON representation of the material
  57312. * @param scene defines the hosting scene
  57313. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57314. * @returns a new node material
  57315. */
  57316. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57317. /**
  57318. * Creates a node material from a snippet saved in a remote file
  57319. * @param name defines the name of the material to create
  57320. * @param url defines the url to load from
  57321. * @param scene defines the hosting scene
  57322. * @returns a promise that will resolve to the new node material
  57323. */
  57324. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57325. /**
  57326. * Creates a node material from a snippet saved by the node material editor
  57327. * @param snippetId defines the snippet to load
  57328. * @param scene defines the hosting scene
  57329. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57330. * @returns a promise that will resolve to the new node material
  57331. */
  57332. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57333. /**
  57334. * Creates a new node material set to default basic configuration
  57335. * @param name defines the name of the material
  57336. * @param scene defines the hosting scene
  57337. * @returns a new NodeMaterial
  57338. */
  57339. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57340. }
  57341. }
  57342. declare module BABYLON {
  57343. /**
  57344. * Block used to read a texture from a sampler
  57345. */
  57346. export class TextureBlock extends NodeMaterialBlock {
  57347. private _defineName;
  57348. private _linearDefineName;
  57349. private _tempTextureRead;
  57350. private _samplerName;
  57351. private _transformedUVName;
  57352. private _textureTransformName;
  57353. private _textureInfoName;
  57354. private _mainUVName;
  57355. private _mainUVDefineName;
  57356. /**
  57357. * Gets or sets the texture associated with the node
  57358. */
  57359. texture: Nullable<Texture>;
  57360. /**
  57361. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57362. */
  57363. convertToGammaSpace: boolean;
  57364. /**
  57365. * Create a new TextureBlock
  57366. * @param name defines the block name
  57367. */
  57368. constructor(name: string);
  57369. /**
  57370. * Gets the current class name
  57371. * @returns the class name
  57372. */
  57373. getClassName(): string;
  57374. /**
  57375. * Gets the uv input component
  57376. */
  57377. get uv(): NodeMaterialConnectionPoint;
  57378. /**
  57379. * Gets the rgba output component
  57380. */
  57381. get rgba(): NodeMaterialConnectionPoint;
  57382. /**
  57383. * Gets the rgb output component
  57384. */
  57385. get rgb(): NodeMaterialConnectionPoint;
  57386. /**
  57387. * Gets the r output component
  57388. */
  57389. get r(): NodeMaterialConnectionPoint;
  57390. /**
  57391. * Gets the g output component
  57392. */
  57393. get g(): NodeMaterialConnectionPoint;
  57394. /**
  57395. * Gets the b output component
  57396. */
  57397. get b(): NodeMaterialConnectionPoint;
  57398. /**
  57399. * Gets the a output component
  57400. */
  57401. get a(): NodeMaterialConnectionPoint;
  57402. get target(): NodeMaterialBlockTargets;
  57403. autoConfigure(material: NodeMaterial): void;
  57404. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57406. isReady(): boolean;
  57407. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57408. private get _isMixed();
  57409. private _injectVertexCode;
  57410. private _writeTextureRead;
  57411. private _writeOutput;
  57412. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57413. protected _dumpPropertiesCode(): string;
  57414. serialize(): any;
  57415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57416. }
  57417. }
  57418. declare module BABYLON {
  57419. /**
  57420. * Class used to store shared data between 2 NodeMaterialBuildState
  57421. */
  57422. export class NodeMaterialBuildStateSharedData {
  57423. /**
  57424. * Gets the list of emitted varyings
  57425. */
  57426. temps: string[];
  57427. /**
  57428. * Gets the list of emitted varyings
  57429. */
  57430. varyings: string[];
  57431. /**
  57432. * Gets the varying declaration string
  57433. */
  57434. varyingDeclaration: string;
  57435. /**
  57436. * Input blocks
  57437. */
  57438. inputBlocks: InputBlock[];
  57439. /**
  57440. * Input blocks
  57441. */
  57442. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57443. /**
  57444. * Bindable blocks (Blocks that need to set data to the effect)
  57445. */
  57446. bindableBlocks: NodeMaterialBlock[];
  57447. /**
  57448. * List of blocks that can provide a compilation fallback
  57449. */
  57450. blocksWithFallbacks: NodeMaterialBlock[];
  57451. /**
  57452. * List of blocks that can provide a define update
  57453. */
  57454. blocksWithDefines: NodeMaterialBlock[];
  57455. /**
  57456. * List of blocks that can provide a repeatable content
  57457. */
  57458. repeatableContentBlocks: NodeMaterialBlock[];
  57459. /**
  57460. * List of blocks that can provide a dynamic list of uniforms
  57461. */
  57462. dynamicUniformBlocks: NodeMaterialBlock[];
  57463. /**
  57464. * List of blocks that can block the isReady function for the material
  57465. */
  57466. blockingBlocks: NodeMaterialBlock[];
  57467. /**
  57468. * Gets the list of animated inputs
  57469. */
  57470. animatedInputs: InputBlock[];
  57471. /**
  57472. * Build Id used to avoid multiple recompilations
  57473. */
  57474. buildId: number;
  57475. /** List of emitted variables */
  57476. variableNames: {
  57477. [key: string]: number;
  57478. };
  57479. /** List of emitted defines */
  57480. defineNames: {
  57481. [key: string]: number;
  57482. };
  57483. /** Should emit comments? */
  57484. emitComments: boolean;
  57485. /** Emit build activity */
  57486. verbose: boolean;
  57487. /** Gets or sets the hosting scene */
  57488. scene: Scene;
  57489. /**
  57490. * Gets the compilation hints emitted at compilation time
  57491. */
  57492. hints: {
  57493. needWorldViewMatrix: boolean;
  57494. needWorldViewProjectionMatrix: boolean;
  57495. needAlphaBlending: boolean;
  57496. needAlphaTesting: boolean;
  57497. };
  57498. /**
  57499. * List of compilation checks
  57500. */
  57501. checks: {
  57502. emitVertex: boolean;
  57503. emitFragment: boolean;
  57504. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57505. };
  57506. /** Creates a new shared data */
  57507. constructor();
  57508. /**
  57509. * Emits console errors and exceptions if there is a failing check
  57510. */
  57511. emitErrors(): void;
  57512. }
  57513. }
  57514. declare module BABYLON {
  57515. /**
  57516. * Class used to store node based material build state
  57517. */
  57518. export class NodeMaterialBuildState {
  57519. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57520. supportUniformBuffers: boolean;
  57521. /**
  57522. * Gets the list of emitted attributes
  57523. */
  57524. attributes: string[];
  57525. /**
  57526. * Gets the list of emitted uniforms
  57527. */
  57528. uniforms: string[];
  57529. /**
  57530. * Gets the list of emitted constants
  57531. */
  57532. constants: string[];
  57533. /**
  57534. * Gets the list of emitted samplers
  57535. */
  57536. samplers: string[];
  57537. /**
  57538. * Gets the list of emitted functions
  57539. */
  57540. functions: {
  57541. [key: string]: string;
  57542. };
  57543. /**
  57544. * Gets the list of emitted extensions
  57545. */
  57546. extensions: {
  57547. [key: string]: string;
  57548. };
  57549. /**
  57550. * Gets the target of the compilation state
  57551. */
  57552. target: NodeMaterialBlockTargets;
  57553. /**
  57554. * Gets the list of emitted counters
  57555. */
  57556. counters: {
  57557. [key: string]: number;
  57558. };
  57559. /**
  57560. * Shared data between multiple NodeMaterialBuildState instances
  57561. */
  57562. sharedData: NodeMaterialBuildStateSharedData;
  57563. /** @hidden */
  57564. _vertexState: NodeMaterialBuildState;
  57565. /** @hidden */
  57566. _attributeDeclaration: string;
  57567. /** @hidden */
  57568. _uniformDeclaration: string;
  57569. /** @hidden */
  57570. _constantDeclaration: string;
  57571. /** @hidden */
  57572. _samplerDeclaration: string;
  57573. /** @hidden */
  57574. _varyingTransfer: string;
  57575. private _repeatableContentAnchorIndex;
  57576. /** @hidden */
  57577. _builtCompilationString: string;
  57578. /**
  57579. * Gets the emitted compilation strings
  57580. */
  57581. compilationString: string;
  57582. /**
  57583. * Finalize the compilation strings
  57584. * @param state defines the current compilation state
  57585. */
  57586. finalize(state: NodeMaterialBuildState): void;
  57587. /** @hidden */
  57588. get _repeatableContentAnchor(): string;
  57589. /** @hidden */
  57590. _getFreeVariableName(prefix: string): string;
  57591. /** @hidden */
  57592. _getFreeDefineName(prefix: string): string;
  57593. /** @hidden */
  57594. _excludeVariableName(name: string): void;
  57595. /** @hidden */
  57596. _emit2DSampler(name: string): void;
  57597. /** @hidden */
  57598. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57599. /** @hidden */
  57600. _emitExtension(name: string, extension: string): void;
  57601. /** @hidden */
  57602. _emitFunction(name: string, code: string, comments: string): void;
  57603. /** @hidden */
  57604. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57605. replaceStrings?: {
  57606. search: RegExp;
  57607. replace: string;
  57608. }[];
  57609. repeatKey?: string;
  57610. }): string;
  57611. /** @hidden */
  57612. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57613. repeatKey?: string;
  57614. removeAttributes?: boolean;
  57615. removeUniforms?: boolean;
  57616. removeVaryings?: boolean;
  57617. removeIfDef?: boolean;
  57618. replaceStrings?: {
  57619. search: RegExp;
  57620. replace: string;
  57621. }[];
  57622. }, storeKey?: string): void;
  57623. /** @hidden */
  57624. _registerTempVariable(name: string): boolean;
  57625. /** @hidden */
  57626. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57627. /** @hidden */
  57628. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57629. /** @hidden */
  57630. _emitFloat(value: number): string;
  57631. }
  57632. }
  57633. declare module BABYLON {
  57634. /**
  57635. * Defines a block that can be used inside a node based material
  57636. */
  57637. export class NodeMaterialBlock {
  57638. private _buildId;
  57639. private _buildTarget;
  57640. private _target;
  57641. private _isFinalMerger;
  57642. private _isInput;
  57643. protected _isUnique: boolean;
  57644. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57645. inputsAreExclusive: boolean;
  57646. /** @hidden */
  57647. _codeVariableName: string;
  57648. /** @hidden */
  57649. _inputs: NodeMaterialConnectionPoint[];
  57650. /** @hidden */
  57651. _outputs: NodeMaterialConnectionPoint[];
  57652. /** @hidden */
  57653. _preparationId: number;
  57654. /**
  57655. * Gets or sets the name of the block
  57656. */
  57657. name: string;
  57658. /**
  57659. * Gets or sets the unique id of the node
  57660. */
  57661. uniqueId: number;
  57662. /**
  57663. * Gets or sets the comments associated with this block
  57664. */
  57665. comments: string;
  57666. /**
  57667. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57668. */
  57669. get isUnique(): boolean;
  57670. /**
  57671. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57672. */
  57673. get isFinalMerger(): boolean;
  57674. /**
  57675. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57676. */
  57677. get isInput(): boolean;
  57678. /**
  57679. * Gets or sets the build Id
  57680. */
  57681. get buildId(): number;
  57682. set buildId(value: number);
  57683. /**
  57684. * Gets or sets the target of the block
  57685. */
  57686. get target(): NodeMaterialBlockTargets;
  57687. set target(value: NodeMaterialBlockTargets);
  57688. /**
  57689. * Gets the list of input points
  57690. */
  57691. get inputs(): NodeMaterialConnectionPoint[];
  57692. /** Gets the list of output points */
  57693. get outputs(): NodeMaterialConnectionPoint[];
  57694. /**
  57695. * Find an input by its name
  57696. * @param name defines the name of the input to look for
  57697. * @returns the input or null if not found
  57698. */
  57699. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57700. /**
  57701. * Find an output by its name
  57702. * @param name defines the name of the outputto look for
  57703. * @returns the output or null if not found
  57704. */
  57705. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57706. /**
  57707. * Creates a new NodeMaterialBlock
  57708. * @param name defines the block name
  57709. * @param target defines the target of that block (Vertex by default)
  57710. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57711. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57712. */
  57713. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57714. /**
  57715. * Initialize the block and prepare the context for build
  57716. * @param state defines the state that will be used for the build
  57717. */
  57718. initialize(state: NodeMaterialBuildState): void;
  57719. /**
  57720. * Bind data to effect. Will only be called for blocks with isBindable === true
  57721. * @param effect defines the effect to bind data to
  57722. * @param nodeMaterial defines the hosting NodeMaterial
  57723. * @param mesh defines the mesh that will be rendered
  57724. */
  57725. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57726. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57727. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57728. protected _writeFloat(value: number): string;
  57729. /**
  57730. * Gets the current class name e.g. "NodeMaterialBlock"
  57731. * @returns the class name
  57732. */
  57733. getClassName(): string;
  57734. /**
  57735. * Register a new input. Must be called inside a block constructor
  57736. * @param name defines the connection point name
  57737. * @param type defines the connection point type
  57738. * @param isOptional defines a boolean indicating that this input can be omitted
  57739. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57740. * @returns the current block
  57741. */
  57742. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57743. /**
  57744. * Register a new output. Must be called inside a block constructor
  57745. * @param name defines the connection point name
  57746. * @param type defines the connection point type
  57747. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57748. * @returns the current block
  57749. */
  57750. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57751. /**
  57752. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57753. * @param forOutput defines an optional connection point to check compatibility with
  57754. * @returns the first available input or null
  57755. */
  57756. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57757. /**
  57758. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57759. * @param forBlock defines an optional block to check compatibility with
  57760. * @returns the first available input or null
  57761. */
  57762. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57763. /**
  57764. * Gets the sibling of the given output
  57765. * @param current defines the current output
  57766. * @returns the next output in the list or null
  57767. */
  57768. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57769. /**
  57770. * Connect current block with another block
  57771. * @param other defines the block to connect with
  57772. * @param options define the various options to help pick the right connections
  57773. * @returns the current block
  57774. */
  57775. connectTo(other: NodeMaterialBlock, options?: {
  57776. input?: string;
  57777. output?: string;
  57778. outputSwizzle?: string;
  57779. }): this | undefined;
  57780. protected _buildBlock(state: NodeMaterialBuildState): void;
  57781. /**
  57782. * Add uniforms, samplers and uniform buffers at compilation time
  57783. * @param state defines the state to update
  57784. * @param nodeMaterial defines the node material requesting the update
  57785. * @param defines defines the material defines to update
  57786. * @param uniformBuffers defines the list of uniform buffer names
  57787. */
  57788. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57789. /**
  57790. * Add potential fallbacks if shader compilation fails
  57791. * @param mesh defines the mesh to be rendered
  57792. * @param fallbacks defines the current prioritized list of fallbacks
  57793. */
  57794. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57795. /**
  57796. * Initialize defines for shader compilation
  57797. * @param mesh defines the mesh to be rendered
  57798. * @param nodeMaterial defines the node material requesting the update
  57799. * @param defines defines the material defines to update
  57800. * @param useInstances specifies that instances should be used
  57801. */
  57802. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57803. /**
  57804. * Update defines for shader compilation
  57805. * @param mesh defines the mesh to be rendered
  57806. * @param nodeMaterial defines the node material requesting the update
  57807. * @param defines defines the material defines to update
  57808. * @param useInstances specifies that instances should be used
  57809. */
  57810. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57811. /**
  57812. * Lets the block try to connect some inputs automatically
  57813. * @param material defines the hosting NodeMaterial
  57814. */
  57815. autoConfigure(material: NodeMaterial): void;
  57816. /**
  57817. * Function called when a block is declared as repeatable content generator
  57818. * @param vertexShaderState defines the current compilation state for the vertex shader
  57819. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57820. * @param mesh defines the mesh to be rendered
  57821. * @param defines defines the material defines to update
  57822. */
  57823. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57824. /**
  57825. * Checks if the block is ready
  57826. * @param mesh defines the mesh to be rendered
  57827. * @param nodeMaterial defines the node material requesting the update
  57828. * @param defines defines the material defines to update
  57829. * @param useInstances specifies that instances should be used
  57830. * @returns true if the block is ready
  57831. */
  57832. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57833. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57834. private _processBuild;
  57835. /**
  57836. * Compile the current node and generate the shader code
  57837. * @param state defines the current compilation state (uniforms, samplers, current string)
  57838. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57839. * @returns true if already built
  57840. */
  57841. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57842. protected _inputRename(name: string): string;
  57843. protected _outputRename(name: string): string;
  57844. protected _dumpPropertiesCode(): string;
  57845. /** @hidden */
  57846. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57847. /** @hidden */
  57848. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57849. /**
  57850. * Clone the current block to a new identical block
  57851. * @param scene defines the hosting scene
  57852. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57853. * @returns a copy of the current block
  57854. */
  57855. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57856. /**
  57857. * Serializes this block in a JSON representation
  57858. * @returns the serialized block object
  57859. */
  57860. serialize(): any;
  57861. /** @hidden */
  57862. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57863. /**
  57864. * Release resources
  57865. */
  57866. dispose(): void;
  57867. }
  57868. }
  57869. declare module BABYLON {
  57870. /**
  57871. * Enum defining the type of animations supported by InputBlock
  57872. */
  57873. export enum AnimatedInputBlockTypes {
  57874. /** No animation */
  57875. None = 0,
  57876. /** Time based animation. Will only work for floats */
  57877. Time = 1
  57878. }
  57879. }
  57880. declare module BABYLON {
  57881. /**
  57882. * Block used to expose an input value
  57883. */
  57884. export class InputBlock extends NodeMaterialBlock {
  57885. private _mode;
  57886. private _associatedVariableName;
  57887. private _storedValue;
  57888. private _valueCallback;
  57889. private _type;
  57890. private _animationType;
  57891. /** Gets or set a value used to limit the range of float values */
  57892. min: number;
  57893. /** Gets or set a value used to limit the range of float values */
  57894. max: number;
  57895. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57896. isBoolean: boolean;
  57897. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57898. matrixMode: number;
  57899. /** @hidden */
  57900. _systemValue: Nullable<NodeMaterialSystemValues>;
  57901. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57902. visibleInInspector: boolean;
  57903. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57904. isConstant: boolean;
  57905. /** Gets or sets the group to use to display this block in the Inspector */
  57906. groupInInspector: string;
  57907. /**
  57908. * Gets or sets the connection point type (default is float)
  57909. */
  57910. get type(): NodeMaterialBlockConnectionPointTypes;
  57911. /**
  57912. * Creates a new InputBlock
  57913. * @param name defines the block name
  57914. * @param target defines the target of that block (Vertex by default)
  57915. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57916. */
  57917. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57918. /**
  57919. * Gets the output component
  57920. */
  57921. get output(): NodeMaterialConnectionPoint;
  57922. /**
  57923. * Set the source of this connection point to a vertex attribute
  57924. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57925. * @returns the current connection point
  57926. */
  57927. setAsAttribute(attributeName?: string): InputBlock;
  57928. /**
  57929. * Set the source of this connection point to a system value
  57930. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57931. * @returns the current connection point
  57932. */
  57933. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57934. /**
  57935. * Gets or sets the value of that point.
  57936. * Please note that this value will be ignored if valueCallback is defined
  57937. */
  57938. get value(): any;
  57939. set value(value: any);
  57940. /**
  57941. * Gets or sets a callback used to get the value of that point.
  57942. * Please note that setting this value will force the connection point to ignore the value property
  57943. */
  57944. get valueCallback(): () => any;
  57945. set valueCallback(value: () => any);
  57946. /**
  57947. * Gets or sets the associated variable name in the shader
  57948. */
  57949. get associatedVariableName(): string;
  57950. set associatedVariableName(value: string);
  57951. /** Gets or sets the type of animation applied to the input */
  57952. get animationType(): AnimatedInputBlockTypes;
  57953. set animationType(value: AnimatedInputBlockTypes);
  57954. /**
  57955. * Gets a boolean indicating that this connection point not defined yet
  57956. */
  57957. get isUndefined(): boolean;
  57958. /**
  57959. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57960. * In this case the connection point name must be the name of the uniform to use.
  57961. * Can only be set on inputs
  57962. */
  57963. get isUniform(): boolean;
  57964. set isUniform(value: boolean);
  57965. /**
  57966. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57967. * In this case the connection point name must be the name of the attribute to use
  57968. * Can only be set on inputs
  57969. */
  57970. get isAttribute(): boolean;
  57971. set isAttribute(value: boolean);
  57972. /**
  57973. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57974. * Can only be set on exit points
  57975. */
  57976. get isVarying(): boolean;
  57977. set isVarying(value: boolean);
  57978. /**
  57979. * Gets a boolean indicating that the current connection point is a system value
  57980. */
  57981. get isSystemValue(): boolean;
  57982. /**
  57983. * Gets or sets the current well known value or null if not defined as a system value
  57984. */
  57985. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57986. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57987. /**
  57988. * Gets the current class name
  57989. * @returns the class name
  57990. */
  57991. getClassName(): string;
  57992. /**
  57993. * Animate the input if animationType !== None
  57994. * @param scene defines the rendering scene
  57995. */
  57996. animate(scene: Scene): void;
  57997. private _emitDefine;
  57998. initialize(state: NodeMaterialBuildState): void;
  57999. /**
  58000. * Set the input block to its default value (based on its type)
  58001. */
  58002. setDefaultValue(): void;
  58003. private _emitConstant;
  58004. private _emit;
  58005. /** @hidden */
  58006. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58007. /** @hidden */
  58008. _transmit(effect: Effect, scene: Scene): void;
  58009. protected _buildBlock(state: NodeMaterialBuildState): void;
  58010. protected _dumpPropertiesCode(): string;
  58011. serialize(): any;
  58012. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58013. }
  58014. }
  58015. declare module BABYLON {
  58016. /**
  58017. * Enum used to define the compatibility state between two connection points
  58018. */
  58019. export enum NodeMaterialConnectionPointCompatibilityStates {
  58020. /** Points are compatibles */
  58021. Compatible = 0,
  58022. /** Points are incompatible because of their types */
  58023. TypeIncompatible = 1,
  58024. /** Points are incompatible because of their targets (vertex vs fragment) */
  58025. TargetIncompatible = 2
  58026. }
  58027. /**
  58028. * Defines the direction of a connection point
  58029. */
  58030. export enum NodeMaterialConnectionPointDirection {
  58031. /** Input */
  58032. Input = 0,
  58033. /** Output */
  58034. Output = 1
  58035. }
  58036. /**
  58037. * Defines a connection point for a block
  58038. */
  58039. export class NodeMaterialConnectionPoint {
  58040. /** @hidden */
  58041. _ownerBlock: NodeMaterialBlock;
  58042. /** @hidden */
  58043. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58044. private _endpoints;
  58045. private _associatedVariableName;
  58046. private _direction;
  58047. /** @hidden */
  58048. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58049. /** @hidden */
  58050. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58051. private _type;
  58052. /** @hidden */
  58053. _enforceAssociatedVariableName: boolean;
  58054. /** Gets the direction of the point */
  58055. get direction(): NodeMaterialConnectionPointDirection;
  58056. /**
  58057. * Gets or sets the additional types supported by this connection point
  58058. */
  58059. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58060. /**
  58061. * Gets or sets the additional types excluded by this connection point
  58062. */
  58063. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58064. /**
  58065. * Observable triggered when this point is connected
  58066. */
  58067. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58068. /**
  58069. * Gets or sets the associated variable name in the shader
  58070. */
  58071. get associatedVariableName(): string;
  58072. set associatedVariableName(value: string);
  58073. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  58074. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58075. /**
  58076. * Gets or sets the connection point type (default is float)
  58077. */
  58078. get type(): NodeMaterialBlockConnectionPointTypes;
  58079. set type(value: NodeMaterialBlockConnectionPointTypes);
  58080. /**
  58081. * Gets or sets the connection point name
  58082. */
  58083. name: string;
  58084. /**
  58085. * Gets or sets a boolean indicating that this connection point can be omitted
  58086. */
  58087. isOptional: boolean;
  58088. /**
  58089. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58090. */
  58091. define: string;
  58092. /** @hidden */
  58093. _prioritizeVertex: boolean;
  58094. private _target;
  58095. /** Gets or sets the target of that connection point */
  58096. get target(): NodeMaterialBlockTargets;
  58097. set target(value: NodeMaterialBlockTargets);
  58098. /**
  58099. * Gets a boolean indicating that the current point is connected
  58100. */
  58101. get isConnected(): boolean;
  58102. /**
  58103. * Gets a boolean indicating that the current point is connected to an input block
  58104. */
  58105. get isConnectedToInputBlock(): boolean;
  58106. /**
  58107. * Gets a the connected input block (if any)
  58108. */
  58109. get connectInputBlock(): Nullable<InputBlock>;
  58110. /** Get the other side of the connection (if any) */
  58111. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58112. /** Get the block that owns this connection point */
  58113. get ownerBlock(): NodeMaterialBlock;
  58114. /** Get the block connected on the other side of this connection (if any) */
  58115. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58116. /** Get the block connected on the endpoints of this connection (if any) */
  58117. get connectedBlocks(): Array<NodeMaterialBlock>;
  58118. /** Gets the list of connected endpoints */
  58119. get endpoints(): NodeMaterialConnectionPoint[];
  58120. /** Gets a boolean indicating if that output point is connected to at least one input */
  58121. get hasEndpoints(): boolean;
  58122. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58123. get isConnectedInVertexShader(): boolean;
  58124. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58125. get isConnectedInFragmentShader(): boolean;
  58126. /**
  58127. * Creates a new connection point
  58128. * @param name defines the connection point name
  58129. * @param ownerBlock defines the block hosting this connection point
  58130. * @param direction defines the direction of the connection point
  58131. */
  58132. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58133. /**
  58134. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58135. * @returns the class name
  58136. */
  58137. getClassName(): string;
  58138. /**
  58139. * Gets a boolean indicating if the current point can be connected to another point
  58140. * @param connectionPoint defines the other connection point
  58141. * @returns a boolean
  58142. */
  58143. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58144. /**
  58145. * Gets a number indicating if the current point can be connected to another point
  58146. * @param connectionPoint defines the other connection point
  58147. * @returns a number defining the compatibility state
  58148. */
  58149. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58150. /**
  58151. * Connect this point to another connection point
  58152. * @param connectionPoint defines the other connection point
  58153. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58154. * @returns the current connection point
  58155. */
  58156. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58157. /**
  58158. * Disconnect this point from one of his endpoint
  58159. * @param endpoint defines the other connection point
  58160. * @returns the current connection point
  58161. */
  58162. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58163. /**
  58164. * Serializes this point in a JSON representation
  58165. * @returns the serialized point object
  58166. */
  58167. serialize(): any;
  58168. /**
  58169. * Release resources
  58170. */
  58171. dispose(): void;
  58172. }
  58173. }
  58174. declare module BABYLON {
  58175. /**
  58176. * Block used to add support for vertex skinning (bones)
  58177. */
  58178. export class BonesBlock extends NodeMaterialBlock {
  58179. /**
  58180. * Creates a new BonesBlock
  58181. * @param name defines the block name
  58182. */
  58183. constructor(name: string);
  58184. /**
  58185. * Initialize the block and prepare the context for build
  58186. * @param state defines the state that will be used for the build
  58187. */
  58188. initialize(state: NodeMaterialBuildState): void;
  58189. /**
  58190. * Gets the current class name
  58191. * @returns the class name
  58192. */
  58193. getClassName(): string;
  58194. /**
  58195. * Gets the matrix indices input component
  58196. */
  58197. get matricesIndices(): NodeMaterialConnectionPoint;
  58198. /**
  58199. * Gets the matrix weights input component
  58200. */
  58201. get matricesWeights(): NodeMaterialConnectionPoint;
  58202. /**
  58203. * Gets the extra matrix indices input component
  58204. */
  58205. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58206. /**
  58207. * Gets the extra matrix weights input component
  58208. */
  58209. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58210. /**
  58211. * Gets the world input component
  58212. */
  58213. get world(): NodeMaterialConnectionPoint;
  58214. /**
  58215. * Gets the output component
  58216. */
  58217. get output(): NodeMaterialConnectionPoint;
  58218. autoConfigure(material: NodeMaterial): void;
  58219. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58222. protected _buildBlock(state: NodeMaterialBuildState): this;
  58223. }
  58224. }
  58225. declare module BABYLON {
  58226. /**
  58227. * Block used to add support for instances
  58228. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58229. */
  58230. export class InstancesBlock extends NodeMaterialBlock {
  58231. /**
  58232. * Creates a new InstancesBlock
  58233. * @param name defines the block name
  58234. */
  58235. constructor(name: string);
  58236. /**
  58237. * Gets the current class name
  58238. * @returns the class name
  58239. */
  58240. getClassName(): string;
  58241. /**
  58242. * Gets the first world row input component
  58243. */
  58244. get world0(): NodeMaterialConnectionPoint;
  58245. /**
  58246. * Gets the second world row input component
  58247. */
  58248. get world1(): NodeMaterialConnectionPoint;
  58249. /**
  58250. * Gets the third world row input component
  58251. */
  58252. get world2(): NodeMaterialConnectionPoint;
  58253. /**
  58254. * Gets the forth world row input component
  58255. */
  58256. get world3(): NodeMaterialConnectionPoint;
  58257. /**
  58258. * Gets the world input component
  58259. */
  58260. get world(): NodeMaterialConnectionPoint;
  58261. /**
  58262. * Gets the output component
  58263. */
  58264. get output(): NodeMaterialConnectionPoint;
  58265. /**
  58266. * Gets the isntanceID component
  58267. */
  58268. get instanceID(): NodeMaterialConnectionPoint;
  58269. autoConfigure(material: NodeMaterial): void;
  58270. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58271. protected _buildBlock(state: NodeMaterialBuildState): this;
  58272. }
  58273. }
  58274. declare module BABYLON {
  58275. /**
  58276. * Block used to add morph targets support to vertex shader
  58277. */
  58278. export class MorphTargetsBlock extends NodeMaterialBlock {
  58279. private _repeatableContentAnchor;
  58280. /**
  58281. * Create a new MorphTargetsBlock
  58282. * @param name defines the block name
  58283. */
  58284. constructor(name: string);
  58285. /**
  58286. * Gets the current class name
  58287. * @returns the class name
  58288. */
  58289. getClassName(): string;
  58290. /**
  58291. * Gets the position input component
  58292. */
  58293. get position(): NodeMaterialConnectionPoint;
  58294. /**
  58295. * Gets the normal input component
  58296. */
  58297. get normal(): NodeMaterialConnectionPoint;
  58298. /**
  58299. * Gets the tangent input component
  58300. */
  58301. get tangent(): NodeMaterialConnectionPoint;
  58302. /**
  58303. * Gets the tangent input component
  58304. */
  58305. get uv(): NodeMaterialConnectionPoint;
  58306. /**
  58307. * Gets the position output component
  58308. */
  58309. get positionOutput(): NodeMaterialConnectionPoint;
  58310. /**
  58311. * Gets the normal output component
  58312. */
  58313. get normalOutput(): NodeMaterialConnectionPoint;
  58314. /**
  58315. * Gets the tangent output component
  58316. */
  58317. get tangentOutput(): NodeMaterialConnectionPoint;
  58318. /**
  58319. * Gets the tangent output component
  58320. */
  58321. get uvOutput(): NodeMaterialConnectionPoint;
  58322. initialize(state: NodeMaterialBuildState): void;
  58323. autoConfigure(material: NodeMaterial): void;
  58324. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58326. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58327. protected _buildBlock(state: NodeMaterialBuildState): this;
  58328. }
  58329. }
  58330. declare module BABYLON {
  58331. /**
  58332. * Block used to get data information from a light
  58333. */
  58334. export class LightInformationBlock extends NodeMaterialBlock {
  58335. private _lightDataUniformName;
  58336. private _lightColorUniformName;
  58337. private _lightTypeDefineName;
  58338. /**
  58339. * Gets or sets the light associated with this block
  58340. */
  58341. light: Nullable<Light>;
  58342. /**
  58343. * Creates a new LightInformationBlock
  58344. * @param name defines the block name
  58345. */
  58346. constructor(name: string);
  58347. /**
  58348. * Gets the current class name
  58349. * @returns the class name
  58350. */
  58351. getClassName(): string;
  58352. /**
  58353. * Gets the world position input component
  58354. */
  58355. get worldPosition(): NodeMaterialConnectionPoint;
  58356. /**
  58357. * Gets the direction output component
  58358. */
  58359. get direction(): NodeMaterialConnectionPoint;
  58360. /**
  58361. * Gets the direction output component
  58362. */
  58363. get color(): NodeMaterialConnectionPoint;
  58364. /**
  58365. * Gets the direction output component
  58366. */
  58367. get intensity(): NodeMaterialConnectionPoint;
  58368. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58369. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58370. protected _buildBlock(state: NodeMaterialBuildState): this;
  58371. serialize(): any;
  58372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58373. }
  58374. }
  58375. declare module BABYLON {
  58376. /**
  58377. * Block used to add image processing support to fragment shader
  58378. */
  58379. export class ImageProcessingBlock extends NodeMaterialBlock {
  58380. /**
  58381. * Create a new ImageProcessingBlock
  58382. * @param name defines the block name
  58383. */
  58384. constructor(name: string);
  58385. /**
  58386. * Gets the current class name
  58387. * @returns the class name
  58388. */
  58389. getClassName(): string;
  58390. /**
  58391. * Gets the color input component
  58392. */
  58393. get color(): NodeMaterialConnectionPoint;
  58394. /**
  58395. * Gets the output component
  58396. */
  58397. get output(): NodeMaterialConnectionPoint;
  58398. /**
  58399. * Initialize the block and prepare the context for build
  58400. * @param state defines the state that will be used for the build
  58401. */
  58402. initialize(state: NodeMaterialBuildState): void;
  58403. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58404. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58405. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58406. protected _buildBlock(state: NodeMaterialBuildState): this;
  58407. }
  58408. }
  58409. declare module BABYLON {
  58410. /**
  58411. * Block used to pertub normals based on a normal map
  58412. */
  58413. export class PerturbNormalBlock extends NodeMaterialBlock {
  58414. private _tangentSpaceParameterName;
  58415. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58416. invertX: boolean;
  58417. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58418. invertY: boolean;
  58419. /**
  58420. * Create a new PerturbNormalBlock
  58421. * @param name defines the block name
  58422. */
  58423. constructor(name: string);
  58424. /**
  58425. * Gets the current class name
  58426. * @returns the class name
  58427. */
  58428. getClassName(): string;
  58429. /**
  58430. * Gets the world position input component
  58431. */
  58432. get worldPosition(): NodeMaterialConnectionPoint;
  58433. /**
  58434. * Gets the world normal input component
  58435. */
  58436. get worldNormal(): NodeMaterialConnectionPoint;
  58437. /**
  58438. * Gets the world tangent input component
  58439. */
  58440. get worldTangent(): NodeMaterialConnectionPoint;
  58441. /**
  58442. * Gets the uv input component
  58443. */
  58444. get uv(): NodeMaterialConnectionPoint;
  58445. /**
  58446. * Gets the normal map color input component
  58447. */
  58448. get normalMapColor(): NodeMaterialConnectionPoint;
  58449. /**
  58450. * Gets the strength input component
  58451. */
  58452. get strength(): NodeMaterialConnectionPoint;
  58453. /**
  58454. * Gets the output component
  58455. */
  58456. get output(): NodeMaterialConnectionPoint;
  58457. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58458. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58459. autoConfigure(material: NodeMaterial): void;
  58460. protected _buildBlock(state: NodeMaterialBuildState): this;
  58461. protected _dumpPropertiesCode(): string;
  58462. serialize(): any;
  58463. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58464. }
  58465. }
  58466. declare module BABYLON {
  58467. /**
  58468. * Block used to discard a pixel if a value is smaller than a cutoff
  58469. */
  58470. export class DiscardBlock extends NodeMaterialBlock {
  58471. /**
  58472. * Create a new DiscardBlock
  58473. * @param name defines the block name
  58474. */
  58475. constructor(name: string);
  58476. /**
  58477. * Gets the current class name
  58478. * @returns the class name
  58479. */
  58480. getClassName(): string;
  58481. /**
  58482. * Gets the color input component
  58483. */
  58484. get value(): NodeMaterialConnectionPoint;
  58485. /**
  58486. * Gets the cutoff input component
  58487. */
  58488. get cutoff(): NodeMaterialConnectionPoint;
  58489. protected _buildBlock(state: NodeMaterialBuildState): this;
  58490. }
  58491. }
  58492. declare module BABYLON {
  58493. /**
  58494. * Block used to test if the fragment shader is front facing
  58495. */
  58496. export class FrontFacingBlock extends NodeMaterialBlock {
  58497. /**
  58498. * Creates a new FrontFacingBlock
  58499. * @param name defines the block name
  58500. */
  58501. constructor(name: string);
  58502. /**
  58503. * Gets the current class name
  58504. * @returns the class name
  58505. */
  58506. getClassName(): string;
  58507. /**
  58508. * Gets the output component
  58509. */
  58510. get output(): NodeMaterialConnectionPoint;
  58511. protected _buildBlock(state: NodeMaterialBuildState): this;
  58512. }
  58513. }
  58514. declare module BABYLON {
  58515. /**
  58516. * Block used to get the derivative value on x and y of a given input
  58517. */
  58518. export class DerivativeBlock extends NodeMaterialBlock {
  58519. /**
  58520. * Create a new DerivativeBlock
  58521. * @param name defines the block name
  58522. */
  58523. constructor(name: string);
  58524. /**
  58525. * Gets the current class name
  58526. * @returns the class name
  58527. */
  58528. getClassName(): string;
  58529. /**
  58530. * Gets the input component
  58531. */
  58532. get input(): NodeMaterialConnectionPoint;
  58533. /**
  58534. * Gets the derivative output on x
  58535. */
  58536. get dx(): NodeMaterialConnectionPoint;
  58537. /**
  58538. * Gets the derivative output on y
  58539. */
  58540. get dy(): NodeMaterialConnectionPoint;
  58541. protected _buildBlock(state: NodeMaterialBuildState): this;
  58542. }
  58543. }
  58544. declare module BABYLON {
  58545. /**
  58546. * Block used to add support for scene fog
  58547. */
  58548. export class FogBlock extends NodeMaterialBlock {
  58549. private _fogDistanceName;
  58550. private _fogParameters;
  58551. /**
  58552. * Create a new FogBlock
  58553. * @param name defines the block name
  58554. */
  58555. constructor(name: string);
  58556. /**
  58557. * Gets the current class name
  58558. * @returns the class name
  58559. */
  58560. getClassName(): string;
  58561. /**
  58562. * Gets the world position input component
  58563. */
  58564. get worldPosition(): NodeMaterialConnectionPoint;
  58565. /**
  58566. * Gets the view input component
  58567. */
  58568. get view(): NodeMaterialConnectionPoint;
  58569. /**
  58570. * Gets the color input component
  58571. */
  58572. get input(): NodeMaterialConnectionPoint;
  58573. /**
  58574. * Gets the fog color input component
  58575. */
  58576. get fogColor(): NodeMaterialConnectionPoint;
  58577. /**
  58578. * Gets the output component
  58579. */
  58580. get output(): NodeMaterialConnectionPoint;
  58581. autoConfigure(material: NodeMaterial): void;
  58582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58584. protected _buildBlock(state: NodeMaterialBuildState): this;
  58585. }
  58586. }
  58587. declare module BABYLON {
  58588. /**
  58589. * Block used to add light in the fragment shader
  58590. */
  58591. export class LightBlock extends NodeMaterialBlock {
  58592. private _lightId;
  58593. /**
  58594. * Gets or sets the light associated with this block
  58595. */
  58596. light: Nullable<Light>;
  58597. /**
  58598. * Create a new LightBlock
  58599. * @param name defines the block name
  58600. */
  58601. constructor(name: string);
  58602. /**
  58603. * Gets the current class name
  58604. * @returns the class name
  58605. */
  58606. getClassName(): string;
  58607. /**
  58608. * Gets the world position input component
  58609. */
  58610. get worldPosition(): NodeMaterialConnectionPoint;
  58611. /**
  58612. * Gets the world normal input component
  58613. */
  58614. get worldNormal(): NodeMaterialConnectionPoint;
  58615. /**
  58616. * Gets the camera (or eye) position component
  58617. */
  58618. get cameraPosition(): NodeMaterialConnectionPoint;
  58619. /**
  58620. * Gets the glossiness component
  58621. */
  58622. get glossiness(): NodeMaterialConnectionPoint;
  58623. /**
  58624. * Gets the glossinness power component
  58625. */
  58626. get glossPower(): NodeMaterialConnectionPoint;
  58627. /**
  58628. * Gets the diffuse color component
  58629. */
  58630. get diffuseColor(): NodeMaterialConnectionPoint;
  58631. /**
  58632. * Gets the specular color component
  58633. */
  58634. get specularColor(): NodeMaterialConnectionPoint;
  58635. /**
  58636. * Gets the diffuse output component
  58637. */
  58638. get diffuseOutput(): NodeMaterialConnectionPoint;
  58639. /**
  58640. * Gets the specular output component
  58641. */
  58642. get specularOutput(): NodeMaterialConnectionPoint;
  58643. /**
  58644. * Gets the shadow output component
  58645. */
  58646. get shadow(): NodeMaterialConnectionPoint;
  58647. autoConfigure(material: NodeMaterial): void;
  58648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58649. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58650. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58651. private _injectVertexCode;
  58652. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58653. serialize(): any;
  58654. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58655. }
  58656. }
  58657. declare module BABYLON {
  58658. /**
  58659. * Block used to multiply 2 values
  58660. */
  58661. export class MultiplyBlock extends NodeMaterialBlock {
  58662. /**
  58663. * Creates a new MultiplyBlock
  58664. * @param name defines the block name
  58665. */
  58666. constructor(name: string);
  58667. /**
  58668. * Gets the current class name
  58669. * @returns the class name
  58670. */
  58671. getClassName(): string;
  58672. /**
  58673. * Gets the left operand input component
  58674. */
  58675. get left(): NodeMaterialConnectionPoint;
  58676. /**
  58677. * Gets the right operand input component
  58678. */
  58679. get right(): NodeMaterialConnectionPoint;
  58680. /**
  58681. * Gets the output component
  58682. */
  58683. get output(): NodeMaterialConnectionPoint;
  58684. protected _buildBlock(state: NodeMaterialBuildState): this;
  58685. }
  58686. }
  58687. declare module BABYLON {
  58688. /**
  58689. * Block used to add 2 vectors
  58690. */
  58691. export class AddBlock extends NodeMaterialBlock {
  58692. /**
  58693. * Creates a new AddBlock
  58694. * @param name defines the block name
  58695. */
  58696. constructor(name: string);
  58697. /**
  58698. * Gets the current class name
  58699. * @returns the class name
  58700. */
  58701. getClassName(): string;
  58702. /**
  58703. * Gets the left operand input component
  58704. */
  58705. get left(): NodeMaterialConnectionPoint;
  58706. /**
  58707. * Gets the right operand input component
  58708. */
  58709. get right(): NodeMaterialConnectionPoint;
  58710. /**
  58711. * Gets the output component
  58712. */
  58713. get output(): NodeMaterialConnectionPoint;
  58714. protected _buildBlock(state: NodeMaterialBuildState): this;
  58715. }
  58716. }
  58717. declare module BABYLON {
  58718. /**
  58719. * Block used to scale a vector by a float
  58720. */
  58721. export class ScaleBlock extends NodeMaterialBlock {
  58722. /**
  58723. * Creates a new ScaleBlock
  58724. * @param name defines the block name
  58725. */
  58726. constructor(name: string);
  58727. /**
  58728. * Gets the current class name
  58729. * @returns the class name
  58730. */
  58731. getClassName(): string;
  58732. /**
  58733. * Gets the input component
  58734. */
  58735. get input(): NodeMaterialConnectionPoint;
  58736. /**
  58737. * Gets the factor input component
  58738. */
  58739. get factor(): NodeMaterialConnectionPoint;
  58740. /**
  58741. * Gets the output component
  58742. */
  58743. get output(): NodeMaterialConnectionPoint;
  58744. protected _buildBlock(state: NodeMaterialBuildState): this;
  58745. }
  58746. }
  58747. declare module BABYLON {
  58748. /**
  58749. * Block used to clamp a float
  58750. */
  58751. export class ClampBlock extends NodeMaterialBlock {
  58752. /** Gets or sets the minimum range */
  58753. minimum: number;
  58754. /** Gets or sets the maximum range */
  58755. maximum: number;
  58756. /**
  58757. * Creates a new ClampBlock
  58758. * @param name defines the block name
  58759. */
  58760. constructor(name: string);
  58761. /**
  58762. * Gets the current class name
  58763. * @returns the class name
  58764. */
  58765. getClassName(): string;
  58766. /**
  58767. * Gets the value input component
  58768. */
  58769. get value(): NodeMaterialConnectionPoint;
  58770. /**
  58771. * Gets the output component
  58772. */
  58773. get output(): NodeMaterialConnectionPoint;
  58774. protected _buildBlock(state: NodeMaterialBuildState): this;
  58775. protected _dumpPropertiesCode(): string;
  58776. serialize(): any;
  58777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58778. }
  58779. }
  58780. declare module BABYLON {
  58781. /**
  58782. * Block used to apply a cross product between 2 vectors
  58783. */
  58784. export class CrossBlock extends NodeMaterialBlock {
  58785. /**
  58786. * Creates a new CrossBlock
  58787. * @param name defines the block name
  58788. */
  58789. constructor(name: string);
  58790. /**
  58791. * Gets the current class name
  58792. * @returns the class name
  58793. */
  58794. getClassName(): string;
  58795. /**
  58796. * Gets the left operand input component
  58797. */
  58798. get left(): NodeMaterialConnectionPoint;
  58799. /**
  58800. * Gets the right operand input component
  58801. */
  58802. get right(): NodeMaterialConnectionPoint;
  58803. /**
  58804. * Gets the output component
  58805. */
  58806. get output(): NodeMaterialConnectionPoint;
  58807. protected _buildBlock(state: NodeMaterialBuildState): this;
  58808. }
  58809. }
  58810. declare module BABYLON {
  58811. /**
  58812. * Block used to apply a dot product between 2 vectors
  58813. */
  58814. export class DotBlock extends NodeMaterialBlock {
  58815. /**
  58816. * Creates a new DotBlock
  58817. * @param name defines the block name
  58818. */
  58819. constructor(name: string);
  58820. /**
  58821. * Gets the current class name
  58822. * @returns the class name
  58823. */
  58824. getClassName(): string;
  58825. /**
  58826. * Gets the left operand input component
  58827. */
  58828. get left(): NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the right operand input component
  58831. */
  58832. get right(): NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the output component
  58835. */
  58836. get output(): NodeMaterialConnectionPoint;
  58837. protected _buildBlock(state: NodeMaterialBuildState): this;
  58838. }
  58839. }
  58840. declare module BABYLON {
  58841. /**
  58842. * Block used to remap a float from a range to a new one
  58843. */
  58844. export class RemapBlock extends NodeMaterialBlock {
  58845. /**
  58846. * Gets or sets the source range
  58847. */
  58848. sourceRange: Vector2;
  58849. /**
  58850. * Gets or sets the target range
  58851. */
  58852. targetRange: Vector2;
  58853. /**
  58854. * Creates a new RemapBlock
  58855. * @param name defines the block name
  58856. */
  58857. constructor(name: string);
  58858. /**
  58859. * Gets the current class name
  58860. * @returns the class name
  58861. */
  58862. getClassName(): string;
  58863. /**
  58864. * Gets the input component
  58865. */
  58866. get input(): NodeMaterialConnectionPoint;
  58867. /**
  58868. * Gets the source min input component
  58869. */
  58870. get sourceMin(): NodeMaterialConnectionPoint;
  58871. /**
  58872. * Gets the source max input component
  58873. */
  58874. get sourceMax(): NodeMaterialConnectionPoint;
  58875. /**
  58876. * Gets the target min input component
  58877. */
  58878. get targetMin(): NodeMaterialConnectionPoint;
  58879. /**
  58880. * Gets the target max input component
  58881. */
  58882. get targetMax(): NodeMaterialConnectionPoint;
  58883. /**
  58884. * Gets the output component
  58885. */
  58886. get output(): NodeMaterialConnectionPoint;
  58887. protected _buildBlock(state: NodeMaterialBuildState): this;
  58888. protected _dumpPropertiesCode(): string;
  58889. serialize(): any;
  58890. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58891. }
  58892. }
  58893. declare module BABYLON {
  58894. /**
  58895. * Block used to normalize a vector
  58896. */
  58897. export class NormalizeBlock extends NodeMaterialBlock {
  58898. /**
  58899. * Creates a new NormalizeBlock
  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 output component
  58914. */
  58915. get output(): NodeMaterialConnectionPoint;
  58916. protected _buildBlock(state: NodeMaterialBuildState): this;
  58917. }
  58918. }
  58919. declare module BABYLON {
  58920. /**
  58921. * Operations supported by the Trigonometry block
  58922. */
  58923. export enum TrigonometryBlockOperations {
  58924. /** Cos */
  58925. Cos = 0,
  58926. /** Sin */
  58927. Sin = 1,
  58928. /** Abs */
  58929. Abs = 2,
  58930. /** Exp */
  58931. Exp = 3,
  58932. /** Exp2 */
  58933. Exp2 = 4,
  58934. /** Round */
  58935. Round = 5,
  58936. /** Floor */
  58937. Floor = 6,
  58938. /** Ceiling */
  58939. Ceiling = 7,
  58940. /** Square root */
  58941. Sqrt = 8,
  58942. /** Log */
  58943. Log = 9,
  58944. /** Tangent */
  58945. Tan = 10,
  58946. /** Arc tangent */
  58947. ArcTan = 11,
  58948. /** Arc cosinus */
  58949. ArcCos = 12,
  58950. /** Arc sinus */
  58951. ArcSin = 13,
  58952. /** Fraction */
  58953. Fract = 14,
  58954. /** Sign */
  58955. Sign = 15,
  58956. /** To radians (from degrees) */
  58957. Radians = 16,
  58958. /** To degrees (from radians) */
  58959. Degrees = 17
  58960. }
  58961. /**
  58962. * Block used to apply trigonometry operation to floats
  58963. */
  58964. export class TrigonometryBlock extends NodeMaterialBlock {
  58965. /**
  58966. * Gets or sets the operation applied by the block
  58967. */
  58968. operation: TrigonometryBlockOperations;
  58969. /**
  58970. * Creates a new TrigonometryBlock
  58971. * @param name defines the block name
  58972. */
  58973. constructor(name: string);
  58974. /**
  58975. * Gets the current class name
  58976. * @returns the class name
  58977. */
  58978. getClassName(): string;
  58979. /**
  58980. * Gets the input component
  58981. */
  58982. get input(): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Gets the output component
  58985. */
  58986. get output(): NodeMaterialConnectionPoint;
  58987. protected _buildBlock(state: NodeMaterialBuildState): this;
  58988. serialize(): any;
  58989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58990. protected _dumpPropertiesCode(): string;
  58991. }
  58992. }
  58993. declare module BABYLON {
  58994. /**
  58995. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58996. */
  58997. export class ColorMergerBlock extends NodeMaterialBlock {
  58998. /**
  58999. * Create a new ColorMergerBlock
  59000. * @param name defines the block name
  59001. */
  59002. constructor(name: string);
  59003. /**
  59004. * Gets the current class name
  59005. * @returns the class name
  59006. */
  59007. getClassName(): string;
  59008. /**
  59009. * Gets the rgb component (input)
  59010. */
  59011. get rgbIn(): NodeMaterialConnectionPoint;
  59012. /**
  59013. * Gets the r component (input)
  59014. */
  59015. get r(): NodeMaterialConnectionPoint;
  59016. /**
  59017. * Gets the g component (input)
  59018. */
  59019. get g(): NodeMaterialConnectionPoint;
  59020. /**
  59021. * Gets the b component (input)
  59022. */
  59023. get b(): NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the a component (input)
  59026. */
  59027. get a(): NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the rgba component (output)
  59030. */
  59031. get rgba(): NodeMaterialConnectionPoint;
  59032. /**
  59033. * Gets the rgb component (output)
  59034. */
  59035. get rgbOut(): NodeMaterialConnectionPoint;
  59036. /**
  59037. * Gets the rgb component (output)
  59038. * @deprecated Please use rgbOut instead.
  59039. */
  59040. get rgb(): NodeMaterialConnectionPoint;
  59041. protected _buildBlock(state: NodeMaterialBuildState): this;
  59042. }
  59043. }
  59044. declare module BABYLON {
  59045. /**
  59046. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59047. */
  59048. export class VectorMergerBlock extends NodeMaterialBlock {
  59049. /**
  59050. * Create a new VectorMergerBlock
  59051. * @param name defines the block name
  59052. */
  59053. constructor(name: string);
  59054. /**
  59055. * Gets the current class name
  59056. * @returns the class name
  59057. */
  59058. getClassName(): string;
  59059. /**
  59060. * Gets the xyz component (input)
  59061. */
  59062. get xyzIn(): NodeMaterialConnectionPoint;
  59063. /**
  59064. * Gets the xy component (input)
  59065. */
  59066. get xyIn(): NodeMaterialConnectionPoint;
  59067. /**
  59068. * Gets the x component (input)
  59069. */
  59070. get x(): NodeMaterialConnectionPoint;
  59071. /**
  59072. * Gets the y component (input)
  59073. */
  59074. get y(): NodeMaterialConnectionPoint;
  59075. /**
  59076. * Gets the z component (input)
  59077. */
  59078. get z(): NodeMaterialConnectionPoint;
  59079. /**
  59080. * Gets the w component (input)
  59081. */
  59082. get w(): NodeMaterialConnectionPoint;
  59083. /**
  59084. * Gets the xyzw component (output)
  59085. */
  59086. get xyzw(): NodeMaterialConnectionPoint;
  59087. /**
  59088. * Gets the xyz component (output)
  59089. */
  59090. get xyzOut(): NodeMaterialConnectionPoint;
  59091. /**
  59092. * Gets the xy component (output)
  59093. */
  59094. get xyOut(): NodeMaterialConnectionPoint;
  59095. /**
  59096. * Gets the xy component (output)
  59097. * @deprecated Please use xyOut instead.
  59098. */
  59099. get xy(): NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the xyz component (output)
  59102. * @deprecated Please use xyzOut instead.
  59103. */
  59104. get xyz(): NodeMaterialConnectionPoint;
  59105. protected _buildBlock(state: NodeMaterialBuildState): this;
  59106. }
  59107. }
  59108. declare module BABYLON {
  59109. /**
  59110. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59111. */
  59112. export class ColorSplitterBlock extends NodeMaterialBlock {
  59113. /**
  59114. * Create a new ColorSplitterBlock
  59115. * @param name defines the block name
  59116. */
  59117. constructor(name: string);
  59118. /**
  59119. * Gets the current class name
  59120. * @returns the class name
  59121. */
  59122. getClassName(): string;
  59123. /**
  59124. * Gets the rgba component (input)
  59125. */
  59126. get rgba(): NodeMaterialConnectionPoint;
  59127. /**
  59128. * Gets the rgb component (input)
  59129. */
  59130. get rgbIn(): NodeMaterialConnectionPoint;
  59131. /**
  59132. * Gets the rgb component (output)
  59133. */
  59134. get rgbOut(): NodeMaterialConnectionPoint;
  59135. /**
  59136. * Gets the r component (output)
  59137. */
  59138. get r(): NodeMaterialConnectionPoint;
  59139. /**
  59140. * Gets the g component (output)
  59141. */
  59142. get g(): NodeMaterialConnectionPoint;
  59143. /**
  59144. * Gets the b component (output)
  59145. */
  59146. get b(): NodeMaterialConnectionPoint;
  59147. /**
  59148. * Gets the a component (output)
  59149. */
  59150. get a(): NodeMaterialConnectionPoint;
  59151. protected _inputRename(name: string): string;
  59152. protected _outputRename(name: string): string;
  59153. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59154. }
  59155. }
  59156. declare module BABYLON {
  59157. /**
  59158. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59159. */
  59160. export class VectorSplitterBlock extends NodeMaterialBlock {
  59161. /**
  59162. * Create a new VectorSplitterBlock
  59163. * @param name defines the block name
  59164. */
  59165. constructor(name: string);
  59166. /**
  59167. * Gets the current class name
  59168. * @returns the class name
  59169. */
  59170. getClassName(): string;
  59171. /**
  59172. * Gets the xyzw component (input)
  59173. */
  59174. get xyzw(): NodeMaterialConnectionPoint;
  59175. /**
  59176. * Gets the xyz component (input)
  59177. */
  59178. get xyzIn(): NodeMaterialConnectionPoint;
  59179. /**
  59180. * Gets the xy component (input)
  59181. */
  59182. get xyIn(): NodeMaterialConnectionPoint;
  59183. /**
  59184. * Gets the xyz component (output)
  59185. */
  59186. get xyzOut(): NodeMaterialConnectionPoint;
  59187. /**
  59188. * Gets the xy component (output)
  59189. */
  59190. get xyOut(): NodeMaterialConnectionPoint;
  59191. /**
  59192. * Gets the x component (output)
  59193. */
  59194. get x(): NodeMaterialConnectionPoint;
  59195. /**
  59196. * Gets the y component (output)
  59197. */
  59198. get y(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the z component (output)
  59201. */
  59202. get z(): NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the w component (output)
  59205. */
  59206. get w(): NodeMaterialConnectionPoint;
  59207. protected _inputRename(name: string): string;
  59208. protected _outputRename(name: string): string;
  59209. protected _buildBlock(state: NodeMaterialBuildState): this;
  59210. }
  59211. }
  59212. declare module BABYLON {
  59213. /**
  59214. * Block used to lerp between 2 values
  59215. */
  59216. export class LerpBlock extends NodeMaterialBlock {
  59217. /**
  59218. * Creates a new LerpBlock
  59219. * @param name defines the block name
  59220. */
  59221. constructor(name: string);
  59222. /**
  59223. * Gets the current class name
  59224. * @returns the class name
  59225. */
  59226. getClassName(): string;
  59227. /**
  59228. * Gets the left operand input component
  59229. */
  59230. get left(): NodeMaterialConnectionPoint;
  59231. /**
  59232. * Gets the right operand input component
  59233. */
  59234. get right(): NodeMaterialConnectionPoint;
  59235. /**
  59236. * Gets the gradient operand input component
  59237. */
  59238. get gradient(): NodeMaterialConnectionPoint;
  59239. /**
  59240. * Gets the output component
  59241. */
  59242. get output(): NodeMaterialConnectionPoint;
  59243. protected _buildBlock(state: NodeMaterialBuildState): this;
  59244. }
  59245. }
  59246. declare module BABYLON {
  59247. /**
  59248. * Block used to divide 2 vectors
  59249. */
  59250. export class DivideBlock extends NodeMaterialBlock {
  59251. /**
  59252. * Creates a new DivideBlock
  59253. * @param name defines the block name
  59254. */
  59255. constructor(name: string);
  59256. /**
  59257. * Gets the current class name
  59258. * @returns the class name
  59259. */
  59260. getClassName(): string;
  59261. /**
  59262. * Gets the left operand input component
  59263. */
  59264. get left(): NodeMaterialConnectionPoint;
  59265. /**
  59266. * Gets the right operand input component
  59267. */
  59268. get right(): NodeMaterialConnectionPoint;
  59269. /**
  59270. * Gets the output component
  59271. */
  59272. get output(): NodeMaterialConnectionPoint;
  59273. protected _buildBlock(state: NodeMaterialBuildState): this;
  59274. }
  59275. }
  59276. declare module BABYLON {
  59277. /**
  59278. * Block used to subtract 2 vectors
  59279. */
  59280. export class SubtractBlock extends NodeMaterialBlock {
  59281. /**
  59282. * Creates a new SubtractBlock
  59283. * @param name defines the block name
  59284. */
  59285. constructor(name: string);
  59286. /**
  59287. * Gets the current class name
  59288. * @returns the class name
  59289. */
  59290. getClassName(): string;
  59291. /**
  59292. * Gets the left operand input component
  59293. */
  59294. get left(): NodeMaterialConnectionPoint;
  59295. /**
  59296. * Gets the right operand input component
  59297. */
  59298. get right(): NodeMaterialConnectionPoint;
  59299. /**
  59300. * Gets the output component
  59301. */
  59302. get output(): NodeMaterialConnectionPoint;
  59303. protected _buildBlock(state: NodeMaterialBuildState): this;
  59304. }
  59305. }
  59306. declare module BABYLON {
  59307. /**
  59308. * Block used to step a value
  59309. */
  59310. export class StepBlock extends NodeMaterialBlock {
  59311. /**
  59312. * Creates a new StepBlock
  59313. * @param name defines the block name
  59314. */
  59315. constructor(name: string);
  59316. /**
  59317. * Gets the current class name
  59318. * @returns the class name
  59319. */
  59320. getClassName(): string;
  59321. /**
  59322. * Gets the value operand input component
  59323. */
  59324. get value(): NodeMaterialConnectionPoint;
  59325. /**
  59326. * Gets the edge operand input component
  59327. */
  59328. get edge(): NodeMaterialConnectionPoint;
  59329. /**
  59330. * Gets the output component
  59331. */
  59332. get output(): NodeMaterialConnectionPoint;
  59333. protected _buildBlock(state: NodeMaterialBuildState): this;
  59334. }
  59335. }
  59336. declare module BABYLON {
  59337. /**
  59338. * Block used to get the opposite (1 - x) of a value
  59339. */
  59340. export class OneMinusBlock extends NodeMaterialBlock {
  59341. /**
  59342. * Creates a new OneMinusBlock
  59343. * @param name defines the block name
  59344. */
  59345. constructor(name: string);
  59346. /**
  59347. * Gets the current class name
  59348. * @returns the class name
  59349. */
  59350. getClassName(): string;
  59351. /**
  59352. * Gets the input component
  59353. */
  59354. get input(): NodeMaterialConnectionPoint;
  59355. /**
  59356. * Gets the output component
  59357. */
  59358. get output(): NodeMaterialConnectionPoint;
  59359. protected _buildBlock(state: NodeMaterialBuildState): this;
  59360. }
  59361. }
  59362. declare module BABYLON {
  59363. /**
  59364. * Block used to get the view direction
  59365. */
  59366. export class ViewDirectionBlock extends NodeMaterialBlock {
  59367. /**
  59368. * Creates a new ViewDirectionBlock
  59369. * @param name defines the block name
  59370. */
  59371. constructor(name: string);
  59372. /**
  59373. * Gets the current class name
  59374. * @returns the class name
  59375. */
  59376. getClassName(): string;
  59377. /**
  59378. * Gets the world position component
  59379. */
  59380. get worldPosition(): NodeMaterialConnectionPoint;
  59381. /**
  59382. * Gets the camera position component
  59383. */
  59384. get cameraPosition(): NodeMaterialConnectionPoint;
  59385. /**
  59386. * Gets the output component
  59387. */
  59388. get output(): NodeMaterialConnectionPoint;
  59389. autoConfigure(material: NodeMaterial): void;
  59390. protected _buildBlock(state: NodeMaterialBuildState): this;
  59391. }
  59392. }
  59393. declare module BABYLON {
  59394. /**
  59395. * Block used to compute fresnel value
  59396. */
  59397. export class FresnelBlock extends NodeMaterialBlock {
  59398. /**
  59399. * Create a new FresnelBlock
  59400. * @param name defines the block name
  59401. */
  59402. constructor(name: string);
  59403. /**
  59404. * Gets the current class name
  59405. * @returns the class name
  59406. */
  59407. getClassName(): string;
  59408. /**
  59409. * Gets the world normal input component
  59410. */
  59411. get worldNormal(): NodeMaterialConnectionPoint;
  59412. /**
  59413. * Gets the view direction input component
  59414. */
  59415. get viewDirection(): NodeMaterialConnectionPoint;
  59416. /**
  59417. * Gets the bias input component
  59418. */
  59419. get bias(): NodeMaterialConnectionPoint;
  59420. /**
  59421. * Gets the camera (or eye) position component
  59422. */
  59423. get power(): NodeMaterialConnectionPoint;
  59424. /**
  59425. * Gets the fresnel output component
  59426. */
  59427. get fresnel(): NodeMaterialConnectionPoint;
  59428. autoConfigure(material: NodeMaterial): void;
  59429. protected _buildBlock(state: NodeMaterialBuildState): this;
  59430. }
  59431. }
  59432. declare module BABYLON {
  59433. /**
  59434. * Block used to get the max of 2 values
  59435. */
  59436. export class MaxBlock extends NodeMaterialBlock {
  59437. /**
  59438. * Creates a new MaxBlock
  59439. * @param name defines the block name
  59440. */
  59441. constructor(name: string);
  59442. /**
  59443. * Gets the current class name
  59444. * @returns the class name
  59445. */
  59446. getClassName(): string;
  59447. /**
  59448. * Gets the left operand input component
  59449. */
  59450. get left(): NodeMaterialConnectionPoint;
  59451. /**
  59452. * Gets the right operand input component
  59453. */
  59454. get right(): NodeMaterialConnectionPoint;
  59455. /**
  59456. * Gets the output component
  59457. */
  59458. get output(): NodeMaterialConnectionPoint;
  59459. protected _buildBlock(state: NodeMaterialBuildState): this;
  59460. }
  59461. }
  59462. declare module BABYLON {
  59463. /**
  59464. * Block used to get the min of 2 values
  59465. */
  59466. export class MinBlock extends NodeMaterialBlock {
  59467. /**
  59468. * Creates a new MinBlock
  59469. * @param name defines the block name
  59470. */
  59471. constructor(name: string);
  59472. /**
  59473. * Gets the current class name
  59474. * @returns the class name
  59475. */
  59476. getClassName(): string;
  59477. /**
  59478. * Gets the left operand input component
  59479. */
  59480. get left(): NodeMaterialConnectionPoint;
  59481. /**
  59482. * Gets the right operand input component
  59483. */
  59484. get right(): NodeMaterialConnectionPoint;
  59485. /**
  59486. * Gets the output component
  59487. */
  59488. get output(): NodeMaterialConnectionPoint;
  59489. protected _buildBlock(state: NodeMaterialBuildState): this;
  59490. }
  59491. }
  59492. declare module BABYLON {
  59493. /**
  59494. * Block used to get the distance between 2 values
  59495. */
  59496. export class DistanceBlock extends NodeMaterialBlock {
  59497. /**
  59498. * Creates a new DistanceBlock
  59499. * @param name defines the block name
  59500. */
  59501. constructor(name: string);
  59502. /**
  59503. * Gets the current class name
  59504. * @returns the class name
  59505. */
  59506. getClassName(): string;
  59507. /**
  59508. * Gets the left operand input component
  59509. */
  59510. get left(): NodeMaterialConnectionPoint;
  59511. /**
  59512. * Gets the right operand input component
  59513. */
  59514. get right(): NodeMaterialConnectionPoint;
  59515. /**
  59516. * Gets the output component
  59517. */
  59518. get output(): NodeMaterialConnectionPoint;
  59519. protected _buildBlock(state: NodeMaterialBuildState): this;
  59520. }
  59521. }
  59522. declare module BABYLON {
  59523. /**
  59524. * Block used to get the length of a vector
  59525. */
  59526. export class LengthBlock extends NodeMaterialBlock {
  59527. /**
  59528. * Creates a new LengthBlock
  59529. * @param name defines the block name
  59530. */
  59531. constructor(name: string);
  59532. /**
  59533. * Gets the current class name
  59534. * @returns the class name
  59535. */
  59536. getClassName(): string;
  59537. /**
  59538. * Gets the value input component
  59539. */
  59540. get value(): NodeMaterialConnectionPoint;
  59541. /**
  59542. * Gets the output component
  59543. */
  59544. get output(): NodeMaterialConnectionPoint;
  59545. protected _buildBlock(state: NodeMaterialBuildState): this;
  59546. }
  59547. }
  59548. declare module BABYLON {
  59549. /**
  59550. * Block used to get negative version of a value (i.e. x * -1)
  59551. */
  59552. export class NegateBlock extends NodeMaterialBlock {
  59553. /**
  59554. * Creates a new NegateBlock
  59555. * @param name defines the block name
  59556. */
  59557. constructor(name: string);
  59558. /**
  59559. * Gets the current class name
  59560. * @returns the class name
  59561. */
  59562. getClassName(): string;
  59563. /**
  59564. * Gets the value input component
  59565. */
  59566. get value(): NodeMaterialConnectionPoint;
  59567. /**
  59568. * Gets the output component
  59569. */
  59570. get output(): NodeMaterialConnectionPoint;
  59571. protected _buildBlock(state: NodeMaterialBuildState): this;
  59572. }
  59573. }
  59574. declare module BABYLON {
  59575. /**
  59576. * Block used to get the value of the first parameter raised to the power of the second
  59577. */
  59578. export class PowBlock extends NodeMaterialBlock {
  59579. /**
  59580. * Creates a new PowBlock
  59581. * @param name defines the block name
  59582. */
  59583. constructor(name: string);
  59584. /**
  59585. * Gets the current class name
  59586. * @returns the class name
  59587. */
  59588. getClassName(): string;
  59589. /**
  59590. * Gets the value operand input component
  59591. */
  59592. get value(): NodeMaterialConnectionPoint;
  59593. /**
  59594. * Gets the power operand input component
  59595. */
  59596. get power(): NodeMaterialConnectionPoint;
  59597. /**
  59598. * Gets the output component
  59599. */
  59600. get output(): NodeMaterialConnectionPoint;
  59601. protected _buildBlock(state: NodeMaterialBuildState): this;
  59602. }
  59603. }
  59604. declare module BABYLON {
  59605. /**
  59606. * Block used to get a random number
  59607. */
  59608. export class RandomNumberBlock extends NodeMaterialBlock {
  59609. /**
  59610. * Creates a new RandomNumberBlock
  59611. * @param name defines the block name
  59612. */
  59613. constructor(name: string);
  59614. /**
  59615. * Gets the current class name
  59616. * @returns the class name
  59617. */
  59618. getClassName(): string;
  59619. /**
  59620. * Gets the seed input component
  59621. */
  59622. get seed(): NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the output component
  59625. */
  59626. get output(): NodeMaterialConnectionPoint;
  59627. protected _buildBlock(state: NodeMaterialBuildState): this;
  59628. }
  59629. }
  59630. declare module BABYLON {
  59631. /**
  59632. * Block used to compute arc tangent of 2 values
  59633. */
  59634. export class ArcTan2Block extends NodeMaterialBlock {
  59635. /**
  59636. * Creates a new ArcTan2Block
  59637. * @param name defines the block name
  59638. */
  59639. constructor(name: string);
  59640. /**
  59641. * Gets the current class name
  59642. * @returns the class name
  59643. */
  59644. getClassName(): string;
  59645. /**
  59646. * Gets the x operand input component
  59647. */
  59648. get x(): NodeMaterialConnectionPoint;
  59649. /**
  59650. * Gets the y operand input component
  59651. */
  59652. get y(): NodeMaterialConnectionPoint;
  59653. /**
  59654. * Gets the output component
  59655. */
  59656. get output(): NodeMaterialConnectionPoint;
  59657. protected _buildBlock(state: NodeMaterialBuildState): this;
  59658. }
  59659. }
  59660. declare module BABYLON {
  59661. /**
  59662. * Block used to smooth step a value
  59663. */
  59664. export class SmoothStepBlock extends NodeMaterialBlock {
  59665. /**
  59666. * Creates a new SmoothStepBlock
  59667. * @param name defines the block name
  59668. */
  59669. constructor(name: string);
  59670. /**
  59671. * Gets the current class name
  59672. * @returns the class name
  59673. */
  59674. getClassName(): string;
  59675. /**
  59676. * Gets the value operand input component
  59677. */
  59678. get value(): NodeMaterialConnectionPoint;
  59679. /**
  59680. * Gets the first edge operand input component
  59681. */
  59682. get edge0(): NodeMaterialConnectionPoint;
  59683. /**
  59684. * Gets the second edge operand input component
  59685. */
  59686. get edge1(): NodeMaterialConnectionPoint;
  59687. /**
  59688. * Gets the output component
  59689. */
  59690. get output(): NodeMaterialConnectionPoint;
  59691. protected _buildBlock(state: NodeMaterialBuildState): this;
  59692. }
  59693. }
  59694. declare module BABYLON {
  59695. /**
  59696. * Block used to get the reciprocal (1 / x) of a value
  59697. */
  59698. export class ReciprocalBlock extends NodeMaterialBlock {
  59699. /**
  59700. * Creates a new ReciprocalBlock
  59701. * @param name defines the block name
  59702. */
  59703. constructor(name: string);
  59704. /**
  59705. * Gets the current class name
  59706. * @returns the class name
  59707. */
  59708. getClassName(): string;
  59709. /**
  59710. * Gets the input component
  59711. */
  59712. get input(): NodeMaterialConnectionPoint;
  59713. /**
  59714. * Gets the output component
  59715. */
  59716. get output(): NodeMaterialConnectionPoint;
  59717. protected _buildBlock(state: NodeMaterialBuildState): this;
  59718. }
  59719. }
  59720. declare module BABYLON {
  59721. /**
  59722. * Block used to replace a color by another one
  59723. */
  59724. export class ReplaceColorBlock extends NodeMaterialBlock {
  59725. /**
  59726. * Creates a new ReplaceColorBlock
  59727. * @param name defines the block name
  59728. */
  59729. constructor(name: string);
  59730. /**
  59731. * Gets the current class name
  59732. * @returns the class name
  59733. */
  59734. getClassName(): string;
  59735. /**
  59736. * Gets the value input component
  59737. */
  59738. get value(): NodeMaterialConnectionPoint;
  59739. /**
  59740. * Gets the reference input component
  59741. */
  59742. get reference(): NodeMaterialConnectionPoint;
  59743. /**
  59744. * Gets the distance input component
  59745. */
  59746. get distance(): NodeMaterialConnectionPoint;
  59747. /**
  59748. * Gets the replacement input component
  59749. */
  59750. get replacement(): NodeMaterialConnectionPoint;
  59751. /**
  59752. * Gets the output component
  59753. */
  59754. get output(): NodeMaterialConnectionPoint;
  59755. protected _buildBlock(state: NodeMaterialBuildState): this;
  59756. }
  59757. }
  59758. declare module BABYLON {
  59759. /**
  59760. * Block used to posterize a value
  59761. * @see https://en.wikipedia.org/wiki/Posterization
  59762. */
  59763. export class PosterizeBlock extends NodeMaterialBlock {
  59764. /**
  59765. * Creates a new PosterizeBlock
  59766. * @param name defines the block name
  59767. */
  59768. constructor(name: string);
  59769. /**
  59770. * Gets the current class name
  59771. * @returns the class name
  59772. */
  59773. getClassName(): string;
  59774. /**
  59775. * Gets the value input component
  59776. */
  59777. get value(): NodeMaterialConnectionPoint;
  59778. /**
  59779. * Gets the steps input component
  59780. */
  59781. get steps(): NodeMaterialConnectionPoint;
  59782. /**
  59783. * Gets the output component
  59784. */
  59785. get output(): NodeMaterialConnectionPoint;
  59786. protected _buildBlock(state: NodeMaterialBuildState): this;
  59787. }
  59788. }
  59789. declare module BABYLON {
  59790. /**
  59791. * Operations supported by the Wave block
  59792. */
  59793. export enum WaveBlockKind {
  59794. /** SawTooth */
  59795. SawTooth = 0,
  59796. /** Square */
  59797. Square = 1,
  59798. /** Triangle */
  59799. Triangle = 2
  59800. }
  59801. /**
  59802. * Block used to apply wave operation to floats
  59803. */
  59804. export class WaveBlock extends NodeMaterialBlock {
  59805. /**
  59806. * Gets or sets the kibnd of wave to be applied by the block
  59807. */
  59808. kind: WaveBlockKind;
  59809. /**
  59810. * Creates a new WaveBlock
  59811. * @param name defines the block name
  59812. */
  59813. constructor(name: string);
  59814. /**
  59815. * Gets the current class name
  59816. * @returns the class name
  59817. */
  59818. getClassName(): string;
  59819. /**
  59820. * Gets the input component
  59821. */
  59822. get input(): NodeMaterialConnectionPoint;
  59823. /**
  59824. * Gets the output component
  59825. */
  59826. get output(): NodeMaterialConnectionPoint;
  59827. protected _buildBlock(state: NodeMaterialBuildState): this;
  59828. serialize(): any;
  59829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59830. }
  59831. }
  59832. declare module BABYLON {
  59833. /**
  59834. * Class used to store a color step for the GradientBlock
  59835. */
  59836. export class GradientBlockColorStep {
  59837. /**
  59838. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59839. */
  59840. step: number;
  59841. /**
  59842. * Gets or sets the color associated with this step
  59843. */
  59844. color: Color3;
  59845. /**
  59846. * Creates a new GradientBlockColorStep
  59847. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59848. * @param color defines the color associated with this step
  59849. */
  59850. constructor(
  59851. /**
  59852. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59853. */
  59854. step: number,
  59855. /**
  59856. * Gets or sets the color associated with this step
  59857. */
  59858. color: Color3);
  59859. }
  59860. /**
  59861. * Block used to return a color from a gradient based on an input value between 0 and 1
  59862. */
  59863. export class GradientBlock extends NodeMaterialBlock {
  59864. /**
  59865. * Gets or sets the list of color steps
  59866. */
  59867. colorSteps: GradientBlockColorStep[];
  59868. /**
  59869. * Creates a new GradientBlock
  59870. * @param name defines the block name
  59871. */
  59872. constructor(name: string);
  59873. /**
  59874. * Gets the current class name
  59875. * @returns the class name
  59876. */
  59877. getClassName(): string;
  59878. /**
  59879. * Gets the gradient input component
  59880. */
  59881. get gradient(): NodeMaterialConnectionPoint;
  59882. /**
  59883. * Gets the output component
  59884. */
  59885. get output(): NodeMaterialConnectionPoint;
  59886. private _writeColorConstant;
  59887. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59888. serialize(): any;
  59889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59890. protected _dumpPropertiesCode(): string;
  59891. }
  59892. }
  59893. declare module BABYLON {
  59894. /**
  59895. * Block used to normalize lerp between 2 values
  59896. */
  59897. export class NLerpBlock extends NodeMaterialBlock {
  59898. /**
  59899. * Creates a new NLerpBlock
  59900. * @param name defines the block name
  59901. */
  59902. constructor(name: string);
  59903. /**
  59904. * Gets the current class name
  59905. * @returns the class name
  59906. */
  59907. getClassName(): string;
  59908. /**
  59909. * Gets the left operand input component
  59910. */
  59911. get left(): NodeMaterialConnectionPoint;
  59912. /**
  59913. * Gets the right operand input component
  59914. */
  59915. get right(): NodeMaterialConnectionPoint;
  59916. /**
  59917. * Gets the gradient operand input component
  59918. */
  59919. get gradient(): 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 Generate a Worley Noise 3D Noise Pattern
  59930. */
  59931. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59932. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59933. manhattanDistance: boolean;
  59934. /**
  59935. * Creates a new WorleyNoise3DBlock
  59936. * @param name defines the block name
  59937. */
  59938. constructor(name: string);
  59939. /**
  59940. * Gets the current class name
  59941. * @returns the class name
  59942. */
  59943. getClassName(): string;
  59944. /**
  59945. * Gets the seed input component
  59946. */
  59947. get seed(): NodeMaterialConnectionPoint;
  59948. /**
  59949. * Gets the jitter input component
  59950. */
  59951. get jitter(): NodeMaterialConnectionPoint;
  59952. /**
  59953. * Gets the output component
  59954. */
  59955. get output(): NodeMaterialConnectionPoint;
  59956. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59957. /**
  59958. * Exposes the properties to the UI?
  59959. */
  59960. protected _dumpPropertiesCode(): string;
  59961. /**
  59962. * Exposes the properties to the Seralize?
  59963. */
  59964. serialize(): any;
  59965. /**
  59966. * Exposes the properties to the deseralize?
  59967. */
  59968. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59969. }
  59970. }
  59971. declare module BABYLON {
  59972. /**
  59973. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59974. */
  59975. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59976. /**
  59977. * Creates a new SimplexPerlin3DBlock
  59978. * @param name defines the block name
  59979. */
  59980. constructor(name: string);
  59981. /**
  59982. * Gets the current class name
  59983. * @returns the class name
  59984. */
  59985. getClassName(): string;
  59986. /**
  59987. * Gets the seed operand input component
  59988. */
  59989. get seed(): NodeMaterialConnectionPoint;
  59990. /**
  59991. * Gets the output component
  59992. */
  59993. get output(): NodeMaterialConnectionPoint;
  59994. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59995. }
  59996. }
  59997. declare module BABYLON {
  59998. /**
  59999. * Block used to blend normals
  60000. */
  60001. export class NormalBlendBlock extends NodeMaterialBlock {
  60002. /**
  60003. * Creates a new NormalBlendBlock
  60004. * @param name defines the block name
  60005. */
  60006. constructor(name: string);
  60007. /**
  60008. * Gets the current class name
  60009. * @returns the class name
  60010. */
  60011. getClassName(): string;
  60012. /**
  60013. * Gets the first input component
  60014. */
  60015. get normalMap0(): NodeMaterialConnectionPoint;
  60016. /**
  60017. * Gets the second input component
  60018. */
  60019. get normalMap1(): NodeMaterialConnectionPoint;
  60020. /**
  60021. * Gets the output component
  60022. */
  60023. get output(): NodeMaterialConnectionPoint;
  60024. protected _buildBlock(state: NodeMaterialBuildState): this;
  60025. }
  60026. }
  60027. declare module BABYLON {
  60028. /**
  60029. * Block used to rotate a 2d vector by a given angle
  60030. */
  60031. export class Rotate2dBlock extends NodeMaterialBlock {
  60032. /**
  60033. * Creates a new Rotate2dBlock
  60034. * @param name defines the block name
  60035. */
  60036. constructor(name: string);
  60037. /**
  60038. * Gets the current class name
  60039. * @returns the class name
  60040. */
  60041. getClassName(): string;
  60042. /**
  60043. * Gets the input vector
  60044. */
  60045. get input(): NodeMaterialConnectionPoint;
  60046. /**
  60047. * Gets the input angle
  60048. */
  60049. get angle(): NodeMaterialConnectionPoint;
  60050. /**
  60051. * Gets the output component
  60052. */
  60053. get output(): NodeMaterialConnectionPoint;
  60054. autoConfigure(material: NodeMaterial): void;
  60055. protected _buildBlock(state: NodeMaterialBuildState): this;
  60056. }
  60057. }
  60058. declare module BABYLON {
  60059. /**
  60060. * Block used to get the reflected vector from a direction and a normal
  60061. */
  60062. export class ReflectBlock extends NodeMaterialBlock {
  60063. /**
  60064. * Creates a new ReflectBlock
  60065. * @param name defines the block name
  60066. */
  60067. constructor(name: string);
  60068. /**
  60069. * Gets the current class name
  60070. * @returns the class name
  60071. */
  60072. getClassName(): string;
  60073. /**
  60074. * Gets the incident component
  60075. */
  60076. get incident(): NodeMaterialConnectionPoint;
  60077. /**
  60078. * Gets the normal component
  60079. */
  60080. get normal(): NodeMaterialConnectionPoint;
  60081. /**
  60082. * Gets the output component
  60083. */
  60084. get output(): NodeMaterialConnectionPoint;
  60085. protected _buildBlock(state: NodeMaterialBuildState): this;
  60086. }
  60087. }
  60088. declare module BABYLON {
  60089. /**
  60090. * Block used to get the refracted vector from a direction and a normal
  60091. */
  60092. export class RefractBlock extends NodeMaterialBlock {
  60093. /**
  60094. * Creates a new RefractBlock
  60095. * @param name defines the block name
  60096. */
  60097. constructor(name: string);
  60098. /**
  60099. * Gets the current class name
  60100. * @returns the class name
  60101. */
  60102. getClassName(): string;
  60103. /**
  60104. * Gets the incident component
  60105. */
  60106. get incident(): NodeMaterialConnectionPoint;
  60107. /**
  60108. * Gets the normal component
  60109. */
  60110. get normal(): NodeMaterialConnectionPoint;
  60111. /**
  60112. * Gets the index of refraction component
  60113. */
  60114. get ior(): NodeMaterialConnectionPoint;
  60115. /**
  60116. * Gets the output component
  60117. */
  60118. get output(): NodeMaterialConnectionPoint;
  60119. protected _buildBlock(state: NodeMaterialBuildState): this;
  60120. }
  60121. }
  60122. declare module BABYLON {
  60123. /**
  60124. * Block used to desaturate a color
  60125. */
  60126. export class DesaturateBlock extends NodeMaterialBlock {
  60127. /**
  60128. * Creates a new DesaturateBlock
  60129. * @param name defines the block name
  60130. */
  60131. constructor(name: string);
  60132. /**
  60133. * Gets the current class name
  60134. * @returns the class name
  60135. */
  60136. getClassName(): string;
  60137. /**
  60138. * Gets the color operand input component
  60139. */
  60140. get color(): NodeMaterialConnectionPoint;
  60141. /**
  60142. * Gets the level operand input component
  60143. */
  60144. get level(): NodeMaterialConnectionPoint;
  60145. /**
  60146. * Gets the output component
  60147. */
  60148. get output(): NodeMaterialConnectionPoint;
  60149. protected _buildBlock(state: NodeMaterialBuildState): this;
  60150. }
  60151. }
  60152. declare module BABYLON {
  60153. /**
  60154. * Effect Render Options
  60155. */
  60156. export interface IEffectRendererOptions {
  60157. /**
  60158. * Defines the vertices positions.
  60159. */
  60160. positions?: number[];
  60161. /**
  60162. * Defines the indices.
  60163. */
  60164. indices?: number[];
  60165. }
  60166. /**
  60167. * Helper class to render one or more effects
  60168. */
  60169. export class EffectRenderer {
  60170. private engine;
  60171. private static _DefaultOptions;
  60172. private _vertexBuffers;
  60173. private _indexBuffer;
  60174. private _ringBufferIndex;
  60175. private _ringScreenBuffer;
  60176. private _fullscreenViewport;
  60177. private _getNextFrameBuffer;
  60178. /**
  60179. * Creates an effect renderer
  60180. * @param engine the engine to use for rendering
  60181. * @param options defines the options of the effect renderer
  60182. */
  60183. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60184. /**
  60185. * Sets the current viewport in normalized coordinates 0-1
  60186. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60187. */
  60188. setViewport(viewport?: Viewport): void;
  60189. /**
  60190. * Binds the embedded attributes buffer to the effect.
  60191. * @param effect Defines the effect to bind the attributes for
  60192. */
  60193. bindBuffers(effect: Effect): void;
  60194. /**
  60195. * Sets the current effect wrapper to use during draw.
  60196. * The effect needs to be ready before calling this api.
  60197. * This also sets the default full screen position attribute.
  60198. * @param effectWrapper Defines the effect to draw with
  60199. */
  60200. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60201. /**
  60202. * Draws a full screen quad.
  60203. */
  60204. draw(): void;
  60205. /**
  60206. * renders one or more effects to a specified texture
  60207. * @param effectWrappers list of effects to renderer
  60208. * @param outputTexture texture to draw to, if null it will render to the screen
  60209. */
  60210. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60211. /**
  60212. * Disposes of the effect renderer
  60213. */
  60214. dispose(): void;
  60215. }
  60216. /**
  60217. * Options to create an EffectWrapper
  60218. */
  60219. interface EffectWrapperCreationOptions {
  60220. /**
  60221. * Engine to use to create the effect
  60222. */
  60223. engine: ThinEngine;
  60224. /**
  60225. * Fragment shader for the effect
  60226. */
  60227. fragmentShader: string;
  60228. /**
  60229. * Vertex shader for the effect
  60230. */
  60231. vertexShader?: string;
  60232. /**
  60233. * Attributes to use in the shader
  60234. */
  60235. attributeNames?: Array<string>;
  60236. /**
  60237. * Uniforms to use in the shader
  60238. */
  60239. uniformNames?: Array<string>;
  60240. /**
  60241. * Texture sampler names to use in the shader
  60242. */
  60243. samplerNames?: Array<string>;
  60244. /**
  60245. * The friendly name of the effect displayed in Spector.
  60246. */
  60247. name?: string;
  60248. }
  60249. /**
  60250. * Wraps an effect to be used for rendering
  60251. */
  60252. export class EffectWrapper {
  60253. /**
  60254. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60255. */
  60256. onApplyObservable: Observable<{}>;
  60257. /**
  60258. * The underlying effect
  60259. */
  60260. effect: Effect;
  60261. /**
  60262. * Creates an effect to be renderer
  60263. * @param creationOptions options to create the effect
  60264. */
  60265. constructor(creationOptions: EffectWrapperCreationOptions);
  60266. /**
  60267. * Disposes of the effect wrapper
  60268. */
  60269. dispose(): void;
  60270. }
  60271. }
  60272. declare module BABYLON {
  60273. /**
  60274. * Helper class to push actions to a pool of workers.
  60275. */
  60276. export class WorkerPool implements IDisposable {
  60277. private _workerInfos;
  60278. private _pendingActions;
  60279. /**
  60280. * Constructor
  60281. * @param workers Array of workers to use for actions
  60282. */
  60283. constructor(workers: Array<Worker>);
  60284. /**
  60285. * Terminates all workers and clears any pending actions.
  60286. */
  60287. dispose(): void;
  60288. /**
  60289. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60290. * pended until a worker has completed its action.
  60291. * @param action The action to perform. Call onComplete when the action is complete.
  60292. */
  60293. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60294. private _execute;
  60295. }
  60296. }
  60297. declare module BABYLON {
  60298. /**
  60299. * Configuration for Draco compression
  60300. */
  60301. export interface IDracoCompressionConfiguration {
  60302. /**
  60303. * Configuration for the decoder.
  60304. */
  60305. decoder: {
  60306. /**
  60307. * The url to the WebAssembly module.
  60308. */
  60309. wasmUrl?: string;
  60310. /**
  60311. * The url to the WebAssembly binary.
  60312. */
  60313. wasmBinaryUrl?: string;
  60314. /**
  60315. * The url to the fallback JavaScript module.
  60316. */
  60317. fallbackUrl?: string;
  60318. };
  60319. }
  60320. /**
  60321. * Draco compression (https://google.github.io/draco/)
  60322. *
  60323. * This class wraps the Draco module.
  60324. *
  60325. * **Encoder**
  60326. *
  60327. * The encoder is not currently implemented.
  60328. *
  60329. * **Decoder**
  60330. *
  60331. * 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.
  60332. *
  60333. * To update the configuration, use the following code:
  60334. * ```javascript
  60335. * DracoCompression.Configuration = {
  60336. * decoder: {
  60337. * wasmUrl: "<url to the WebAssembly library>",
  60338. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60339. * fallbackUrl: "<url to the fallback JavaScript library>",
  60340. * }
  60341. * };
  60342. * ```
  60343. *
  60344. * 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.
  60345. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60346. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60347. *
  60348. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60349. * ```javascript
  60350. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60351. * ```
  60352. *
  60353. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60354. */
  60355. export class DracoCompression implements IDisposable {
  60356. private _workerPoolPromise?;
  60357. private _decoderModulePromise?;
  60358. /**
  60359. * The configuration. Defaults to the following urls:
  60360. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60361. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60362. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60363. */
  60364. static Configuration: IDracoCompressionConfiguration;
  60365. /**
  60366. * Returns true if the decoder configuration is available.
  60367. */
  60368. static get DecoderAvailable(): boolean;
  60369. /**
  60370. * Default number of workers to create when creating the draco compression object.
  60371. */
  60372. static DefaultNumWorkers: number;
  60373. private static GetDefaultNumWorkers;
  60374. private static _Default;
  60375. /**
  60376. * Default instance for the draco compression object.
  60377. */
  60378. static get Default(): DracoCompression;
  60379. /**
  60380. * Constructor
  60381. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60382. */
  60383. constructor(numWorkers?: number);
  60384. /**
  60385. * Stop all async operations and release resources.
  60386. */
  60387. dispose(): void;
  60388. /**
  60389. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60390. * @returns a promise that resolves when ready
  60391. */
  60392. whenReadyAsync(): Promise<void>;
  60393. /**
  60394. * Decode Draco compressed mesh data to vertex data.
  60395. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60396. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60397. * @returns A promise that resolves with the decoded vertex data
  60398. */
  60399. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60400. [kind: string]: number;
  60401. }): Promise<VertexData>;
  60402. }
  60403. }
  60404. declare module BABYLON {
  60405. /**
  60406. * Class for building Constructive Solid Geometry
  60407. */
  60408. export class CSG {
  60409. private polygons;
  60410. /**
  60411. * The world matrix
  60412. */
  60413. matrix: Matrix;
  60414. /**
  60415. * Stores the position
  60416. */
  60417. position: Vector3;
  60418. /**
  60419. * Stores the rotation
  60420. */
  60421. rotation: Vector3;
  60422. /**
  60423. * Stores the rotation quaternion
  60424. */
  60425. rotationQuaternion: Nullable<Quaternion>;
  60426. /**
  60427. * Stores the scaling vector
  60428. */
  60429. scaling: Vector3;
  60430. /**
  60431. * Convert the Mesh to CSG
  60432. * @param mesh The Mesh to convert to CSG
  60433. * @returns A new CSG from the Mesh
  60434. */
  60435. static FromMesh(mesh: Mesh): CSG;
  60436. /**
  60437. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60438. * @param polygons Polygons used to construct a CSG solid
  60439. */
  60440. private static FromPolygons;
  60441. /**
  60442. * Clones, or makes a deep copy, of the CSG
  60443. * @returns A new CSG
  60444. */
  60445. clone(): CSG;
  60446. /**
  60447. * Unions this CSG with another CSG
  60448. * @param csg The CSG to union against this CSG
  60449. * @returns The unioned CSG
  60450. */
  60451. union(csg: CSG): CSG;
  60452. /**
  60453. * Unions this CSG with another CSG in place
  60454. * @param csg The CSG to union against this CSG
  60455. */
  60456. unionInPlace(csg: CSG): void;
  60457. /**
  60458. * Subtracts this CSG with another CSG
  60459. * @param csg The CSG to subtract against this CSG
  60460. * @returns A new CSG
  60461. */
  60462. subtract(csg: CSG): CSG;
  60463. /**
  60464. * Subtracts this CSG with another CSG in place
  60465. * @param csg The CSG to subtact against this CSG
  60466. */
  60467. subtractInPlace(csg: CSG): void;
  60468. /**
  60469. * Intersect this CSG with another CSG
  60470. * @param csg The CSG to intersect against this CSG
  60471. * @returns A new CSG
  60472. */
  60473. intersect(csg: CSG): CSG;
  60474. /**
  60475. * Intersects this CSG with another CSG in place
  60476. * @param csg The CSG to intersect against this CSG
  60477. */
  60478. intersectInPlace(csg: CSG): void;
  60479. /**
  60480. * Return a new CSG solid with solid and empty space switched. This solid is
  60481. * not modified.
  60482. * @returns A new CSG solid with solid and empty space switched
  60483. */
  60484. inverse(): CSG;
  60485. /**
  60486. * Inverses the CSG in place
  60487. */
  60488. inverseInPlace(): void;
  60489. /**
  60490. * This is used to keep meshes transformations so they can be restored
  60491. * when we build back a Babylon Mesh
  60492. * NB : All CSG operations are performed in world coordinates
  60493. * @param csg The CSG to copy the transform attributes from
  60494. * @returns This CSG
  60495. */
  60496. copyTransformAttributes(csg: CSG): CSG;
  60497. /**
  60498. * Build Raw mesh from CSG
  60499. * Coordinates here are in world space
  60500. * @param name The name of the mesh geometry
  60501. * @param scene The Scene
  60502. * @param keepSubMeshes Specifies if the submeshes should be kept
  60503. * @returns A new Mesh
  60504. */
  60505. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60506. /**
  60507. * Build Mesh from CSG taking material and transforms into account
  60508. * @param name The name of the Mesh
  60509. * @param material The material of the Mesh
  60510. * @param scene The Scene
  60511. * @param keepSubMeshes Specifies if submeshes should be kept
  60512. * @returns The new Mesh
  60513. */
  60514. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60515. }
  60516. }
  60517. declare module BABYLON {
  60518. /**
  60519. * Class used to create a trail following a mesh
  60520. */
  60521. export class TrailMesh extends Mesh {
  60522. private _generator;
  60523. private _autoStart;
  60524. private _running;
  60525. private _diameter;
  60526. private _length;
  60527. private _sectionPolygonPointsCount;
  60528. private _sectionVectors;
  60529. private _sectionNormalVectors;
  60530. private _beforeRenderObserver;
  60531. /**
  60532. * @constructor
  60533. * @param name The value used by scene.getMeshByName() to do a lookup.
  60534. * @param generator The mesh or transform node to generate a trail.
  60535. * @param scene The scene to add this mesh to.
  60536. * @param diameter Diameter of trailing mesh. Default is 1.
  60537. * @param length Length of trailing mesh. Default is 60.
  60538. * @param autoStart Automatically start trailing mesh. Default true.
  60539. */
  60540. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60541. /**
  60542. * "TrailMesh"
  60543. * @returns "TrailMesh"
  60544. */
  60545. getClassName(): string;
  60546. private _createMesh;
  60547. /**
  60548. * Start trailing mesh.
  60549. */
  60550. start(): void;
  60551. /**
  60552. * Stop trailing mesh.
  60553. */
  60554. stop(): void;
  60555. /**
  60556. * Update trailing mesh geometry.
  60557. */
  60558. update(): void;
  60559. /**
  60560. * Returns a new TrailMesh object.
  60561. * @param name is a string, the name given to the new mesh
  60562. * @param newGenerator use new generator object for cloned trail mesh
  60563. * @returns a new mesh
  60564. */
  60565. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60566. /**
  60567. * Serializes this trail mesh
  60568. * @param serializationObject object to write serialization to
  60569. */
  60570. serialize(serializationObject: any): void;
  60571. /**
  60572. * Parses a serialized trail mesh
  60573. * @param parsedMesh the serialized mesh
  60574. * @param scene the scene to create the trail mesh in
  60575. * @returns the created trail mesh
  60576. */
  60577. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60578. }
  60579. }
  60580. declare module BABYLON {
  60581. /**
  60582. * Class containing static functions to help procedurally build meshes
  60583. */
  60584. export class TiledBoxBuilder {
  60585. /**
  60586. * Creates a box mesh
  60587. * 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)
  60588. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60590. * * 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
  60591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60592. * @param name defines the name of the mesh
  60593. * @param options defines the options used to create the mesh
  60594. * @param scene defines the hosting scene
  60595. * @returns the box mesh
  60596. */
  60597. static CreateTiledBox(name: string, options: {
  60598. pattern?: number;
  60599. width?: number;
  60600. height?: number;
  60601. depth?: number;
  60602. tileSize?: number;
  60603. tileWidth?: number;
  60604. tileHeight?: number;
  60605. alignHorizontal?: number;
  60606. alignVertical?: number;
  60607. faceUV?: Vector4[];
  60608. faceColors?: Color4[];
  60609. sideOrientation?: number;
  60610. updatable?: boolean;
  60611. }, scene?: Nullable<Scene>): Mesh;
  60612. }
  60613. }
  60614. declare module BABYLON {
  60615. /**
  60616. * Class containing static functions to help procedurally build meshes
  60617. */
  60618. export class TorusKnotBuilder {
  60619. /**
  60620. * Creates a torus knot mesh
  60621. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60622. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60623. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60624. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60626. * * 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
  60627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60628. * @param name defines the name of the mesh
  60629. * @param options defines the options used to create the mesh
  60630. * @param scene defines the hosting scene
  60631. * @returns the torus knot mesh
  60632. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60633. */
  60634. static CreateTorusKnot(name: string, options: {
  60635. radius?: number;
  60636. tube?: number;
  60637. radialSegments?: number;
  60638. tubularSegments?: number;
  60639. p?: number;
  60640. q?: number;
  60641. updatable?: boolean;
  60642. sideOrientation?: number;
  60643. frontUVs?: Vector4;
  60644. backUVs?: Vector4;
  60645. }, scene: any): Mesh;
  60646. }
  60647. }
  60648. declare module BABYLON {
  60649. /**
  60650. * Polygon
  60651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60652. */
  60653. export class Polygon {
  60654. /**
  60655. * Creates a rectangle
  60656. * @param xmin bottom X coord
  60657. * @param ymin bottom Y coord
  60658. * @param xmax top X coord
  60659. * @param ymax top Y coord
  60660. * @returns points that make the resulting rectation
  60661. */
  60662. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60663. /**
  60664. * Creates a circle
  60665. * @param radius radius of circle
  60666. * @param cx scale in x
  60667. * @param cy scale in y
  60668. * @param numberOfSides number of sides that make up the circle
  60669. * @returns points that make the resulting circle
  60670. */
  60671. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60672. /**
  60673. * Creates a polygon from input string
  60674. * @param input Input polygon data
  60675. * @returns the parsed points
  60676. */
  60677. static Parse(input: string): Vector2[];
  60678. /**
  60679. * Starts building a polygon from x and y coordinates
  60680. * @param x x coordinate
  60681. * @param y y coordinate
  60682. * @returns the started path2
  60683. */
  60684. static StartingAt(x: number, y: number): Path2;
  60685. }
  60686. /**
  60687. * Builds a polygon
  60688. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60689. */
  60690. export class PolygonMeshBuilder {
  60691. private _points;
  60692. private _outlinepoints;
  60693. private _holes;
  60694. private _name;
  60695. private _scene;
  60696. private _epoints;
  60697. private _eholes;
  60698. private _addToepoint;
  60699. /**
  60700. * Babylon reference to the earcut plugin.
  60701. */
  60702. bjsEarcut: any;
  60703. /**
  60704. * Creates a PolygonMeshBuilder
  60705. * @param name name of the builder
  60706. * @param contours Path of the polygon
  60707. * @param scene scene to add to when creating the mesh
  60708. * @param earcutInjection can be used to inject your own earcut reference
  60709. */
  60710. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60711. /**
  60712. * Adds a whole within the polygon
  60713. * @param hole Array of points defining the hole
  60714. * @returns this
  60715. */
  60716. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60717. /**
  60718. * Creates the polygon
  60719. * @param updatable If the mesh should be updatable
  60720. * @param depth The depth of the mesh created
  60721. * @returns the created mesh
  60722. */
  60723. build(updatable?: boolean, depth?: number): Mesh;
  60724. /**
  60725. * Creates the polygon
  60726. * @param depth The depth of the mesh created
  60727. * @returns the created VertexData
  60728. */
  60729. buildVertexData(depth?: number): VertexData;
  60730. /**
  60731. * Adds a side to the polygon
  60732. * @param positions points that make the polygon
  60733. * @param normals normals of the polygon
  60734. * @param uvs uvs of the polygon
  60735. * @param indices indices of the polygon
  60736. * @param bounds bounds of the polygon
  60737. * @param points points of the polygon
  60738. * @param depth depth of the polygon
  60739. * @param flip flip of the polygon
  60740. */
  60741. private addSide;
  60742. }
  60743. }
  60744. declare module BABYLON {
  60745. /**
  60746. * Class containing static functions to help procedurally build meshes
  60747. */
  60748. export class PolygonBuilder {
  60749. /**
  60750. * Creates a polygon mesh
  60751. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60752. * * 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
  60753. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60755. * * 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)
  60756. * * Remember you can only change the shape positions, not their number when updating a polygon
  60757. * @param name defines the name of the mesh
  60758. * @param options defines the options used to create the mesh
  60759. * @param scene defines the hosting scene
  60760. * @param earcutInjection can be used to inject your own earcut reference
  60761. * @returns the polygon mesh
  60762. */
  60763. static CreatePolygon(name: string, options: {
  60764. shape: Vector3[];
  60765. holes?: Vector3[][];
  60766. depth?: number;
  60767. faceUV?: Vector4[];
  60768. faceColors?: Color4[];
  60769. updatable?: boolean;
  60770. sideOrientation?: number;
  60771. frontUVs?: Vector4;
  60772. backUVs?: Vector4;
  60773. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60774. /**
  60775. * Creates an extruded polygon mesh, with depth in the Y direction.
  60776. * * 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)
  60777. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60778. * @param name defines the name of the mesh
  60779. * @param options defines the options used to create the mesh
  60780. * @param scene defines the hosting scene
  60781. * @param earcutInjection can be used to inject your own earcut reference
  60782. * @returns the polygon mesh
  60783. */
  60784. static ExtrudePolygon(name: string, options: {
  60785. shape: Vector3[];
  60786. holes?: Vector3[][];
  60787. depth?: number;
  60788. faceUV?: Vector4[];
  60789. faceColors?: Color4[];
  60790. updatable?: boolean;
  60791. sideOrientation?: number;
  60792. frontUVs?: Vector4;
  60793. backUVs?: Vector4;
  60794. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60795. }
  60796. }
  60797. declare module BABYLON {
  60798. /**
  60799. * Class containing static functions to help procedurally build meshes
  60800. */
  60801. export class LatheBuilder {
  60802. /**
  60803. * Creates lathe mesh.
  60804. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60805. * * 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
  60806. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60807. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60808. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60809. * * 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
  60810. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60811. * * 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
  60812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60813. * * 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
  60814. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60816. * @param name defines the name of the mesh
  60817. * @param options defines the options used to create the mesh
  60818. * @param scene defines the hosting scene
  60819. * @returns the lathe mesh
  60820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60821. */
  60822. static CreateLathe(name: string, options: {
  60823. shape: Vector3[];
  60824. radius?: number;
  60825. tessellation?: number;
  60826. clip?: number;
  60827. arc?: number;
  60828. closed?: boolean;
  60829. updatable?: boolean;
  60830. sideOrientation?: number;
  60831. frontUVs?: Vector4;
  60832. backUVs?: Vector4;
  60833. cap?: number;
  60834. invertUV?: boolean;
  60835. }, scene?: Nullable<Scene>): Mesh;
  60836. }
  60837. }
  60838. declare module BABYLON {
  60839. /**
  60840. * Class containing static functions to help procedurally build meshes
  60841. */
  60842. export class TiledPlaneBuilder {
  60843. /**
  60844. * Creates a tiled plane mesh
  60845. * * The parameter `pattern` will, depending on value, do nothing or
  60846. * * * flip (reflect about central vertical) alternate tiles across and up
  60847. * * * flip every tile on alternate rows
  60848. * * * rotate (180 degs) alternate tiles across and up
  60849. * * * rotate every tile on alternate rows
  60850. * * * flip and rotate alternate tiles across and up
  60851. * * * flip and rotate every tile on alternate rows
  60852. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60853. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60854. * * 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
  60855. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60856. * * 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)
  60857. * * 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)
  60858. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60859. * @param name defines the name of the mesh
  60860. * @param options defines the options used to create the mesh
  60861. * @param scene defines the hosting scene
  60862. * @returns the box mesh
  60863. */
  60864. static CreateTiledPlane(name: string, options: {
  60865. pattern?: number;
  60866. tileSize?: number;
  60867. tileWidth?: number;
  60868. tileHeight?: number;
  60869. size?: number;
  60870. width?: number;
  60871. height?: number;
  60872. alignHorizontal?: number;
  60873. alignVertical?: number;
  60874. sideOrientation?: number;
  60875. frontUVs?: Vector4;
  60876. backUVs?: Vector4;
  60877. updatable?: boolean;
  60878. }, scene?: Nullable<Scene>): Mesh;
  60879. }
  60880. }
  60881. declare module BABYLON {
  60882. /**
  60883. * Class containing static functions to help procedurally build meshes
  60884. */
  60885. export class TubeBuilder {
  60886. /**
  60887. * Creates a tube mesh.
  60888. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60889. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60890. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60891. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60892. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60893. * * 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)
  60894. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60895. * * 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
  60896. * * 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
  60897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60898. * * 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
  60899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60901. * @param name defines the name of the mesh
  60902. * @param options defines the options used to create the mesh
  60903. * @param scene defines the hosting scene
  60904. * @returns the tube mesh
  60905. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60906. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60907. */
  60908. static CreateTube(name: string, options: {
  60909. path: Vector3[];
  60910. radius?: number;
  60911. tessellation?: number;
  60912. radiusFunction?: {
  60913. (i: number, distance: number): number;
  60914. };
  60915. cap?: number;
  60916. arc?: number;
  60917. updatable?: boolean;
  60918. sideOrientation?: number;
  60919. frontUVs?: Vector4;
  60920. backUVs?: Vector4;
  60921. instance?: Mesh;
  60922. invertUV?: boolean;
  60923. }, scene?: Nullable<Scene>): Mesh;
  60924. }
  60925. }
  60926. declare module BABYLON {
  60927. /**
  60928. * Class containing static functions to help procedurally build meshes
  60929. */
  60930. export class IcoSphereBuilder {
  60931. /**
  60932. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60933. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60934. * * 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`)
  60935. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60936. * * 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
  60937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60938. * * 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
  60939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60940. * @param name defines the name of the mesh
  60941. * @param options defines the options used to create the mesh
  60942. * @param scene defines the hosting scene
  60943. * @returns the icosahedron mesh
  60944. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60945. */
  60946. static CreateIcoSphere(name: string, options: {
  60947. radius?: number;
  60948. radiusX?: number;
  60949. radiusY?: number;
  60950. radiusZ?: number;
  60951. flat?: boolean;
  60952. subdivisions?: number;
  60953. sideOrientation?: number;
  60954. frontUVs?: Vector4;
  60955. backUVs?: Vector4;
  60956. updatable?: boolean;
  60957. }, scene?: Nullable<Scene>): Mesh;
  60958. }
  60959. }
  60960. declare module BABYLON {
  60961. /**
  60962. * Class containing static functions to help procedurally build meshes
  60963. */
  60964. export class DecalBuilder {
  60965. /**
  60966. * Creates a decal mesh.
  60967. * 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
  60968. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60969. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60970. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60971. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60972. * @param name defines the name of the mesh
  60973. * @param sourceMesh defines the mesh where the decal must be applied
  60974. * @param options defines the options used to create the mesh
  60975. * @param scene defines the hosting scene
  60976. * @returns the decal mesh
  60977. * @see https://doc.babylonjs.com/how_to/decals
  60978. */
  60979. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60980. position?: Vector3;
  60981. normal?: Vector3;
  60982. size?: Vector3;
  60983. angle?: number;
  60984. }): Mesh;
  60985. }
  60986. }
  60987. declare module BABYLON {
  60988. /**
  60989. * Class containing static functions to help procedurally build meshes
  60990. */
  60991. export class MeshBuilder {
  60992. /**
  60993. * Creates a box mesh
  60994. * * The parameter `size` sets the size (float) of each box side (default 1)
  60995. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60996. * * 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)
  60997. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60999. * * 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
  61000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61001. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61002. * @param name defines the name of the mesh
  61003. * @param options defines the options used to create the mesh
  61004. * @param scene defines the hosting scene
  61005. * @returns the box mesh
  61006. */
  61007. static CreateBox(name: string, options: {
  61008. size?: number;
  61009. width?: number;
  61010. height?: number;
  61011. depth?: number;
  61012. faceUV?: Vector4[];
  61013. faceColors?: Color4[];
  61014. sideOrientation?: number;
  61015. frontUVs?: Vector4;
  61016. backUVs?: Vector4;
  61017. updatable?: boolean;
  61018. }, scene?: Nullable<Scene>): Mesh;
  61019. /**
  61020. * Creates a tiled box mesh
  61021. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61023. * @param name defines the name of the mesh
  61024. * @param options defines the options used to create the mesh
  61025. * @param scene defines the hosting scene
  61026. * @returns the tiled box mesh
  61027. */
  61028. static CreateTiledBox(name: string, options: {
  61029. pattern?: number;
  61030. size?: number;
  61031. width?: number;
  61032. height?: number;
  61033. depth: number;
  61034. tileSize?: number;
  61035. tileWidth?: number;
  61036. tileHeight?: number;
  61037. faceUV?: Vector4[];
  61038. faceColors?: Color4[];
  61039. alignHorizontal?: number;
  61040. alignVertical?: number;
  61041. sideOrientation?: number;
  61042. updatable?: boolean;
  61043. }, scene?: Nullable<Scene>): Mesh;
  61044. /**
  61045. * Creates a sphere mesh
  61046. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61047. * * 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`)
  61048. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61049. * * 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
  61050. * * 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)
  61051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61052. * * 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
  61053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61054. * @param name defines the name of the mesh
  61055. * @param options defines the options used to create the mesh
  61056. * @param scene defines the hosting scene
  61057. * @returns the sphere mesh
  61058. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61059. */
  61060. static CreateSphere(name: string, options: {
  61061. segments?: number;
  61062. diameter?: number;
  61063. diameterX?: number;
  61064. diameterY?: number;
  61065. diameterZ?: number;
  61066. arc?: number;
  61067. slice?: number;
  61068. sideOrientation?: number;
  61069. frontUVs?: Vector4;
  61070. backUVs?: Vector4;
  61071. updatable?: boolean;
  61072. }, scene?: Nullable<Scene>): Mesh;
  61073. /**
  61074. * Creates a plane polygonal mesh. By default, this is a disc
  61075. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61076. * * 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
  61077. * * 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
  61078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61079. * * 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
  61080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61081. * @param name defines the name of the mesh
  61082. * @param options defines the options used to create the mesh
  61083. * @param scene defines the hosting scene
  61084. * @returns the plane polygonal mesh
  61085. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61086. */
  61087. static CreateDisc(name: string, options: {
  61088. radius?: number;
  61089. tessellation?: number;
  61090. arc?: number;
  61091. updatable?: boolean;
  61092. sideOrientation?: number;
  61093. frontUVs?: Vector4;
  61094. backUVs?: Vector4;
  61095. }, scene?: Nullable<Scene>): Mesh;
  61096. /**
  61097. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61098. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61099. * * 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`)
  61100. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61101. * * 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
  61102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61103. * * 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
  61104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61105. * @param name defines the name of the mesh
  61106. * @param options defines the options used to create the mesh
  61107. * @param scene defines the hosting scene
  61108. * @returns the icosahedron mesh
  61109. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61110. */
  61111. static CreateIcoSphere(name: string, options: {
  61112. radius?: number;
  61113. radiusX?: number;
  61114. radiusY?: number;
  61115. radiusZ?: number;
  61116. flat?: boolean;
  61117. subdivisions?: number;
  61118. sideOrientation?: number;
  61119. frontUVs?: Vector4;
  61120. backUVs?: Vector4;
  61121. updatable?: boolean;
  61122. }, scene?: Nullable<Scene>): Mesh;
  61123. /**
  61124. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61125. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61126. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61127. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61128. * * 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
  61129. * * 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
  61130. * * 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
  61131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61132. * * 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
  61133. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61134. * * 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
  61135. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61136. * * 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
  61137. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61139. * @param name defines the name of the mesh
  61140. * @param options defines the options used to create the mesh
  61141. * @param scene defines the hosting scene
  61142. * @returns the ribbon mesh
  61143. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61145. */
  61146. static CreateRibbon(name: string, options: {
  61147. pathArray: Vector3[][];
  61148. closeArray?: boolean;
  61149. closePath?: boolean;
  61150. offset?: number;
  61151. updatable?: boolean;
  61152. sideOrientation?: number;
  61153. frontUVs?: Vector4;
  61154. backUVs?: Vector4;
  61155. instance?: Mesh;
  61156. invertUV?: boolean;
  61157. uvs?: Vector2[];
  61158. colors?: Color4[];
  61159. }, scene?: Nullable<Scene>): Mesh;
  61160. /**
  61161. * Creates a cylinder or a cone mesh
  61162. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61163. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61164. * * 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.
  61165. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61166. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61167. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61168. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61169. * * 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).
  61170. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61171. * * 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).
  61172. * * 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
  61173. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61174. * * 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
  61175. * * 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.
  61176. * * If `enclose` is false, a ring surface is one element.
  61177. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61178. * * 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
  61179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61180. * * 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
  61181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61182. * @param name defines the name of the mesh
  61183. * @param options defines the options used to create the mesh
  61184. * @param scene defines the hosting scene
  61185. * @returns the cylinder mesh
  61186. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61187. */
  61188. static CreateCylinder(name: string, options: {
  61189. height?: number;
  61190. diameterTop?: number;
  61191. diameterBottom?: number;
  61192. diameter?: number;
  61193. tessellation?: number;
  61194. subdivisions?: number;
  61195. arc?: number;
  61196. faceColors?: Color4[];
  61197. faceUV?: Vector4[];
  61198. updatable?: boolean;
  61199. hasRings?: boolean;
  61200. enclose?: boolean;
  61201. cap?: number;
  61202. sideOrientation?: number;
  61203. frontUVs?: Vector4;
  61204. backUVs?: Vector4;
  61205. }, scene?: Nullable<Scene>): Mesh;
  61206. /**
  61207. * Creates a torus mesh
  61208. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61209. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61210. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61212. * * 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
  61213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61214. * @param name defines the name of the mesh
  61215. * @param options defines the options used to create the mesh
  61216. * @param scene defines the hosting scene
  61217. * @returns the torus mesh
  61218. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61219. */
  61220. static CreateTorus(name: string, options: {
  61221. diameter?: number;
  61222. thickness?: number;
  61223. tessellation?: number;
  61224. updatable?: boolean;
  61225. sideOrientation?: number;
  61226. frontUVs?: Vector4;
  61227. backUVs?: Vector4;
  61228. }, scene?: Nullable<Scene>): Mesh;
  61229. /**
  61230. * Creates a torus knot mesh
  61231. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61232. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61233. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61234. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61236. * * 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
  61237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  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 torus knot mesh
  61242. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61243. */
  61244. static CreateTorusKnot(name: string, options: {
  61245. radius?: number;
  61246. tube?: number;
  61247. radialSegments?: number;
  61248. tubularSegments?: number;
  61249. p?: number;
  61250. q?: number;
  61251. updatable?: boolean;
  61252. sideOrientation?: number;
  61253. frontUVs?: Vector4;
  61254. backUVs?: Vector4;
  61255. }, scene?: Nullable<Scene>): Mesh;
  61256. /**
  61257. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61258. * * 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
  61259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61260. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61261. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61262. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61263. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61264. * * 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
  61265. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61268. * @param name defines the name of the new line system
  61269. * @param options defines the options used to create the line system
  61270. * @param scene defines the hosting scene
  61271. * @returns a new line system mesh
  61272. */
  61273. static CreateLineSystem(name: string, options: {
  61274. lines: Vector3[][];
  61275. updatable?: boolean;
  61276. instance?: Nullable<LinesMesh>;
  61277. colors?: Nullable<Color4[][]>;
  61278. useVertexAlpha?: boolean;
  61279. }, scene: Nullable<Scene>): LinesMesh;
  61280. /**
  61281. * Creates a line mesh
  61282. * 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
  61283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61284. * * The parameter `points` is an array successive Vector3
  61285. * * 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
  61286. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61287. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61288. * * When updating an instance, remember that only point positions can change, not the number of points
  61289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61291. * @param name defines the name of the new line system
  61292. * @param options defines the options used to create the line system
  61293. * @param scene defines the hosting scene
  61294. * @returns a new line mesh
  61295. */
  61296. static CreateLines(name: string, options: {
  61297. points: Vector3[];
  61298. updatable?: boolean;
  61299. instance?: Nullable<LinesMesh>;
  61300. colors?: Color4[];
  61301. useVertexAlpha?: boolean;
  61302. }, scene?: Nullable<Scene>): LinesMesh;
  61303. /**
  61304. * Creates a dashed line mesh
  61305. * * 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
  61306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61307. * * The parameter `points` is an array successive Vector3
  61308. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61309. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61310. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61311. * * 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
  61312. * * When updating an instance, remember that only point positions can change, not the number of points
  61313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61314. * @param name defines the name of the mesh
  61315. * @param options defines the options used to create the mesh
  61316. * @param scene defines the hosting scene
  61317. * @returns the dashed line mesh
  61318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61319. */
  61320. static CreateDashedLines(name: string, options: {
  61321. points: Vector3[];
  61322. dashSize?: number;
  61323. gapSize?: number;
  61324. dashNb?: number;
  61325. updatable?: boolean;
  61326. instance?: LinesMesh;
  61327. }, scene?: Nullable<Scene>): LinesMesh;
  61328. /**
  61329. * 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.
  61330. * * 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.
  61331. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61332. * * 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.
  61333. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61334. * * 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
  61335. * * 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
  61336. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61338. * * 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
  61339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61341. * @param name defines the name of the mesh
  61342. * @param options defines the options used to create the mesh
  61343. * @param scene defines the hosting scene
  61344. * @returns the extruded shape mesh
  61345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61347. */
  61348. static ExtrudeShape(name: string, options: {
  61349. shape: Vector3[];
  61350. path: Vector3[];
  61351. scale?: number;
  61352. rotation?: number;
  61353. cap?: number;
  61354. updatable?: boolean;
  61355. sideOrientation?: number;
  61356. frontUVs?: Vector4;
  61357. backUVs?: Vector4;
  61358. instance?: Mesh;
  61359. invertUV?: boolean;
  61360. }, scene?: Nullable<Scene>): Mesh;
  61361. /**
  61362. * Creates an custom extruded shape mesh.
  61363. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61364. * * 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.
  61365. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61366. * * 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
  61367. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61368. * * 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
  61369. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61370. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61371. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61372. * * 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
  61373. * * 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
  61374. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61376. * * 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
  61377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61379. * @param name defines the name of the mesh
  61380. * @param options defines the options used to create the mesh
  61381. * @param scene defines the hosting scene
  61382. * @returns the custom extruded shape mesh
  61383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61386. */
  61387. static ExtrudeShapeCustom(name: string, options: {
  61388. shape: Vector3[];
  61389. path: Vector3[];
  61390. scaleFunction?: any;
  61391. rotationFunction?: any;
  61392. ribbonCloseArray?: boolean;
  61393. ribbonClosePath?: boolean;
  61394. cap?: number;
  61395. updatable?: boolean;
  61396. sideOrientation?: number;
  61397. frontUVs?: Vector4;
  61398. backUVs?: Vector4;
  61399. instance?: Mesh;
  61400. invertUV?: boolean;
  61401. }, scene?: Nullable<Scene>): Mesh;
  61402. /**
  61403. * Creates lathe mesh.
  61404. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61405. * * 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
  61406. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61407. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61408. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61409. * * 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
  61410. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61411. * * 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
  61412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61413. * * 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
  61414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61416. * @param name defines the name of the mesh
  61417. * @param options defines the options used to create the mesh
  61418. * @param scene defines the hosting scene
  61419. * @returns the lathe mesh
  61420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61421. */
  61422. static CreateLathe(name: string, options: {
  61423. shape: Vector3[];
  61424. radius?: number;
  61425. tessellation?: number;
  61426. clip?: number;
  61427. arc?: number;
  61428. closed?: boolean;
  61429. updatable?: boolean;
  61430. sideOrientation?: number;
  61431. frontUVs?: Vector4;
  61432. backUVs?: Vector4;
  61433. cap?: number;
  61434. invertUV?: boolean;
  61435. }, scene?: Nullable<Scene>): Mesh;
  61436. /**
  61437. * Creates a tiled plane mesh
  61438. * * You can set a limited pattern arrangement with the tiles
  61439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61440. * * 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
  61441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61442. * @param name defines the name of the mesh
  61443. * @param options defines the options used to create the mesh
  61444. * @param scene defines the hosting scene
  61445. * @returns the plane mesh
  61446. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61447. */
  61448. static CreateTiledPlane(name: string, options: {
  61449. pattern?: number;
  61450. tileSize?: number;
  61451. tileWidth?: number;
  61452. tileHeight?: number;
  61453. size?: number;
  61454. width?: number;
  61455. height?: number;
  61456. alignHorizontal?: number;
  61457. alignVertical?: number;
  61458. sideOrientation?: number;
  61459. frontUVs?: Vector4;
  61460. backUVs?: Vector4;
  61461. updatable?: boolean;
  61462. }, scene?: Nullable<Scene>): Mesh;
  61463. /**
  61464. * Creates a plane mesh
  61465. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61466. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61467. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61469. * * 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
  61470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61471. * @param name defines the name of the mesh
  61472. * @param options defines the options used to create the mesh
  61473. * @param scene defines the hosting scene
  61474. * @returns the plane mesh
  61475. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61476. */
  61477. static CreatePlane(name: string, options: {
  61478. size?: number;
  61479. width?: number;
  61480. height?: number;
  61481. sideOrientation?: number;
  61482. frontUVs?: Vector4;
  61483. backUVs?: Vector4;
  61484. updatable?: boolean;
  61485. sourcePlane?: Plane;
  61486. }, scene?: Nullable<Scene>): Mesh;
  61487. /**
  61488. * Creates a ground mesh
  61489. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61490. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61492. * @param name defines the name of the mesh
  61493. * @param options defines the options used to create the mesh
  61494. * @param scene defines the hosting scene
  61495. * @returns the ground mesh
  61496. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61497. */
  61498. static CreateGround(name: string, options: {
  61499. width?: number;
  61500. height?: number;
  61501. subdivisions?: number;
  61502. subdivisionsX?: number;
  61503. subdivisionsY?: number;
  61504. updatable?: boolean;
  61505. }, scene?: Nullable<Scene>): Mesh;
  61506. /**
  61507. * Creates a tiled ground mesh
  61508. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61509. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61510. * * 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
  61511. * * 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
  61512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61513. * @param name defines the name of the mesh
  61514. * @param options defines the options used to create the mesh
  61515. * @param scene defines the hosting scene
  61516. * @returns the tiled ground mesh
  61517. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61518. */
  61519. static CreateTiledGround(name: string, options: {
  61520. xmin: number;
  61521. zmin: number;
  61522. xmax: number;
  61523. zmax: number;
  61524. subdivisions?: {
  61525. w: number;
  61526. h: number;
  61527. };
  61528. precision?: {
  61529. w: number;
  61530. h: number;
  61531. };
  61532. updatable?: boolean;
  61533. }, scene?: Nullable<Scene>): Mesh;
  61534. /**
  61535. * Creates a ground mesh from a height map
  61536. * * The parameter `url` sets the URL of the height map image resource.
  61537. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61538. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61539. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61540. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61541. * * 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.
  61542. * * 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).
  61543. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61545. * @param name defines the name of the mesh
  61546. * @param url defines the url to the height map
  61547. * @param options defines the options used to create the mesh
  61548. * @param scene defines the hosting scene
  61549. * @returns the ground mesh
  61550. * @see https://doc.babylonjs.com/babylon101/height_map
  61551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61552. */
  61553. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61554. width?: number;
  61555. height?: number;
  61556. subdivisions?: number;
  61557. minHeight?: number;
  61558. maxHeight?: number;
  61559. colorFilter?: Color3;
  61560. alphaFilter?: number;
  61561. updatable?: boolean;
  61562. onReady?: (mesh: GroundMesh) => void;
  61563. }, scene?: Nullable<Scene>): GroundMesh;
  61564. /**
  61565. * Creates a polygon mesh
  61566. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61567. * * 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
  61568. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61570. * * 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)
  61571. * * Remember you can only change the shape positions, not their number when updating a polygon
  61572. * @param name defines the name of the mesh
  61573. * @param options defines the options used to create the mesh
  61574. * @param scene defines the hosting scene
  61575. * @param earcutInjection can be used to inject your own earcut reference
  61576. * @returns the polygon mesh
  61577. */
  61578. static CreatePolygon(name: string, options: {
  61579. shape: Vector3[];
  61580. holes?: Vector3[][];
  61581. depth?: number;
  61582. faceUV?: Vector4[];
  61583. faceColors?: Color4[];
  61584. updatable?: boolean;
  61585. sideOrientation?: number;
  61586. frontUVs?: Vector4;
  61587. backUVs?: Vector4;
  61588. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61589. /**
  61590. * Creates an extruded polygon mesh, with depth in the Y direction.
  61591. * * 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)
  61592. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61593. * @param name defines the name of the mesh
  61594. * @param options defines the options used to create the mesh
  61595. * @param scene defines the hosting scene
  61596. * @param earcutInjection can be used to inject your own earcut reference
  61597. * @returns the polygon mesh
  61598. */
  61599. static ExtrudePolygon(name: string, options: {
  61600. shape: Vector3[];
  61601. holes?: Vector3[][];
  61602. depth?: number;
  61603. faceUV?: Vector4[];
  61604. faceColors?: Color4[];
  61605. updatable?: boolean;
  61606. sideOrientation?: number;
  61607. frontUVs?: Vector4;
  61608. backUVs?: Vector4;
  61609. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61610. /**
  61611. * Creates a tube mesh.
  61612. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61613. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61614. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61615. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61616. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61617. * * 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)
  61618. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61619. * * 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
  61620. * * 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
  61621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61622. * * 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
  61623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61625. * @param name defines the name of the mesh
  61626. * @param options defines the options used to create the mesh
  61627. * @param scene defines the hosting scene
  61628. * @returns the tube mesh
  61629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61630. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61631. */
  61632. static CreateTube(name: string, options: {
  61633. path: Vector3[];
  61634. radius?: number;
  61635. tessellation?: number;
  61636. radiusFunction?: {
  61637. (i: number, distance: number): number;
  61638. };
  61639. cap?: number;
  61640. arc?: number;
  61641. updatable?: boolean;
  61642. sideOrientation?: number;
  61643. frontUVs?: Vector4;
  61644. backUVs?: Vector4;
  61645. instance?: Mesh;
  61646. invertUV?: boolean;
  61647. }, scene?: Nullable<Scene>): Mesh;
  61648. /**
  61649. * Creates a polyhedron mesh
  61650. * * 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
  61651. * * The parameter `size` (positive float, default 1) sets the polygon size
  61652. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61653. * * 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`
  61654. * * 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
  61655. * * 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)`)
  61656. * * 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
  61657. * * 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
  61658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61659. * * 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
  61660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61661. * @param name defines the name of the mesh
  61662. * @param options defines the options used to create the mesh
  61663. * @param scene defines the hosting scene
  61664. * @returns the polyhedron mesh
  61665. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61666. */
  61667. static CreatePolyhedron(name: string, options: {
  61668. type?: number;
  61669. size?: number;
  61670. sizeX?: number;
  61671. sizeY?: number;
  61672. sizeZ?: number;
  61673. custom?: any;
  61674. faceUV?: Vector4[];
  61675. faceColors?: Color4[];
  61676. flat?: boolean;
  61677. updatable?: boolean;
  61678. sideOrientation?: number;
  61679. frontUVs?: Vector4;
  61680. backUVs?: Vector4;
  61681. }, scene?: Nullable<Scene>): Mesh;
  61682. /**
  61683. * Creates a decal mesh.
  61684. * 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
  61685. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61686. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61687. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61688. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61689. * @param name defines the name of the mesh
  61690. * @param sourceMesh defines the mesh where the decal must be applied
  61691. * @param options defines the options used to create the mesh
  61692. * @param scene defines the hosting scene
  61693. * @returns the decal mesh
  61694. * @see https://doc.babylonjs.com/how_to/decals
  61695. */
  61696. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61697. position?: Vector3;
  61698. normal?: Vector3;
  61699. size?: Vector3;
  61700. angle?: number;
  61701. }): Mesh;
  61702. }
  61703. }
  61704. declare module BABYLON {
  61705. /**
  61706. * A simplifier interface for future simplification implementations
  61707. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61708. */
  61709. export interface ISimplifier {
  61710. /**
  61711. * Simplification of a given mesh according to the given settings.
  61712. * Since this requires computation, it is assumed that the function runs async.
  61713. * @param settings The settings of the simplification, including quality and distance
  61714. * @param successCallback A callback that will be called after the mesh was simplified.
  61715. * @param errorCallback in case of an error, this callback will be called. optional.
  61716. */
  61717. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61718. }
  61719. /**
  61720. * Expected simplification settings.
  61721. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61722. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61723. */
  61724. export interface ISimplificationSettings {
  61725. /**
  61726. * Gets or sets the expected quality
  61727. */
  61728. quality: number;
  61729. /**
  61730. * Gets or sets the distance when this optimized version should be used
  61731. */
  61732. distance: number;
  61733. /**
  61734. * Gets an already optimized mesh
  61735. */
  61736. optimizeMesh?: boolean;
  61737. }
  61738. /**
  61739. * Class used to specify simplification options
  61740. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61741. */
  61742. export class SimplificationSettings implements ISimplificationSettings {
  61743. /** expected quality */
  61744. quality: number;
  61745. /** distance when this optimized version should be used */
  61746. distance: number;
  61747. /** already optimized mesh */
  61748. optimizeMesh?: boolean | undefined;
  61749. /**
  61750. * Creates a SimplificationSettings
  61751. * @param quality expected quality
  61752. * @param distance distance when this optimized version should be used
  61753. * @param optimizeMesh already optimized mesh
  61754. */
  61755. constructor(
  61756. /** expected quality */
  61757. quality: number,
  61758. /** distance when this optimized version should be used */
  61759. distance: number,
  61760. /** already optimized mesh */
  61761. optimizeMesh?: boolean | undefined);
  61762. }
  61763. /**
  61764. * Interface used to define a simplification task
  61765. */
  61766. export interface ISimplificationTask {
  61767. /**
  61768. * Array of settings
  61769. */
  61770. settings: Array<ISimplificationSettings>;
  61771. /**
  61772. * Simplification type
  61773. */
  61774. simplificationType: SimplificationType;
  61775. /**
  61776. * Mesh to simplify
  61777. */
  61778. mesh: Mesh;
  61779. /**
  61780. * Callback called on success
  61781. */
  61782. successCallback?: () => void;
  61783. /**
  61784. * Defines if parallel processing can be used
  61785. */
  61786. parallelProcessing: boolean;
  61787. }
  61788. /**
  61789. * Queue used to order the simplification tasks
  61790. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61791. */
  61792. export class SimplificationQueue {
  61793. private _simplificationArray;
  61794. /**
  61795. * Gets a boolean indicating that the process is still running
  61796. */
  61797. running: boolean;
  61798. /**
  61799. * Creates a new queue
  61800. */
  61801. constructor();
  61802. /**
  61803. * Adds a new simplification task
  61804. * @param task defines a task to add
  61805. */
  61806. addTask(task: ISimplificationTask): void;
  61807. /**
  61808. * Execute next task
  61809. */
  61810. executeNext(): void;
  61811. /**
  61812. * Execute a simplification task
  61813. * @param task defines the task to run
  61814. */
  61815. runSimplification(task: ISimplificationTask): void;
  61816. private getSimplifier;
  61817. }
  61818. /**
  61819. * The implemented types of simplification
  61820. * At the moment only Quadratic Error Decimation is implemented
  61821. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61822. */
  61823. export enum SimplificationType {
  61824. /** Quadratic error decimation */
  61825. QUADRATIC = 0
  61826. }
  61827. }
  61828. declare module BABYLON {
  61829. interface Scene {
  61830. /** @hidden (Backing field) */
  61831. _simplificationQueue: SimplificationQueue;
  61832. /**
  61833. * Gets or sets the simplification queue attached to the scene
  61834. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61835. */
  61836. simplificationQueue: SimplificationQueue;
  61837. }
  61838. interface Mesh {
  61839. /**
  61840. * Simplify the mesh according to the given array of settings.
  61841. * Function will return immediately and will simplify async
  61842. * @param settings a collection of simplification settings
  61843. * @param parallelProcessing should all levels calculate parallel or one after the other
  61844. * @param simplificationType the type of simplification to run
  61845. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61846. * @returns the current mesh
  61847. */
  61848. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61849. }
  61850. /**
  61851. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61852. * created in a scene
  61853. */
  61854. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61855. /**
  61856. * The component name helpfull to identify the component in the list of scene components.
  61857. */
  61858. readonly name: string;
  61859. /**
  61860. * The scene the component belongs to.
  61861. */
  61862. scene: Scene;
  61863. /**
  61864. * Creates a new instance of the component for the given scene
  61865. * @param scene Defines the scene to register the component in
  61866. */
  61867. constructor(scene: Scene);
  61868. /**
  61869. * Registers the component in a given scene
  61870. */
  61871. register(): void;
  61872. /**
  61873. * Rebuilds the elements related to this component in case of
  61874. * context lost for instance.
  61875. */
  61876. rebuild(): void;
  61877. /**
  61878. * Disposes the component and the associated ressources
  61879. */
  61880. dispose(): void;
  61881. private _beforeCameraUpdate;
  61882. }
  61883. }
  61884. declare module BABYLON {
  61885. /**
  61886. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61887. */
  61888. export interface INavigationEnginePlugin {
  61889. /**
  61890. * plugin name
  61891. */
  61892. name: string;
  61893. /**
  61894. * Creates a navigation mesh
  61895. * @param meshes array of all the geometry used to compute the navigatio mesh
  61896. * @param parameters bunch of parameters used to filter geometry
  61897. */
  61898. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61899. /**
  61900. * Create a navigation mesh debug mesh
  61901. * @param scene is where the mesh will be added
  61902. * @returns debug display mesh
  61903. */
  61904. createDebugNavMesh(scene: Scene): Mesh;
  61905. /**
  61906. * Get a navigation mesh constrained position, closest to the parameter position
  61907. * @param position world position
  61908. * @returns the closest point to position constrained by the navigation mesh
  61909. */
  61910. getClosestPoint(position: Vector3): Vector3;
  61911. /**
  61912. * Get a navigation mesh constrained position, within a particular radius
  61913. * @param position world position
  61914. * @param maxRadius the maximum distance to the constrained world position
  61915. * @returns the closest point to position constrained by the navigation mesh
  61916. */
  61917. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61918. /**
  61919. * Compute the final position from a segment made of destination-position
  61920. * @param position world position
  61921. * @param destination world position
  61922. * @returns the resulting point along the navmesh
  61923. */
  61924. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61925. /**
  61926. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61927. * @param start world position
  61928. * @param end world position
  61929. * @returns array containing world position composing the path
  61930. */
  61931. computePath(start: Vector3, end: Vector3): Vector3[];
  61932. /**
  61933. * If this plugin is supported
  61934. * @returns true if plugin is supported
  61935. */
  61936. isSupported(): boolean;
  61937. /**
  61938. * Create a new Crowd so you can add agents
  61939. * @param maxAgents the maximum agent count in the crowd
  61940. * @param maxAgentRadius the maximum radius an agent can have
  61941. * @param scene to attach the crowd to
  61942. * @returns the crowd you can add agents to
  61943. */
  61944. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61945. /**
  61946. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61947. * The queries will try to find a solution within those bounds
  61948. * default is (1,1,1)
  61949. * @param extent x,y,z value that define the extent around the queries point of reference
  61950. */
  61951. setDefaultQueryExtent(extent: Vector3): void;
  61952. /**
  61953. * Get the Bounding box extent specified by setDefaultQueryExtent
  61954. * @returns the box extent values
  61955. */
  61956. getDefaultQueryExtent(): Vector3;
  61957. /**
  61958. * Release all resources
  61959. */
  61960. dispose(): void;
  61961. }
  61962. /**
  61963. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61964. */
  61965. export interface ICrowd {
  61966. /**
  61967. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61968. * You can attach anything to that node. The node position is updated in the scene update tick.
  61969. * @param pos world position that will be constrained by the navigation mesh
  61970. * @param parameters agent parameters
  61971. * @param transform hooked to the agent that will be update by the scene
  61972. * @returns agent index
  61973. */
  61974. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61975. /**
  61976. * Returns the agent position in world space
  61977. * @param index agent index returned by addAgent
  61978. * @returns world space position
  61979. */
  61980. getAgentPosition(index: number): Vector3;
  61981. /**
  61982. * Gets the agent velocity in world space
  61983. * @param index agent index returned by addAgent
  61984. * @returns world space velocity
  61985. */
  61986. getAgentVelocity(index: number): Vector3;
  61987. /**
  61988. * remove a particular agent previously created
  61989. * @param index agent index returned by addAgent
  61990. */
  61991. removeAgent(index: number): void;
  61992. /**
  61993. * get the list of all agents attached to this crowd
  61994. * @returns list of agent indices
  61995. */
  61996. getAgents(): number[];
  61997. /**
  61998. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61999. * @param deltaTime in seconds
  62000. */
  62001. update(deltaTime: number): void;
  62002. /**
  62003. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62004. * @param index agent index returned by addAgent
  62005. * @param destination targeted world position
  62006. */
  62007. agentGoto(index: number, destination: Vector3): void;
  62008. /**
  62009. * Teleport the agent to a new position
  62010. * @param index agent index returned by addAgent
  62011. * @param destination targeted world position
  62012. */
  62013. agentTeleport(index: number, destination: Vector3): void;
  62014. /**
  62015. * Update agent parameters
  62016. * @param index agent index returned by addAgent
  62017. * @param parameters agent parameters
  62018. */
  62019. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62020. /**
  62021. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62022. * The queries will try to find a solution within those bounds
  62023. * default is (1,1,1)
  62024. * @param extent x,y,z value that define the extent around the queries point of reference
  62025. */
  62026. setDefaultQueryExtent(extent: Vector3): void;
  62027. /**
  62028. * Get the Bounding box extent specified by setDefaultQueryExtent
  62029. * @returns the box extent values
  62030. */
  62031. getDefaultQueryExtent(): Vector3;
  62032. /**
  62033. * Release all resources
  62034. */
  62035. dispose(): void;
  62036. }
  62037. /**
  62038. * Configures an agent
  62039. */
  62040. export interface IAgentParameters {
  62041. /**
  62042. * Agent radius. [Limit: >= 0]
  62043. */
  62044. radius: number;
  62045. /**
  62046. * Agent height. [Limit: > 0]
  62047. */
  62048. height: number;
  62049. /**
  62050. * Maximum allowed acceleration. [Limit: >= 0]
  62051. */
  62052. maxAcceleration: number;
  62053. /**
  62054. * Maximum allowed speed. [Limit: >= 0]
  62055. */
  62056. maxSpeed: number;
  62057. /**
  62058. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62059. */
  62060. collisionQueryRange: number;
  62061. /**
  62062. * The path visibility optimization range. [Limit: > 0]
  62063. */
  62064. pathOptimizationRange: number;
  62065. /**
  62066. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62067. */
  62068. separationWeight: number;
  62069. }
  62070. /**
  62071. * Configures the navigation mesh creation
  62072. */
  62073. export interface INavMeshParameters {
  62074. /**
  62075. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62076. */
  62077. cs: number;
  62078. /**
  62079. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62080. */
  62081. ch: number;
  62082. /**
  62083. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62084. */
  62085. walkableSlopeAngle: number;
  62086. /**
  62087. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62088. * be considered walkable. [Limit: >= 3] [Units: vx]
  62089. */
  62090. walkableHeight: number;
  62091. /**
  62092. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62093. */
  62094. walkableClimb: number;
  62095. /**
  62096. * The distance to erode/shrink the walkable area of the heightfield away from
  62097. * obstructions. [Limit: >=0] [Units: vx]
  62098. */
  62099. walkableRadius: number;
  62100. /**
  62101. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62102. */
  62103. maxEdgeLen: number;
  62104. /**
  62105. * The maximum distance a simplfied contour's border edges should deviate
  62106. * the original raw contour. [Limit: >=0] [Units: vx]
  62107. */
  62108. maxSimplificationError: number;
  62109. /**
  62110. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62111. */
  62112. minRegionArea: number;
  62113. /**
  62114. * Any regions with a span count smaller than this value will, if possible,
  62115. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62116. */
  62117. mergeRegionArea: number;
  62118. /**
  62119. * The maximum number of vertices allowed for polygons generated during the
  62120. * contour to polygon conversion process. [Limit: >= 3]
  62121. */
  62122. maxVertsPerPoly: number;
  62123. /**
  62124. * Sets the sampling distance to use when generating the detail mesh.
  62125. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62126. */
  62127. detailSampleDist: number;
  62128. /**
  62129. * The maximum distance the detail mesh surface should deviate from heightfield
  62130. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62131. */
  62132. detailSampleMaxError: number;
  62133. }
  62134. }
  62135. declare module BABYLON {
  62136. /**
  62137. * RecastJS navigation plugin
  62138. */
  62139. export class RecastJSPlugin implements INavigationEnginePlugin {
  62140. /**
  62141. * Reference to the Recast library
  62142. */
  62143. bjsRECAST: any;
  62144. /**
  62145. * plugin name
  62146. */
  62147. name: string;
  62148. /**
  62149. * the first navmesh created. We might extend this to support multiple navmeshes
  62150. */
  62151. navMesh: any;
  62152. /**
  62153. * Initializes the recastJS plugin
  62154. * @param recastInjection can be used to inject your own recast reference
  62155. */
  62156. constructor(recastInjection?: any);
  62157. /**
  62158. * Creates a navigation mesh
  62159. * @param meshes array of all the geometry used to compute the navigatio mesh
  62160. * @param parameters bunch of parameters used to filter geometry
  62161. */
  62162. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62163. /**
  62164. * Create a navigation mesh debug mesh
  62165. * @param scene is where the mesh will be added
  62166. * @returns debug display mesh
  62167. */
  62168. createDebugNavMesh(scene: Scene): Mesh;
  62169. /**
  62170. * Get a navigation mesh constrained position, closest to the parameter position
  62171. * @param position world position
  62172. * @returns the closest point to position constrained by the navigation mesh
  62173. */
  62174. getClosestPoint(position: Vector3): Vector3;
  62175. /**
  62176. * Get a navigation mesh constrained position, within a particular radius
  62177. * @param position world position
  62178. * @param maxRadius the maximum distance to the constrained world position
  62179. * @returns the closest point to position constrained by the navigation mesh
  62180. */
  62181. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62182. /**
  62183. * Compute the final position from a segment made of destination-position
  62184. * @param position world position
  62185. * @param destination world position
  62186. * @returns the resulting point along the navmesh
  62187. */
  62188. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62189. /**
  62190. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62191. * @param start world position
  62192. * @param end world position
  62193. * @returns array containing world position composing the path
  62194. */
  62195. computePath(start: Vector3, end: Vector3): Vector3[];
  62196. /**
  62197. * Create a new Crowd so you can add agents
  62198. * @param maxAgents the maximum agent count in the crowd
  62199. * @param maxAgentRadius the maximum radius an agent can have
  62200. * @param scene to attach the crowd to
  62201. * @returns the crowd you can add agents to
  62202. */
  62203. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62204. /**
  62205. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62206. * The queries will try to find a solution within those bounds
  62207. * default is (1,1,1)
  62208. * @param extent x,y,z value that define the extent around the queries point of reference
  62209. */
  62210. setDefaultQueryExtent(extent: Vector3): void;
  62211. /**
  62212. * Get the Bounding box extent specified by setDefaultQueryExtent
  62213. * @returns the box extent values
  62214. */
  62215. getDefaultQueryExtent(): Vector3;
  62216. /**
  62217. * Disposes
  62218. */
  62219. dispose(): void;
  62220. /**
  62221. * If this plugin is supported
  62222. * @returns true if plugin is supported
  62223. */
  62224. isSupported(): boolean;
  62225. }
  62226. /**
  62227. * Recast detour crowd implementation
  62228. */
  62229. export class RecastJSCrowd implements ICrowd {
  62230. /**
  62231. * Recast/detour plugin
  62232. */
  62233. bjsRECASTPlugin: RecastJSPlugin;
  62234. /**
  62235. * Link to the detour crowd
  62236. */
  62237. recastCrowd: any;
  62238. /**
  62239. * One transform per agent
  62240. */
  62241. transforms: TransformNode[];
  62242. /**
  62243. * All agents created
  62244. */
  62245. agents: number[];
  62246. /**
  62247. * Link to the scene is kept to unregister the crowd from the scene
  62248. */
  62249. private _scene;
  62250. /**
  62251. * Observer for crowd updates
  62252. */
  62253. private _onBeforeAnimationsObserver;
  62254. /**
  62255. * Constructor
  62256. * @param plugin recastJS plugin
  62257. * @param maxAgents the maximum agent count in the crowd
  62258. * @param maxAgentRadius the maximum radius an agent can have
  62259. * @param scene to attach the crowd to
  62260. * @returns the crowd you can add agents to
  62261. */
  62262. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62263. /**
  62264. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62265. * You can attach anything to that node. The node position is updated in the scene update tick.
  62266. * @param pos world position that will be constrained by the navigation mesh
  62267. * @param parameters agent parameters
  62268. * @param transform hooked to the agent that will be update by the scene
  62269. * @returns agent index
  62270. */
  62271. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62272. /**
  62273. * Returns the agent position in world space
  62274. * @param index agent index returned by addAgent
  62275. * @returns world space position
  62276. */
  62277. getAgentPosition(index: number): Vector3;
  62278. /**
  62279. * Returns the agent velocity in world space
  62280. * @param index agent index returned by addAgent
  62281. * @returns world space velocity
  62282. */
  62283. getAgentVelocity(index: number): Vector3;
  62284. /**
  62285. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62286. * @param index agent index returned by addAgent
  62287. * @param destination targeted world position
  62288. */
  62289. agentGoto(index: number, destination: Vector3): void;
  62290. /**
  62291. * Teleport the agent to a new position
  62292. * @param index agent index returned by addAgent
  62293. * @param destination targeted world position
  62294. */
  62295. agentTeleport(index: number, destination: Vector3): void;
  62296. /**
  62297. * Update agent parameters
  62298. * @param index agent index returned by addAgent
  62299. * @param parameters agent parameters
  62300. */
  62301. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62302. /**
  62303. * remove a particular agent previously created
  62304. * @param index agent index returned by addAgent
  62305. */
  62306. removeAgent(index: number): void;
  62307. /**
  62308. * get the list of all agents attached to this crowd
  62309. * @returns list of agent indices
  62310. */
  62311. getAgents(): number[];
  62312. /**
  62313. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62314. * @param deltaTime in seconds
  62315. */
  62316. update(deltaTime: number): void;
  62317. /**
  62318. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62319. * The queries will try to find a solution within those bounds
  62320. * default is (1,1,1)
  62321. * @param extent x,y,z value that define the extent around the queries point of reference
  62322. */
  62323. setDefaultQueryExtent(extent: Vector3): void;
  62324. /**
  62325. * Get the Bounding box extent specified by setDefaultQueryExtent
  62326. * @returns the box extent values
  62327. */
  62328. getDefaultQueryExtent(): Vector3;
  62329. /**
  62330. * Release all resources
  62331. */
  62332. dispose(): void;
  62333. }
  62334. }
  62335. declare module BABYLON {
  62336. /**
  62337. * Class used to enable access to IndexedDB
  62338. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62339. */
  62340. export class Database implements IOfflineProvider {
  62341. private _callbackManifestChecked;
  62342. private _currentSceneUrl;
  62343. private _db;
  62344. private _enableSceneOffline;
  62345. private _enableTexturesOffline;
  62346. private _manifestVersionFound;
  62347. private _mustUpdateRessources;
  62348. private _hasReachedQuota;
  62349. private _isSupported;
  62350. private _idbFactory;
  62351. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62352. private static IsUASupportingBlobStorage;
  62353. /**
  62354. * Gets a boolean indicating if Database storate is enabled (off by default)
  62355. */
  62356. static IDBStorageEnabled: boolean;
  62357. /**
  62358. * Gets a boolean indicating if scene must be saved in the database
  62359. */
  62360. get enableSceneOffline(): boolean;
  62361. /**
  62362. * Gets a boolean indicating if textures must be saved in the database
  62363. */
  62364. get enableTexturesOffline(): boolean;
  62365. /**
  62366. * Creates a new Database
  62367. * @param urlToScene defines the url to load the scene
  62368. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62369. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62370. */
  62371. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62372. private static _ParseURL;
  62373. private static _ReturnFullUrlLocation;
  62374. private _checkManifestFile;
  62375. /**
  62376. * Open the database and make it available
  62377. * @param successCallback defines the callback to call on success
  62378. * @param errorCallback defines the callback to call on error
  62379. */
  62380. open(successCallback: () => void, errorCallback: () => void): void;
  62381. /**
  62382. * Loads an image from the database
  62383. * @param url defines the url to load from
  62384. * @param image defines the target DOM image
  62385. */
  62386. loadImage(url: string, image: HTMLImageElement): void;
  62387. private _loadImageFromDBAsync;
  62388. private _saveImageIntoDBAsync;
  62389. private _checkVersionFromDB;
  62390. private _loadVersionFromDBAsync;
  62391. private _saveVersionIntoDBAsync;
  62392. /**
  62393. * Loads a file from database
  62394. * @param url defines the URL to load from
  62395. * @param sceneLoaded defines a callback to call on success
  62396. * @param progressCallBack defines a callback to call when progress changed
  62397. * @param errorCallback defines a callback to call on error
  62398. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62399. */
  62400. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62401. private _loadFileAsync;
  62402. private _saveFileAsync;
  62403. /**
  62404. * Validates if xhr data is correct
  62405. * @param xhr defines the request to validate
  62406. * @param dataType defines the expected data type
  62407. * @returns true if data is correct
  62408. */
  62409. private static _ValidateXHRData;
  62410. }
  62411. }
  62412. declare module BABYLON {
  62413. /** @hidden */
  62414. export var gpuUpdateParticlesPixelShader: {
  62415. name: string;
  62416. shader: string;
  62417. };
  62418. }
  62419. declare module BABYLON {
  62420. /** @hidden */
  62421. export var gpuUpdateParticlesVertexShader: {
  62422. name: string;
  62423. shader: string;
  62424. };
  62425. }
  62426. declare module BABYLON {
  62427. /** @hidden */
  62428. export var clipPlaneFragmentDeclaration2: {
  62429. name: string;
  62430. shader: string;
  62431. };
  62432. }
  62433. declare module BABYLON {
  62434. /** @hidden */
  62435. export var gpuRenderParticlesPixelShader: {
  62436. name: string;
  62437. shader: string;
  62438. };
  62439. }
  62440. declare module BABYLON {
  62441. /** @hidden */
  62442. export var clipPlaneVertexDeclaration2: {
  62443. name: string;
  62444. shader: string;
  62445. };
  62446. }
  62447. declare module BABYLON {
  62448. /** @hidden */
  62449. export var gpuRenderParticlesVertexShader: {
  62450. name: string;
  62451. shader: string;
  62452. };
  62453. }
  62454. declare module BABYLON {
  62455. /**
  62456. * This represents a GPU particle system in Babylon
  62457. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62458. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62459. */
  62460. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62461. /**
  62462. * The layer mask we are rendering the particles through.
  62463. */
  62464. layerMask: number;
  62465. private _capacity;
  62466. private _activeCount;
  62467. private _currentActiveCount;
  62468. private _accumulatedCount;
  62469. private _renderEffect;
  62470. private _updateEffect;
  62471. private _buffer0;
  62472. private _buffer1;
  62473. private _spriteBuffer;
  62474. private _updateVAO;
  62475. private _renderVAO;
  62476. private _targetIndex;
  62477. private _sourceBuffer;
  62478. private _targetBuffer;
  62479. private _engine;
  62480. private _currentRenderId;
  62481. private _started;
  62482. private _stopped;
  62483. private _timeDelta;
  62484. private _randomTexture;
  62485. private _randomTexture2;
  62486. private _attributesStrideSize;
  62487. private _updateEffectOptions;
  62488. private _randomTextureSize;
  62489. private _actualFrame;
  62490. private readonly _rawTextureWidth;
  62491. /**
  62492. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62493. */
  62494. static get IsSupported(): boolean;
  62495. /**
  62496. * An event triggered when the system is disposed.
  62497. */
  62498. onDisposeObservable: Observable<GPUParticleSystem>;
  62499. /**
  62500. * Gets the maximum number of particles active at the same time.
  62501. * @returns The max number of active particles.
  62502. */
  62503. getCapacity(): number;
  62504. /**
  62505. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62506. * to override the particles.
  62507. */
  62508. forceDepthWrite: boolean;
  62509. /**
  62510. * Gets or set the number of active particles
  62511. */
  62512. get activeParticleCount(): number;
  62513. set activeParticleCount(value: number);
  62514. private _preWarmDone;
  62515. /**
  62516. * Is this system ready to be used/rendered
  62517. * @return true if the system is ready
  62518. */
  62519. isReady(): boolean;
  62520. /**
  62521. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62522. * @returns True if it has been started, otherwise false.
  62523. */
  62524. isStarted(): boolean;
  62525. /**
  62526. * Starts the particle system and begins to emit
  62527. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62528. */
  62529. start(delay?: number): void;
  62530. /**
  62531. * Stops the particle system.
  62532. */
  62533. stop(): void;
  62534. /**
  62535. * Remove all active particles
  62536. */
  62537. reset(): void;
  62538. /**
  62539. * Returns the string "GPUParticleSystem"
  62540. * @returns a string containing the class name
  62541. */
  62542. getClassName(): string;
  62543. private _colorGradientsTexture;
  62544. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62545. /**
  62546. * Adds a new color gradient
  62547. * @param gradient defines the gradient to use (between 0 and 1)
  62548. * @param color1 defines the color to affect to the specified gradient
  62549. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62550. * @returns the current particle system
  62551. */
  62552. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62553. /**
  62554. * Remove a specific color gradient
  62555. * @param gradient defines the gradient to remove
  62556. * @returns the current particle system
  62557. */
  62558. removeColorGradient(gradient: number): GPUParticleSystem;
  62559. private _angularSpeedGradientsTexture;
  62560. private _sizeGradientsTexture;
  62561. private _velocityGradientsTexture;
  62562. private _limitVelocityGradientsTexture;
  62563. private _dragGradientsTexture;
  62564. private _addFactorGradient;
  62565. /**
  62566. * Adds a new size gradient
  62567. * @param gradient defines the gradient to use (between 0 and 1)
  62568. * @param factor defines the size factor to affect to the specified gradient
  62569. * @returns the current particle system
  62570. */
  62571. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62572. /**
  62573. * Remove a specific size gradient
  62574. * @param gradient defines the gradient to remove
  62575. * @returns the current particle system
  62576. */
  62577. removeSizeGradient(gradient: number): GPUParticleSystem;
  62578. /**
  62579. * Adds a new angular speed gradient
  62580. * @param gradient defines the gradient to use (between 0 and 1)
  62581. * @param factor defines the angular speed to affect to the specified gradient
  62582. * @returns the current particle system
  62583. */
  62584. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62585. /**
  62586. * Remove a specific angular speed gradient
  62587. * @param gradient defines the gradient to remove
  62588. * @returns the current particle system
  62589. */
  62590. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62591. /**
  62592. * Adds a new velocity gradient
  62593. * @param gradient defines the gradient to use (between 0 and 1)
  62594. * @param factor defines the velocity to affect to the specified gradient
  62595. * @returns the current particle system
  62596. */
  62597. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62598. /**
  62599. * Remove a specific velocity gradient
  62600. * @param gradient defines the gradient to remove
  62601. * @returns the current particle system
  62602. */
  62603. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62604. /**
  62605. * Adds a new limit velocity gradient
  62606. * @param gradient defines the gradient to use (between 0 and 1)
  62607. * @param factor defines the limit velocity value to affect to the specified gradient
  62608. * @returns the current particle system
  62609. */
  62610. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62611. /**
  62612. * Remove a specific limit velocity gradient
  62613. * @param gradient defines the gradient to remove
  62614. * @returns the current particle system
  62615. */
  62616. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62617. /**
  62618. * Adds a new drag gradient
  62619. * @param gradient defines the gradient to use (between 0 and 1)
  62620. * @param factor defines the drag value to affect to the specified gradient
  62621. * @returns the current particle system
  62622. */
  62623. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62624. /**
  62625. * Remove a specific drag gradient
  62626. * @param gradient defines the gradient to remove
  62627. * @returns the current particle system
  62628. */
  62629. removeDragGradient(gradient: number): GPUParticleSystem;
  62630. /**
  62631. * Not supported by GPUParticleSystem
  62632. * @param gradient defines the gradient to use (between 0 and 1)
  62633. * @param factor defines the emit rate value to affect to the specified gradient
  62634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62635. * @returns the current particle system
  62636. */
  62637. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62638. /**
  62639. * Not supported by GPUParticleSystem
  62640. * @param gradient defines the gradient to remove
  62641. * @returns the current particle system
  62642. */
  62643. removeEmitRateGradient(gradient: number): IParticleSystem;
  62644. /**
  62645. * Not supported by GPUParticleSystem
  62646. * @param gradient defines the gradient to use (between 0 and 1)
  62647. * @param factor defines the start size value to affect to the specified gradient
  62648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62649. * @returns the current particle system
  62650. */
  62651. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62652. /**
  62653. * Not supported by GPUParticleSystem
  62654. * @param gradient defines the gradient to remove
  62655. * @returns the current particle system
  62656. */
  62657. removeStartSizeGradient(gradient: number): IParticleSystem;
  62658. /**
  62659. * Not supported by GPUParticleSystem
  62660. * @param gradient defines the gradient to use (between 0 and 1)
  62661. * @param min defines the color remap minimal range
  62662. * @param max defines the color remap maximal range
  62663. * @returns the current particle system
  62664. */
  62665. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62666. /**
  62667. * Not supported by GPUParticleSystem
  62668. * @param gradient defines the gradient to remove
  62669. * @returns the current particle system
  62670. */
  62671. removeColorRemapGradient(): IParticleSystem;
  62672. /**
  62673. * Not supported by GPUParticleSystem
  62674. * @param gradient defines the gradient to use (between 0 and 1)
  62675. * @param min defines the alpha remap minimal range
  62676. * @param max defines the alpha remap maximal range
  62677. * @returns the current particle system
  62678. */
  62679. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62680. /**
  62681. * Not supported by GPUParticleSystem
  62682. * @param gradient defines the gradient to remove
  62683. * @returns the current particle system
  62684. */
  62685. removeAlphaRemapGradient(): IParticleSystem;
  62686. /**
  62687. * Not supported by GPUParticleSystem
  62688. * @param gradient defines the gradient to use (between 0 and 1)
  62689. * @param color defines the color to affect to the specified gradient
  62690. * @returns the current particle system
  62691. */
  62692. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62693. /**
  62694. * Not supported by GPUParticleSystem
  62695. * @param gradient defines the gradient to remove
  62696. * @returns the current particle system
  62697. */
  62698. removeRampGradient(): IParticleSystem;
  62699. /**
  62700. * Not supported by GPUParticleSystem
  62701. * @returns the list of ramp gradients
  62702. */
  62703. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62704. /**
  62705. * Not supported by GPUParticleSystem
  62706. * Gets or sets a boolean indicating that ramp gradients must be used
  62707. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62708. */
  62709. get useRampGradients(): boolean;
  62710. set useRampGradients(value: boolean);
  62711. /**
  62712. * Not supported by GPUParticleSystem
  62713. * @param gradient defines the gradient to use (between 0 and 1)
  62714. * @param factor defines the life time factor to affect to the specified gradient
  62715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62716. * @returns the current particle system
  62717. */
  62718. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62719. /**
  62720. * Not supported by GPUParticleSystem
  62721. * @param gradient defines the gradient to remove
  62722. * @returns the current particle system
  62723. */
  62724. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62725. /**
  62726. * Instantiates a GPU particle system.
  62727. * 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.
  62728. * @param name The name of the particle system
  62729. * @param options The options used to create the system
  62730. * @param scene The scene the particle system belongs to
  62731. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62732. */
  62733. constructor(name: string, options: Partial<{
  62734. capacity: number;
  62735. randomTextureSize: number;
  62736. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62737. protected _reset(): void;
  62738. private _createUpdateVAO;
  62739. private _createRenderVAO;
  62740. private _initialize;
  62741. /** @hidden */
  62742. _recreateUpdateEffect(): void;
  62743. /** @hidden */
  62744. _recreateRenderEffect(): void;
  62745. /**
  62746. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62747. * @param preWarm defines if we are in the pre-warmimg phase
  62748. */
  62749. animate(preWarm?: boolean): void;
  62750. private _createFactorGradientTexture;
  62751. private _createSizeGradientTexture;
  62752. private _createAngularSpeedGradientTexture;
  62753. private _createVelocityGradientTexture;
  62754. private _createLimitVelocityGradientTexture;
  62755. private _createDragGradientTexture;
  62756. private _createColorGradientTexture;
  62757. /**
  62758. * Renders the particle system in its current state
  62759. * @param preWarm defines if the system should only update the particles but not render them
  62760. * @returns the current number of particles
  62761. */
  62762. render(preWarm?: boolean): number;
  62763. /**
  62764. * Rebuilds the particle system
  62765. */
  62766. rebuild(): void;
  62767. private _releaseBuffers;
  62768. private _releaseVAOs;
  62769. /**
  62770. * Disposes the particle system and free the associated resources
  62771. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62772. */
  62773. dispose(disposeTexture?: boolean): void;
  62774. /**
  62775. * Clones the particle system.
  62776. * @param name The name of the cloned object
  62777. * @param newEmitter The new emitter to use
  62778. * @returns the cloned particle system
  62779. */
  62780. clone(name: string, newEmitter: any): GPUParticleSystem;
  62781. /**
  62782. * Serializes the particle system to a JSON object.
  62783. * @returns the JSON object
  62784. */
  62785. serialize(): any;
  62786. /**
  62787. * Parses a JSON object to create a GPU particle system.
  62788. * @param parsedParticleSystem The JSON object to parse
  62789. * @param scene The scene to create the particle system in
  62790. * @param rootUrl The root url to use to load external dependencies like texture
  62791. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62792. * @returns the parsed GPU particle system
  62793. */
  62794. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62795. }
  62796. }
  62797. declare module BABYLON {
  62798. /**
  62799. * Represents a set of particle systems working together to create a specific effect
  62800. */
  62801. export class ParticleSystemSet implements IDisposable {
  62802. /**
  62803. * Gets or sets base Assets URL
  62804. */
  62805. static BaseAssetsUrl: string;
  62806. private _emitterCreationOptions;
  62807. private _emitterNode;
  62808. /**
  62809. * Gets the particle system list
  62810. */
  62811. systems: IParticleSystem[];
  62812. /**
  62813. * Gets the emitter node used with this set
  62814. */
  62815. get emitterNode(): Nullable<TransformNode>;
  62816. /**
  62817. * Creates a new emitter mesh as a sphere
  62818. * @param options defines the options used to create the sphere
  62819. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62820. * @param scene defines the hosting scene
  62821. */
  62822. setEmitterAsSphere(options: {
  62823. diameter: number;
  62824. segments: number;
  62825. color: Color3;
  62826. }, renderingGroupId: number, scene: Scene): void;
  62827. /**
  62828. * Starts all particle systems of the set
  62829. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62830. */
  62831. start(emitter?: AbstractMesh): void;
  62832. /**
  62833. * Release all associated resources
  62834. */
  62835. dispose(): void;
  62836. /**
  62837. * Serialize the set into a JSON compatible object
  62838. * @returns a JSON compatible representation of the set
  62839. */
  62840. serialize(): any;
  62841. /**
  62842. * Parse a new ParticleSystemSet from a serialized source
  62843. * @param data defines a JSON compatible representation of the set
  62844. * @param scene defines the hosting scene
  62845. * @param gpu defines if we want GPU particles or CPU particles
  62846. * @returns a new ParticleSystemSet
  62847. */
  62848. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62849. }
  62850. }
  62851. declare module BABYLON {
  62852. /**
  62853. * This class is made for on one-liner static method to help creating particle system set.
  62854. */
  62855. export class ParticleHelper {
  62856. /**
  62857. * Gets or sets base Assets URL
  62858. */
  62859. static BaseAssetsUrl: string;
  62860. /**
  62861. * Create a default particle system that you can tweak
  62862. * @param emitter defines the emitter to use
  62863. * @param capacity defines the system capacity (default is 500 particles)
  62864. * @param scene defines the hosting scene
  62865. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62866. * @returns the new Particle system
  62867. */
  62868. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62869. /**
  62870. * This is the main static method (one-liner) of this helper to create different particle systems
  62871. * @param type This string represents the type to the particle system to create
  62872. * @param scene The scene where the particle system should live
  62873. * @param gpu If the system will use gpu
  62874. * @returns the ParticleSystemSet created
  62875. */
  62876. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62877. /**
  62878. * Static function used to export a particle system to a ParticleSystemSet variable.
  62879. * Please note that the emitter shape is not exported
  62880. * @param systems defines the particle systems to export
  62881. * @returns the created particle system set
  62882. */
  62883. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62884. }
  62885. }
  62886. declare module BABYLON {
  62887. interface Engine {
  62888. /**
  62889. * Create an effect to use with particle systems.
  62890. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62891. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62892. * @param uniformsNames defines a list of attribute names
  62893. * @param samplers defines an array of string used to represent textures
  62894. * @param defines defines the string containing the defines to use to compile the shaders
  62895. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62896. * @param onCompiled defines a function to call when the effect creation is successful
  62897. * @param onError defines a function to call when the effect creation has failed
  62898. * @returns the new Effect
  62899. */
  62900. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62901. }
  62902. interface Mesh {
  62903. /**
  62904. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62905. * @returns an array of IParticleSystem
  62906. */
  62907. getEmittedParticleSystems(): IParticleSystem[];
  62908. /**
  62909. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62910. * @returns an array of IParticleSystem
  62911. */
  62912. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62913. }
  62914. /**
  62915. * @hidden
  62916. */
  62917. export var _IDoNeedToBeInTheBuild: number;
  62918. }
  62919. declare module BABYLON {
  62920. /** Defines the 4 color options */
  62921. export enum PointColor {
  62922. /** color value */
  62923. Color = 2,
  62924. /** uv value */
  62925. UV = 1,
  62926. /** random value */
  62927. Random = 0,
  62928. /** stated value */
  62929. Stated = 3
  62930. }
  62931. /**
  62932. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62933. * 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.
  62934. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62935. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62936. *
  62937. * Full documentation here : TO BE ENTERED
  62938. */
  62939. export class PointsCloudSystem implements IDisposable {
  62940. /**
  62941. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62942. * Example : var p = SPS.particles[i];
  62943. */
  62944. particles: CloudPoint[];
  62945. /**
  62946. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62947. */
  62948. nbParticles: number;
  62949. /**
  62950. * This a counter for your own usage. It's not set by any SPS functions.
  62951. */
  62952. counter: number;
  62953. /**
  62954. * The PCS name. This name is also given to the underlying mesh.
  62955. */
  62956. name: string;
  62957. /**
  62958. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62959. */
  62960. mesh: Mesh;
  62961. /**
  62962. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62963. * Please read :
  62964. */
  62965. vars: any;
  62966. /**
  62967. * @hidden
  62968. */
  62969. _size: number;
  62970. private _scene;
  62971. private _promises;
  62972. private _positions;
  62973. private _indices;
  62974. private _normals;
  62975. private _colors;
  62976. private _uvs;
  62977. private _indices32;
  62978. private _positions32;
  62979. private _colors32;
  62980. private _uvs32;
  62981. private _updatable;
  62982. private _isVisibilityBoxLocked;
  62983. private _alwaysVisible;
  62984. private _groups;
  62985. private _groupCounter;
  62986. private _computeParticleColor;
  62987. private _computeParticleTexture;
  62988. private _computeParticleRotation;
  62989. private _computeBoundingBox;
  62990. private _isReady;
  62991. /**
  62992. * Creates a PCS (Points Cloud System) object
  62993. * @param name (String) is the PCS name, this will be the underlying mesh name
  62994. * @param pointSize (number) is the size for each point
  62995. * @param scene (Scene) is the scene in which the PCS is added
  62996. * @param options defines the options of the PCS e.g.
  62997. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62998. */
  62999. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63000. updatable?: boolean;
  63001. });
  63002. /**
  63003. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63004. * If no points were added to the PCS, the returned mesh is just a single point.
  63005. * @returns a promise for the created mesh
  63006. */
  63007. buildMeshAsync(): Promise<Mesh>;
  63008. /**
  63009. * @hidden
  63010. */
  63011. private _buildMesh;
  63012. private _addParticle;
  63013. private _randomUnitVector;
  63014. private _getColorIndicesForCoord;
  63015. private _setPointsColorOrUV;
  63016. private _colorFromTexture;
  63017. private _calculateDensity;
  63018. /**
  63019. * Adds points to the PCS in random positions within a unit sphere
  63020. * @param nb (positive integer) the number of particles to be created from this model
  63021. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63022. * @returns the number of groups in the system
  63023. */
  63024. addPoints(nb: number, pointFunction?: any): number;
  63025. /**
  63026. * Adds points to the PCS from the surface of the model shape
  63027. * @param mesh is any Mesh object that will be used as a surface model for the points
  63028. * @param nb (positive integer) the number of particles to be created from this model
  63029. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63030. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63031. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63032. * @returns the number of groups in the system
  63033. */
  63034. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63035. /**
  63036. * Adds points to the PCS inside the model shape
  63037. * @param mesh is any Mesh object that will be used as a surface model for the points
  63038. * @param nb (positive integer) the number of particles to be created from this model
  63039. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63040. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63041. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63042. * @returns the number of groups in the system
  63043. */
  63044. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63045. /**
  63046. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63047. * This method calls `updateParticle()` for each particle of the SPS.
  63048. * For an animated SPS, it is usually called within the render loop.
  63049. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63050. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63051. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63052. * @returns the PCS.
  63053. */
  63054. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63055. /**
  63056. * Disposes the PCS.
  63057. */
  63058. dispose(): void;
  63059. /**
  63060. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63061. * doc :
  63062. * @returns the PCS.
  63063. */
  63064. refreshVisibleSize(): PointsCloudSystem;
  63065. /**
  63066. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63067. * @param size the size (float) of the visibility box
  63068. * note : this doesn't lock the PCS mesh bounding box.
  63069. * doc :
  63070. */
  63071. setVisibilityBox(size: number): void;
  63072. /**
  63073. * Gets whether the PCS is always visible or not
  63074. * doc :
  63075. */
  63076. get isAlwaysVisible(): boolean;
  63077. /**
  63078. * Sets the PCS as always visible or not
  63079. * doc :
  63080. */
  63081. set isAlwaysVisible(val: boolean);
  63082. /**
  63083. * Tells to `setParticles()` to compute the particle rotations or not
  63084. * Default value : false. The PCS is faster when it's set to false
  63085. * Note : particle rotations are only applied to parent particles
  63086. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63087. */
  63088. set computeParticleRotation(val: boolean);
  63089. /**
  63090. * Tells to `setParticles()` to compute the particle colors or not.
  63091. * Default value : true. The PCS is faster when it's set to false.
  63092. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63093. */
  63094. set computeParticleColor(val: boolean);
  63095. set computeParticleTexture(val: boolean);
  63096. /**
  63097. * Gets if `setParticles()` computes the particle colors or not.
  63098. * Default value : false. The PCS is faster when it's set to false.
  63099. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63100. */
  63101. get computeParticleColor(): boolean;
  63102. /**
  63103. * Gets if `setParticles()` computes the particle textures or not.
  63104. * Default value : false. The PCS is faster when it's set to false.
  63105. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63106. */
  63107. get computeParticleTexture(): boolean;
  63108. /**
  63109. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63110. */
  63111. set computeBoundingBox(val: boolean);
  63112. /**
  63113. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63114. */
  63115. get computeBoundingBox(): boolean;
  63116. /**
  63117. * This function does nothing. It may be overwritten to set all the particle first values.
  63118. * The PCS doesn't call this function, you may have to call it by your own.
  63119. * doc :
  63120. */
  63121. initParticles(): void;
  63122. /**
  63123. * This function does nothing. It may be overwritten to recycle a particle
  63124. * The PCS doesn't call this function, you can to call it
  63125. * doc :
  63126. * @param particle The particle to recycle
  63127. * @returns the recycled particle
  63128. */
  63129. recycleParticle(particle: CloudPoint): CloudPoint;
  63130. /**
  63131. * Updates a particle : this function should be overwritten by the user.
  63132. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63133. * doc :
  63134. * @example : just set a particle position or velocity and recycle conditions
  63135. * @param particle The particle to update
  63136. * @returns the updated particle
  63137. */
  63138. updateParticle(particle: CloudPoint): CloudPoint;
  63139. /**
  63140. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63141. * This does nothing and may be overwritten by the user.
  63142. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63143. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63144. * @param update the boolean update value actually passed to setParticles()
  63145. */
  63146. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63147. /**
  63148. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63149. * This will be passed three parameters.
  63150. * This does nothing and may be overwritten by the user.
  63151. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63152. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63153. * @param update the boolean update value actually passed to setParticles()
  63154. */
  63155. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63156. }
  63157. }
  63158. declare module BABYLON {
  63159. /**
  63160. * Represents one particle of a points cloud system.
  63161. */
  63162. export class CloudPoint {
  63163. /**
  63164. * particle global index
  63165. */
  63166. idx: number;
  63167. /**
  63168. * The color of the particle
  63169. */
  63170. color: Nullable<Color4>;
  63171. /**
  63172. * The world space position of the particle.
  63173. */
  63174. position: Vector3;
  63175. /**
  63176. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63177. */
  63178. rotation: Vector3;
  63179. /**
  63180. * The world space rotation quaternion of the particle.
  63181. */
  63182. rotationQuaternion: Nullable<Quaternion>;
  63183. /**
  63184. * The uv of the particle.
  63185. */
  63186. uv: Nullable<Vector2>;
  63187. /**
  63188. * The current speed of the particle.
  63189. */
  63190. velocity: Vector3;
  63191. /**
  63192. * The pivot point in the particle local space.
  63193. */
  63194. pivot: Vector3;
  63195. /**
  63196. * Must the particle be translated from its pivot point in its local space ?
  63197. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63198. * Default : false
  63199. */
  63200. translateFromPivot: boolean;
  63201. /**
  63202. * Index of this particle in the global "positions" array (Internal use)
  63203. * @hidden
  63204. */
  63205. _pos: number;
  63206. /**
  63207. * @hidden Index of this particle in the global "indices" array (Internal use)
  63208. */
  63209. _ind: number;
  63210. /**
  63211. * Group this particle belongs to
  63212. */
  63213. _group: PointsGroup;
  63214. /**
  63215. * Group id of this particle
  63216. */
  63217. groupId: number;
  63218. /**
  63219. * Index of the particle in its group id (Internal use)
  63220. */
  63221. idxInGroup: number;
  63222. /**
  63223. * @hidden Particle BoundingInfo object (Internal use)
  63224. */
  63225. _boundingInfo: BoundingInfo;
  63226. /**
  63227. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63228. */
  63229. _pcs: PointsCloudSystem;
  63230. /**
  63231. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63232. */
  63233. _stillInvisible: boolean;
  63234. /**
  63235. * @hidden Last computed particle rotation matrix
  63236. */
  63237. _rotationMatrix: number[];
  63238. /**
  63239. * Parent particle Id, if any.
  63240. * Default null.
  63241. */
  63242. parentId: Nullable<number>;
  63243. /**
  63244. * @hidden Internal global position in the PCS.
  63245. */
  63246. _globalPosition: Vector3;
  63247. /**
  63248. * Creates a Point Cloud object.
  63249. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63250. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63251. * @param group (PointsGroup) is the group the particle belongs to
  63252. * @param groupId (integer) is the group identifier in the PCS.
  63253. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63254. * @param pcs defines the PCS it is associated to
  63255. */
  63256. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63257. /**
  63258. * get point size
  63259. */
  63260. get size(): Vector3;
  63261. /**
  63262. * Set point size
  63263. */
  63264. set size(scale: Vector3);
  63265. /**
  63266. * Legacy support, changed quaternion to rotationQuaternion
  63267. */
  63268. get quaternion(): Nullable<Quaternion>;
  63269. /**
  63270. * Legacy support, changed quaternion to rotationQuaternion
  63271. */
  63272. set quaternion(q: Nullable<Quaternion>);
  63273. /**
  63274. * Returns a boolean. True if the particle intersects a mesh, else false
  63275. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63276. * @param target is the object (point or mesh) what the intersection is computed against
  63277. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63278. * @returns true if it intersects
  63279. */
  63280. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63281. /**
  63282. * get the rotation matrix of the particle
  63283. * @hidden
  63284. */
  63285. getRotationMatrix(m: Matrix): void;
  63286. }
  63287. /**
  63288. * Represents a group of points in a points cloud system
  63289. * * PCS internal tool, don't use it manually.
  63290. */
  63291. export class PointsGroup {
  63292. /**
  63293. * The group id
  63294. * @hidden
  63295. */
  63296. groupID: number;
  63297. /**
  63298. * image data for group (internal use)
  63299. * @hidden
  63300. */
  63301. _groupImageData: Nullable<ArrayBufferView>;
  63302. /**
  63303. * Image Width (internal use)
  63304. * @hidden
  63305. */
  63306. _groupImgWidth: number;
  63307. /**
  63308. * Image Height (internal use)
  63309. * @hidden
  63310. */
  63311. _groupImgHeight: number;
  63312. /**
  63313. * Custom position function (internal use)
  63314. * @hidden
  63315. */
  63316. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63317. /**
  63318. * density per facet for surface points
  63319. * @hidden
  63320. */
  63321. _groupDensity: number[];
  63322. /**
  63323. * Only when points are colored by texture carries pointer to texture list array
  63324. * @hidden
  63325. */
  63326. _textureNb: number;
  63327. /**
  63328. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63329. * PCS internal tool, don't use it manually.
  63330. * @hidden
  63331. */
  63332. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63333. }
  63334. }
  63335. declare module BABYLON {
  63336. interface Scene {
  63337. /** @hidden (Backing field) */
  63338. _physicsEngine: Nullable<IPhysicsEngine>;
  63339. /** @hidden */
  63340. _physicsTimeAccumulator: number;
  63341. /**
  63342. * Gets the current physics engine
  63343. * @returns a IPhysicsEngine or null if none attached
  63344. */
  63345. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63346. /**
  63347. * Enables physics to the current scene
  63348. * @param gravity defines the scene's gravity for the physics engine
  63349. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63350. * @return a boolean indicating if the physics engine was initialized
  63351. */
  63352. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63353. /**
  63354. * Disables and disposes the physics engine associated with the scene
  63355. */
  63356. disablePhysicsEngine(): void;
  63357. /**
  63358. * Gets a boolean indicating if there is an active physics engine
  63359. * @returns a boolean indicating if there is an active physics engine
  63360. */
  63361. isPhysicsEnabled(): boolean;
  63362. /**
  63363. * Deletes a physics compound impostor
  63364. * @param compound defines the compound to delete
  63365. */
  63366. deleteCompoundImpostor(compound: any): void;
  63367. /**
  63368. * An event triggered when physic simulation is about to be run
  63369. */
  63370. onBeforePhysicsObservable: Observable<Scene>;
  63371. /**
  63372. * An event triggered when physic simulation has been done
  63373. */
  63374. onAfterPhysicsObservable: Observable<Scene>;
  63375. }
  63376. interface AbstractMesh {
  63377. /** @hidden */
  63378. _physicsImpostor: Nullable<PhysicsImpostor>;
  63379. /**
  63380. * Gets or sets impostor used for physic simulation
  63381. * @see http://doc.babylonjs.com/features/physics_engine
  63382. */
  63383. physicsImpostor: Nullable<PhysicsImpostor>;
  63384. /**
  63385. * Gets the current physics impostor
  63386. * @see http://doc.babylonjs.com/features/physics_engine
  63387. * @returns a physics impostor or null
  63388. */
  63389. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63390. /** Apply a physic impulse to the mesh
  63391. * @param force defines the force to apply
  63392. * @param contactPoint defines where to apply the force
  63393. * @returns the current mesh
  63394. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63395. */
  63396. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63397. /**
  63398. * Creates a physic joint between two meshes
  63399. * @param otherMesh defines the other mesh to use
  63400. * @param pivot1 defines the pivot to use on this mesh
  63401. * @param pivot2 defines the pivot to use on the other mesh
  63402. * @param options defines additional options (can be plugin dependent)
  63403. * @returns the current mesh
  63404. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63405. */
  63406. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63407. /** @hidden */
  63408. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63409. }
  63410. /**
  63411. * Defines the physics engine scene component responsible to manage a physics engine
  63412. */
  63413. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63414. /**
  63415. * The component name helpful to identify the component in the list of scene components.
  63416. */
  63417. readonly name: string;
  63418. /**
  63419. * The scene the component belongs to.
  63420. */
  63421. scene: Scene;
  63422. /**
  63423. * Creates a new instance of the component for the given scene
  63424. * @param scene Defines the scene to register the component in
  63425. */
  63426. constructor(scene: Scene);
  63427. /**
  63428. * Registers the component in a given scene
  63429. */
  63430. register(): void;
  63431. /**
  63432. * Rebuilds the elements related to this component in case of
  63433. * context lost for instance.
  63434. */
  63435. rebuild(): void;
  63436. /**
  63437. * Disposes the component and the associated ressources
  63438. */
  63439. dispose(): void;
  63440. }
  63441. }
  63442. declare module BABYLON {
  63443. /**
  63444. * A helper for physics simulations
  63445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63446. */
  63447. export class PhysicsHelper {
  63448. private _scene;
  63449. private _physicsEngine;
  63450. /**
  63451. * Initializes the Physics helper
  63452. * @param scene Babylon.js scene
  63453. */
  63454. constructor(scene: Scene);
  63455. /**
  63456. * Applies a radial explosion impulse
  63457. * @param origin the origin of the explosion
  63458. * @param radiusOrEventOptions the radius or the options of radial explosion
  63459. * @param strength the explosion strength
  63460. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63461. * @returns A physics radial explosion event, or null
  63462. */
  63463. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63464. /**
  63465. * Applies a radial explosion force
  63466. * @param origin the origin of the explosion
  63467. * @param radiusOrEventOptions the radius or the options of radial explosion
  63468. * @param strength the explosion strength
  63469. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63470. * @returns A physics radial explosion event, or null
  63471. */
  63472. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63473. /**
  63474. * Creates a gravitational field
  63475. * @param origin the origin of the explosion
  63476. * @param radiusOrEventOptions the radius or the options of radial explosion
  63477. * @param strength the explosion strength
  63478. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63479. * @returns A physics gravitational field event, or null
  63480. */
  63481. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63482. /**
  63483. * Creates a physics updraft event
  63484. * @param origin the origin of the updraft
  63485. * @param radiusOrEventOptions the radius or the options of the updraft
  63486. * @param strength the strength of the updraft
  63487. * @param height the height of the updraft
  63488. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63489. * @returns A physics updraft event, or null
  63490. */
  63491. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63492. /**
  63493. * Creates a physics vortex event
  63494. * @param origin the of the vortex
  63495. * @param radiusOrEventOptions the radius or the options of the vortex
  63496. * @param strength the strength of the vortex
  63497. * @param height the height of the vortex
  63498. * @returns a Physics vortex event, or null
  63499. * A physics vortex event or null
  63500. */
  63501. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63502. }
  63503. /**
  63504. * Represents a physics radial explosion event
  63505. */
  63506. class PhysicsRadialExplosionEvent {
  63507. private _scene;
  63508. private _options;
  63509. private _sphere;
  63510. private _dataFetched;
  63511. /**
  63512. * Initializes a radial explosioin event
  63513. * @param _scene BabylonJS scene
  63514. * @param _options The options for the vortex event
  63515. */
  63516. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63517. /**
  63518. * Returns the data related to the radial explosion event (sphere).
  63519. * @returns The radial explosion event data
  63520. */
  63521. getData(): PhysicsRadialExplosionEventData;
  63522. /**
  63523. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63524. * @param impostor A physics imposter
  63525. * @param origin the origin of the explosion
  63526. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63527. */
  63528. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63529. /**
  63530. * Triggers affecterd impostors callbacks
  63531. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63532. */
  63533. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63534. /**
  63535. * Disposes the sphere.
  63536. * @param force Specifies if the sphere should be disposed by force
  63537. */
  63538. dispose(force?: boolean): void;
  63539. /*** Helpers ***/
  63540. private _prepareSphere;
  63541. private _intersectsWithSphere;
  63542. }
  63543. /**
  63544. * Represents a gravitational field event
  63545. */
  63546. class PhysicsGravitationalFieldEvent {
  63547. private _physicsHelper;
  63548. private _scene;
  63549. private _origin;
  63550. private _options;
  63551. private _tickCallback;
  63552. private _sphere;
  63553. private _dataFetched;
  63554. /**
  63555. * Initializes the physics gravitational field event
  63556. * @param _physicsHelper A physics helper
  63557. * @param _scene BabylonJS scene
  63558. * @param _origin The origin position of the gravitational field event
  63559. * @param _options The options for the vortex event
  63560. */
  63561. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63562. /**
  63563. * Returns the data related to the gravitational field event (sphere).
  63564. * @returns A gravitational field event
  63565. */
  63566. getData(): PhysicsGravitationalFieldEventData;
  63567. /**
  63568. * Enables the gravitational field.
  63569. */
  63570. enable(): void;
  63571. /**
  63572. * Disables the gravitational field.
  63573. */
  63574. disable(): void;
  63575. /**
  63576. * Disposes the sphere.
  63577. * @param force The force to dispose from the gravitational field event
  63578. */
  63579. dispose(force?: boolean): void;
  63580. private _tick;
  63581. }
  63582. /**
  63583. * Represents a physics updraft event
  63584. */
  63585. class PhysicsUpdraftEvent {
  63586. private _scene;
  63587. private _origin;
  63588. private _options;
  63589. private _physicsEngine;
  63590. private _originTop;
  63591. private _originDirection;
  63592. private _tickCallback;
  63593. private _cylinder;
  63594. private _cylinderPosition;
  63595. private _dataFetched;
  63596. /**
  63597. * Initializes the physics updraft event
  63598. * @param _scene BabylonJS scene
  63599. * @param _origin The origin position of the updraft
  63600. * @param _options The options for the updraft event
  63601. */
  63602. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63603. /**
  63604. * Returns the data related to the updraft event (cylinder).
  63605. * @returns A physics updraft event
  63606. */
  63607. getData(): PhysicsUpdraftEventData;
  63608. /**
  63609. * Enables the updraft.
  63610. */
  63611. enable(): void;
  63612. /**
  63613. * Disables the updraft.
  63614. */
  63615. disable(): void;
  63616. /**
  63617. * Disposes the cylinder.
  63618. * @param force Specifies if the updraft should be disposed by force
  63619. */
  63620. dispose(force?: boolean): void;
  63621. private getImpostorHitData;
  63622. private _tick;
  63623. /*** Helpers ***/
  63624. private _prepareCylinder;
  63625. private _intersectsWithCylinder;
  63626. }
  63627. /**
  63628. * Represents a physics vortex event
  63629. */
  63630. class PhysicsVortexEvent {
  63631. private _scene;
  63632. private _origin;
  63633. private _options;
  63634. private _physicsEngine;
  63635. private _originTop;
  63636. private _tickCallback;
  63637. private _cylinder;
  63638. private _cylinderPosition;
  63639. private _dataFetched;
  63640. /**
  63641. * Initializes the physics vortex event
  63642. * @param _scene The BabylonJS scene
  63643. * @param _origin The origin position of the vortex
  63644. * @param _options The options for the vortex event
  63645. */
  63646. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63647. /**
  63648. * Returns the data related to the vortex event (cylinder).
  63649. * @returns The physics vortex event data
  63650. */
  63651. getData(): PhysicsVortexEventData;
  63652. /**
  63653. * Enables the vortex.
  63654. */
  63655. enable(): void;
  63656. /**
  63657. * Disables the cortex.
  63658. */
  63659. disable(): void;
  63660. /**
  63661. * Disposes the sphere.
  63662. * @param force
  63663. */
  63664. dispose(force?: boolean): void;
  63665. private getImpostorHitData;
  63666. private _tick;
  63667. /*** Helpers ***/
  63668. private _prepareCylinder;
  63669. private _intersectsWithCylinder;
  63670. }
  63671. /**
  63672. * Options fot the radial explosion event
  63673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63674. */
  63675. export class PhysicsRadialExplosionEventOptions {
  63676. /**
  63677. * The radius of the sphere for the radial explosion.
  63678. */
  63679. radius: number;
  63680. /**
  63681. * The strenth of the explosion.
  63682. */
  63683. strength: number;
  63684. /**
  63685. * The strenght of the force in correspondence to the distance of the affected object
  63686. */
  63687. falloff: PhysicsRadialImpulseFalloff;
  63688. /**
  63689. * Sphere options for the radial explosion.
  63690. */
  63691. sphere: {
  63692. segments: number;
  63693. diameter: number;
  63694. };
  63695. /**
  63696. * Sphere options for the radial explosion.
  63697. */
  63698. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63699. }
  63700. /**
  63701. * Options fot the updraft event
  63702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63703. */
  63704. export class PhysicsUpdraftEventOptions {
  63705. /**
  63706. * The radius of the cylinder for the vortex
  63707. */
  63708. radius: number;
  63709. /**
  63710. * The strenth of the updraft.
  63711. */
  63712. strength: number;
  63713. /**
  63714. * The height of the cylinder for the updraft.
  63715. */
  63716. height: number;
  63717. /**
  63718. * The mode for the the updraft.
  63719. */
  63720. updraftMode: PhysicsUpdraftMode;
  63721. }
  63722. /**
  63723. * Options fot the vortex event
  63724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63725. */
  63726. export class PhysicsVortexEventOptions {
  63727. /**
  63728. * The radius of the cylinder for the vortex
  63729. */
  63730. radius: number;
  63731. /**
  63732. * The strenth of the vortex.
  63733. */
  63734. strength: number;
  63735. /**
  63736. * The height of the cylinder for the vortex.
  63737. */
  63738. height: number;
  63739. /**
  63740. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63741. */
  63742. centripetalForceThreshold: number;
  63743. /**
  63744. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63745. */
  63746. centripetalForceMultiplier: number;
  63747. /**
  63748. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63749. */
  63750. centrifugalForceMultiplier: number;
  63751. /**
  63752. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63753. */
  63754. updraftForceMultiplier: number;
  63755. }
  63756. /**
  63757. * The strenght of the force in correspondence to the distance of the affected object
  63758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63759. */
  63760. export enum PhysicsRadialImpulseFalloff {
  63761. /** Defines that impulse is constant in strength across it's whole radius */
  63762. Constant = 0,
  63763. /** Defines that impulse gets weaker if it's further from the origin */
  63764. Linear = 1
  63765. }
  63766. /**
  63767. * The strength of the force in correspondence to the distance of the affected object
  63768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63769. */
  63770. export enum PhysicsUpdraftMode {
  63771. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63772. Center = 0,
  63773. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63774. Perpendicular = 1
  63775. }
  63776. /**
  63777. * Interface for a physics hit data
  63778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63779. */
  63780. export interface PhysicsHitData {
  63781. /**
  63782. * The force applied at the contact point
  63783. */
  63784. force: Vector3;
  63785. /**
  63786. * The contact point
  63787. */
  63788. contactPoint: Vector3;
  63789. /**
  63790. * The distance from the origin to the contact point
  63791. */
  63792. distanceFromOrigin: number;
  63793. }
  63794. /**
  63795. * Interface for radial explosion event data
  63796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63797. */
  63798. export interface PhysicsRadialExplosionEventData {
  63799. /**
  63800. * A sphere used for the radial explosion event
  63801. */
  63802. sphere: Mesh;
  63803. }
  63804. /**
  63805. * Interface for gravitational field event data
  63806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63807. */
  63808. export interface PhysicsGravitationalFieldEventData {
  63809. /**
  63810. * A sphere mesh used for the gravitational field event
  63811. */
  63812. sphere: Mesh;
  63813. }
  63814. /**
  63815. * Interface for updraft event data
  63816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63817. */
  63818. export interface PhysicsUpdraftEventData {
  63819. /**
  63820. * A cylinder used for the updraft event
  63821. */
  63822. cylinder: Mesh;
  63823. }
  63824. /**
  63825. * Interface for vortex event data
  63826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63827. */
  63828. export interface PhysicsVortexEventData {
  63829. /**
  63830. * A cylinder used for the vortex event
  63831. */
  63832. cylinder: Mesh;
  63833. }
  63834. /**
  63835. * Interface for an affected physics impostor
  63836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63837. */
  63838. export interface PhysicsAffectedImpostorWithData {
  63839. /**
  63840. * The impostor affected by the effect
  63841. */
  63842. impostor: PhysicsImpostor;
  63843. /**
  63844. * The data about the hit/horce from the explosion
  63845. */
  63846. hitData: PhysicsHitData;
  63847. }
  63848. }
  63849. declare module BABYLON {
  63850. /** @hidden */
  63851. export var blackAndWhitePixelShader: {
  63852. name: string;
  63853. shader: string;
  63854. };
  63855. }
  63856. declare module BABYLON {
  63857. /**
  63858. * Post process used to render in black and white
  63859. */
  63860. export class BlackAndWhitePostProcess extends PostProcess {
  63861. /**
  63862. * Linear about to convert he result to black and white (default: 1)
  63863. */
  63864. degree: number;
  63865. /**
  63866. * Creates a black and white post process
  63867. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63868. * @param name The name of the effect.
  63869. * @param options The required width/height ratio to downsize to before computing the render pass.
  63870. * @param camera The camera to apply the render pass to.
  63871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63872. * @param engine The engine which the post process will be applied. (default: current engine)
  63873. * @param reusable If the post process can be reused on the same frame. (default: false)
  63874. */
  63875. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63876. }
  63877. }
  63878. declare module BABYLON {
  63879. /**
  63880. * This represents a set of one or more post processes in Babylon.
  63881. * A post process can be used to apply a shader to a texture after it is rendered.
  63882. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63883. */
  63884. export class PostProcessRenderEffect {
  63885. private _postProcesses;
  63886. private _getPostProcesses;
  63887. private _singleInstance;
  63888. private _cameras;
  63889. private _indicesForCamera;
  63890. /**
  63891. * Name of the effect
  63892. * @hidden
  63893. */
  63894. _name: string;
  63895. /**
  63896. * Instantiates a post process render effect.
  63897. * A post process can be used to apply a shader to a texture after it is rendered.
  63898. * @param engine The engine the effect is tied to
  63899. * @param name The name of the effect
  63900. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63901. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63902. */
  63903. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63904. /**
  63905. * Checks if all the post processes in the effect are supported.
  63906. */
  63907. get isSupported(): boolean;
  63908. /**
  63909. * Updates the current state of the effect
  63910. * @hidden
  63911. */
  63912. _update(): void;
  63913. /**
  63914. * Attaches the effect on cameras
  63915. * @param cameras The camera to attach to.
  63916. * @hidden
  63917. */
  63918. _attachCameras(cameras: Camera): void;
  63919. /**
  63920. * Attaches the effect on cameras
  63921. * @param cameras The camera to attach to.
  63922. * @hidden
  63923. */
  63924. _attachCameras(cameras: Camera[]): void;
  63925. /**
  63926. * Detaches the effect on cameras
  63927. * @param cameras The camera to detatch from.
  63928. * @hidden
  63929. */
  63930. _detachCameras(cameras: Camera): void;
  63931. /**
  63932. * Detatches the effect on cameras
  63933. * @param cameras The camera to detatch from.
  63934. * @hidden
  63935. */
  63936. _detachCameras(cameras: Camera[]): void;
  63937. /**
  63938. * Enables the effect on given cameras
  63939. * @param cameras The camera to enable.
  63940. * @hidden
  63941. */
  63942. _enable(cameras: Camera): void;
  63943. /**
  63944. * Enables the effect on given cameras
  63945. * @param cameras The camera to enable.
  63946. * @hidden
  63947. */
  63948. _enable(cameras: Nullable<Camera[]>): void;
  63949. /**
  63950. * Disables the effect on the given cameras
  63951. * @param cameras The camera to disable.
  63952. * @hidden
  63953. */
  63954. _disable(cameras: Camera): void;
  63955. /**
  63956. * Disables the effect on the given cameras
  63957. * @param cameras The camera to disable.
  63958. * @hidden
  63959. */
  63960. _disable(cameras: Nullable<Camera[]>): void;
  63961. /**
  63962. * Gets a list of the post processes contained in the effect.
  63963. * @param camera The camera to get the post processes on.
  63964. * @returns The list of the post processes in the effect.
  63965. */
  63966. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63967. }
  63968. }
  63969. declare module BABYLON {
  63970. /** @hidden */
  63971. export var extractHighlightsPixelShader: {
  63972. name: string;
  63973. shader: string;
  63974. };
  63975. }
  63976. declare module BABYLON {
  63977. /**
  63978. * 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.
  63979. */
  63980. export class ExtractHighlightsPostProcess extends PostProcess {
  63981. /**
  63982. * The luminance threshold, pixels below this value will be set to black.
  63983. */
  63984. threshold: number;
  63985. /** @hidden */
  63986. _exposure: number;
  63987. /**
  63988. * Post process which has the input texture to be used when performing highlight extraction
  63989. * @hidden
  63990. */
  63991. _inputPostProcess: Nullable<PostProcess>;
  63992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63993. }
  63994. }
  63995. declare module BABYLON {
  63996. /** @hidden */
  63997. export var bloomMergePixelShader: {
  63998. name: string;
  63999. shader: string;
  64000. };
  64001. }
  64002. declare module BABYLON {
  64003. /**
  64004. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64005. */
  64006. export class BloomMergePostProcess extends PostProcess {
  64007. /** Weight of the bloom to be added to the original input. */
  64008. weight: number;
  64009. /**
  64010. * Creates a new instance of @see BloomMergePostProcess
  64011. * @param name The name of the effect.
  64012. * @param originalFromInput Post process which's input will be used for the merge.
  64013. * @param blurred Blurred highlights post process which's output will be used.
  64014. * @param weight Weight of the bloom to be added to the original input.
  64015. * @param options The required width/height ratio to downsize to before computing the render pass.
  64016. * @param camera The camera to apply the render pass to.
  64017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64018. * @param engine The engine which the post process will be applied. (default: current engine)
  64019. * @param reusable If the post process can be reused on the same frame. (default: false)
  64020. * @param textureType Type of textures used when performing the post process. (default: 0)
  64021. * @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)
  64022. */
  64023. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64024. /** Weight of the bloom to be added to the original input. */
  64025. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64026. }
  64027. }
  64028. declare module BABYLON {
  64029. /**
  64030. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64031. */
  64032. export class BloomEffect extends PostProcessRenderEffect {
  64033. private bloomScale;
  64034. /**
  64035. * @hidden Internal
  64036. */
  64037. _effects: Array<PostProcess>;
  64038. /**
  64039. * @hidden Internal
  64040. */
  64041. _downscale: ExtractHighlightsPostProcess;
  64042. private _blurX;
  64043. private _blurY;
  64044. private _merge;
  64045. /**
  64046. * The luminance threshold to find bright areas of the image to bloom.
  64047. */
  64048. get threshold(): number;
  64049. set threshold(value: number);
  64050. /**
  64051. * The strength of the bloom.
  64052. */
  64053. get weight(): number;
  64054. set weight(value: number);
  64055. /**
  64056. * Specifies the size of the bloom blur kernel, relative to the final output size
  64057. */
  64058. get kernel(): number;
  64059. set kernel(value: number);
  64060. /**
  64061. * Creates a new instance of @see BloomEffect
  64062. * @param scene The scene the effect belongs to.
  64063. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64064. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64065. * @param bloomWeight The the strength of bloom.
  64066. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64067. * @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)
  64068. */
  64069. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64070. /**
  64071. * Disposes each of the internal effects for a given camera.
  64072. * @param camera The camera to dispose the effect on.
  64073. */
  64074. disposeEffects(camera: Camera): void;
  64075. /**
  64076. * @hidden Internal
  64077. */
  64078. _updateEffects(): void;
  64079. /**
  64080. * Internal
  64081. * @returns if all the contained post processes are ready.
  64082. * @hidden
  64083. */
  64084. _isReady(): boolean;
  64085. }
  64086. }
  64087. declare module BABYLON {
  64088. /** @hidden */
  64089. export var chromaticAberrationPixelShader: {
  64090. name: string;
  64091. shader: string;
  64092. };
  64093. }
  64094. declare module BABYLON {
  64095. /**
  64096. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64097. */
  64098. export class ChromaticAberrationPostProcess extends PostProcess {
  64099. /**
  64100. * The amount of seperation of rgb channels (default: 30)
  64101. */
  64102. aberrationAmount: number;
  64103. /**
  64104. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64105. */
  64106. radialIntensity: number;
  64107. /**
  64108. * 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))
  64109. */
  64110. direction: Vector2;
  64111. /**
  64112. * 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))
  64113. */
  64114. centerPosition: Vector2;
  64115. /**
  64116. * Creates a new instance ChromaticAberrationPostProcess
  64117. * @param name The name of the effect.
  64118. * @param screenWidth The width of the screen to apply the effect on.
  64119. * @param screenHeight The height of the screen to apply the effect on.
  64120. * @param options The required width/height ratio to downsize to before computing the render pass.
  64121. * @param camera The camera to apply the render pass to.
  64122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64123. * @param engine The engine which the post process will be applied. (default: current engine)
  64124. * @param reusable If the post process can be reused on the same frame. (default: false)
  64125. * @param textureType Type of textures used when performing the post process. (default: 0)
  64126. * @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)
  64127. */
  64128. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64129. }
  64130. }
  64131. declare module BABYLON {
  64132. /** @hidden */
  64133. export var circleOfConfusionPixelShader: {
  64134. name: string;
  64135. shader: string;
  64136. };
  64137. }
  64138. declare module BABYLON {
  64139. /**
  64140. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64141. */
  64142. export class CircleOfConfusionPostProcess extends PostProcess {
  64143. /**
  64144. * 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.
  64145. */
  64146. lensSize: number;
  64147. /**
  64148. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64149. */
  64150. fStop: number;
  64151. /**
  64152. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64153. */
  64154. focusDistance: number;
  64155. /**
  64156. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64157. */
  64158. focalLength: number;
  64159. private _depthTexture;
  64160. /**
  64161. * Creates a new instance CircleOfConfusionPostProcess
  64162. * @param name The name of the effect.
  64163. * @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.
  64164. * @param options The required width/height ratio to downsize to before computing the render pass.
  64165. * @param camera The camera to apply the render pass to.
  64166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64167. * @param engine The engine which the post process will be applied. (default: current engine)
  64168. * @param reusable If the post process can be reused on the same frame. (default: false)
  64169. * @param textureType Type of textures used when performing the post process. (default: 0)
  64170. * @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)
  64171. */
  64172. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64173. /**
  64174. * 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.
  64175. */
  64176. set depthTexture(value: RenderTargetTexture);
  64177. }
  64178. }
  64179. declare module BABYLON {
  64180. /** @hidden */
  64181. export var colorCorrectionPixelShader: {
  64182. name: string;
  64183. shader: string;
  64184. };
  64185. }
  64186. declare module BABYLON {
  64187. /**
  64188. *
  64189. * This post-process allows the modification of rendered colors by using
  64190. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64191. *
  64192. * The object needs to be provided an url to a texture containing the color
  64193. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64194. * Use an image editing software to tweak the LUT to match your needs.
  64195. *
  64196. * For an example of a color LUT, see here:
  64197. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64198. * For explanations on color grading, see here:
  64199. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64200. *
  64201. */
  64202. export class ColorCorrectionPostProcess extends PostProcess {
  64203. private _colorTableTexture;
  64204. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64205. }
  64206. }
  64207. declare module BABYLON {
  64208. /** @hidden */
  64209. export var convolutionPixelShader: {
  64210. name: string;
  64211. shader: string;
  64212. };
  64213. }
  64214. declare module BABYLON {
  64215. /**
  64216. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64217. * input texture to perform effects such as edge detection or sharpening
  64218. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64219. */
  64220. export class ConvolutionPostProcess extends PostProcess {
  64221. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64222. kernel: number[];
  64223. /**
  64224. * Creates a new instance ConvolutionPostProcess
  64225. * @param name The name of the effect.
  64226. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64227. * @param options The required width/height ratio to downsize to before computing the render pass.
  64228. * @param camera The camera to apply the render pass to.
  64229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64230. * @param engine The engine which the post process will be applied. (default: current engine)
  64231. * @param reusable If the post process can be reused on the same frame. (default: false)
  64232. * @param textureType Type of textures used when performing the post process. (default: 0)
  64233. */
  64234. constructor(name: string,
  64235. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64236. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64237. /**
  64238. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64239. */
  64240. static EdgeDetect0Kernel: number[];
  64241. /**
  64242. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64243. */
  64244. static EdgeDetect1Kernel: number[];
  64245. /**
  64246. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64247. */
  64248. static EdgeDetect2Kernel: number[];
  64249. /**
  64250. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64251. */
  64252. static SharpenKernel: number[];
  64253. /**
  64254. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64255. */
  64256. static EmbossKernel: number[];
  64257. /**
  64258. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64259. */
  64260. static GaussianKernel: number[];
  64261. }
  64262. }
  64263. declare module BABYLON {
  64264. /**
  64265. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64266. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64267. * based on samples that have a large difference in distance than the center pixel.
  64268. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64269. */
  64270. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64271. direction: Vector2;
  64272. /**
  64273. * Creates a new instance CircleOfConfusionPostProcess
  64274. * @param name The name of the effect.
  64275. * @param scene The scene the effect belongs to.
  64276. * @param direction The direction the blur should be applied.
  64277. * @param kernel The size of the kernel used to blur.
  64278. * @param options The required width/height ratio to downsize to before computing the render pass.
  64279. * @param camera The camera to apply the render pass to.
  64280. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64281. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64283. * @param engine The engine which the post process will be applied. (default: current engine)
  64284. * @param reusable If the post process can be reused on the same frame. (default: false)
  64285. * @param textureType Type of textures used when performing the post process. (default: 0)
  64286. * @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)
  64287. */
  64288. 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);
  64289. }
  64290. }
  64291. declare module BABYLON {
  64292. /** @hidden */
  64293. export var depthOfFieldMergePixelShader: {
  64294. name: string;
  64295. shader: string;
  64296. };
  64297. }
  64298. declare module BABYLON {
  64299. /**
  64300. * Options to be set when merging outputs from the default pipeline.
  64301. */
  64302. export class DepthOfFieldMergePostProcessOptions {
  64303. /**
  64304. * The original image to merge on top of
  64305. */
  64306. originalFromInput: PostProcess;
  64307. /**
  64308. * Parameters to perform the merge of the depth of field effect
  64309. */
  64310. depthOfField?: {
  64311. circleOfConfusion: PostProcess;
  64312. blurSteps: Array<PostProcess>;
  64313. };
  64314. /**
  64315. * Parameters to perform the merge of bloom effect
  64316. */
  64317. bloom?: {
  64318. blurred: PostProcess;
  64319. weight: number;
  64320. };
  64321. }
  64322. /**
  64323. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64324. */
  64325. export class DepthOfFieldMergePostProcess extends PostProcess {
  64326. private blurSteps;
  64327. /**
  64328. * Creates a new instance of DepthOfFieldMergePostProcess
  64329. * @param name The name of the effect.
  64330. * @param originalFromInput Post process which's input will be used for the merge.
  64331. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64332. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64333. * @param options The required width/height ratio to downsize to before computing the render pass.
  64334. * @param camera The camera to apply the render pass to.
  64335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64336. * @param engine The engine which the post process will be applied. (default: current engine)
  64337. * @param reusable If the post process can be reused on the same frame. (default: false)
  64338. * @param textureType Type of textures used when performing the post process. (default: 0)
  64339. * @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)
  64340. */
  64341. 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);
  64342. /**
  64343. * Updates the effect with the current post process compile time values and recompiles the shader.
  64344. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64345. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64346. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64347. * @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
  64348. * @param onCompiled Called when the shader has been compiled.
  64349. * @param onError Called if there is an error when compiling a shader.
  64350. */
  64351. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64352. }
  64353. }
  64354. declare module BABYLON {
  64355. /**
  64356. * Specifies the level of max blur that should be applied when using the depth of field effect
  64357. */
  64358. export enum DepthOfFieldEffectBlurLevel {
  64359. /**
  64360. * Subtle blur
  64361. */
  64362. Low = 0,
  64363. /**
  64364. * Medium blur
  64365. */
  64366. Medium = 1,
  64367. /**
  64368. * Large blur
  64369. */
  64370. High = 2
  64371. }
  64372. /**
  64373. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64374. */
  64375. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64376. private _circleOfConfusion;
  64377. /**
  64378. * @hidden Internal, blurs from high to low
  64379. */
  64380. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64381. private _depthOfFieldBlurY;
  64382. private _dofMerge;
  64383. /**
  64384. * @hidden Internal post processes in depth of field effect
  64385. */
  64386. _effects: Array<PostProcess>;
  64387. /**
  64388. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64389. */
  64390. set focalLength(value: number);
  64391. get focalLength(): number;
  64392. /**
  64393. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64394. */
  64395. set fStop(value: number);
  64396. get fStop(): number;
  64397. /**
  64398. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64399. */
  64400. set focusDistance(value: number);
  64401. get focusDistance(): number;
  64402. /**
  64403. * 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.
  64404. */
  64405. set lensSize(value: number);
  64406. get lensSize(): number;
  64407. /**
  64408. * Creates a new instance DepthOfFieldEffect
  64409. * @param scene The scene the effect belongs to.
  64410. * @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.
  64411. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64412. * @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)
  64413. */
  64414. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64415. /**
  64416. * Get the current class name of the current effet
  64417. * @returns "DepthOfFieldEffect"
  64418. */
  64419. getClassName(): string;
  64420. /**
  64421. * 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.
  64422. */
  64423. set depthTexture(value: RenderTargetTexture);
  64424. /**
  64425. * Disposes each of the internal effects for a given camera.
  64426. * @param camera The camera to dispose the effect on.
  64427. */
  64428. disposeEffects(camera: Camera): void;
  64429. /**
  64430. * @hidden Internal
  64431. */
  64432. _updateEffects(): void;
  64433. /**
  64434. * Internal
  64435. * @returns if all the contained post processes are ready.
  64436. * @hidden
  64437. */
  64438. _isReady(): boolean;
  64439. }
  64440. }
  64441. declare module BABYLON {
  64442. /** @hidden */
  64443. export var displayPassPixelShader: {
  64444. name: string;
  64445. shader: string;
  64446. };
  64447. }
  64448. declare module BABYLON {
  64449. /**
  64450. * DisplayPassPostProcess which produces an output the same as it's input
  64451. */
  64452. export class DisplayPassPostProcess extends PostProcess {
  64453. /**
  64454. * Creates the DisplayPassPostProcess
  64455. * @param name The name of the effect.
  64456. * @param options The required width/height ratio to downsize to before computing the render pass.
  64457. * @param camera The camera to apply the render pass to.
  64458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64459. * @param engine The engine which the post process will be applied. (default: current engine)
  64460. * @param reusable If the post process can be reused on the same frame. (default: false)
  64461. */
  64462. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64463. }
  64464. }
  64465. declare module BABYLON {
  64466. /** @hidden */
  64467. export var filterPixelShader: {
  64468. name: string;
  64469. shader: string;
  64470. };
  64471. }
  64472. declare module BABYLON {
  64473. /**
  64474. * Applies a kernel filter to the image
  64475. */
  64476. export class FilterPostProcess extends PostProcess {
  64477. /** The matrix to be applied to the image */
  64478. kernelMatrix: Matrix;
  64479. /**
  64480. *
  64481. * @param name The name of the effect.
  64482. * @param kernelMatrix The matrix to be applied to the image
  64483. * @param options The required width/height ratio to downsize to before computing the render pass.
  64484. * @param camera The camera to apply the render pass to.
  64485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64486. * @param engine The engine which the post process will be applied. (default: current engine)
  64487. * @param reusable If the post process can be reused on the same frame. (default: false)
  64488. */
  64489. constructor(name: string,
  64490. /** The matrix to be applied to the image */
  64491. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64492. }
  64493. }
  64494. declare module BABYLON {
  64495. /** @hidden */
  64496. export var fxaaPixelShader: {
  64497. name: string;
  64498. shader: string;
  64499. };
  64500. }
  64501. declare module BABYLON {
  64502. /** @hidden */
  64503. export var fxaaVertexShader: {
  64504. name: string;
  64505. shader: string;
  64506. };
  64507. }
  64508. declare module BABYLON {
  64509. /**
  64510. * Fxaa post process
  64511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64512. */
  64513. export class FxaaPostProcess extends PostProcess {
  64514. /** @hidden */
  64515. texelWidth: number;
  64516. /** @hidden */
  64517. texelHeight: number;
  64518. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64519. private _getDefines;
  64520. }
  64521. }
  64522. declare module BABYLON {
  64523. /** @hidden */
  64524. export var grainPixelShader: {
  64525. name: string;
  64526. shader: string;
  64527. };
  64528. }
  64529. declare module BABYLON {
  64530. /**
  64531. * The GrainPostProcess adds noise to the image at mid luminance levels
  64532. */
  64533. export class GrainPostProcess extends PostProcess {
  64534. /**
  64535. * The intensity of the grain added (default: 30)
  64536. */
  64537. intensity: number;
  64538. /**
  64539. * If the grain should be randomized on every frame
  64540. */
  64541. animated: boolean;
  64542. /**
  64543. * Creates a new instance of @see GrainPostProcess
  64544. * @param name The name of the effect.
  64545. * @param options The required width/height ratio to downsize to before computing the render pass.
  64546. * @param camera The camera to apply the render pass to.
  64547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64548. * @param engine The engine which the post process will be applied. (default: current engine)
  64549. * @param reusable If the post process can be reused on the same frame. (default: false)
  64550. * @param textureType Type of textures used when performing the post process. (default: 0)
  64551. * @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)
  64552. */
  64553. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64554. }
  64555. }
  64556. declare module BABYLON {
  64557. /** @hidden */
  64558. export var highlightsPixelShader: {
  64559. name: string;
  64560. shader: string;
  64561. };
  64562. }
  64563. declare module BABYLON {
  64564. /**
  64565. * Extracts highlights from the image
  64566. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64567. */
  64568. export class HighlightsPostProcess extends PostProcess {
  64569. /**
  64570. * Extracts highlights from the image
  64571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64572. * @param name The name of the effect.
  64573. * @param options The required width/height ratio to downsize to before computing the render pass.
  64574. * @param camera The camera to apply the render pass to.
  64575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64576. * @param engine The engine which the post process will be applied. (default: current engine)
  64577. * @param reusable If the post process can be reused on the same frame. (default: false)
  64578. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64579. */
  64580. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64581. }
  64582. }
  64583. declare module BABYLON {
  64584. /** @hidden */
  64585. export var mrtFragmentDeclaration: {
  64586. name: string;
  64587. shader: string;
  64588. };
  64589. }
  64590. declare module BABYLON {
  64591. /** @hidden */
  64592. export var geometryPixelShader: {
  64593. name: string;
  64594. shader: string;
  64595. };
  64596. }
  64597. declare module BABYLON {
  64598. /** @hidden */
  64599. export var geometryVertexShader: {
  64600. name: string;
  64601. shader: string;
  64602. };
  64603. }
  64604. declare module BABYLON {
  64605. /** @hidden */
  64606. interface ISavedTransformationMatrix {
  64607. world: Matrix;
  64608. viewProjection: Matrix;
  64609. }
  64610. /**
  64611. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64612. */
  64613. export class GeometryBufferRenderer {
  64614. /**
  64615. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64616. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64617. */
  64618. static readonly POSITION_TEXTURE_TYPE: number;
  64619. /**
  64620. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64621. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64622. */
  64623. static readonly VELOCITY_TEXTURE_TYPE: number;
  64624. /**
  64625. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64626. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64627. */
  64628. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64629. /**
  64630. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64631. * in order to compute objects velocities when enableVelocity is set to "true"
  64632. * @hidden
  64633. */
  64634. _previousTransformationMatrices: {
  64635. [index: number]: ISavedTransformationMatrix;
  64636. };
  64637. /**
  64638. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64639. * in order to compute objects velocities when enableVelocity is set to "true"
  64640. * @hidden
  64641. */
  64642. _previousBonesTransformationMatrices: {
  64643. [index: number]: Float32Array;
  64644. };
  64645. /**
  64646. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64647. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64648. */
  64649. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64650. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64651. renderTransparentMeshes: boolean;
  64652. private _scene;
  64653. private _multiRenderTarget;
  64654. private _ratio;
  64655. private _enablePosition;
  64656. private _enableVelocity;
  64657. private _enableReflectivity;
  64658. private _positionIndex;
  64659. private _velocityIndex;
  64660. private _reflectivityIndex;
  64661. protected _effect: Effect;
  64662. protected _cachedDefines: string;
  64663. /**
  64664. * Set the render list (meshes to be rendered) used in the G buffer.
  64665. */
  64666. set renderList(meshes: Mesh[]);
  64667. /**
  64668. * Gets wether or not G buffer are supported by the running hardware.
  64669. * This requires draw buffer supports
  64670. */
  64671. get isSupported(): boolean;
  64672. /**
  64673. * Returns the index of the given texture type in the G-Buffer textures array
  64674. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64675. * @returns the index of the given texture type in the G-Buffer textures array
  64676. */
  64677. getTextureIndex(textureType: number): number;
  64678. /**
  64679. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64680. */
  64681. get enablePosition(): boolean;
  64682. /**
  64683. * Sets whether or not objects positions are enabled for the G buffer.
  64684. */
  64685. set enablePosition(enable: boolean);
  64686. /**
  64687. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64688. */
  64689. get enableVelocity(): boolean;
  64690. /**
  64691. * Sets wether or not objects velocities are enabled for the G buffer.
  64692. */
  64693. set enableVelocity(enable: boolean);
  64694. /**
  64695. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64696. */
  64697. get enableReflectivity(): boolean;
  64698. /**
  64699. * Sets wether or not objects roughness are enabled for the G buffer.
  64700. */
  64701. set enableReflectivity(enable: boolean);
  64702. /**
  64703. * Gets the scene associated with the buffer.
  64704. */
  64705. get scene(): Scene;
  64706. /**
  64707. * Gets the ratio used by the buffer during its creation.
  64708. * How big is the buffer related to the main canvas.
  64709. */
  64710. get ratio(): number;
  64711. /** @hidden */
  64712. static _SceneComponentInitialization: (scene: Scene) => void;
  64713. /**
  64714. * Creates a new G Buffer for the scene
  64715. * @param scene The scene the buffer belongs to
  64716. * @param ratio How big is the buffer related to the main canvas.
  64717. */
  64718. constructor(scene: Scene, ratio?: number);
  64719. /**
  64720. * Checks wether everything is ready to render a submesh to the G buffer.
  64721. * @param subMesh the submesh to check readiness for
  64722. * @param useInstances is the mesh drawn using instance or not
  64723. * @returns true if ready otherwise false
  64724. */
  64725. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64726. /**
  64727. * Gets the current underlying G Buffer.
  64728. * @returns the buffer
  64729. */
  64730. getGBuffer(): MultiRenderTarget;
  64731. /**
  64732. * Gets the number of samples used to render the buffer (anti aliasing).
  64733. */
  64734. get samples(): number;
  64735. /**
  64736. * Sets the number of samples used to render the buffer (anti aliasing).
  64737. */
  64738. set samples(value: number);
  64739. /**
  64740. * Disposes the renderer and frees up associated resources.
  64741. */
  64742. dispose(): void;
  64743. protected _createRenderTargets(): void;
  64744. private _copyBonesTransformationMatrices;
  64745. }
  64746. }
  64747. declare module BABYLON {
  64748. interface Scene {
  64749. /** @hidden (Backing field) */
  64750. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64751. /**
  64752. * Gets or Sets the current geometry buffer associated to the scene.
  64753. */
  64754. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64755. /**
  64756. * Enables a GeometryBufferRender and associates it with the scene
  64757. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64758. * @returns the GeometryBufferRenderer
  64759. */
  64760. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64761. /**
  64762. * Disables the GeometryBufferRender associated with the scene
  64763. */
  64764. disableGeometryBufferRenderer(): void;
  64765. }
  64766. /**
  64767. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64768. * in several rendering techniques.
  64769. */
  64770. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64771. /**
  64772. * The component name helpful to identify the component in the list of scene components.
  64773. */
  64774. readonly name: string;
  64775. /**
  64776. * The scene the component belongs to.
  64777. */
  64778. scene: Scene;
  64779. /**
  64780. * Creates a new instance of the component for the given scene
  64781. * @param scene Defines the scene to register the component in
  64782. */
  64783. constructor(scene: Scene);
  64784. /**
  64785. * Registers the component in a given scene
  64786. */
  64787. register(): void;
  64788. /**
  64789. * Rebuilds the elements related to this component in case of
  64790. * context lost for instance.
  64791. */
  64792. rebuild(): void;
  64793. /**
  64794. * Disposes the component and the associated ressources
  64795. */
  64796. dispose(): void;
  64797. private _gatherRenderTargets;
  64798. }
  64799. }
  64800. declare module BABYLON {
  64801. /** @hidden */
  64802. export var motionBlurPixelShader: {
  64803. name: string;
  64804. shader: string;
  64805. };
  64806. }
  64807. declare module BABYLON {
  64808. /**
  64809. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64810. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64811. * As an example, all you have to do is to create the post-process:
  64812. * var mb = new BABYLON.MotionBlurPostProcess(
  64813. * 'mb', // The name of the effect.
  64814. * scene, // The scene containing the objects to blur according to their velocity.
  64815. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64816. * camera // The camera to apply the render pass to.
  64817. * );
  64818. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64819. */
  64820. export class MotionBlurPostProcess extends PostProcess {
  64821. /**
  64822. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64823. */
  64824. motionStrength: number;
  64825. /**
  64826. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64827. */
  64828. get motionBlurSamples(): number;
  64829. /**
  64830. * Sets the number of iterations to be used for motion blur quality
  64831. */
  64832. set motionBlurSamples(samples: number);
  64833. private _motionBlurSamples;
  64834. private _geometryBufferRenderer;
  64835. /**
  64836. * Creates a new instance MotionBlurPostProcess
  64837. * @param name The name of the effect.
  64838. * @param scene The scene containing the objects to blur according to their velocity.
  64839. * @param options The required width/height ratio to downsize to before computing the render pass.
  64840. * @param camera The camera to apply the render pass to.
  64841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64842. * @param engine The engine which the post process will be applied. (default: current engine)
  64843. * @param reusable If the post process can be reused on the same frame. (default: false)
  64844. * @param textureType Type of textures used when performing the post process. (default: 0)
  64845. * @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)
  64846. */
  64847. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64848. /**
  64849. * Excludes the given skinned mesh from computing bones velocities.
  64850. * 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.
  64851. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64852. */
  64853. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64854. /**
  64855. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64856. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64857. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64858. */
  64859. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64860. /**
  64861. * Disposes the post process.
  64862. * @param camera The camera to dispose the post process on.
  64863. */
  64864. dispose(camera?: Camera): void;
  64865. }
  64866. }
  64867. declare module BABYLON {
  64868. /** @hidden */
  64869. export var refractionPixelShader: {
  64870. name: string;
  64871. shader: string;
  64872. };
  64873. }
  64874. declare module BABYLON {
  64875. /**
  64876. * Post process which applies a refractin texture
  64877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64878. */
  64879. export class RefractionPostProcess extends PostProcess {
  64880. /** the base color of the refraction (used to taint the rendering) */
  64881. color: Color3;
  64882. /** simulated refraction depth */
  64883. depth: number;
  64884. /** the coefficient of the base color (0 to remove base color tainting) */
  64885. colorLevel: number;
  64886. private _refTexture;
  64887. private _ownRefractionTexture;
  64888. /**
  64889. * Gets or sets the refraction texture
  64890. * Please note that you are responsible for disposing the texture if you set it manually
  64891. */
  64892. get refractionTexture(): Texture;
  64893. set refractionTexture(value: Texture);
  64894. /**
  64895. * Initializes the RefractionPostProcess
  64896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64897. * @param name The name of the effect.
  64898. * @param refractionTextureUrl Url of the refraction texture to use
  64899. * @param color the base color of the refraction (used to taint the rendering)
  64900. * @param depth simulated refraction depth
  64901. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64902. * @param camera The camera to apply the render pass to.
  64903. * @param options The required width/height ratio to downsize to before computing the render pass.
  64904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64905. * @param engine The engine which the post process will be applied. (default: current engine)
  64906. * @param reusable If the post process can be reused on the same frame. (default: false)
  64907. */
  64908. constructor(name: string, refractionTextureUrl: string,
  64909. /** the base color of the refraction (used to taint the rendering) */
  64910. color: Color3,
  64911. /** simulated refraction depth */
  64912. depth: number,
  64913. /** the coefficient of the base color (0 to remove base color tainting) */
  64914. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64915. /**
  64916. * Disposes of the post process
  64917. * @param camera Camera to dispose post process on
  64918. */
  64919. dispose(camera: Camera): void;
  64920. }
  64921. }
  64922. declare module BABYLON {
  64923. /** @hidden */
  64924. export var sharpenPixelShader: {
  64925. name: string;
  64926. shader: string;
  64927. };
  64928. }
  64929. declare module BABYLON {
  64930. /**
  64931. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64932. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64933. */
  64934. export class SharpenPostProcess extends PostProcess {
  64935. /**
  64936. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64937. */
  64938. colorAmount: number;
  64939. /**
  64940. * How much sharpness should be applied (default: 0.3)
  64941. */
  64942. edgeAmount: number;
  64943. /**
  64944. * Creates a new instance ConvolutionPostProcess
  64945. * @param name The name of the effect.
  64946. * @param options The required width/height ratio to downsize to before computing the render pass.
  64947. * @param camera The camera to apply the render pass to.
  64948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64949. * @param engine The engine which the post process will be applied. (default: current engine)
  64950. * @param reusable If the post process can be reused on the same frame. (default: false)
  64951. * @param textureType Type of textures used when performing the post process. (default: 0)
  64952. * @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)
  64953. */
  64954. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64955. }
  64956. }
  64957. declare module BABYLON {
  64958. /**
  64959. * PostProcessRenderPipeline
  64960. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64961. */
  64962. export class PostProcessRenderPipeline {
  64963. private engine;
  64964. private _renderEffects;
  64965. private _renderEffectsForIsolatedPass;
  64966. /**
  64967. * List of inspectable custom properties (used by the Inspector)
  64968. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64969. */
  64970. inspectableCustomProperties: IInspectable[];
  64971. /**
  64972. * @hidden
  64973. */
  64974. protected _cameras: Camera[];
  64975. /** @hidden */
  64976. _name: string;
  64977. /**
  64978. * Gets pipeline name
  64979. */
  64980. get name(): string;
  64981. /** Gets the list of attached cameras */
  64982. get cameras(): Camera[];
  64983. /**
  64984. * Initializes a PostProcessRenderPipeline
  64985. * @param engine engine to add the pipeline to
  64986. * @param name name of the pipeline
  64987. */
  64988. constructor(engine: Engine, name: string);
  64989. /**
  64990. * Gets the class name
  64991. * @returns "PostProcessRenderPipeline"
  64992. */
  64993. getClassName(): string;
  64994. /**
  64995. * If all the render effects in the pipeline are supported
  64996. */
  64997. get isSupported(): boolean;
  64998. /**
  64999. * Adds an effect to the pipeline
  65000. * @param renderEffect the effect to add
  65001. */
  65002. addEffect(renderEffect: PostProcessRenderEffect): void;
  65003. /** @hidden */
  65004. _rebuild(): void;
  65005. /** @hidden */
  65006. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65007. /** @hidden */
  65008. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65009. /** @hidden */
  65010. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65011. /** @hidden */
  65012. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65013. /** @hidden */
  65014. _attachCameras(cameras: Camera, unique: boolean): void;
  65015. /** @hidden */
  65016. _attachCameras(cameras: Camera[], unique: boolean): void;
  65017. /** @hidden */
  65018. _detachCameras(cameras: Camera): void;
  65019. /** @hidden */
  65020. _detachCameras(cameras: Nullable<Camera[]>): void;
  65021. /** @hidden */
  65022. _update(): void;
  65023. /** @hidden */
  65024. _reset(): void;
  65025. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65026. /**
  65027. * Disposes of the pipeline
  65028. */
  65029. dispose(): void;
  65030. }
  65031. }
  65032. declare module BABYLON {
  65033. /**
  65034. * PostProcessRenderPipelineManager class
  65035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65036. */
  65037. export class PostProcessRenderPipelineManager {
  65038. private _renderPipelines;
  65039. /**
  65040. * Initializes a PostProcessRenderPipelineManager
  65041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65042. */
  65043. constructor();
  65044. /**
  65045. * Gets the list of supported render pipelines
  65046. */
  65047. get supportedPipelines(): PostProcessRenderPipeline[];
  65048. /**
  65049. * Adds a pipeline to the manager
  65050. * @param renderPipeline The pipeline to add
  65051. */
  65052. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65053. /**
  65054. * Attaches a camera to the pipeline
  65055. * @param renderPipelineName The name of the pipeline to attach to
  65056. * @param cameras the camera to attach
  65057. * @param unique if the camera can be attached multiple times to the pipeline
  65058. */
  65059. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65060. /**
  65061. * Detaches a camera from the pipeline
  65062. * @param renderPipelineName The name of the pipeline to detach from
  65063. * @param cameras the camera to detach
  65064. */
  65065. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65066. /**
  65067. * Enables an effect by name on a pipeline
  65068. * @param renderPipelineName the name of the pipeline to enable the effect in
  65069. * @param renderEffectName the name of the effect to enable
  65070. * @param cameras the cameras that the effect should be enabled on
  65071. */
  65072. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65073. /**
  65074. * Disables an effect by name on a pipeline
  65075. * @param renderPipelineName the name of the pipeline to disable the effect in
  65076. * @param renderEffectName the name of the effect to disable
  65077. * @param cameras the cameras that the effect should be disabled on
  65078. */
  65079. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65080. /**
  65081. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65082. */
  65083. update(): void;
  65084. /** @hidden */
  65085. _rebuild(): void;
  65086. /**
  65087. * Disposes of the manager and pipelines
  65088. */
  65089. dispose(): void;
  65090. }
  65091. }
  65092. declare module BABYLON {
  65093. interface Scene {
  65094. /** @hidden (Backing field) */
  65095. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65096. /**
  65097. * Gets the postprocess render pipeline manager
  65098. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65099. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65100. */
  65101. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65102. }
  65103. /**
  65104. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65105. */
  65106. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65107. /**
  65108. * The component name helpfull to identify the component in the list of scene components.
  65109. */
  65110. readonly name: string;
  65111. /**
  65112. * The scene the component belongs to.
  65113. */
  65114. scene: Scene;
  65115. /**
  65116. * Creates a new instance of the component for the given scene
  65117. * @param scene Defines the scene to register the component in
  65118. */
  65119. constructor(scene: Scene);
  65120. /**
  65121. * Registers the component in a given scene
  65122. */
  65123. register(): void;
  65124. /**
  65125. * Rebuilds the elements related to this component in case of
  65126. * context lost for instance.
  65127. */
  65128. rebuild(): void;
  65129. /**
  65130. * Disposes the component and the associated ressources
  65131. */
  65132. dispose(): void;
  65133. private _gatherRenderTargets;
  65134. }
  65135. }
  65136. declare module BABYLON {
  65137. /**
  65138. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65139. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65140. */
  65141. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65142. private _scene;
  65143. private _camerasToBeAttached;
  65144. /**
  65145. * ID of the sharpen post process,
  65146. */
  65147. private readonly SharpenPostProcessId;
  65148. /**
  65149. * @ignore
  65150. * ID of the image processing post process;
  65151. */
  65152. readonly ImageProcessingPostProcessId: string;
  65153. /**
  65154. * @ignore
  65155. * ID of the Fast Approximate Anti-Aliasing post process;
  65156. */
  65157. readonly FxaaPostProcessId: string;
  65158. /**
  65159. * ID of the chromatic aberration post process,
  65160. */
  65161. private readonly ChromaticAberrationPostProcessId;
  65162. /**
  65163. * ID of the grain post process
  65164. */
  65165. private readonly GrainPostProcessId;
  65166. /**
  65167. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65168. */
  65169. sharpen: SharpenPostProcess;
  65170. private _sharpenEffect;
  65171. private bloom;
  65172. /**
  65173. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65174. */
  65175. depthOfField: DepthOfFieldEffect;
  65176. /**
  65177. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65178. */
  65179. fxaa: FxaaPostProcess;
  65180. /**
  65181. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65182. */
  65183. imageProcessing: ImageProcessingPostProcess;
  65184. /**
  65185. * Chromatic aberration post process which will shift rgb colors in the image
  65186. */
  65187. chromaticAberration: ChromaticAberrationPostProcess;
  65188. private _chromaticAberrationEffect;
  65189. /**
  65190. * Grain post process which add noise to the image
  65191. */
  65192. grain: GrainPostProcess;
  65193. private _grainEffect;
  65194. /**
  65195. * Glow post process which adds a glow to emissive areas of the image
  65196. */
  65197. private _glowLayer;
  65198. /**
  65199. * Animations which can be used to tweak settings over a period of time
  65200. */
  65201. animations: Animation[];
  65202. private _imageProcessingConfigurationObserver;
  65203. private _sharpenEnabled;
  65204. private _bloomEnabled;
  65205. private _depthOfFieldEnabled;
  65206. private _depthOfFieldBlurLevel;
  65207. private _fxaaEnabled;
  65208. private _imageProcessingEnabled;
  65209. private _defaultPipelineTextureType;
  65210. private _bloomScale;
  65211. private _chromaticAberrationEnabled;
  65212. private _grainEnabled;
  65213. private _buildAllowed;
  65214. /**
  65215. * Gets active scene
  65216. */
  65217. get scene(): Scene;
  65218. /**
  65219. * Enable or disable the sharpen process from the pipeline
  65220. */
  65221. set sharpenEnabled(enabled: boolean);
  65222. get sharpenEnabled(): boolean;
  65223. private _resizeObserver;
  65224. private _hardwareScaleLevel;
  65225. private _bloomKernel;
  65226. /**
  65227. * Specifies the size of the bloom blur kernel, relative to the final output size
  65228. */
  65229. get bloomKernel(): number;
  65230. set bloomKernel(value: number);
  65231. /**
  65232. * Specifies the weight of the bloom in the final rendering
  65233. */
  65234. private _bloomWeight;
  65235. /**
  65236. * Specifies the luma threshold for the area that will be blurred by the bloom
  65237. */
  65238. private _bloomThreshold;
  65239. private _hdr;
  65240. /**
  65241. * The strength of the bloom.
  65242. */
  65243. set bloomWeight(value: number);
  65244. get bloomWeight(): number;
  65245. /**
  65246. * The strength of the bloom.
  65247. */
  65248. set bloomThreshold(value: number);
  65249. get bloomThreshold(): number;
  65250. /**
  65251. * The scale of the bloom, lower value will provide better performance.
  65252. */
  65253. set bloomScale(value: number);
  65254. get bloomScale(): number;
  65255. /**
  65256. * Enable or disable the bloom from the pipeline
  65257. */
  65258. set bloomEnabled(enabled: boolean);
  65259. get bloomEnabled(): boolean;
  65260. private _rebuildBloom;
  65261. /**
  65262. * If the depth of field is enabled.
  65263. */
  65264. get depthOfFieldEnabled(): boolean;
  65265. set depthOfFieldEnabled(enabled: boolean);
  65266. /**
  65267. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65268. */
  65269. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65270. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65271. /**
  65272. * If the anti aliasing is enabled.
  65273. */
  65274. set fxaaEnabled(enabled: boolean);
  65275. get fxaaEnabled(): boolean;
  65276. private _samples;
  65277. /**
  65278. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65279. */
  65280. set samples(sampleCount: number);
  65281. get samples(): number;
  65282. /**
  65283. * If image processing is enabled.
  65284. */
  65285. set imageProcessingEnabled(enabled: boolean);
  65286. get imageProcessingEnabled(): boolean;
  65287. /**
  65288. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65289. */
  65290. set glowLayerEnabled(enabled: boolean);
  65291. get glowLayerEnabled(): boolean;
  65292. /**
  65293. * Gets the glow layer (or null if not defined)
  65294. */
  65295. get glowLayer(): Nullable<GlowLayer>;
  65296. /**
  65297. * Enable or disable the chromaticAberration process from the pipeline
  65298. */
  65299. set chromaticAberrationEnabled(enabled: boolean);
  65300. get chromaticAberrationEnabled(): boolean;
  65301. /**
  65302. * Enable or disable the grain process from the pipeline
  65303. */
  65304. set grainEnabled(enabled: boolean);
  65305. get grainEnabled(): boolean;
  65306. /**
  65307. * @constructor
  65308. * @param name - The rendering pipeline name (default: "")
  65309. * @param hdr - If high dynamic range textures should be used (default: true)
  65310. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65311. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65312. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65313. */
  65314. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65315. /**
  65316. * Get the class name
  65317. * @returns "DefaultRenderingPipeline"
  65318. */
  65319. getClassName(): string;
  65320. /**
  65321. * Force the compilation of the entire pipeline.
  65322. */
  65323. prepare(): void;
  65324. private _hasCleared;
  65325. private _prevPostProcess;
  65326. private _prevPrevPostProcess;
  65327. private _setAutoClearAndTextureSharing;
  65328. private _depthOfFieldSceneObserver;
  65329. private _buildPipeline;
  65330. private _disposePostProcesses;
  65331. /**
  65332. * Adds a camera to the pipeline
  65333. * @param camera the camera to be added
  65334. */
  65335. addCamera(camera: Camera): void;
  65336. /**
  65337. * Removes a camera from the pipeline
  65338. * @param camera the camera to remove
  65339. */
  65340. removeCamera(camera: Camera): void;
  65341. /**
  65342. * Dispose of the pipeline and stop all post processes
  65343. */
  65344. dispose(): void;
  65345. /**
  65346. * Serialize the rendering pipeline (Used when exporting)
  65347. * @returns the serialized object
  65348. */
  65349. serialize(): any;
  65350. /**
  65351. * Parse the serialized pipeline
  65352. * @param source Source pipeline.
  65353. * @param scene The scene to load the pipeline to.
  65354. * @param rootUrl The URL of the serialized pipeline.
  65355. * @returns An instantiated pipeline from the serialized object.
  65356. */
  65357. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65358. }
  65359. }
  65360. declare module BABYLON {
  65361. /** @hidden */
  65362. export var lensHighlightsPixelShader: {
  65363. name: string;
  65364. shader: string;
  65365. };
  65366. }
  65367. declare module BABYLON {
  65368. /** @hidden */
  65369. export var depthOfFieldPixelShader: {
  65370. name: string;
  65371. shader: string;
  65372. };
  65373. }
  65374. declare module BABYLON {
  65375. /**
  65376. * BABYLON.JS Chromatic Aberration GLSL Shader
  65377. * Author: Olivier Guyot
  65378. * Separates very slightly R, G and B colors on the edges of the screen
  65379. * Inspired by Francois Tarlier & Martins Upitis
  65380. */
  65381. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65382. /**
  65383. * @ignore
  65384. * The chromatic aberration PostProcess id in the pipeline
  65385. */
  65386. LensChromaticAberrationEffect: string;
  65387. /**
  65388. * @ignore
  65389. * The highlights enhancing PostProcess id in the pipeline
  65390. */
  65391. HighlightsEnhancingEffect: string;
  65392. /**
  65393. * @ignore
  65394. * The depth-of-field PostProcess id in the pipeline
  65395. */
  65396. LensDepthOfFieldEffect: string;
  65397. private _scene;
  65398. private _depthTexture;
  65399. private _grainTexture;
  65400. private _chromaticAberrationPostProcess;
  65401. private _highlightsPostProcess;
  65402. private _depthOfFieldPostProcess;
  65403. private _edgeBlur;
  65404. private _grainAmount;
  65405. private _chromaticAberration;
  65406. private _distortion;
  65407. private _highlightsGain;
  65408. private _highlightsThreshold;
  65409. private _dofDistance;
  65410. private _dofAperture;
  65411. private _dofDarken;
  65412. private _dofPentagon;
  65413. private _blurNoise;
  65414. /**
  65415. * @constructor
  65416. *
  65417. * Effect parameters are as follow:
  65418. * {
  65419. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65420. * edge_blur: number; // from 0 to x (1 for realism)
  65421. * distortion: number; // from 0 to x (1 for realism)
  65422. * grain_amount: number; // from 0 to 1
  65423. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65424. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65425. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65426. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65427. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65428. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65429. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65430. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65431. * }
  65432. * Note: if an effect parameter is unset, effect is disabled
  65433. *
  65434. * @param name The rendering pipeline name
  65435. * @param parameters - An object containing all parameters (see above)
  65436. * @param scene The scene linked to this pipeline
  65437. * @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)
  65438. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65439. */
  65440. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65441. /**
  65442. * Get the class name
  65443. * @returns "LensRenderingPipeline"
  65444. */
  65445. getClassName(): string;
  65446. /**
  65447. * Gets associated scene
  65448. */
  65449. get scene(): Scene;
  65450. /**
  65451. * Gets or sets the edge blur
  65452. */
  65453. get edgeBlur(): number;
  65454. set edgeBlur(value: number);
  65455. /**
  65456. * Gets or sets the grain amount
  65457. */
  65458. get grainAmount(): number;
  65459. set grainAmount(value: number);
  65460. /**
  65461. * Gets or sets the chromatic aberration amount
  65462. */
  65463. get chromaticAberration(): number;
  65464. set chromaticAberration(value: number);
  65465. /**
  65466. * Gets or sets the depth of field aperture
  65467. */
  65468. get dofAperture(): number;
  65469. set dofAperture(value: number);
  65470. /**
  65471. * Gets or sets the edge distortion
  65472. */
  65473. get edgeDistortion(): number;
  65474. set edgeDistortion(value: number);
  65475. /**
  65476. * Gets or sets the depth of field distortion
  65477. */
  65478. get dofDistortion(): number;
  65479. set dofDistortion(value: number);
  65480. /**
  65481. * Gets or sets the darken out of focus amount
  65482. */
  65483. get darkenOutOfFocus(): number;
  65484. set darkenOutOfFocus(value: number);
  65485. /**
  65486. * Gets or sets a boolean indicating if blur noise is enabled
  65487. */
  65488. get blurNoise(): boolean;
  65489. set blurNoise(value: boolean);
  65490. /**
  65491. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65492. */
  65493. get pentagonBokeh(): boolean;
  65494. set pentagonBokeh(value: boolean);
  65495. /**
  65496. * Gets or sets the highlight grain amount
  65497. */
  65498. get highlightsGain(): number;
  65499. set highlightsGain(value: number);
  65500. /**
  65501. * Gets or sets the highlight threshold
  65502. */
  65503. get highlightsThreshold(): number;
  65504. set highlightsThreshold(value: number);
  65505. /**
  65506. * Sets the amount of blur at the edges
  65507. * @param amount blur amount
  65508. */
  65509. setEdgeBlur(amount: number): void;
  65510. /**
  65511. * Sets edge blur to 0
  65512. */
  65513. disableEdgeBlur(): void;
  65514. /**
  65515. * Sets the amout of grain
  65516. * @param amount Amount of grain
  65517. */
  65518. setGrainAmount(amount: number): void;
  65519. /**
  65520. * Set grain amount to 0
  65521. */
  65522. disableGrain(): void;
  65523. /**
  65524. * Sets the chromatic aberration amount
  65525. * @param amount amount of chromatic aberration
  65526. */
  65527. setChromaticAberration(amount: number): void;
  65528. /**
  65529. * Sets chromatic aberration amount to 0
  65530. */
  65531. disableChromaticAberration(): void;
  65532. /**
  65533. * Sets the EdgeDistortion amount
  65534. * @param amount amount of EdgeDistortion
  65535. */
  65536. setEdgeDistortion(amount: number): void;
  65537. /**
  65538. * Sets edge distortion to 0
  65539. */
  65540. disableEdgeDistortion(): void;
  65541. /**
  65542. * Sets the FocusDistance amount
  65543. * @param amount amount of FocusDistance
  65544. */
  65545. setFocusDistance(amount: number): void;
  65546. /**
  65547. * Disables depth of field
  65548. */
  65549. disableDepthOfField(): void;
  65550. /**
  65551. * Sets the Aperture amount
  65552. * @param amount amount of Aperture
  65553. */
  65554. setAperture(amount: number): void;
  65555. /**
  65556. * Sets the DarkenOutOfFocus amount
  65557. * @param amount amount of DarkenOutOfFocus
  65558. */
  65559. setDarkenOutOfFocus(amount: number): void;
  65560. private _pentagonBokehIsEnabled;
  65561. /**
  65562. * Creates a pentagon bokeh effect
  65563. */
  65564. enablePentagonBokeh(): void;
  65565. /**
  65566. * Disables the pentagon bokeh effect
  65567. */
  65568. disablePentagonBokeh(): void;
  65569. /**
  65570. * Enables noise blur
  65571. */
  65572. enableNoiseBlur(): void;
  65573. /**
  65574. * Disables noise blur
  65575. */
  65576. disableNoiseBlur(): void;
  65577. /**
  65578. * Sets the HighlightsGain amount
  65579. * @param amount amount of HighlightsGain
  65580. */
  65581. setHighlightsGain(amount: number): void;
  65582. /**
  65583. * Sets the HighlightsThreshold amount
  65584. * @param amount amount of HighlightsThreshold
  65585. */
  65586. setHighlightsThreshold(amount: number): void;
  65587. /**
  65588. * Disables highlights
  65589. */
  65590. disableHighlights(): void;
  65591. /**
  65592. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65593. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65594. */
  65595. dispose(disableDepthRender?: boolean): void;
  65596. private _createChromaticAberrationPostProcess;
  65597. private _createHighlightsPostProcess;
  65598. private _createDepthOfFieldPostProcess;
  65599. private _createGrainTexture;
  65600. }
  65601. }
  65602. declare module BABYLON {
  65603. /** @hidden */
  65604. export var ssao2PixelShader: {
  65605. name: string;
  65606. shader: string;
  65607. };
  65608. }
  65609. declare module BABYLON {
  65610. /** @hidden */
  65611. export var ssaoCombinePixelShader: {
  65612. name: string;
  65613. shader: string;
  65614. };
  65615. }
  65616. declare module BABYLON {
  65617. /**
  65618. * Render pipeline to produce ssao effect
  65619. */
  65620. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65621. /**
  65622. * @ignore
  65623. * The PassPostProcess id in the pipeline that contains the original scene color
  65624. */
  65625. SSAOOriginalSceneColorEffect: string;
  65626. /**
  65627. * @ignore
  65628. * The SSAO PostProcess id in the pipeline
  65629. */
  65630. SSAORenderEffect: string;
  65631. /**
  65632. * @ignore
  65633. * The horizontal blur PostProcess id in the pipeline
  65634. */
  65635. SSAOBlurHRenderEffect: string;
  65636. /**
  65637. * @ignore
  65638. * The vertical blur PostProcess id in the pipeline
  65639. */
  65640. SSAOBlurVRenderEffect: string;
  65641. /**
  65642. * @ignore
  65643. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65644. */
  65645. SSAOCombineRenderEffect: string;
  65646. /**
  65647. * The output strength of the SSAO post-process. Default value is 1.0.
  65648. */
  65649. totalStrength: number;
  65650. /**
  65651. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65652. */
  65653. maxZ: number;
  65654. /**
  65655. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65656. */
  65657. minZAspect: number;
  65658. private _samples;
  65659. /**
  65660. * Number of samples used for the SSAO calculations. Default value is 8
  65661. */
  65662. set samples(n: number);
  65663. get samples(): number;
  65664. private _textureSamples;
  65665. /**
  65666. * Number of samples to use for antialiasing
  65667. */
  65668. set textureSamples(n: number);
  65669. get textureSamples(): number;
  65670. /**
  65671. * Ratio object used for SSAO ratio and blur ratio
  65672. */
  65673. private _ratio;
  65674. /**
  65675. * Dynamically generated sphere sampler.
  65676. */
  65677. private _sampleSphere;
  65678. /**
  65679. * Blur filter offsets
  65680. */
  65681. private _samplerOffsets;
  65682. private _expensiveBlur;
  65683. /**
  65684. * If bilateral blur should be used
  65685. */
  65686. set expensiveBlur(b: boolean);
  65687. get expensiveBlur(): boolean;
  65688. /**
  65689. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65690. */
  65691. radius: number;
  65692. /**
  65693. * The base color of the SSAO post-process
  65694. * The final result is "base + ssao" between [0, 1]
  65695. */
  65696. base: number;
  65697. /**
  65698. * Support test.
  65699. */
  65700. static get IsSupported(): boolean;
  65701. private _scene;
  65702. private _depthTexture;
  65703. private _normalTexture;
  65704. private _randomTexture;
  65705. private _originalColorPostProcess;
  65706. private _ssaoPostProcess;
  65707. private _blurHPostProcess;
  65708. private _blurVPostProcess;
  65709. private _ssaoCombinePostProcess;
  65710. /**
  65711. * Gets active scene
  65712. */
  65713. get scene(): Scene;
  65714. /**
  65715. * @constructor
  65716. * @param name The rendering pipeline name
  65717. * @param scene The scene linked to this pipeline
  65718. * @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 }
  65719. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65720. */
  65721. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65722. /**
  65723. * Get the class name
  65724. * @returns "SSAO2RenderingPipeline"
  65725. */
  65726. getClassName(): string;
  65727. /**
  65728. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65729. */
  65730. dispose(disableGeometryBufferRenderer?: boolean): void;
  65731. private _createBlurPostProcess;
  65732. /** @hidden */
  65733. _rebuild(): void;
  65734. private _bits;
  65735. private _radicalInverse_VdC;
  65736. private _hammersley;
  65737. private _hemisphereSample_uniform;
  65738. private _generateHemisphere;
  65739. private _createSSAOPostProcess;
  65740. private _createSSAOCombinePostProcess;
  65741. private _createRandomTexture;
  65742. /**
  65743. * Serialize the rendering pipeline (Used when exporting)
  65744. * @returns the serialized object
  65745. */
  65746. serialize(): any;
  65747. /**
  65748. * Parse the serialized pipeline
  65749. * @param source Source pipeline.
  65750. * @param scene The scene to load the pipeline to.
  65751. * @param rootUrl The URL of the serialized pipeline.
  65752. * @returns An instantiated pipeline from the serialized object.
  65753. */
  65754. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65755. }
  65756. }
  65757. declare module BABYLON {
  65758. /** @hidden */
  65759. export var ssaoPixelShader: {
  65760. name: string;
  65761. shader: string;
  65762. };
  65763. }
  65764. declare module BABYLON {
  65765. /**
  65766. * Render pipeline to produce ssao effect
  65767. */
  65768. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65769. /**
  65770. * @ignore
  65771. * The PassPostProcess id in the pipeline that contains the original scene color
  65772. */
  65773. SSAOOriginalSceneColorEffect: string;
  65774. /**
  65775. * @ignore
  65776. * The SSAO PostProcess id in the pipeline
  65777. */
  65778. SSAORenderEffect: string;
  65779. /**
  65780. * @ignore
  65781. * The horizontal blur PostProcess id in the pipeline
  65782. */
  65783. SSAOBlurHRenderEffect: string;
  65784. /**
  65785. * @ignore
  65786. * The vertical blur PostProcess id in the pipeline
  65787. */
  65788. SSAOBlurVRenderEffect: string;
  65789. /**
  65790. * @ignore
  65791. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65792. */
  65793. SSAOCombineRenderEffect: string;
  65794. /**
  65795. * The output strength of the SSAO post-process. Default value is 1.0.
  65796. */
  65797. totalStrength: number;
  65798. /**
  65799. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65800. */
  65801. radius: number;
  65802. /**
  65803. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65804. * Must not be equal to fallOff and superior to fallOff.
  65805. * Default value is 0.0075
  65806. */
  65807. area: number;
  65808. /**
  65809. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65810. * Must not be equal to area and inferior to area.
  65811. * Default value is 0.000001
  65812. */
  65813. fallOff: number;
  65814. /**
  65815. * The base color of the SSAO post-process
  65816. * The final result is "base + ssao" between [0, 1]
  65817. */
  65818. base: number;
  65819. private _scene;
  65820. private _depthTexture;
  65821. private _randomTexture;
  65822. private _originalColorPostProcess;
  65823. private _ssaoPostProcess;
  65824. private _blurHPostProcess;
  65825. private _blurVPostProcess;
  65826. private _ssaoCombinePostProcess;
  65827. private _firstUpdate;
  65828. /**
  65829. * Gets active scene
  65830. */
  65831. get scene(): Scene;
  65832. /**
  65833. * @constructor
  65834. * @param name - The rendering pipeline name
  65835. * @param scene - The scene linked to this pipeline
  65836. * @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 }
  65837. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65838. */
  65839. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65840. /**
  65841. * Get the class name
  65842. * @returns "SSAORenderingPipeline"
  65843. */
  65844. getClassName(): string;
  65845. /**
  65846. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65847. */
  65848. dispose(disableDepthRender?: boolean): void;
  65849. private _createBlurPostProcess;
  65850. /** @hidden */
  65851. _rebuild(): void;
  65852. private _createSSAOPostProcess;
  65853. private _createSSAOCombinePostProcess;
  65854. private _createRandomTexture;
  65855. }
  65856. }
  65857. declare module BABYLON {
  65858. /** @hidden */
  65859. export var screenSpaceReflectionPixelShader: {
  65860. name: string;
  65861. shader: string;
  65862. };
  65863. }
  65864. declare module BABYLON {
  65865. /**
  65866. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65867. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65868. */
  65869. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65870. /**
  65871. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65872. */
  65873. threshold: number;
  65874. /**
  65875. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65876. */
  65877. strength: number;
  65878. /**
  65879. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65880. */
  65881. reflectionSpecularFalloffExponent: number;
  65882. /**
  65883. * 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]
  65884. */
  65885. step: number;
  65886. /**
  65887. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65888. */
  65889. roughnessFactor: number;
  65890. private _geometryBufferRenderer;
  65891. private _enableSmoothReflections;
  65892. private _reflectionSamples;
  65893. private _smoothSteps;
  65894. /**
  65895. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65896. * @param name The name of the effect.
  65897. * @param scene The scene containing the objects to calculate reflections.
  65898. * @param options The required width/height ratio to downsize to before computing the render pass.
  65899. * @param camera The camera to apply the render pass to.
  65900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65901. * @param engine The engine which the post process will be applied. (default: current engine)
  65902. * @param reusable If the post process can be reused on the same frame. (default: false)
  65903. * @param textureType Type of textures used when performing the post process. (default: 0)
  65904. * @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)
  65905. */
  65906. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65907. /**
  65908. * Gets wether or not smoothing reflections is enabled.
  65909. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65910. */
  65911. get enableSmoothReflections(): boolean;
  65912. /**
  65913. * Sets wether or not smoothing reflections is enabled.
  65914. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65915. */
  65916. set enableSmoothReflections(enabled: boolean);
  65917. /**
  65918. * Gets the number of samples taken while computing reflections. More samples count is high,
  65919. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65920. */
  65921. get reflectionSamples(): number;
  65922. /**
  65923. * Sets the number of samples taken while computing reflections. More samples count is high,
  65924. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65925. */
  65926. set reflectionSamples(samples: number);
  65927. /**
  65928. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65929. * more the post-process will require GPU power and can generate a drop in FPS.
  65930. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65931. */
  65932. get smoothSteps(): number;
  65933. set smoothSteps(steps: number);
  65934. private _updateEffectDefines;
  65935. }
  65936. }
  65937. declare module BABYLON {
  65938. /** @hidden */
  65939. export var standardPixelShader: {
  65940. name: string;
  65941. shader: string;
  65942. };
  65943. }
  65944. declare module BABYLON {
  65945. /**
  65946. * Standard rendering pipeline
  65947. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65948. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65949. */
  65950. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65951. /**
  65952. * Public members
  65953. */
  65954. /**
  65955. * Post-process which contains the original scene color before the pipeline applies all the effects
  65956. */
  65957. originalPostProcess: Nullable<PostProcess>;
  65958. /**
  65959. * Post-process used to down scale an image x4
  65960. */
  65961. downSampleX4PostProcess: Nullable<PostProcess>;
  65962. /**
  65963. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65964. */
  65965. brightPassPostProcess: Nullable<PostProcess>;
  65966. /**
  65967. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65968. */
  65969. blurHPostProcesses: PostProcess[];
  65970. /**
  65971. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65972. */
  65973. blurVPostProcesses: PostProcess[];
  65974. /**
  65975. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65976. */
  65977. textureAdderPostProcess: Nullable<PostProcess>;
  65978. /**
  65979. * Post-process used to create volumetric lighting effect
  65980. */
  65981. volumetricLightPostProcess: Nullable<PostProcess>;
  65982. /**
  65983. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65984. */
  65985. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65986. /**
  65987. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65988. */
  65989. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65990. /**
  65991. * Post-process used to merge the volumetric light effect and the real scene color
  65992. */
  65993. volumetricLightMergePostProces: Nullable<PostProcess>;
  65994. /**
  65995. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65996. */
  65997. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65998. /**
  65999. * Base post-process used to calculate the average luminance of the final image for HDR
  66000. */
  66001. luminancePostProcess: Nullable<PostProcess>;
  66002. /**
  66003. * Post-processes used to create down sample post-processes in order to get
  66004. * the average luminance of the final image for HDR
  66005. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66006. */
  66007. luminanceDownSamplePostProcesses: PostProcess[];
  66008. /**
  66009. * Post-process used to create a HDR effect (light adaptation)
  66010. */
  66011. hdrPostProcess: Nullable<PostProcess>;
  66012. /**
  66013. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66014. */
  66015. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66016. /**
  66017. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66018. */
  66019. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66020. /**
  66021. * Post-process used to merge the final HDR post-process and the real scene color
  66022. */
  66023. hdrFinalPostProcess: Nullable<PostProcess>;
  66024. /**
  66025. * Post-process used to create a lens flare effect
  66026. */
  66027. lensFlarePostProcess: Nullable<PostProcess>;
  66028. /**
  66029. * Post-process that merges the result of the lens flare post-process and the real scene color
  66030. */
  66031. lensFlareComposePostProcess: Nullable<PostProcess>;
  66032. /**
  66033. * Post-process used to create a motion blur effect
  66034. */
  66035. motionBlurPostProcess: Nullable<PostProcess>;
  66036. /**
  66037. * Post-process used to create a depth of field effect
  66038. */
  66039. depthOfFieldPostProcess: Nullable<PostProcess>;
  66040. /**
  66041. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66042. */
  66043. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66044. /**
  66045. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66046. */
  66047. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66048. /**
  66049. * Represents the brightness threshold in order to configure the illuminated surfaces
  66050. */
  66051. brightThreshold: number;
  66052. /**
  66053. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66054. */
  66055. blurWidth: number;
  66056. /**
  66057. * Sets if the blur for highlighted surfaces must be only horizontal
  66058. */
  66059. horizontalBlur: boolean;
  66060. /**
  66061. * Gets the overall exposure used by the pipeline
  66062. */
  66063. get exposure(): number;
  66064. /**
  66065. * Sets the overall exposure used by the pipeline
  66066. */
  66067. set exposure(value: number);
  66068. /**
  66069. * Texture used typically to simulate "dirty" on camera lens
  66070. */
  66071. lensTexture: Nullable<Texture>;
  66072. /**
  66073. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66074. */
  66075. volumetricLightCoefficient: number;
  66076. /**
  66077. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66078. */
  66079. volumetricLightPower: number;
  66080. /**
  66081. * Used the set the blur intensity to smooth the volumetric lights
  66082. */
  66083. volumetricLightBlurScale: number;
  66084. /**
  66085. * Light (spot or directional) used to generate the volumetric lights rays
  66086. * The source light must have a shadow generate so the pipeline can get its
  66087. * depth map
  66088. */
  66089. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66090. /**
  66091. * For eye adaptation, represents the minimum luminance the eye can see
  66092. */
  66093. hdrMinimumLuminance: number;
  66094. /**
  66095. * For eye adaptation, represents the decrease luminance speed
  66096. */
  66097. hdrDecreaseRate: number;
  66098. /**
  66099. * For eye adaptation, represents the increase luminance speed
  66100. */
  66101. hdrIncreaseRate: number;
  66102. /**
  66103. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66104. */
  66105. get hdrAutoExposure(): boolean;
  66106. /**
  66107. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66108. */
  66109. set hdrAutoExposure(value: boolean);
  66110. /**
  66111. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66112. */
  66113. lensColorTexture: Nullable<Texture>;
  66114. /**
  66115. * The overall strengh for the lens flare effect
  66116. */
  66117. lensFlareStrength: number;
  66118. /**
  66119. * Dispersion coefficient for lens flare ghosts
  66120. */
  66121. lensFlareGhostDispersal: number;
  66122. /**
  66123. * Main lens flare halo width
  66124. */
  66125. lensFlareHaloWidth: number;
  66126. /**
  66127. * Based on the lens distortion effect, defines how much the lens flare result
  66128. * is distorted
  66129. */
  66130. lensFlareDistortionStrength: number;
  66131. /**
  66132. * Configures the blur intensity used for for lens flare (halo)
  66133. */
  66134. lensFlareBlurWidth: number;
  66135. /**
  66136. * Lens star texture must be used to simulate rays on the flares and is available
  66137. * in the documentation
  66138. */
  66139. lensStarTexture: Nullable<Texture>;
  66140. /**
  66141. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66142. * flare effect by taking account of the dirt texture
  66143. */
  66144. lensFlareDirtTexture: Nullable<Texture>;
  66145. /**
  66146. * Represents the focal length for the depth of field effect
  66147. */
  66148. depthOfFieldDistance: number;
  66149. /**
  66150. * Represents the blur intensity for the blurred part of the depth of field effect
  66151. */
  66152. depthOfFieldBlurWidth: number;
  66153. /**
  66154. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66155. */
  66156. get motionStrength(): number;
  66157. /**
  66158. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66159. */
  66160. set motionStrength(strength: number);
  66161. /**
  66162. * Gets wether or not the motion blur post-process is object based or screen based.
  66163. */
  66164. get objectBasedMotionBlur(): boolean;
  66165. /**
  66166. * Sets wether or not the motion blur post-process should be object based or screen based
  66167. */
  66168. set objectBasedMotionBlur(value: boolean);
  66169. /**
  66170. * List of animations for the pipeline (IAnimatable implementation)
  66171. */
  66172. animations: Animation[];
  66173. /**
  66174. * Private members
  66175. */
  66176. private _scene;
  66177. private _currentDepthOfFieldSource;
  66178. private _basePostProcess;
  66179. private _fixedExposure;
  66180. private _currentExposure;
  66181. private _hdrAutoExposure;
  66182. private _hdrCurrentLuminance;
  66183. private _motionStrength;
  66184. private _isObjectBasedMotionBlur;
  66185. private _floatTextureType;
  66186. private _camerasToBeAttached;
  66187. private _ratio;
  66188. private _bloomEnabled;
  66189. private _depthOfFieldEnabled;
  66190. private _vlsEnabled;
  66191. private _lensFlareEnabled;
  66192. private _hdrEnabled;
  66193. private _motionBlurEnabled;
  66194. private _fxaaEnabled;
  66195. private _screenSpaceReflectionsEnabled;
  66196. private _motionBlurSamples;
  66197. private _volumetricLightStepsCount;
  66198. private _samples;
  66199. /**
  66200. * @ignore
  66201. * Specifies if the bloom pipeline is enabled
  66202. */
  66203. get BloomEnabled(): boolean;
  66204. set BloomEnabled(enabled: boolean);
  66205. /**
  66206. * @ignore
  66207. * Specifies if the depth of field pipeline is enabed
  66208. */
  66209. get DepthOfFieldEnabled(): boolean;
  66210. set DepthOfFieldEnabled(enabled: boolean);
  66211. /**
  66212. * @ignore
  66213. * Specifies if the lens flare pipeline is enabed
  66214. */
  66215. get LensFlareEnabled(): boolean;
  66216. set LensFlareEnabled(enabled: boolean);
  66217. /**
  66218. * @ignore
  66219. * Specifies if the HDR pipeline is enabled
  66220. */
  66221. get HDREnabled(): boolean;
  66222. set HDREnabled(enabled: boolean);
  66223. /**
  66224. * @ignore
  66225. * Specifies if the volumetric lights scattering effect is enabled
  66226. */
  66227. get VLSEnabled(): boolean;
  66228. set VLSEnabled(enabled: boolean);
  66229. /**
  66230. * @ignore
  66231. * Specifies if the motion blur effect is enabled
  66232. */
  66233. get MotionBlurEnabled(): boolean;
  66234. set MotionBlurEnabled(enabled: boolean);
  66235. /**
  66236. * Specifies if anti-aliasing is enabled
  66237. */
  66238. get fxaaEnabled(): boolean;
  66239. set fxaaEnabled(enabled: boolean);
  66240. /**
  66241. * Specifies if screen space reflections are enabled.
  66242. */
  66243. get screenSpaceReflectionsEnabled(): boolean;
  66244. set screenSpaceReflectionsEnabled(enabled: boolean);
  66245. /**
  66246. * Specifies the number of steps used to calculate the volumetric lights
  66247. * Typically in interval [50, 200]
  66248. */
  66249. get volumetricLightStepsCount(): number;
  66250. set volumetricLightStepsCount(count: number);
  66251. /**
  66252. * Specifies the number of samples used for the motion blur effect
  66253. * Typically in interval [16, 64]
  66254. */
  66255. get motionBlurSamples(): number;
  66256. set motionBlurSamples(samples: number);
  66257. /**
  66258. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66259. */
  66260. get samples(): number;
  66261. set samples(sampleCount: number);
  66262. /**
  66263. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66264. * @constructor
  66265. * @param name The rendering pipeline name
  66266. * @param scene The scene linked to this pipeline
  66267. * @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)
  66268. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66269. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66270. */
  66271. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66272. private _buildPipeline;
  66273. private _createDownSampleX4PostProcess;
  66274. private _createBrightPassPostProcess;
  66275. private _createBlurPostProcesses;
  66276. private _createTextureAdderPostProcess;
  66277. private _createVolumetricLightPostProcess;
  66278. private _createLuminancePostProcesses;
  66279. private _createHdrPostProcess;
  66280. private _createLensFlarePostProcess;
  66281. private _createDepthOfFieldPostProcess;
  66282. private _createMotionBlurPostProcess;
  66283. private _getDepthTexture;
  66284. private _disposePostProcesses;
  66285. /**
  66286. * Dispose of the pipeline and stop all post processes
  66287. */
  66288. dispose(): void;
  66289. /**
  66290. * Serialize the rendering pipeline (Used when exporting)
  66291. * @returns the serialized object
  66292. */
  66293. serialize(): any;
  66294. /**
  66295. * Parse the serialized pipeline
  66296. * @param source Source pipeline.
  66297. * @param scene The scene to load the pipeline to.
  66298. * @param rootUrl The URL of the serialized pipeline.
  66299. * @returns An instantiated pipeline from the serialized object.
  66300. */
  66301. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66302. /**
  66303. * Luminance steps
  66304. */
  66305. static LuminanceSteps: number;
  66306. }
  66307. }
  66308. declare module BABYLON {
  66309. /** @hidden */
  66310. export var tonemapPixelShader: {
  66311. name: string;
  66312. shader: string;
  66313. };
  66314. }
  66315. declare module BABYLON {
  66316. /** Defines operator used for tonemapping */
  66317. export enum TonemappingOperator {
  66318. /** Hable */
  66319. Hable = 0,
  66320. /** Reinhard */
  66321. Reinhard = 1,
  66322. /** HejiDawson */
  66323. HejiDawson = 2,
  66324. /** Photographic */
  66325. Photographic = 3
  66326. }
  66327. /**
  66328. * Defines a post process to apply tone mapping
  66329. */
  66330. export class TonemapPostProcess extends PostProcess {
  66331. private _operator;
  66332. /** Defines the required exposure adjustement */
  66333. exposureAdjustment: number;
  66334. /**
  66335. * Creates a new TonemapPostProcess
  66336. * @param name defines the name of the postprocess
  66337. * @param _operator defines the operator to use
  66338. * @param exposureAdjustment defines the required exposure adjustement
  66339. * @param camera defines the camera to use (can be null)
  66340. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66341. * @param engine defines the hosting engine (can be ignore if camera is set)
  66342. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66343. */
  66344. constructor(name: string, _operator: TonemappingOperator,
  66345. /** Defines the required exposure adjustement */
  66346. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66347. }
  66348. }
  66349. declare module BABYLON {
  66350. /** @hidden */
  66351. export var volumetricLightScatteringPixelShader: {
  66352. name: string;
  66353. shader: string;
  66354. };
  66355. }
  66356. declare module BABYLON {
  66357. /** @hidden */
  66358. export var volumetricLightScatteringPassVertexShader: {
  66359. name: string;
  66360. shader: string;
  66361. };
  66362. }
  66363. declare module BABYLON {
  66364. /** @hidden */
  66365. export var volumetricLightScatteringPassPixelShader: {
  66366. name: string;
  66367. shader: string;
  66368. };
  66369. }
  66370. declare module BABYLON {
  66371. /**
  66372. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66373. */
  66374. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66375. private _volumetricLightScatteringPass;
  66376. private _volumetricLightScatteringRTT;
  66377. private _viewPort;
  66378. private _screenCoordinates;
  66379. private _cachedDefines;
  66380. /**
  66381. * If not undefined, the mesh position is computed from the attached node position
  66382. */
  66383. attachedNode: {
  66384. position: Vector3;
  66385. };
  66386. /**
  66387. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66388. */
  66389. customMeshPosition: Vector3;
  66390. /**
  66391. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66392. */
  66393. useCustomMeshPosition: boolean;
  66394. /**
  66395. * If the post-process should inverse the light scattering direction
  66396. */
  66397. invert: boolean;
  66398. /**
  66399. * The internal mesh used by the post-process
  66400. */
  66401. mesh: Mesh;
  66402. /**
  66403. * @hidden
  66404. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66405. */
  66406. get useDiffuseColor(): boolean;
  66407. set useDiffuseColor(useDiffuseColor: boolean);
  66408. /**
  66409. * Array containing the excluded meshes not rendered in the internal pass
  66410. */
  66411. excludedMeshes: AbstractMesh[];
  66412. /**
  66413. * Controls the overall intensity of the post-process
  66414. */
  66415. exposure: number;
  66416. /**
  66417. * Dissipates each sample's contribution in range [0, 1]
  66418. */
  66419. decay: number;
  66420. /**
  66421. * Controls the overall intensity of each sample
  66422. */
  66423. weight: number;
  66424. /**
  66425. * Controls the density of each sample
  66426. */
  66427. density: number;
  66428. /**
  66429. * @constructor
  66430. * @param name The post-process name
  66431. * @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)
  66432. * @param camera The camera that the post-process will be attached to
  66433. * @param mesh The mesh used to create the light scattering
  66434. * @param samples The post-process quality, default 100
  66435. * @param samplingModeThe post-process filtering mode
  66436. * @param engine The babylon engine
  66437. * @param reusable If the post-process is reusable
  66438. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66439. */
  66440. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66441. /**
  66442. * Returns the string "VolumetricLightScatteringPostProcess"
  66443. * @returns "VolumetricLightScatteringPostProcess"
  66444. */
  66445. getClassName(): string;
  66446. private _isReady;
  66447. /**
  66448. * Sets the new light position for light scattering effect
  66449. * @param position The new custom light position
  66450. */
  66451. setCustomMeshPosition(position: Vector3): void;
  66452. /**
  66453. * Returns the light position for light scattering effect
  66454. * @return Vector3 The custom light position
  66455. */
  66456. getCustomMeshPosition(): Vector3;
  66457. /**
  66458. * Disposes the internal assets and detaches the post-process from the camera
  66459. */
  66460. dispose(camera: Camera): void;
  66461. /**
  66462. * Returns the render target texture used by the post-process
  66463. * @return the render target texture used by the post-process
  66464. */
  66465. getPass(): RenderTargetTexture;
  66466. private _meshExcluded;
  66467. private _createPass;
  66468. private _updateMeshScreenCoordinates;
  66469. /**
  66470. * Creates a default mesh for the Volumeric Light Scattering post-process
  66471. * @param name The mesh name
  66472. * @param scene The scene where to create the mesh
  66473. * @return the default mesh
  66474. */
  66475. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66476. }
  66477. }
  66478. declare module BABYLON {
  66479. interface Scene {
  66480. /** @hidden (Backing field) */
  66481. _boundingBoxRenderer: BoundingBoxRenderer;
  66482. /** @hidden (Backing field) */
  66483. _forceShowBoundingBoxes: boolean;
  66484. /**
  66485. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66486. */
  66487. forceShowBoundingBoxes: boolean;
  66488. /**
  66489. * Gets the bounding box renderer associated with the scene
  66490. * @returns a BoundingBoxRenderer
  66491. */
  66492. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66493. }
  66494. interface AbstractMesh {
  66495. /** @hidden (Backing field) */
  66496. _showBoundingBox: boolean;
  66497. /**
  66498. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66499. */
  66500. showBoundingBox: boolean;
  66501. }
  66502. /**
  66503. * Component responsible of rendering the bounding box of the meshes in a scene.
  66504. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66505. */
  66506. export class BoundingBoxRenderer implements ISceneComponent {
  66507. /**
  66508. * The component name helpfull to identify the component in the list of scene components.
  66509. */
  66510. readonly name: string;
  66511. /**
  66512. * The scene the component belongs to.
  66513. */
  66514. scene: Scene;
  66515. /**
  66516. * Color of the bounding box lines placed in front of an object
  66517. */
  66518. frontColor: Color3;
  66519. /**
  66520. * Color of the bounding box lines placed behind an object
  66521. */
  66522. backColor: Color3;
  66523. /**
  66524. * Defines if the renderer should show the back lines or not
  66525. */
  66526. showBackLines: boolean;
  66527. /**
  66528. * @hidden
  66529. */
  66530. renderList: SmartArray<BoundingBox>;
  66531. private _colorShader;
  66532. private _vertexBuffers;
  66533. private _indexBuffer;
  66534. private _fillIndexBuffer;
  66535. private _fillIndexData;
  66536. /**
  66537. * Instantiates a new bounding box renderer in a scene.
  66538. * @param scene the scene the renderer renders in
  66539. */
  66540. constructor(scene: Scene);
  66541. /**
  66542. * Registers the component in a given scene
  66543. */
  66544. register(): void;
  66545. private _evaluateSubMesh;
  66546. private _activeMesh;
  66547. private _prepareRessources;
  66548. private _createIndexBuffer;
  66549. /**
  66550. * Rebuilds the elements related to this component in case of
  66551. * context lost for instance.
  66552. */
  66553. rebuild(): void;
  66554. /**
  66555. * @hidden
  66556. */
  66557. reset(): void;
  66558. /**
  66559. * Render the bounding boxes of a specific rendering group
  66560. * @param renderingGroupId defines the rendering group to render
  66561. */
  66562. render(renderingGroupId: number): void;
  66563. /**
  66564. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66565. * @param mesh Define the mesh to render the occlusion bounding box for
  66566. */
  66567. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66568. /**
  66569. * Dispose and release the resources attached to this renderer.
  66570. */
  66571. dispose(): void;
  66572. }
  66573. }
  66574. declare module BABYLON {
  66575. interface Scene {
  66576. /** @hidden (Backing field) */
  66577. _depthRenderer: {
  66578. [id: string]: DepthRenderer;
  66579. };
  66580. /**
  66581. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66582. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66583. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66584. * @returns the created depth renderer
  66585. */
  66586. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66587. /**
  66588. * Disables a depth renderer for a given camera
  66589. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66590. */
  66591. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66592. }
  66593. /**
  66594. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66595. * in several rendering techniques.
  66596. */
  66597. export class DepthRendererSceneComponent implements ISceneComponent {
  66598. /**
  66599. * The component name helpfull to identify the component in the list of scene components.
  66600. */
  66601. readonly name: string;
  66602. /**
  66603. * The scene the component belongs to.
  66604. */
  66605. scene: Scene;
  66606. /**
  66607. * Creates a new instance of the component for the given scene
  66608. * @param scene Defines the scene to register the component in
  66609. */
  66610. constructor(scene: Scene);
  66611. /**
  66612. * Registers the component in a given scene
  66613. */
  66614. register(): void;
  66615. /**
  66616. * Rebuilds the elements related to this component in case of
  66617. * context lost for instance.
  66618. */
  66619. rebuild(): void;
  66620. /**
  66621. * Disposes the component and the associated ressources
  66622. */
  66623. dispose(): void;
  66624. private _gatherRenderTargets;
  66625. private _gatherActiveCameraRenderTargets;
  66626. }
  66627. }
  66628. declare module BABYLON {
  66629. /** @hidden */
  66630. export var outlinePixelShader: {
  66631. name: string;
  66632. shader: string;
  66633. };
  66634. }
  66635. declare module BABYLON {
  66636. /** @hidden */
  66637. export var outlineVertexShader: {
  66638. name: string;
  66639. shader: string;
  66640. };
  66641. }
  66642. declare module BABYLON {
  66643. interface Scene {
  66644. /** @hidden */
  66645. _outlineRenderer: OutlineRenderer;
  66646. /**
  66647. * Gets the outline renderer associated with the scene
  66648. * @returns a OutlineRenderer
  66649. */
  66650. getOutlineRenderer(): OutlineRenderer;
  66651. }
  66652. interface AbstractMesh {
  66653. /** @hidden (Backing field) */
  66654. _renderOutline: boolean;
  66655. /**
  66656. * Gets or sets a boolean indicating if the outline must be rendered as well
  66657. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66658. */
  66659. renderOutline: boolean;
  66660. /** @hidden (Backing field) */
  66661. _renderOverlay: boolean;
  66662. /**
  66663. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66664. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66665. */
  66666. renderOverlay: boolean;
  66667. }
  66668. /**
  66669. * This class is responsible to draw bothe outline/overlay of meshes.
  66670. * It should not be used directly but through the available method on mesh.
  66671. */
  66672. export class OutlineRenderer implements ISceneComponent {
  66673. /**
  66674. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66675. */
  66676. private static _StencilReference;
  66677. /**
  66678. * The name of the component. Each component must have a unique name.
  66679. */
  66680. name: string;
  66681. /**
  66682. * The scene the component belongs to.
  66683. */
  66684. scene: Scene;
  66685. /**
  66686. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66687. */
  66688. zOffset: number;
  66689. private _engine;
  66690. private _effect;
  66691. private _cachedDefines;
  66692. private _savedDepthWrite;
  66693. /**
  66694. * Instantiates a new outline renderer. (There could be only one per scene).
  66695. * @param scene Defines the scene it belongs to
  66696. */
  66697. constructor(scene: Scene);
  66698. /**
  66699. * Register the component to one instance of a scene.
  66700. */
  66701. register(): void;
  66702. /**
  66703. * Rebuilds the elements related to this component in case of
  66704. * context lost for instance.
  66705. */
  66706. rebuild(): void;
  66707. /**
  66708. * Disposes the component and the associated ressources.
  66709. */
  66710. dispose(): void;
  66711. /**
  66712. * Renders the outline in the canvas.
  66713. * @param subMesh Defines the sumesh to render
  66714. * @param batch Defines the batch of meshes in case of instances
  66715. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66716. */
  66717. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66718. /**
  66719. * Returns whether or not the outline renderer is ready for a given submesh.
  66720. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66721. * @param subMesh Defines the submesh to check readyness for
  66722. * @param useInstances Defines wheter wee are trying to render instances or not
  66723. * @returns true if ready otherwise false
  66724. */
  66725. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66726. private _beforeRenderingMesh;
  66727. private _afterRenderingMesh;
  66728. }
  66729. }
  66730. declare module BABYLON {
  66731. /**
  66732. * Defines the basic options interface of a Sprite Frame Source Size.
  66733. */
  66734. export interface ISpriteJSONSpriteSourceSize {
  66735. /**
  66736. * number of the original width of the Frame
  66737. */
  66738. w: number;
  66739. /**
  66740. * number of the original height of the Frame
  66741. */
  66742. h: number;
  66743. }
  66744. /**
  66745. * Defines the basic options interface of a Sprite Frame Data.
  66746. */
  66747. export interface ISpriteJSONSpriteFrameData {
  66748. /**
  66749. * number of the x offset of the Frame
  66750. */
  66751. x: number;
  66752. /**
  66753. * number of the y offset of the Frame
  66754. */
  66755. y: number;
  66756. /**
  66757. * number of the width of the Frame
  66758. */
  66759. w: number;
  66760. /**
  66761. * number of the height of the Frame
  66762. */
  66763. h: number;
  66764. }
  66765. /**
  66766. * Defines the basic options interface of a JSON Sprite.
  66767. */
  66768. export interface ISpriteJSONSprite {
  66769. /**
  66770. * string name of the Frame
  66771. */
  66772. filename: string;
  66773. /**
  66774. * ISpriteJSONSpriteFrame basic object of the frame data
  66775. */
  66776. frame: ISpriteJSONSpriteFrameData;
  66777. /**
  66778. * boolean to flag is the frame was rotated.
  66779. */
  66780. rotated: boolean;
  66781. /**
  66782. * boolean to flag is the frame was trimmed.
  66783. */
  66784. trimmed: boolean;
  66785. /**
  66786. * ISpriteJSONSpriteFrame basic object of the source data
  66787. */
  66788. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66789. /**
  66790. * ISpriteJSONSpriteFrame basic object of the source data
  66791. */
  66792. sourceSize: ISpriteJSONSpriteSourceSize;
  66793. }
  66794. /**
  66795. * Defines the basic options interface of a JSON atlas.
  66796. */
  66797. export interface ISpriteJSONAtlas {
  66798. /**
  66799. * Array of objects that contain the frame data.
  66800. */
  66801. frames: Array<ISpriteJSONSprite>;
  66802. /**
  66803. * object basic object containing the sprite meta data.
  66804. */
  66805. meta?: object;
  66806. }
  66807. }
  66808. declare module BABYLON {
  66809. /** @hidden */
  66810. export var spriteMapPixelShader: {
  66811. name: string;
  66812. shader: string;
  66813. };
  66814. }
  66815. declare module BABYLON {
  66816. /** @hidden */
  66817. export var spriteMapVertexShader: {
  66818. name: string;
  66819. shader: string;
  66820. };
  66821. }
  66822. declare module BABYLON {
  66823. /**
  66824. * Defines the basic options interface of a SpriteMap
  66825. */
  66826. export interface ISpriteMapOptions {
  66827. /**
  66828. * Vector2 of the number of cells in the grid.
  66829. */
  66830. stageSize?: Vector2;
  66831. /**
  66832. * Vector2 of the size of the output plane in World Units.
  66833. */
  66834. outputSize?: Vector2;
  66835. /**
  66836. * Vector3 of the position of the output plane in World Units.
  66837. */
  66838. outputPosition?: Vector3;
  66839. /**
  66840. * Vector3 of the rotation of the output plane.
  66841. */
  66842. outputRotation?: Vector3;
  66843. /**
  66844. * number of layers that the system will reserve in resources.
  66845. */
  66846. layerCount?: number;
  66847. /**
  66848. * number of max animation frames a single cell will reserve in resources.
  66849. */
  66850. maxAnimationFrames?: number;
  66851. /**
  66852. * number cell index of the base tile when the system compiles.
  66853. */
  66854. baseTile?: number;
  66855. /**
  66856. * boolean flip the sprite after its been repositioned by the framing data.
  66857. */
  66858. flipU?: boolean;
  66859. /**
  66860. * Vector3 scalar of the global RGB values of the SpriteMap.
  66861. */
  66862. colorMultiply?: Vector3;
  66863. }
  66864. /**
  66865. * Defines the IDisposable interface in order to be cleanable from resources.
  66866. */
  66867. export interface ISpriteMap extends IDisposable {
  66868. /**
  66869. * String name of the SpriteMap.
  66870. */
  66871. name: string;
  66872. /**
  66873. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66874. */
  66875. atlasJSON: ISpriteJSONAtlas;
  66876. /**
  66877. * Texture of the SpriteMap.
  66878. */
  66879. spriteSheet: Texture;
  66880. /**
  66881. * The parameters to initialize the SpriteMap with.
  66882. */
  66883. options: ISpriteMapOptions;
  66884. }
  66885. /**
  66886. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66887. */
  66888. export class SpriteMap implements ISpriteMap {
  66889. /** The Name of the spriteMap */
  66890. name: string;
  66891. /** The JSON file with the frame and meta data */
  66892. atlasJSON: ISpriteJSONAtlas;
  66893. /** The systems Sprite Sheet Texture */
  66894. spriteSheet: Texture;
  66895. /** Arguments passed with the Constructor */
  66896. options: ISpriteMapOptions;
  66897. /** Public Sprite Storage array, parsed from atlasJSON */
  66898. sprites: Array<ISpriteJSONSprite>;
  66899. /** Returns the Number of Sprites in the System */
  66900. get spriteCount(): number;
  66901. /** Returns the Position of Output Plane*/
  66902. get position(): Vector3;
  66903. /** Returns the Position of Output Plane*/
  66904. set position(v: Vector3);
  66905. /** Returns the Rotation of Output Plane*/
  66906. get rotation(): Vector3;
  66907. /** Returns the Rotation of Output Plane*/
  66908. set rotation(v: Vector3);
  66909. /** Sets the AnimationMap*/
  66910. get animationMap(): RawTexture;
  66911. /** Sets the AnimationMap*/
  66912. set animationMap(v: RawTexture);
  66913. /** Scene that the SpriteMap was created in */
  66914. private _scene;
  66915. /** Texture Buffer of Float32 that holds tile frame data*/
  66916. private _frameMap;
  66917. /** Texture Buffers of Float32 that holds tileMap data*/
  66918. private _tileMaps;
  66919. /** Texture Buffer of Float32 that holds Animation Data*/
  66920. private _animationMap;
  66921. /** Custom ShaderMaterial Central to the System*/
  66922. private _material;
  66923. /** Custom ShaderMaterial Central to the System*/
  66924. private _output;
  66925. /** Systems Time Ticker*/
  66926. private _time;
  66927. /**
  66928. * Creates a new SpriteMap
  66929. * @param name defines the SpriteMaps Name
  66930. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66931. * @param spriteSheet is the Texture that the Sprites are on.
  66932. * @param options a basic deployment configuration
  66933. * @param scene The Scene that the map is deployed on
  66934. */
  66935. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66936. /**
  66937. * Returns tileID location
  66938. * @returns Vector2 the cell position ID
  66939. */
  66940. getTileID(): Vector2;
  66941. /**
  66942. * Gets the UV location of the mouse over the SpriteMap.
  66943. * @returns Vector2 the UV position of the mouse interaction
  66944. */
  66945. getMousePosition(): Vector2;
  66946. /**
  66947. * Creates the "frame" texture Buffer
  66948. * -------------------------------------
  66949. * Structure of frames
  66950. * "filename": "Falling-Water-2.png",
  66951. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66952. * "rotated": true,
  66953. * "trimmed": true,
  66954. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66955. * "sourceSize": {"w":32,"h":32}
  66956. * @returns RawTexture of the frameMap
  66957. */
  66958. private _createFrameBuffer;
  66959. /**
  66960. * Creates the tileMap texture Buffer
  66961. * @param buffer normally and array of numbers, or a false to generate from scratch
  66962. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66963. * @returns RawTexture of the tileMap
  66964. */
  66965. private _createTileBuffer;
  66966. /**
  66967. * Modifies the data of the tileMaps
  66968. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66969. * @param pos is the iVector2 Coordinates of the Tile
  66970. * @param tile The SpriteIndex of the new Tile
  66971. */
  66972. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66973. /**
  66974. * Creates the animationMap texture Buffer
  66975. * @param buffer normally and array of numbers, or a false to generate from scratch
  66976. * @returns RawTexture of the animationMap
  66977. */
  66978. private _createTileAnimationBuffer;
  66979. /**
  66980. * Modifies the data of the animationMap
  66981. * @param cellID is the Index of the Sprite
  66982. * @param _frame is the target Animation frame
  66983. * @param toCell is the Target Index of the next frame of the animation
  66984. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66985. * @param speed is a global scalar of the time variable on the map.
  66986. */
  66987. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66988. /**
  66989. * Exports the .tilemaps file
  66990. */
  66991. saveTileMaps(): void;
  66992. /**
  66993. * Imports the .tilemaps file
  66994. * @param url of the .tilemaps file
  66995. */
  66996. loadTileMaps(url: string): void;
  66997. /**
  66998. * Release associated resources
  66999. */
  67000. dispose(): void;
  67001. }
  67002. }
  67003. declare module BABYLON {
  67004. /**
  67005. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67006. * @see http://doc.babylonjs.com/babylon101/sprites
  67007. */
  67008. export class SpritePackedManager extends SpriteManager {
  67009. /** defines the packed manager's name */
  67010. name: string;
  67011. /**
  67012. * Creates a new sprite manager from a packed sprite sheet
  67013. * @param name defines the manager's name
  67014. * @param imgUrl defines the sprite sheet url
  67015. * @param capacity defines the maximum allowed number of sprites
  67016. * @param scene defines the hosting scene
  67017. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67018. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67019. * @param samplingMode defines the smapling mode to use with spritesheet
  67020. * @param fromPacked set to true; do not alter
  67021. */
  67022. constructor(
  67023. /** defines the packed manager's name */
  67024. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67025. }
  67026. }
  67027. declare module BABYLON {
  67028. /**
  67029. * Defines the list of states available for a task inside a AssetsManager
  67030. */
  67031. export enum AssetTaskState {
  67032. /**
  67033. * Initialization
  67034. */
  67035. INIT = 0,
  67036. /**
  67037. * Running
  67038. */
  67039. RUNNING = 1,
  67040. /**
  67041. * Done
  67042. */
  67043. DONE = 2,
  67044. /**
  67045. * Error
  67046. */
  67047. ERROR = 3
  67048. }
  67049. /**
  67050. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67051. */
  67052. export abstract class AbstractAssetTask {
  67053. /**
  67054. * Task name
  67055. */ name: string;
  67056. /**
  67057. * Callback called when the task is successful
  67058. */
  67059. onSuccess: (task: any) => void;
  67060. /**
  67061. * Callback called when the task is not successful
  67062. */
  67063. onError: (task: any, message?: string, exception?: any) => void;
  67064. /**
  67065. * Creates a new AssetsManager
  67066. * @param name defines the name of the task
  67067. */
  67068. constructor(
  67069. /**
  67070. * Task name
  67071. */ name: string);
  67072. private _isCompleted;
  67073. private _taskState;
  67074. private _errorObject;
  67075. /**
  67076. * Get if the task is completed
  67077. */
  67078. get isCompleted(): boolean;
  67079. /**
  67080. * Gets the current state of the task
  67081. */
  67082. get taskState(): AssetTaskState;
  67083. /**
  67084. * Gets the current error object (if task is in error)
  67085. */
  67086. get errorObject(): {
  67087. message?: string;
  67088. exception?: any;
  67089. };
  67090. /**
  67091. * Internal only
  67092. * @hidden
  67093. */
  67094. _setErrorObject(message?: string, exception?: any): void;
  67095. /**
  67096. * Execute the current task
  67097. * @param scene defines the scene where you want your assets to be loaded
  67098. * @param onSuccess is a callback called when the task is successfully executed
  67099. * @param onError is a callback called if an error occurs
  67100. */
  67101. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67102. /**
  67103. * Execute the current task
  67104. * @param scene defines the scene where you want your assets to be loaded
  67105. * @param onSuccess is a callback called when the task is successfully executed
  67106. * @param onError is a callback called if an error occurs
  67107. */
  67108. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67109. /**
  67110. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67111. * This can be used with failed tasks that have the reason for failure fixed.
  67112. */
  67113. reset(): void;
  67114. private onErrorCallback;
  67115. private onDoneCallback;
  67116. }
  67117. /**
  67118. * Define the interface used by progress events raised during assets loading
  67119. */
  67120. export interface IAssetsProgressEvent {
  67121. /**
  67122. * Defines the number of remaining tasks to process
  67123. */
  67124. remainingCount: number;
  67125. /**
  67126. * Defines the total number of tasks
  67127. */
  67128. totalCount: number;
  67129. /**
  67130. * Defines the task that was just processed
  67131. */
  67132. task: AbstractAssetTask;
  67133. }
  67134. /**
  67135. * Class used to share progress information about assets loading
  67136. */
  67137. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67138. /**
  67139. * Defines the number of remaining tasks to process
  67140. */
  67141. remainingCount: number;
  67142. /**
  67143. * Defines the total number of tasks
  67144. */
  67145. totalCount: number;
  67146. /**
  67147. * Defines the task that was just processed
  67148. */
  67149. task: AbstractAssetTask;
  67150. /**
  67151. * Creates a AssetsProgressEvent
  67152. * @param remainingCount defines the number of remaining tasks to process
  67153. * @param totalCount defines the total number of tasks
  67154. * @param task defines the task that was just processed
  67155. */
  67156. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67157. }
  67158. /**
  67159. * Define a task used by AssetsManager to load meshes
  67160. */
  67161. export class MeshAssetTask extends AbstractAssetTask {
  67162. /**
  67163. * Defines the name of the task
  67164. */
  67165. name: string;
  67166. /**
  67167. * Defines the list of mesh's names you want to load
  67168. */
  67169. meshesNames: any;
  67170. /**
  67171. * Defines the root url to use as a base to load your meshes and associated resources
  67172. */
  67173. rootUrl: string;
  67174. /**
  67175. * Defines the filename of the scene to load from
  67176. */
  67177. sceneFilename: string;
  67178. /**
  67179. * Gets the list of loaded meshes
  67180. */
  67181. loadedMeshes: Array<AbstractMesh>;
  67182. /**
  67183. * Gets the list of loaded particle systems
  67184. */
  67185. loadedParticleSystems: Array<IParticleSystem>;
  67186. /**
  67187. * Gets the list of loaded skeletons
  67188. */
  67189. loadedSkeletons: Array<Skeleton>;
  67190. /**
  67191. * Gets the list of loaded animation groups
  67192. */
  67193. loadedAnimationGroups: Array<AnimationGroup>;
  67194. /**
  67195. * Callback called when the task is successful
  67196. */
  67197. onSuccess: (task: MeshAssetTask) => void;
  67198. /**
  67199. * Callback called when the task is successful
  67200. */
  67201. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67202. /**
  67203. * Creates a new MeshAssetTask
  67204. * @param name defines the name of the task
  67205. * @param meshesNames defines the list of mesh's names you want to load
  67206. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67207. * @param sceneFilename defines the filename of the scene to load from
  67208. */
  67209. constructor(
  67210. /**
  67211. * Defines the name of the task
  67212. */
  67213. name: string,
  67214. /**
  67215. * Defines the list of mesh's names you want to load
  67216. */
  67217. meshesNames: any,
  67218. /**
  67219. * Defines the root url to use as a base to load your meshes and associated resources
  67220. */
  67221. rootUrl: string,
  67222. /**
  67223. * Defines the filename of the scene to load from
  67224. */
  67225. sceneFilename: string);
  67226. /**
  67227. * Execute the current task
  67228. * @param scene defines the scene where you want your assets to be loaded
  67229. * @param onSuccess is a callback called when the task is successfully executed
  67230. * @param onError is a callback called if an error occurs
  67231. */
  67232. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67233. }
  67234. /**
  67235. * Define a task used by AssetsManager to load text content
  67236. */
  67237. export class TextFileAssetTask extends AbstractAssetTask {
  67238. /**
  67239. * Defines the name of the task
  67240. */
  67241. name: string;
  67242. /**
  67243. * Defines the location of the file to load
  67244. */
  67245. url: string;
  67246. /**
  67247. * Gets the loaded text string
  67248. */
  67249. text: string;
  67250. /**
  67251. * Callback called when the task is successful
  67252. */
  67253. onSuccess: (task: TextFileAssetTask) => void;
  67254. /**
  67255. * Callback called when the task is successful
  67256. */
  67257. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67258. /**
  67259. * Creates a new TextFileAssetTask object
  67260. * @param name defines the name of the task
  67261. * @param url defines the location of the file to load
  67262. */
  67263. constructor(
  67264. /**
  67265. * Defines the name of the task
  67266. */
  67267. name: string,
  67268. /**
  67269. * Defines the location of the file to load
  67270. */
  67271. url: string);
  67272. /**
  67273. * Execute the current task
  67274. * @param scene defines the scene where you want your assets to be loaded
  67275. * @param onSuccess is a callback called when the task is successfully executed
  67276. * @param onError is a callback called if an error occurs
  67277. */
  67278. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67279. }
  67280. /**
  67281. * Define a task used by AssetsManager to load binary data
  67282. */
  67283. export class BinaryFileAssetTask extends AbstractAssetTask {
  67284. /**
  67285. * Defines the name of the task
  67286. */
  67287. name: string;
  67288. /**
  67289. * Defines the location of the file to load
  67290. */
  67291. url: string;
  67292. /**
  67293. * Gets the lodaded data (as an array buffer)
  67294. */
  67295. data: ArrayBuffer;
  67296. /**
  67297. * Callback called when the task is successful
  67298. */
  67299. onSuccess: (task: BinaryFileAssetTask) => void;
  67300. /**
  67301. * Callback called when the task is successful
  67302. */
  67303. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67304. /**
  67305. * Creates a new BinaryFileAssetTask object
  67306. * @param name defines the name of the new task
  67307. * @param url defines the location of the file to load
  67308. */
  67309. constructor(
  67310. /**
  67311. * Defines the name of the task
  67312. */
  67313. name: string,
  67314. /**
  67315. * Defines the location of the file to load
  67316. */
  67317. url: string);
  67318. /**
  67319. * Execute the current task
  67320. * @param scene defines the scene where you want your assets to be loaded
  67321. * @param onSuccess is a callback called when the task is successfully executed
  67322. * @param onError is a callback called if an error occurs
  67323. */
  67324. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67325. }
  67326. /**
  67327. * Define a task used by AssetsManager to load images
  67328. */
  67329. export class ImageAssetTask extends AbstractAssetTask {
  67330. /**
  67331. * Defines the name of the task
  67332. */
  67333. name: string;
  67334. /**
  67335. * Defines the location of the image to load
  67336. */
  67337. url: string;
  67338. /**
  67339. * Gets the loaded images
  67340. */
  67341. image: HTMLImageElement;
  67342. /**
  67343. * Callback called when the task is successful
  67344. */
  67345. onSuccess: (task: ImageAssetTask) => void;
  67346. /**
  67347. * Callback called when the task is successful
  67348. */
  67349. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67350. /**
  67351. * Creates a new ImageAssetTask
  67352. * @param name defines the name of the task
  67353. * @param url defines the location of the image to load
  67354. */
  67355. constructor(
  67356. /**
  67357. * Defines the name of the task
  67358. */
  67359. name: string,
  67360. /**
  67361. * Defines the location of the image to load
  67362. */
  67363. url: string);
  67364. /**
  67365. * Execute the current task
  67366. * @param scene defines the scene where you want your assets to be loaded
  67367. * @param onSuccess is a callback called when the task is successfully executed
  67368. * @param onError is a callback called if an error occurs
  67369. */
  67370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67371. }
  67372. /**
  67373. * Defines the interface used by texture loading tasks
  67374. */
  67375. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67376. /**
  67377. * Gets the loaded texture
  67378. */
  67379. texture: TEX;
  67380. }
  67381. /**
  67382. * Define a task used by AssetsManager to load 2D textures
  67383. */
  67384. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67385. /**
  67386. * Defines the name of the task
  67387. */
  67388. name: string;
  67389. /**
  67390. * Defines the location of the file to load
  67391. */
  67392. url: string;
  67393. /**
  67394. * Defines if mipmap should not be generated (default is false)
  67395. */
  67396. noMipmap?: boolean | undefined;
  67397. /**
  67398. * Defines if texture must be inverted on Y axis (default is false)
  67399. */
  67400. invertY?: boolean | undefined;
  67401. /**
  67402. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67403. */
  67404. samplingMode: number;
  67405. /**
  67406. * Gets the loaded texture
  67407. */
  67408. texture: Texture;
  67409. /**
  67410. * Callback called when the task is successful
  67411. */
  67412. onSuccess: (task: TextureAssetTask) => void;
  67413. /**
  67414. * Callback called when the task is successful
  67415. */
  67416. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67417. /**
  67418. * Creates a new TextureAssetTask object
  67419. * @param name defines the name of the task
  67420. * @param url defines the location of the file to load
  67421. * @param noMipmap defines if mipmap should not be generated (default is false)
  67422. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67423. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67424. */
  67425. constructor(
  67426. /**
  67427. * Defines the name of the task
  67428. */
  67429. name: string,
  67430. /**
  67431. * Defines the location of the file to load
  67432. */
  67433. url: string,
  67434. /**
  67435. * Defines if mipmap should not be generated (default is false)
  67436. */
  67437. noMipmap?: boolean | undefined,
  67438. /**
  67439. * Defines if texture must be inverted on Y axis (default is false)
  67440. */
  67441. invertY?: boolean | undefined,
  67442. /**
  67443. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67444. */
  67445. samplingMode?: number);
  67446. /**
  67447. * Execute the current task
  67448. * @param scene defines the scene where you want your assets to be loaded
  67449. * @param onSuccess is a callback called when the task is successfully executed
  67450. * @param onError is a callback called if an error occurs
  67451. */
  67452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67453. }
  67454. /**
  67455. * Define a task used by AssetsManager to load cube textures
  67456. */
  67457. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67458. /**
  67459. * Defines the name of the task
  67460. */
  67461. name: string;
  67462. /**
  67463. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67464. */
  67465. url: string;
  67466. /**
  67467. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67468. */
  67469. extensions?: string[] | undefined;
  67470. /**
  67471. * Defines if mipmaps should not be generated (default is false)
  67472. */
  67473. noMipmap?: boolean | undefined;
  67474. /**
  67475. * Defines the explicit list of files (undefined by default)
  67476. */
  67477. files?: string[] | undefined;
  67478. /**
  67479. * Gets the loaded texture
  67480. */
  67481. texture: CubeTexture;
  67482. /**
  67483. * Callback called when the task is successful
  67484. */
  67485. onSuccess: (task: CubeTextureAssetTask) => void;
  67486. /**
  67487. * Callback called when the task is successful
  67488. */
  67489. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67490. /**
  67491. * Creates a new CubeTextureAssetTask
  67492. * @param name defines the name of the task
  67493. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67494. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67495. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67496. * @param files defines the explicit list of files (undefined by default)
  67497. */
  67498. constructor(
  67499. /**
  67500. * Defines the name of the task
  67501. */
  67502. name: string,
  67503. /**
  67504. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67505. */
  67506. url: string,
  67507. /**
  67508. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67509. */
  67510. extensions?: string[] | undefined,
  67511. /**
  67512. * Defines if mipmaps should not be generated (default is false)
  67513. */
  67514. noMipmap?: boolean | undefined,
  67515. /**
  67516. * Defines the explicit list of files (undefined by default)
  67517. */
  67518. files?: string[] | undefined);
  67519. /**
  67520. * Execute the current task
  67521. * @param scene defines the scene where you want your assets to be loaded
  67522. * @param onSuccess is a callback called when the task is successfully executed
  67523. * @param onError is a callback called if an error occurs
  67524. */
  67525. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67526. }
  67527. /**
  67528. * Define a task used by AssetsManager to load HDR cube textures
  67529. */
  67530. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67531. /**
  67532. * Defines the name of the task
  67533. */
  67534. name: string;
  67535. /**
  67536. * Defines the location of the file to load
  67537. */
  67538. url: string;
  67539. /**
  67540. * Defines the desired size (the more it increases the longer the generation will be)
  67541. */
  67542. size: number;
  67543. /**
  67544. * Defines if mipmaps should not be generated (default is false)
  67545. */
  67546. noMipmap: boolean;
  67547. /**
  67548. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67549. */
  67550. generateHarmonics: boolean;
  67551. /**
  67552. * 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)
  67553. */
  67554. gammaSpace: boolean;
  67555. /**
  67556. * Internal Use Only
  67557. */
  67558. reserved: boolean;
  67559. /**
  67560. * Gets the loaded texture
  67561. */
  67562. texture: HDRCubeTexture;
  67563. /**
  67564. * Callback called when the task is successful
  67565. */
  67566. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67567. /**
  67568. * Callback called when the task is successful
  67569. */
  67570. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67571. /**
  67572. * Creates a new HDRCubeTextureAssetTask object
  67573. * @param name defines the name of the task
  67574. * @param url defines the location of the file to load
  67575. * @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.
  67576. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67577. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67578. * @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)
  67579. * @param reserved Internal use only
  67580. */
  67581. constructor(
  67582. /**
  67583. * Defines the name of the task
  67584. */
  67585. name: string,
  67586. /**
  67587. * Defines the location of the file to load
  67588. */
  67589. url: string,
  67590. /**
  67591. * Defines the desired size (the more it increases the longer the generation will be)
  67592. */
  67593. size: number,
  67594. /**
  67595. * Defines if mipmaps should not be generated (default is false)
  67596. */
  67597. noMipmap?: boolean,
  67598. /**
  67599. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67600. */
  67601. generateHarmonics?: boolean,
  67602. /**
  67603. * 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)
  67604. */
  67605. gammaSpace?: boolean,
  67606. /**
  67607. * Internal Use Only
  67608. */
  67609. reserved?: boolean);
  67610. /**
  67611. * Execute the current task
  67612. * @param scene defines the scene where you want your assets to be loaded
  67613. * @param onSuccess is a callback called when the task is successfully executed
  67614. * @param onError is a callback called if an error occurs
  67615. */
  67616. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67617. }
  67618. /**
  67619. * Define a task used by AssetsManager to load Equirectangular cube textures
  67620. */
  67621. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67622. /**
  67623. * Defines the name of the task
  67624. */
  67625. name: string;
  67626. /**
  67627. * Defines the location of the file to load
  67628. */
  67629. url: string;
  67630. /**
  67631. * Defines the desired size (the more it increases the longer the generation will be)
  67632. */
  67633. size: number;
  67634. /**
  67635. * Defines if mipmaps should not be generated (default is false)
  67636. */
  67637. noMipmap: boolean;
  67638. /**
  67639. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67640. * but the standard material would require them in Gamma space) (default is true)
  67641. */
  67642. gammaSpace: boolean;
  67643. /**
  67644. * Gets the loaded texture
  67645. */
  67646. texture: EquiRectangularCubeTexture;
  67647. /**
  67648. * Callback called when the task is successful
  67649. */
  67650. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67651. /**
  67652. * Callback called when the task is successful
  67653. */
  67654. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67655. /**
  67656. * Creates a new EquiRectangularCubeTextureAssetTask object
  67657. * @param name defines the name of the task
  67658. * @param url defines the location of the file to load
  67659. * @param size defines the desired size (the more it increases the longer the generation will be)
  67660. * If the size is omitted this implies you are using a preprocessed cubemap.
  67661. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67662. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67663. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67664. * (default is true)
  67665. */
  67666. constructor(
  67667. /**
  67668. * Defines the name of the task
  67669. */
  67670. name: string,
  67671. /**
  67672. * Defines the location of the file to load
  67673. */
  67674. url: string,
  67675. /**
  67676. * Defines the desired size (the more it increases the longer the generation will be)
  67677. */
  67678. size: number,
  67679. /**
  67680. * Defines if mipmaps should not be generated (default is false)
  67681. */
  67682. noMipmap?: boolean,
  67683. /**
  67684. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67685. * but the standard material would require them in Gamma space) (default is true)
  67686. */
  67687. gammaSpace?: boolean);
  67688. /**
  67689. * Execute the current task
  67690. * @param scene defines the scene where you want your assets to be loaded
  67691. * @param onSuccess is a callback called when the task is successfully executed
  67692. * @param onError is a callback called if an error occurs
  67693. */
  67694. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67695. }
  67696. /**
  67697. * This class can be used to easily import assets into a scene
  67698. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67699. */
  67700. export class AssetsManager {
  67701. private _scene;
  67702. private _isLoading;
  67703. protected _tasks: AbstractAssetTask[];
  67704. protected _waitingTasksCount: number;
  67705. protected _totalTasksCount: number;
  67706. /**
  67707. * Callback called when all tasks are processed
  67708. */
  67709. onFinish: (tasks: AbstractAssetTask[]) => void;
  67710. /**
  67711. * Callback called when a task is successful
  67712. */
  67713. onTaskSuccess: (task: AbstractAssetTask) => void;
  67714. /**
  67715. * Callback called when a task had an error
  67716. */
  67717. onTaskError: (task: AbstractAssetTask) => void;
  67718. /**
  67719. * Callback called when a task is done (whatever the result is)
  67720. */
  67721. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67722. /**
  67723. * Observable called when all tasks are processed
  67724. */
  67725. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67726. /**
  67727. * Observable called when a task had an error
  67728. */
  67729. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67730. /**
  67731. * Observable called when all tasks were executed
  67732. */
  67733. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67734. /**
  67735. * Observable called when a task is done (whatever the result is)
  67736. */
  67737. onProgressObservable: Observable<IAssetsProgressEvent>;
  67738. /**
  67739. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67740. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67741. */
  67742. useDefaultLoadingScreen: boolean;
  67743. /**
  67744. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67745. * when all assets have been downloaded.
  67746. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67747. */
  67748. autoHideLoadingUI: boolean;
  67749. /**
  67750. * Creates a new AssetsManager
  67751. * @param scene defines the scene to work on
  67752. */
  67753. constructor(scene: Scene);
  67754. /**
  67755. * Add a MeshAssetTask to the list of active tasks
  67756. * @param taskName defines the name of the new task
  67757. * @param meshesNames defines the name of meshes to load
  67758. * @param rootUrl defines the root url to use to locate files
  67759. * @param sceneFilename defines the filename of the scene file
  67760. * @returns a new MeshAssetTask object
  67761. */
  67762. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67763. /**
  67764. * Add a TextFileAssetTask to the list of active tasks
  67765. * @param taskName defines the name of the new task
  67766. * @param url defines the url of the file to load
  67767. * @returns a new TextFileAssetTask object
  67768. */
  67769. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67770. /**
  67771. * Add a BinaryFileAssetTask to the list of active tasks
  67772. * @param taskName defines the name of the new task
  67773. * @param url defines the url of the file to load
  67774. * @returns a new BinaryFileAssetTask object
  67775. */
  67776. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67777. /**
  67778. * Add a ImageAssetTask to the list of active tasks
  67779. * @param taskName defines the name of the new task
  67780. * @param url defines the url of the file to load
  67781. * @returns a new ImageAssetTask object
  67782. */
  67783. addImageTask(taskName: string, url: string): ImageAssetTask;
  67784. /**
  67785. * Add a TextureAssetTask to the list of active tasks
  67786. * @param taskName defines the name of the new task
  67787. * @param url defines the url of the file to load
  67788. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67789. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67790. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67791. * @returns a new TextureAssetTask object
  67792. */
  67793. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67794. /**
  67795. * Add a CubeTextureAssetTask to the list of active tasks
  67796. * @param taskName defines the name of the new task
  67797. * @param url defines the url of the file to load
  67798. * @param extensions defines the extension to use to load the cube map (can be null)
  67799. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67800. * @param files defines the list of files to load (can be null)
  67801. * @returns a new CubeTextureAssetTask object
  67802. */
  67803. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67804. /**
  67805. *
  67806. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67807. * @param taskName defines the name of the new task
  67808. * @param url defines the url of the file to load
  67809. * @param size defines the size you want for the cubemap (can be null)
  67810. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67811. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67812. * @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)
  67813. * @param reserved Internal use only
  67814. * @returns a new HDRCubeTextureAssetTask object
  67815. */
  67816. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67817. /**
  67818. *
  67819. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67820. * @param taskName defines the name of the new task
  67821. * @param url defines the url of the file to load
  67822. * @param size defines the size you want for the cubemap (can be null)
  67823. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67824. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67825. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67826. * @returns a new EquiRectangularCubeTextureAssetTask object
  67827. */
  67828. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67829. /**
  67830. * Remove a task from the assets manager.
  67831. * @param task the task to remove
  67832. */
  67833. removeTask(task: AbstractAssetTask): void;
  67834. private _decreaseWaitingTasksCount;
  67835. private _runTask;
  67836. /**
  67837. * Reset the AssetsManager and remove all tasks
  67838. * @return the current instance of the AssetsManager
  67839. */
  67840. reset(): AssetsManager;
  67841. /**
  67842. * Start the loading process
  67843. * @return the current instance of the AssetsManager
  67844. */
  67845. load(): AssetsManager;
  67846. /**
  67847. * Start the loading process as an async operation
  67848. * @return a promise returning the list of failed tasks
  67849. */
  67850. loadAsync(): Promise<void>;
  67851. }
  67852. }
  67853. declare module BABYLON {
  67854. /**
  67855. * Wrapper class for promise with external resolve and reject.
  67856. */
  67857. export class Deferred<T> {
  67858. /**
  67859. * The promise associated with this deferred object.
  67860. */
  67861. readonly promise: Promise<T>;
  67862. private _resolve;
  67863. private _reject;
  67864. /**
  67865. * The resolve method of the promise associated with this deferred object.
  67866. */
  67867. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67868. /**
  67869. * The reject method of the promise associated with this deferred object.
  67870. */
  67871. get reject(): (reason?: any) => void;
  67872. /**
  67873. * Constructor for this deferred object.
  67874. */
  67875. constructor();
  67876. }
  67877. }
  67878. declare module BABYLON {
  67879. /**
  67880. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67881. */
  67882. export class MeshExploder {
  67883. private _centerMesh;
  67884. private _meshes;
  67885. private _meshesOrigins;
  67886. private _toCenterVectors;
  67887. private _scaledDirection;
  67888. private _newPosition;
  67889. private _centerPosition;
  67890. /**
  67891. * Explodes meshes from a center mesh.
  67892. * @param meshes The meshes to explode.
  67893. * @param centerMesh The mesh to be center of explosion.
  67894. */
  67895. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67896. private _setCenterMesh;
  67897. /**
  67898. * Get class name
  67899. * @returns "MeshExploder"
  67900. */
  67901. getClassName(): string;
  67902. /**
  67903. * "Exploded meshes"
  67904. * @returns Array of meshes with the centerMesh at index 0.
  67905. */
  67906. getMeshes(): Array<Mesh>;
  67907. /**
  67908. * Explodes meshes giving a specific direction
  67909. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67910. */
  67911. explode(direction?: number): void;
  67912. }
  67913. }
  67914. declare module BABYLON {
  67915. /**
  67916. * Class used to help managing file picking and drag'n'drop
  67917. */
  67918. export class FilesInput {
  67919. /**
  67920. * List of files ready to be loaded
  67921. */
  67922. static get FilesToLoad(): {
  67923. [key: string]: File;
  67924. };
  67925. /**
  67926. * Callback called when a file is processed
  67927. */
  67928. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67929. private _engine;
  67930. private _currentScene;
  67931. private _sceneLoadedCallback;
  67932. private _progressCallback;
  67933. private _additionalRenderLoopLogicCallback;
  67934. private _textureLoadingCallback;
  67935. private _startingProcessingFilesCallback;
  67936. private _onReloadCallback;
  67937. private _errorCallback;
  67938. private _elementToMonitor;
  67939. private _sceneFileToLoad;
  67940. private _filesToLoad;
  67941. /**
  67942. * Creates a new FilesInput
  67943. * @param engine defines the rendering engine
  67944. * @param scene defines the hosting scene
  67945. * @param sceneLoadedCallback callback called when scene is loaded
  67946. * @param progressCallback callback called to track progress
  67947. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67948. * @param textureLoadingCallback callback called when a texture is loading
  67949. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67950. * @param onReloadCallback callback called when a reload is requested
  67951. * @param errorCallback callback call if an error occurs
  67952. */
  67953. 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);
  67954. private _dragEnterHandler;
  67955. private _dragOverHandler;
  67956. private _dropHandler;
  67957. /**
  67958. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67959. * @param elementToMonitor defines the DOM element to track
  67960. */
  67961. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67962. /**
  67963. * Release all associated resources
  67964. */
  67965. dispose(): void;
  67966. private renderFunction;
  67967. private drag;
  67968. private drop;
  67969. private _traverseFolder;
  67970. private _processFiles;
  67971. /**
  67972. * Load files from a drop event
  67973. * @param event defines the drop event to use as source
  67974. */
  67975. loadFiles(event: any): void;
  67976. private _processReload;
  67977. /**
  67978. * Reload the current scene from the loaded files
  67979. */
  67980. reload(): void;
  67981. }
  67982. }
  67983. declare module BABYLON {
  67984. /**
  67985. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67986. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67987. */
  67988. export class SceneOptimization {
  67989. /**
  67990. * Defines the priority of this optimization (0 by default which means first in the list)
  67991. */
  67992. priority: number;
  67993. /**
  67994. * Gets a string describing the action executed by the current optimization
  67995. * @returns description string
  67996. */
  67997. getDescription(): string;
  67998. /**
  67999. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68000. * @param scene defines the current scene where to apply this optimization
  68001. * @param optimizer defines the current optimizer
  68002. * @returns true if everything that can be done was applied
  68003. */
  68004. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68005. /**
  68006. * Creates the SceneOptimization object
  68007. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68008. * @param desc defines the description associated with the optimization
  68009. */
  68010. constructor(
  68011. /**
  68012. * Defines the priority of this optimization (0 by default which means first in the list)
  68013. */
  68014. priority?: number);
  68015. }
  68016. /**
  68017. * Defines an optimization used to reduce the size of render target textures
  68018. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68019. */
  68020. export class TextureOptimization extends SceneOptimization {
  68021. /**
  68022. * Defines the priority of this optimization (0 by default which means first in the list)
  68023. */
  68024. priority: number;
  68025. /**
  68026. * 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
  68027. */
  68028. maximumSize: number;
  68029. /**
  68030. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68031. */
  68032. step: number;
  68033. /**
  68034. * Gets a string describing the action executed by the current optimization
  68035. * @returns description string
  68036. */
  68037. getDescription(): string;
  68038. /**
  68039. * Creates the TextureOptimization object
  68040. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68041. * @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
  68042. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68043. */
  68044. constructor(
  68045. /**
  68046. * Defines the priority of this optimization (0 by default which means first in the list)
  68047. */
  68048. priority?: number,
  68049. /**
  68050. * 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
  68051. */
  68052. maximumSize?: number,
  68053. /**
  68054. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68055. */
  68056. step?: number);
  68057. /**
  68058. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68059. * @param scene defines the current scene where to apply this optimization
  68060. * @param optimizer defines the current optimizer
  68061. * @returns true if everything that can be done was applied
  68062. */
  68063. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68064. }
  68065. /**
  68066. * Defines an optimization used to increase or decrease the rendering resolution
  68067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68068. */
  68069. export class HardwareScalingOptimization extends SceneOptimization {
  68070. /**
  68071. * Defines the priority of this optimization (0 by default which means first in the list)
  68072. */
  68073. priority: number;
  68074. /**
  68075. * Defines the maximum scale to use (2 by default)
  68076. */
  68077. maximumScale: number;
  68078. /**
  68079. * Defines the step to use between two passes (0.5 by default)
  68080. */
  68081. step: number;
  68082. private _currentScale;
  68083. private _directionOffset;
  68084. /**
  68085. * Gets a string describing the action executed by the current optimization
  68086. * @return description string
  68087. */
  68088. getDescription(): string;
  68089. /**
  68090. * Creates the HardwareScalingOptimization object
  68091. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68092. * @param maximumScale defines the maximum scale to use (2 by default)
  68093. * @param step defines the step to use between two passes (0.5 by default)
  68094. */
  68095. constructor(
  68096. /**
  68097. * Defines the priority of this optimization (0 by default which means first in the list)
  68098. */
  68099. priority?: number,
  68100. /**
  68101. * Defines the maximum scale to use (2 by default)
  68102. */
  68103. maximumScale?: number,
  68104. /**
  68105. * Defines the step to use between two passes (0.5 by default)
  68106. */
  68107. step?: number);
  68108. /**
  68109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68110. * @param scene defines the current scene where to apply this optimization
  68111. * @param optimizer defines the current optimizer
  68112. * @returns true if everything that can be done was applied
  68113. */
  68114. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68115. }
  68116. /**
  68117. * Defines an optimization used to remove shadows
  68118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68119. */
  68120. export class ShadowsOptimization extends SceneOptimization {
  68121. /**
  68122. * Gets a string describing the action executed by the current optimization
  68123. * @return description string
  68124. */
  68125. getDescription(): string;
  68126. /**
  68127. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68128. * @param scene defines the current scene where to apply this optimization
  68129. * @param optimizer defines the current optimizer
  68130. * @returns true if everything that can be done was applied
  68131. */
  68132. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68133. }
  68134. /**
  68135. * Defines an optimization used to turn post-processes off
  68136. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68137. */
  68138. export class PostProcessesOptimization extends SceneOptimization {
  68139. /**
  68140. * Gets a string describing the action executed by the current optimization
  68141. * @return description string
  68142. */
  68143. getDescription(): string;
  68144. /**
  68145. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68146. * @param scene defines the current scene where to apply this optimization
  68147. * @param optimizer defines the current optimizer
  68148. * @returns true if everything that can be done was applied
  68149. */
  68150. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68151. }
  68152. /**
  68153. * Defines an optimization used to turn lens flares off
  68154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68155. */
  68156. export class LensFlaresOptimization extends SceneOptimization {
  68157. /**
  68158. * Gets a string describing the action executed by the current optimization
  68159. * @return description string
  68160. */
  68161. getDescription(): string;
  68162. /**
  68163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68164. * @param scene defines the current scene where to apply this optimization
  68165. * @param optimizer defines the current optimizer
  68166. * @returns true if everything that can be done was applied
  68167. */
  68168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68169. }
  68170. /**
  68171. * Defines an optimization based on user defined callback.
  68172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68173. */
  68174. export class CustomOptimization extends SceneOptimization {
  68175. /**
  68176. * Callback called to apply the custom optimization.
  68177. */
  68178. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68179. /**
  68180. * Callback called to get custom description
  68181. */
  68182. onGetDescription: () => string;
  68183. /**
  68184. * Gets a string describing the action executed by the current optimization
  68185. * @returns description string
  68186. */
  68187. getDescription(): string;
  68188. /**
  68189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68190. * @param scene defines the current scene where to apply this optimization
  68191. * @param optimizer defines the current optimizer
  68192. * @returns true if everything that can be done was applied
  68193. */
  68194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68195. }
  68196. /**
  68197. * Defines an optimization used to turn particles off
  68198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68199. */
  68200. export class ParticlesOptimization extends SceneOptimization {
  68201. /**
  68202. * Gets a string describing the action executed by the current optimization
  68203. * @return description string
  68204. */
  68205. getDescription(): string;
  68206. /**
  68207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68208. * @param scene defines the current scene where to apply this optimization
  68209. * @param optimizer defines the current optimizer
  68210. * @returns true if everything that can be done was applied
  68211. */
  68212. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68213. }
  68214. /**
  68215. * Defines an optimization used to turn render targets off
  68216. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68217. */
  68218. export class RenderTargetsOptimization extends SceneOptimization {
  68219. /**
  68220. * Gets a string describing the action executed by the current optimization
  68221. * @return description string
  68222. */
  68223. getDescription(): string;
  68224. /**
  68225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68226. * @param scene defines the current scene where to apply this optimization
  68227. * @param optimizer defines the current optimizer
  68228. * @returns true if everything that can be done was applied
  68229. */
  68230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68231. }
  68232. /**
  68233. * Defines an optimization used to merge meshes with compatible materials
  68234. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68235. */
  68236. export class MergeMeshesOptimization extends SceneOptimization {
  68237. private static _UpdateSelectionTree;
  68238. /**
  68239. * Gets or sets a boolean which defines if optimization octree has to be updated
  68240. */
  68241. static get UpdateSelectionTree(): boolean;
  68242. /**
  68243. * Gets or sets a boolean which defines if optimization octree has to be updated
  68244. */
  68245. static set UpdateSelectionTree(value: boolean);
  68246. /**
  68247. * Gets a string describing the action executed by the current optimization
  68248. * @return description string
  68249. */
  68250. getDescription(): string;
  68251. private _canBeMerged;
  68252. /**
  68253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68254. * @param scene defines the current scene where to apply this optimization
  68255. * @param optimizer defines the current optimizer
  68256. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68257. * @returns true if everything that can be done was applied
  68258. */
  68259. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68260. }
  68261. /**
  68262. * Defines a list of options used by SceneOptimizer
  68263. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68264. */
  68265. export class SceneOptimizerOptions {
  68266. /**
  68267. * Defines the target frame rate to reach (60 by default)
  68268. */
  68269. targetFrameRate: number;
  68270. /**
  68271. * Defines the interval between two checkes (2000ms by default)
  68272. */
  68273. trackerDuration: number;
  68274. /**
  68275. * Gets the list of optimizations to apply
  68276. */
  68277. optimizations: SceneOptimization[];
  68278. /**
  68279. * Creates a new list of options used by SceneOptimizer
  68280. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68281. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68282. */
  68283. constructor(
  68284. /**
  68285. * Defines the target frame rate to reach (60 by default)
  68286. */
  68287. targetFrameRate?: number,
  68288. /**
  68289. * Defines the interval between two checkes (2000ms by default)
  68290. */
  68291. trackerDuration?: number);
  68292. /**
  68293. * Add a new optimization
  68294. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68295. * @returns the current SceneOptimizerOptions
  68296. */
  68297. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68298. /**
  68299. * Add a new custom optimization
  68300. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68301. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68302. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68303. * @returns the current SceneOptimizerOptions
  68304. */
  68305. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68306. /**
  68307. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68308. * @param targetFrameRate defines the target frame rate (60 by default)
  68309. * @returns a SceneOptimizerOptions object
  68310. */
  68311. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68312. /**
  68313. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68314. * @param targetFrameRate defines the target frame rate (60 by default)
  68315. * @returns a SceneOptimizerOptions object
  68316. */
  68317. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68318. /**
  68319. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68320. * @param targetFrameRate defines the target frame rate (60 by default)
  68321. * @returns a SceneOptimizerOptions object
  68322. */
  68323. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68324. }
  68325. /**
  68326. * Class used to run optimizations in order to reach a target frame rate
  68327. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68328. */
  68329. export class SceneOptimizer implements IDisposable {
  68330. private _isRunning;
  68331. private _options;
  68332. private _scene;
  68333. private _currentPriorityLevel;
  68334. private _targetFrameRate;
  68335. private _trackerDuration;
  68336. private _currentFrameRate;
  68337. private _sceneDisposeObserver;
  68338. private _improvementMode;
  68339. /**
  68340. * Defines an observable called when the optimizer reaches the target frame rate
  68341. */
  68342. onSuccessObservable: Observable<SceneOptimizer>;
  68343. /**
  68344. * Defines an observable called when the optimizer enables an optimization
  68345. */
  68346. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68347. /**
  68348. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68349. */
  68350. onFailureObservable: Observable<SceneOptimizer>;
  68351. /**
  68352. * Gets a boolean indicating if the optimizer is in improvement mode
  68353. */
  68354. get isInImprovementMode(): boolean;
  68355. /**
  68356. * Gets the current priority level (0 at start)
  68357. */
  68358. get currentPriorityLevel(): number;
  68359. /**
  68360. * Gets the current frame rate checked by the SceneOptimizer
  68361. */
  68362. get currentFrameRate(): number;
  68363. /**
  68364. * Gets or sets the current target frame rate (60 by default)
  68365. */
  68366. get targetFrameRate(): number;
  68367. /**
  68368. * Gets or sets the current target frame rate (60 by default)
  68369. */
  68370. set targetFrameRate(value: number);
  68371. /**
  68372. * Gets or sets the current interval between two checks (every 2000ms by default)
  68373. */
  68374. get trackerDuration(): number;
  68375. /**
  68376. * Gets or sets the current interval between two checks (every 2000ms by default)
  68377. */
  68378. set trackerDuration(value: number);
  68379. /**
  68380. * Gets the list of active optimizations
  68381. */
  68382. get optimizations(): SceneOptimization[];
  68383. /**
  68384. * Creates a new SceneOptimizer
  68385. * @param scene defines the scene to work on
  68386. * @param options defines the options to use with the SceneOptimizer
  68387. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68388. * @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)
  68389. */
  68390. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68391. /**
  68392. * Stops the current optimizer
  68393. */
  68394. stop(): void;
  68395. /**
  68396. * Reset the optimizer to initial step (current priority level = 0)
  68397. */
  68398. reset(): void;
  68399. /**
  68400. * Start the optimizer. By default it will try to reach a specific framerate
  68401. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68402. */
  68403. start(): void;
  68404. private _checkCurrentState;
  68405. /**
  68406. * Release all resources
  68407. */
  68408. dispose(): void;
  68409. /**
  68410. * Helper function to create a SceneOptimizer with one single line of code
  68411. * @param scene defines the scene to work on
  68412. * @param options defines the options to use with the SceneOptimizer
  68413. * @param onSuccess defines a callback to call on success
  68414. * @param onFailure defines a callback to call on failure
  68415. * @returns the new SceneOptimizer object
  68416. */
  68417. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68418. }
  68419. }
  68420. declare module BABYLON {
  68421. /**
  68422. * Class used to serialize a scene into a string
  68423. */
  68424. export class SceneSerializer {
  68425. /**
  68426. * Clear cache used by a previous serialization
  68427. */
  68428. static ClearCache(): void;
  68429. /**
  68430. * Serialize a scene into a JSON compatible object
  68431. * @param scene defines the scene to serialize
  68432. * @returns a JSON compatible object
  68433. */
  68434. static Serialize(scene: Scene): any;
  68435. /**
  68436. * Serialize a mesh into a JSON compatible object
  68437. * @param toSerialize defines the mesh to serialize
  68438. * @param withParents defines if parents must be serialized as well
  68439. * @param withChildren defines if children must be serialized as well
  68440. * @returns a JSON compatible object
  68441. */
  68442. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68443. }
  68444. }
  68445. declare module BABYLON {
  68446. /**
  68447. * Class used to host texture specific utilities
  68448. */
  68449. export class TextureTools {
  68450. /**
  68451. * Uses the GPU to create a copy texture rescaled at a given size
  68452. * @param texture Texture to copy from
  68453. * @param width defines the desired width
  68454. * @param height defines the desired height
  68455. * @param useBilinearMode defines if bilinear mode has to be used
  68456. * @return the generated texture
  68457. */
  68458. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68459. }
  68460. }
  68461. declare module BABYLON {
  68462. /**
  68463. * This represents the different options available for the video capture.
  68464. */
  68465. export interface VideoRecorderOptions {
  68466. /** Defines the mime type of the video. */
  68467. mimeType: string;
  68468. /** Defines the FPS the video should be recorded at. */
  68469. fps: number;
  68470. /** Defines the chunk size for the recording data. */
  68471. recordChunckSize: number;
  68472. /** The audio tracks to attach to the recording. */
  68473. audioTracks?: MediaStreamTrack[];
  68474. }
  68475. /**
  68476. * This can help with recording videos from BabylonJS.
  68477. * This is based on the available WebRTC functionalities of the browser.
  68478. *
  68479. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68480. */
  68481. export class VideoRecorder {
  68482. private static readonly _defaultOptions;
  68483. /**
  68484. * Returns whether or not the VideoRecorder is available in your browser.
  68485. * @param engine Defines the Babylon Engine.
  68486. * @returns true if supported otherwise false.
  68487. */
  68488. static IsSupported(engine: Engine): boolean;
  68489. private readonly _options;
  68490. private _canvas;
  68491. private _mediaRecorder;
  68492. private _recordedChunks;
  68493. private _fileName;
  68494. private _resolve;
  68495. private _reject;
  68496. /**
  68497. * True when a recording is already in progress.
  68498. */
  68499. get isRecording(): boolean;
  68500. /**
  68501. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68502. * @param engine Defines the BabylonJS Engine you wish to record.
  68503. * @param options Defines options that can be used to customize the capture.
  68504. */
  68505. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68506. /**
  68507. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68508. */
  68509. stopRecording(): void;
  68510. /**
  68511. * Starts recording the canvas for a max duration specified in parameters.
  68512. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68513. * If null no automatic download will start and you can rely on the promise to get the data back.
  68514. * @param maxDuration Defines the maximum recording time in seconds.
  68515. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68516. * @return A promise callback at the end of the recording with the video data in Blob.
  68517. */
  68518. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68519. /**
  68520. * Releases internal resources used during the recording.
  68521. */
  68522. dispose(): void;
  68523. private _handleDataAvailable;
  68524. private _handleError;
  68525. private _handleStop;
  68526. }
  68527. }
  68528. declare module BABYLON {
  68529. /**
  68530. * Class containing a set of static utilities functions for screenshots
  68531. */
  68532. export class ScreenshotTools {
  68533. /**
  68534. * Captures a screenshot of the current rendering
  68535. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68536. * @param engine defines the rendering engine
  68537. * @param camera defines the source camera
  68538. * @param size This parameter can be set to a single number or to an object with the
  68539. * following (optional) properties: precision, width, height. If a single number is passed,
  68540. * it will be used for both width and height. If an object is passed, the screenshot size
  68541. * will be derived from the parameters. The precision property is a multiplier allowing
  68542. * rendering at a higher or lower resolution
  68543. * @param successCallback defines the callback receives a single parameter which contains the
  68544. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68545. * src parameter of an <img> to display it
  68546. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68547. * Check your browser for supported MIME types
  68548. */
  68549. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68550. /**
  68551. * Captures a screenshot of the current rendering
  68552. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68553. * @param engine defines the rendering engine
  68554. * @param camera defines the source camera
  68555. * @param size This parameter can be set to a single number or to an object with the
  68556. * following (optional) properties: precision, width, height. If a single number is passed,
  68557. * it will be used for both width and height. If an object is passed, the screenshot size
  68558. * will be derived from the parameters. The precision property is a multiplier allowing
  68559. * rendering at a higher or lower resolution
  68560. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68561. * Check your browser for supported MIME types
  68562. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68563. * to the src parameter of an <img> to display it
  68564. */
  68565. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68566. /**
  68567. * Generates an image screenshot from the specified camera.
  68568. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68569. * @param engine The engine to use for rendering
  68570. * @param camera The camera to use for rendering
  68571. * @param size This parameter can be set to a single number or to an object with the
  68572. * following (optional) properties: precision, width, height. If a single number is passed,
  68573. * it will be used for both width and height. If an object is passed, the screenshot size
  68574. * will be derived from the parameters. The precision property is a multiplier allowing
  68575. * rendering at a higher or lower resolution
  68576. * @param successCallback The callback receives a single parameter which contains the
  68577. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68578. * src parameter of an <img> to display it
  68579. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68580. * Check your browser for supported MIME types
  68581. * @param samples Texture samples (default: 1)
  68582. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68583. * @param fileName A name for for the downloaded file.
  68584. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68585. */
  68586. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68587. /**
  68588. * Generates an image screenshot from the specified camera.
  68589. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68590. * @param engine The engine to use for rendering
  68591. * @param camera The camera to use for rendering
  68592. * @param size This parameter can be set to a single number or to an object with the
  68593. * following (optional) properties: precision, width, height. If a single number is passed,
  68594. * it will be used for both width and height. If an object is passed, the screenshot size
  68595. * will be derived from the parameters. The precision property is a multiplier allowing
  68596. * rendering at a higher or lower resolution
  68597. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68598. * Check your browser for supported MIME types
  68599. * @param samples Texture samples (default: 1)
  68600. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68601. * @param fileName A name for for the downloaded file.
  68602. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68603. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68604. * to the src parameter of an <img> to display it
  68605. */
  68606. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68607. /**
  68608. * Gets height and width for screenshot size
  68609. * @private
  68610. */
  68611. private static _getScreenshotSize;
  68612. }
  68613. }
  68614. declare module BABYLON {
  68615. /**
  68616. * Interface for a data buffer
  68617. */
  68618. export interface IDataBuffer {
  68619. /**
  68620. * Reads bytes from the data buffer.
  68621. * @param byteOffset The byte offset to read
  68622. * @param byteLength The byte length to read
  68623. * @returns A promise that resolves when the bytes are read
  68624. */
  68625. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68626. /**
  68627. * The byte length of the buffer.
  68628. */
  68629. readonly byteLength: number;
  68630. }
  68631. /**
  68632. * Utility class for reading from a data buffer
  68633. */
  68634. export class DataReader {
  68635. /**
  68636. * The data buffer associated with this data reader.
  68637. */
  68638. readonly buffer: IDataBuffer;
  68639. /**
  68640. * The current byte offset from the beginning of the data buffer.
  68641. */
  68642. byteOffset: number;
  68643. private _dataView;
  68644. private _dataByteOffset;
  68645. /**
  68646. * Constructor
  68647. * @param buffer The buffer to read
  68648. */
  68649. constructor(buffer: IDataBuffer);
  68650. /**
  68651. * Loads the given byte length.
  68652. * @param byteLength The byte length to load
  68653. * @returns A promise that resolves when the load is complete
  68654. */
  68655. loadAsync(byteLength: number): Promise<void>;
  68656. /**
  68657. * Read a unsigned 32-bit integer from the currently loaded data range.
  68658. * @returns The 32-bit integer read
  68659. */
  68660. readUint32(): number;
  68661. /**
  68662. * Read a byte array from the currently loaded data range.
  68663. * @param byteLength The byte length to read
  68664. * @returns The byte array read
  68665. */
  68666. readUint8Array(byteLength: number): Uint8Array;
  68667. /**
  68668. * Read a string from the currently loaded data range.
  68669. * @param byteLength The byte length to read
  68670. * @returns The string read
  68671. */
  68672. readString(byteLength: number): string;
  68673. /**
  68674. * Skips the given byte length the currently loaded data range.
  68675. * @param byteLength The byte length to skip
  68676. */
  68677. skipBytes(byteLength: number): void;
  68678. }
  68679. }
  68680. declare module BABYLON {
  68681. /**
  68682. * Options used for hit testing
  68683. */
  68684. export interface IWebXRHitTestOptions {
  68685. /**
  68686. * Only test when user interacted with the scene. Default - hit test every frame
  68687. */
  68688. testOnPointerDownOnly?: boolean;
  68689. /**
  68690. * The node to use to transform the local results to world coordinates
  68691. */
  68692. worldParentNode?: TransformNode;
  68693. }
  68694. /**
  68695. * Interface defining the babylon result of raycasting/hit-test
  68696. */
  68697. export interface IWebXRHitResult {
  68698. /**
  68699. * The native hit test result
  68700. */
  68701. xrHitResult: XRHitResult;
  68702. /**
  68703. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68704. */
  68705. transformationMatrix: Matrix;
  68706. }
  68707. /**
  68708. * The currently-working hit-test module.
  68709. * Hit test (or raycasting) is used to interact with the real world.
  68710. * For further information read here - https://github.com/immersive-web/hit-test
  68711. */
  68712. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68713. /**
  68714. * options to use when constructing this feature
  68715. */
  68716. readonly options: IWebXRHitTestOptions;
  68717. /**
  68718. * The module's name
  68719. */
  68720. static readonly Name: string;
  68721. /**
  68722. * The (Babylon) version of this module.
  68723. * This is an integer representing the implementation version.
  68724. * This number does not correspond to the webxr specs version
  68725. */
  68726. static readonly Version: number;
  68727. /**
  68728. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68729. * @param event the (select) event to use to select with
  68730. * @param referenceSpace the reference space to use for this hit test
  68731. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68732. */
  68733. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68734. /**
  68735. * execute a hit test with an XR Ray
  68736. *
  68737. * @param xrSession a native xrSession that will execute this hit test
  68738. * @param xrRay the ray (position and direction) to use for raycasting
  68739. * @param referenceSpace native XR reference space to use for the hit-test
  68740. * @param filter filter function that will filter the results
  68741. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68742. */
  68743. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68744. /**
  68745. * Triggered when new babylon (transformed) hit test results are available
  68746. */
  68747. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68748. private _onSelectEnabled;
  68749. /**
  68750. * Creates a new instance of the (legacy version) hit test feature
  68751. * @param _xrSessionManager an instance of WebXRSessionManager
  68752. * @param options options to use when constructing this feature
  68753. */
  68754. constructor(_xrSessionManager: WebXRSessionManager,
  68755. /**
  68756. * options to use when constructing this feature
  68757. */
  68758. options?: IWebXRHitTestOptions);
  68759. /**
  68760. * Populated with the last native XR Hit Results
  68761. */
  68762. lastNativeXRHitResults: XRHitResult[];
  68763. /**
  68764. * attach this feature
  68765. * Will usually be called by the features manager
  68766. *
  68767. * @returns true if successful.
  68768. */
  68769. attach(): boolean;
  68770. /**
  68771. * detach this feature.
  68772. * Will usually be called by the features manager
  68773. *
  68774. * @returns true if successful.
  68775. */
  68776. detach(): boolean;
  68777. private _onHitTestResults;
  68778. private _origin;
  68779. private _direction;
  68780. private _mat;
  68781. protected _onXRFrame(frame: XRFrame): void;
  68782. private _onSelect;
  68783. /**
  68784. * Dispose this feature and all of the resources attached
  68785. */
  68786. dispose(): void;
  68787. }
  68788. }
  68789. declare module BABYLON {
  68790. /**
  68791. * Options used in the plane detector module
  68792. */
  68793. export interface IWebXRPlaneDetectorOptions {
  68794. /**
  68795. * The node to use to transform the local results to world coordinates
  68796. */
  68797. worldParentNode?: TransformNode;
  68798. }
  68799. /**
  68800. * A babylon interface for a webxr plane.
  68801. * A Plane is actually a polygon, built from N points in space
  68802. *
  68803. * Supported in chrome 79, not supported in canary 81 ATM
  68804. */
  68805. export interface IWebXRPlane {
  68806. /**
  68807. * a babylon-assigned ID for this polygon
  68808. */
  68809. id: number;
  68810. /**
  68811. * the native xr-plane object
  68812. */
  68813. xrPlane: XRPlane;
  68814. /**
  68815. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68816. */
  68817. polygonDefinition: Array<Vector3>;
  68818. /**
  68819. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68820. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68821. */
  68822. transformationMatrix: Matrix;
  68823. }
  68824. /**
  68825. * The plane detector is used to detect planes in the real world when in AR
  68826. * For more information see https://github.com/immersive-web/real-world-geometry/
  68827. */
  68828. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68829. private _options;
  68830. /**
  68831. * The module's name
  68832. */
  68833. static readonly Name: string;
  68834. /**
  68835. * The (Babylon) version of this module.
  68836. * This is an integer representing the implementation version.
  68837. * This number does not correspond to the webxr specs version
  68838. */
  68839. static readonly Version: number;
  68840. /**
  68841. * Observers registered here will be executed when a new plane was added to the session
  68842. */
  68843. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68844. /**
  68845. * Observers registered here will be executed when a plane is no longer detected in the session
  68846. */
  68847. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68848. /**
  68849. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68850. * This can execute N times every frame
  68851. */
  68852. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68853. private _enabled;
  68854. private _detectedPlanes;
  68855. private _lastFrameDetected;
  68856. /**
  68857. * construct a new Plane Detector
  68858. * @param _xrSessionManager an instance of xr Session manager
  68859. * @param _options configuration to use when constructing this feature
  68860. */
  68861. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68862. private _init;
  68863. protected _onXRFrame(frame: XRFrame): void;
  68864. /**
  68865. * Dispose this feature and all of the resources attached
  68866. */
  68867. dispose(): void;
  68868. private _updatePlaneWithXRPlane;
  68869. /**
  68870. * avoiding using Array.find for global support.
  68871. * @param xrPlane the plane to find in the array
  68872. */
  68873. private findIndexInPlaneArray;
  68874. }
  68875. }
  68876. declare module BABYLON {
  68877. /**
  68878. * Configuration options of the anchor system
  68879. */
  68880. export interface IWebXRAnchorSystemOptions {
  68881. /**
  68882. * a node that will be used to convert local to world coordinates
  68883. */
  68884. worldParentNode?: TransformNode;
  68885. /**
  68886. * should the anchor system use plane detection.
  68887. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68888. */
  68889. usePlaneDetection?: boolean;
  68890. /**
  68891. * Should a new anchor be added every time a select event is triggered
  68892. */
  68893. addAnchorOnSelect?: boolean;
  68894. }
  68895. /**
  68896. * A babylon container for an XR Anchor
  68897. */
  68898. export interface IWebXRAnchor {
  68899. /**
  68900. * A babylon-assigned ID for this anchor
  68901. */
  68902. id: number;
  68903. /**
  68904. * The native anchor object
  68905. */
  68906. xrAnchor: XRAnchor;
  68907. /**
  68908. * Transformation matrix to apply to an object attached to this anchor
  68909. */
  68910. transformationMatrix: Matrix;
  68911. }
  68912. /**
  68913. * An implementation of the anchor system of WebXR.
  68914. * Note that the current documented implementation is not available in any browser. Future implementations
  68915. * will use the frame to create an anchor and not the session or a detected plane
  68916. * For further information see https://github.com/immersive-web/anchors/
  68917. */
  68918. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68919. private _options;
  68920. /**
  68921. * The module's name
  68922. */
  68923. static readonly Name: string;
  68924. /**
  68925. * The (Babylon) version of this module.
  68926. * This is an integer representing the implementation version.
  68927. * This number does not correspond to the webxr specs version
  68928. */
  68929. static readonly Version: number;
  68930. /**
  68931. * Observers registered here will be executed when a new anchor was added to the session
  68932. */
  68933. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  68934. /**
  68935. * Observers registered here will be executed when an existing anchor updates
  68936. * This can execute N times every frame
  68937. */
  68938. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  68939. /**
  68940. * Observers registered here will be executed when an anchor was removed from the session
  68941. */
  68942. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  68943. private _planeDetector;
  68944. private _hitTestModule;
  68945. private _enabled;
  68946. private _trackedAnchors;
  68947. private _lastFrameDetected;
  68948. /**
  68949. * constructs a new anchor system
  68950. * @param _xrSessionManager an instance of WebXRSessionManager
  68951. * @param _options configuration object for this feature
  68952. */
  68953. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  68954. /**
  68955. * set the plane detector to use in order to create anchors from frames
  68956. * @param planeDetector the plane-detector module to use
  68957. * @param enable enable plane-anchors. default is true
  68958. */
  68959. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  68960. /**
  68961. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  68962. * @param hitTestModule the hit-test module to use.
  68963. */
  68964. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  68965. /**
  68966. * attach this feature
  68967. * Will usually be called by the features manager
  68968. *
  68969. * @returns true if successful.
  68970. */
  68971. attach(): boolean;
  68972. /**
  68973. * detach this feature.
  68974. * Will usually be called by the features manager
  68975. *
  68976. * @returns true if successful.
  68977. */
  68978. detach(): boolean;
  68979. /**
  68980. * Dispose this feature and all of the resources attached
  68981. */
  68982. dispose(): void;
  68983. protected _onXRFrame(frame: XRFrame): void;
  68984. private _onSelect;
  68985. /**
  68986. * Add anchor at a specific XR point.
  68987. *
  68988. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  68989. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  68990. * @returns a promise the fulfills when the anchor was created
  68991. */
  68992. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  68993. private _updateAnchorWithXRFrame;
  68994. /**
  68995. * avoiding using Array.find for global support.
  68996. * @param xrAnchor the plane to find in the array
  68997. */
  68998. private _findIndexInAnchorArray;
  68999. }
  69000. }
  69001. declare module BABYLON {
  69002. /**
  69003. * Options interface for the background remover plugin
  69004. */
  69005. export interface IWebXRBackgroundRemoverOptions {
  69006. /**
  69007. * don't disable the environment helper
  69008. */
  69009. ignoreEnvironmentHelper?: boolean;
  69010. /**
  69011. * flags to configure the removal of the environment helper.
  69012. * If not set, the entire background will be removed. If set, flags should be set as well.
  69013. */
  69014. environmentHelperRemovalFlags?: {
  69015. /**
  69016. * Should the skybox be removed (default false)
  69017. */
  69018. skyBox?: boolean;
  69019. /**
  69020. * Should the ground be removed (default false)
  69021. */
  69022. ground?: boolean;
  69023. };
  69024. /**
  69025. * Further background meshes to disable when entering AR
  69026. */
  69027. backgroundMeshes?: AbstractMesh[];
  69028. }
  69029. /**
  69030. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69031. */
  69032. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69033. /**
  69034. * read-only options to be used in this module
  69035. */
  69036. readonly options: IWebXRBackgroundRemoverOptions;
  69037. /**
  69038. * The module's name
  69039. */
  69040. static readonly Name: string;
  69041. /**
  69042. * The (Babylon) version of this module.
  69043. * This is an integer representing the implementation version.
  69044. * This number does not correspond to the webxr specs version
  69045. */
  69046. static readonly Version: number;
  69047. /**
  69048. * registered observers will be triggered when the background state changes
  69049. */
  69050. onBackgroundStateChangedObservable: Observable<boolean>;
  69051. /**
  69052. * constructs a new background remover module
  69053. * @param _xrSessionManager the session manager for this module
  69054. * @param options read-only options to be used in this module
  69055. */
  69056. constructor(_xrSessionManager: WebXRSessionManager,
  69057. /**
  69058. * read-only options to be used in this module
  69059. */
  69060. options?: IWebXRBackgroundRemoverOptions);
  69061. /**
  69062. * attach this feature
  69063. * Will usually be called by the features manager
  69064. *
  69065. * @returns true if successful.
  69066. */
  69067. attach(): boolean;
  69068. /**
  69069. * detach this feature.
  69070. * Will usually be called by the features manager
  69071. *
  69072. * @returns true if successful.
  69073. */
  69074. detach(): boolean;
  69075. private _setBackgroundState;
  69076. /**
  69077. * Dispose this feature and all of the resources attached
  69078. */
  69079. dispose(): void;
  69080. protected _onXRFrame(_xrFrame: XRFrame): void;
  69081. }
  69082. }
  69083. declare module BABYLON {
  69084. /**
  69085. * Options for the controller physics feature
  69086. */
  69087. export class IWebXRControllerPhysicsOptions {
  69088. /**
  69089. * the xr input to use with this pointer selection
  69090. */
  69091. xrInput: WebXRInput;
  69092. /**
  69093. * The physics properties of the future impostors
  69094. */
  69095. physicsProperties?: {
  69096. /**
  69097. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69098. * Note that this requires a physics engine that supports mesh impostors!
  69099. */
  69100. useControllerMesh?: boolean;
  69101. /**
  69102. * The type of impostor to create. Default is sphere
  69103. */
  69104. impostorType?: number;
  69105. /**
  69106. * the size of the impostor. Defaults to 10cm
  69107. */
  69108. impostorSize?: number | {
  69109. width: number;
  69110. height: number;
  69111. depth: number;
  69112. };
  69113. /**
  69114. * Friction definitions
  69115. */
  69116. friction?: number;
  69117. /**
  69118. * Restitution
  69119. */
  69120. restitution?: number;
  69121. };
  69122. /**
  69123. * Should the headset get its own impostor
  69124. */
  69125. enableHeadsetImpostor?: boolean;
  69126. /**
  69127. * Optional parameters for the headset impostor
  69128. */
  69129. headsetImpostorParams?: {
  69130. /**
  69131. * The type of impostor to create. Default is sphere
  69132. */
  69133. impostorType: number;
  69134. /**
  69135. * the size of the impostor. Defaults to 10cm
  69136. */
  69137. impostorSize?: number | {
  69138. width: number;
  69139. height: number;
  69140. depth: number;
  69141. };
  69142. /**
  69143. * Friction definitions
  69144. */
  69145. friction?: number;
  69146. /**
  69147. * Restitution
  69148. */
  69149. restitution?: number;
  69150. };
  69151. }
  69152. /**
  69153. * Add physics impostor to your webxr controllers,
  69154. * including naive calculation of their linear and angular velocity
  69155. */
  69156. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69157. private readonly _options;
  69158. /**
  69159. * The module's name
  69160. */
  69161. static readonly Name: string;
  69162. /**
  69163. * The (Babylon) version of this module.
  69164. * This is an integer representing the implementation version.
  69165. * This number does not correspond to the webxr specs version
  69166. */
  69167. static readonly Version: number;
  69168. private _lastTimestamp;
  69169. private _delta;
  69170. private _controllers;
  69171. private _headsetImpostor?;
  69172. private _headsetMesh?;
  69173. private _tmpVector;
  69174. private _tmpQuaternion;
  69175. /**
  69176. * Construct a new Controller Physics Feature
  69177. * @param _xrSessionManager the corresponding xr session manager
  69178. * @param _options options to create this feature with
  69179. */
  69180. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69181. /**
  69182. * Update the physics properties provided in the constructor
  69183. * @param newProperties the new properties object
  69184. */
  69185. setPhysicsProperties(newProperties: {
  69186. impostorType?: number;
  69187. impostorSize?: number | {
  69188. width: number;
  69189. height: number;
  69190. depth: number;
  69191. };
  69192. friction?: number;
  69193. restitution?: number;
  69194. }): void;
  69195. /**
  69196. * Get the physics impostor of a specific controller.
  69197. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69198. * @param controller the controller or the controller id of which to get the impostor
  69199. * @returns the impostor or null
  69200. */
  69201. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69202. /**
  69203. * Get the headset impostor, if enabled
  69204. * @returns the impostor
  69205. */
  69206. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69207. /**
  69208. * attach this feature
  69209. * Will usually be called by the features manager
  69210. *
  69211. * @returns true if successful.
  69212. */
  69213. attach(): boolean;
  69214. /**
  69215. * detach this feature.
  69216. * Will usually be called by the features manager
  69217. *
  69218. * @returns true if successful.
  69219. */
  69220. detach(): boolean;
  69221. /**
  69222. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69223. * @param xrController the controller to add
  69224. */
  69225. addController(xrController: WebXRInputSource): void;
  69226. private _debugMode;
  69227. /**
  69228. * @hidden
  69229. * enable debugging - will show console outputs and the impostor mesh
  69230. */
  69231. _enablePhysicsDebug(): void;
  69232. private _attachController;
  69233. private _detachController;
  69234. protected _onXRFrame(_xrFrame: any): void;
  69235. }
  69236. }
  69237. declare module BABYLON {
  69238. /**
  69239. * The motion controller class for all microsoft mixed reality controllers
  69240. */
  69241. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69242. /**
  69243. * The base url used to load the left and right controller models
  69244. */
  69245. static MODEL_BASE_URL: string;
  69246. /**
  69247. * The name of the left controller model file
  69248. */
  69249. static MODEL_LEFT_FILENAME: string;
  69250. /**
  69251. * The name of the right controller model file
  69252. */
  69253. static MODEL_RIGHT_FILENAME: string;
  69254. profileId: string;
  69255. protected readonly _mapping: {
  69256. defaultButton: {
  69257. "valueNodeName": string;
  69258. "unpressedNodeName": string;
  69259. "pressedNodeName": string;
  69260. };
  69261. defaultAxis: {
  69262. "valueNodeName": string;
  69263. "minNodeName": string;
  69264. "maxNodeName": string;
  69265. };
  69266. buttons: {
  69267. "xr-standard-trigger": {
  69268. "rootNodeName": string;
  69269. "componentProperty": string;
  69270. "states": string[];
  69271. };
  69272. "xr-standard-squeeze": {
  69273. "rootNodeName": string;
  69274. "componentProperty": string;
  69275. "states": string[];
  69276. };
  69277. "xr-standard-touchpad": {
  69278. "rootNodeName": string;
  69279. "labelAnchorNodeName": string;
  69280. "touchPointNodeName": string;
  69281. };
  69282. "xr-standard-thumbstick": {
  69283. "rootNodeName": string;
  69284. "componentProperty": string;
  69285. "states": string[];
  69286. };
  69287. };
  69288. axes: {
  69289. "xr-standard-touchpad": {
  69290. "x-axis": {
  69291. "rootNodeName": string;
  69292. };
  69293. "y-axis": {
  69294. "rootNodeName": string;
  69295. };
  69296. };
  69297. "xr-standard-thumbstick": {
  69298. "x-axis": {
  69299. "rootNodeName": string;
  69300. };
  69301. "y-axis": {
  69302. "rootNodeName": string;
  69303. };
  69304. };
  69305. };
  69306. };
  69307. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69308. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69309. protected _getFilenameAndPath(): {
  69310. filename: string;
  69311. path: string;
  69312. };
  69313. protected _updateModel(): void;
  69314. protected _getModelLoadingConstraints(): boolean;
  69315. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69316. }
  69317. }
  69318. declare module BABYLON {
  69319. /**
  69320. * The motion controller class for oculus touch (quest, rift).
  69321. * This class supports legacy mapping as well the standard xr mapping
  69322. */
  69323. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69324. private _forceLegacyControllers;
  69325. /**
  69326. * The base url used to load the left and right controller models
  69327. */
  69328. static MODEL_BASE_URL: string;
  69329. /**
  69330. * The name of the left controller model file
  69331. */
  69332. static MODEL_LEFT_FILENAME: string;
  69333. /**
  69334. * The name of the right controller model file
  69335. */
  69336. static MODEL_RIGHT_FILENAME: string;
  69337. /**
  69338. * Base Url for the Quest controller model.
  69339. */
  69340. static QUEST_MODEL_BASE_URL: string;
  69341. profileId: string;
  69342. private _modelRootNode;
  69343. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69344. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69345. protected _getFilenameAndPath(): {
  69346. filename: string;
  69347. path: string;
  69348. };
  69349. /**
  69350. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69351. * between the touch and touch 2.
  69352. */
  69353. private _isQuest;
  69354. protected _updateModel(): void;
  69355. protected _getModelLoadingConstraints(): boolean;
  69356. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69357. }
  69358. }
  69359. declare module BABYLON {
  69360. /**
  69361. * The motion controller class for the standard HTC-Vive controllers
  69362. */
  69363. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69364. /**
  69365. * The base url used to load the left and right controller models
  69366. */
  69367. static MODEL_BASE_URL: string;
  69368. /**
  69369. * File name for the controller model.
  69370. */
  69371. static MODEL_FILENAME: string;
  69372. profileId: string;
  69373. private _modelRootNode;
  69374. /**
  69375. * Create a new Vive motion controller object
  69376. * @param scene the scene to use to create this controller
  69377. * @param gamepadObject the corresponding gamepad object
  69378. * @param handness the handness of the controller
  69379. */
  69380. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69381. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69382. protected _getFilenameAndPath(): {
  69383. filename: string;
  69384. path: string;
  69385. };
  69386. protected _updateModel(): void;
  69387. protected _getModelLoadingConstraints(): boolean;
  69388. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69389. }
  69390. }
  69391. declare module BABYLON {
  69392. /**
  69393. * A cursor which tracks a point on a path
  69394. */
  69395. export class PathCursor {
  69396. private path;
  69397. /**
  69398. * Stores path cursor callbacks for when an onchange event is triggered
  69399. */
  69400. private _onchange;
  69401. /**
  69402. * The value of the path cursor
  69403. */
  69404. value: number;
  69405. /**
  69406. * The animation array of the path cursor
  69407. */
  69408. animations: Animation[];
  69409. /**
  69410. * Initializes the path cursor
  69411. * @param path The path to track
  69412. */
  69413. constructor(path: Path2);
  69414. /**
  69415. * Gets the cursor point on the path
  69416. * @returns A point on the path cursor at the cursor location
  69417. */
  69418. getPoint(): Vector3;
  69419. /**
  69420. * Moves the cursor ahead by the step amount
  69421. * @param step The amount to move the cursor forward
  69422. * @returns This path cursor
  69423. */
  69424. moveAhead(step?: number): PathCursor;
  69425. /**
  69426. * Moves the cursor behind by the step amount
  69427. * @param step The amount to move the cursor back
  69428. * @returns This path cursor
  69429. */
  69430. moveBack(step?: number): PathCursor;
  69431. /**
  69432. * Moves the cursor by the step amount
  69433. * If the step amount is greater than one, an exception is thrown
  69434. * @param step The amount to move the cursor
  69435. * @returns This path cursor
  69436. */
  69437. move(step: number): PathCursor;
  69438. /**
  69439. * Ensures that the value is limited between zero and one
  69440. * @returns This path cursor
  69441. */
  69442. private ensureLimits;
  69443. /**
  69444. * Runs onchange callbacks on change (used by the animation engine)
  69445. * @returns This path cursor
  69446. */
  69447. private raiseOnChange;
  69448. /**
  69449. * Executes a function on change
  69450. * @param f A path cursor onchange callback
  69451. * @returns This path cursor
  69452. */
  69453. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69454. }
  69455. }
  69456. declare module BABYLON {
  69457. /** @hidden */
  69458. export var blurPixelShader: {
  69459. name: string;
  69460. shader: string;
  69461. };
  69462. }
  69463. declare module BABYLON {
  69464. /** @hidden */
  69465. export var pointCloudVertexDeclaration: {
  69466. name: string;
  69467. shader: string;
  69468. };
  69469. }
  69470. // Mixins
  69471. interface Window {
  69472. mozIndexedDB: IDBFactory;
  69473. webkitIndexedDB: IDBFactory;
  69474. msIndexedDB: IDBFactory;
  69475. webkitURL: typeof URL;
  69476. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69477. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69478. WebGLRenderingContext: WebGLRenderingContext;
  69479. MSGesture: MSGesture;
  69480. CANNON: any;
  69481. AudioContext: AudioContext;
  69482. webkitAudioContext: AudioContext;
  69483. PointerEvent: any;
  69484. Math: Math;
  69485. Uint8Array: Uint8ArrayConstructor;
  69486. Float32Array: Float32ArrayConstructor;
  69487. mozURL: typeof URL;
  69488. msURL: typeof URL;
  69489. VRFrameData: any; // WebVR, from specs 1.1
  69490. DracoDecoderModule: any;
  69491. setImmediate(handler: (...args: any[]) => void): number;
  69492. }
  69493. interface HTMLCanvasElement {
  69494. requestPointerLock(): void;
  69495. msRequestPointerLock?(): void;
  69496. mozRequestPointerLock?(): void;
  69497. webkitRequestPointerLock?(): void;
  69498. /** Track wether a record is in progress */
  69499. isRecording: boolean;
  69500. /** Capture Stream method defined by some browsers */
  69501. captureStream(fps?: number): MediaStream;
  69502. }
  69503. interface CanvasRenderingContext2D {
  69504. msImageSmoothingEnabled: boolean;
  69505. }
  69506. interface MouseEvent {
  69507. mozMovementX: number;
  69508. mozMovementY: number;
  69509. webkitMovementX: number;
  69510. webkitMovementY: number;
  69511. msMovementX: number;
  69512. msMovementY: number;
  69513. }
  69514. interface Navigator {
  69515. mozGetVRDevices: (any: any) => any;
  69516. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69517. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69518. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69519. webkitGetGamepads(): Gamepad[];
  69520. msGetGamepads(): Gamepad[];
  69521. webkitGamepads(): Gamepad[];
  69522. }
  69523. interface HTMLVideoElement {
  69524. mozSrcObject: any;
  69525. }
  69526. interface Math {
  69527. fround(x: number): number;
  69528. imul(a: number, b: number): number;
  69529. }
  69530. interface WebGLRenderingContext {
  69531. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69532. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69533. vertexAttribDivisor(index: number, divisor: number): void;
  69534. createVertexArray(): any;
  69535. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69536. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69537. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69538. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69539. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69540. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69541. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69542. // Queries
  69543. createQuery(): WebGLQuery;
  69544. deleteQuery(query: WebGLQuery): void;
  69545. beginQuery(target: number, query: WebGLQuery): void;
  69546. endQuery(target: number): void;
  69547. getQueryParameter(query: WebGLQuery, pname: number): any;
  69548. getQuery(target: number, pname: number): any;
  69549. MAX_SAMPLES: number;
  69550. RGBA8: number;
  69551. READ_FRAMEBUFFER: number;
  69552. DRAW_FRAMEBUFFER: number;
  69553. UNIFORM_BUFFER: number;
  69554. HALF_FLOAT_OES: number;
  69555. RGBA16F: number;
  69556. RGBA32F: number;
  69557. R32F: number;
  69558. RG32F: number;
  69559. RGB32F: number;
  69560. R16F: number;
  69561. RG16F: number;
  69562. RGB16F: number;
  69563. RED: number;
  69564. RG: number;
  69565. R8: number;
  69566. RG8: number;
  69567. UNSIGNED_INT_24_8: number;
  69568. DEPTH24_STENCIL8: number;
  69569. MIN: number;
  69570. MAX: number;
  69571. /* Multiple Render Targets */
  69572. drawBuffers(buffers: number[]): void;
  69573. readBuffer(src: number): void;
  69574. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69575. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69576. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69577. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69578. // Occlusion Query
  69579. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69580. ANY_SAMPLES_PASSED: number;
  69581. QUERY_RESULT_AVAILABLE: number;
  69582. QUERY_RESULT: number;
  69583. }
  69584. interface WebGLProgram {
  69585. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69586. }
  69587. interface EXT_disjoint_timer_query {
  69588. QUERY_COUNTER_BITS_EXT: number;
  69589. TIME_ELAPSED_EXT: number;
  69590. TIMESTAMP_EXT: number;
  69591. GPU_DISJOINT_EXT: number;
  69592. QUERY_RESULT_EXT: number;
  69593. QUERY_RESULT_AVAILABLE_EXT: number;
  69594. queryCounterEXT(query: WebGLQuery, target: number): void;
  69595. createQueryEXT(): WebGLQuery;
  69596. beginQueryEXT(target: number, query: WebGLQuery): void;
  69597. endQueryEXT(target: number): void;
  69598. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69599. deleteQueryEXT(query: WebGLQuery): void;
  69600. }
  69601. interface WebGLUniformLocation {
  69602. _currentState: any;
  69603. }
  69604. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69605. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69606. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69607. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69608. interface WebGLRenderingContext {
  69609. readonly RASTERIZER_DISCARD: number;
  69610. readonly DEPTH_COMPONENT24: number;
  69611. readonly TEXTURE_3D: number;
  69612. readonly TEXTURE_2D_ARRAY: number;
  69613. readonly TEXTURE_COMPARE_FUNC: number;
  69614. readonly TEXTURE_COMPARE_MODE: number;
  69615. readonly COMPARE_REF_TO_TEXTURE: number;
  69616. readonly TEXTURE_WRAP_R: number;
  69617. readonly HALF_FLOAT: number;
  69618. readonly RGB8: number;
  69619. readonly RED_INTEGER: number;
  69620. readonly RG_INTEGER: number;
  69621. readonly RGB_INTEGER: number;
  69622. readonly RGBA_INTEGER: number;
  69623. readonly R8_SNORM: number;
  69624. readonly RG8_SNORM: number;
  69625. readonly RGB8_SNORM: number;
  69626. readonly RGBA8_SNORM: number;
  69627. readonly R8I: number;
  69628. readonly RG8I: number;
  69629. readonly RGB8I: number;
  69630. readonly RGBA8I: number;
  69631. readonly R8UI: number;
  69632. readonly RG8UI: number;
  69633. readonly RGB8UI: number;
  69634. readonly RGBA8UI: number;
  69635. readonly R16I: number;
  69636. readonly RG16I: number;
  69637. readonly RGB16I: number;
  69638. readonly RGBA16I: number;
  69639. readonly R16UI: number;
  69640. readonly RG16UI: number;
  69641. readonly RGB16UI: number;
  69642. readonly RGBA16UI: number;
  69643. readonly R32I: number;
  69644. readonly RG32I: number;
  69645. readonly RGB32I: number;
  69646. readonly RGBA32I: number;
  69647. readonly R32UI: number;
  69648. readonly RG32UI: number;
  69649. readonly RGB32UI: number;
  69650. readonly RGBA32UI: number;
  69651. readonly RGB10_A2UI: number;
  69652. readonly R11F_G11F_B10F: number;
  69653. readonly RGB9_E5: number;
  69654. readonly RGB10_A2: number;
  69655. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69656. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69657. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69658. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69659. readonly DEPTH_COMPONENT32F: number;
  69660. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69661. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69662. 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;
  69663. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69664. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69665. readonly TRANSFORM_FEEDBACK: number;
  69666. readonly INTERLEAVED_ATTRIBS: number;
  69667. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69668. createTransformFeedback(): WebGLTransformFeedback;
  69669. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69670. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69671. beginTransformFeedback(primitiveMode: number): void;
  69672. endTransformFeedback(): void;
  69673. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69674. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69675. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69676. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69677. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69678. }
  69679. interface ImageBitmap {
  69680. readonly width: number;
  69681. readonly height: number;
  69682. close(): void;
  69683. }
  69684. interface WebGLQuery extends WebGLObject {
  69685. }
  69686. declare var WebGLQuery: {
  69687. prototype: WebGLQuery;
  69688. new(): WebGLQuery;
  69689. };
  69690. interface WebGLSampler extends WebGLObject {
  69691. }
  69692. declare var WebGLSampler: {
  69693. prototype: WebGLSampler;
  69694. new(): WebGLSampler;
  69695. };
  69696. interface WebGLSync extends WebGLObject {
  69697. }
  69698. declare var WebGLSync: {
  69699. prototype: WebGLSync;
  69700. new(): WebGLSync;
  69701. };
  69702. interface WebGLTransformFeedback extends WebGLObject {
  69703. }
  69704. declare var WebGLTransformFeedback: {
  69705. prototype: WebGLTransformFeedback;
  69706. new(): WebGLTransformFeedback;
  69707. };
  69708. interface WebGLVertexArrayObject extends WebGLObject {
  69709. }
  69710. declare var WebGLVertexArrayObject: {
  69711. prototype: WebGLVertexArrayObject;
  69712. new(): WebGLVertexArrayObject;
  69713. };
  69714. // Type definitions for WebVR API
  69715. // Project: https://w3c.github.io/webvr/
  69716. // Definitions by: six a <https://github.com/lostfictions>
  69717. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69718. interface VRDisplay extends EventTarget {
  69719. /**
  69720. * Dictionary of capabilities describing the VRDisplay.
  69721. */
  69722. readonly capabilities: VRDisplayCapabilities;
  69723. /**
  69724. * z-depth defining the far plane of the eye view frustum
  69725. * enables mapping of values in the render target depth
  69726. * attachment to scene coordinates. Initially set to 10000.0.
  69727. */
  69728. depthFar: number;
  69729. /**
  69730. * z-depth defining the near plane of the eye view frustum
  69731. * enables mapping of values in the render target depth
  69732. * attachment to scene coordinates. Initially set to 0.01.
  69733. */
  69734. depthNear: number;
  69735. /**
  69736. * An identifier for this distinct VRDisplay. Used as an
  69737. * association point in the Gamepad API.
  69738. */
  69739. readonly displayId: number;
  69740. /**
  69741. * A display name, a user-readable name identifying it.
  69742. */
  69743. readonly displayName: string;
  69744. readonly isConnected: boolean;
  69745. readonly isPresenting: boolean;
  69746. /**
  69747. * If this VRDisplay supports room-scale experiences, the optional
  69748. * stage attribute contains details on the room-scale parameters.
  69749. */
  69750. readonly stageParameters: VRStageParameters | null;
  69751. /**
  69752. * Passing the value returned by `requestAnimationFrame` to
  69753. * `cancelAnimationFrame` will unregister the callback.
  69754. * @param handle Define the hanle of the request to cancel
  69755. */
  69756. cancelAnimationFrame(handle: number): void;
  69757. /**
  69758. * Stops presenting to the VRDisplay.
  69759. * @returns a promise to know when it stopped
  69760. */
  69761. exitPresent(): Promise<void>;
  69762. /**
  69763. * Return the current VREyeParameters for the given eye.
  69764. * @param whichEye Define the eye we want the parameter for
  69765. * @returns the eye parameters
  69766. */
  69767. getEyeParameters(whichEye: string): VREyeParameters;
  69768. /**
  69769. * Populates the passed VRFrameData with the information required to render
  69770. * the current frame.
  69771. * @param frameData Define the data structure to populate
  69772. * @returns true if ok otherwise false
  69773. */
  69774. getFrameData(frameData: VRFrameData): boolean;
  69775. /**
  69776. * Get the layers currently being presented.
  69777. * @returns the list of VR layers
  69778. */
  69779. getLayers(): VRLayer[];
  69780. /**
  69781. * Return a VRPose containing the future predicted pose of the VRDisplay
  69782. * when the current frame will be presented. The value returned will not
  69783. * change until JavaScript has returned control to the browser.
  69784. *
  69785. * The VRPose will contain the position, orientation, velocity,
  69786. * and acceleration of each of these properties.
  69787. * @returns the pose object
  69788. */
  69789. getPose(): VRPose;
  69790. /**
  69791. * Return the current instantaneous pose of the VRDisplay, with no
  69792. * prediction applied.
  69793. * @returns the current instantaneous pose
  69794. */
  69795. getImmediatePose(): VRPose;
  69796. /**
  69797. * The callback passed to `requestAnimationFrame` will be called
  69798. * any time a new frame should be rendered. When the VRDisplay is
  69799. * presenting the callback will be called at the native refresh
  69800. * rate of the HMD. When not presenting this function acts
  69801. * identically to how window.requestAnimationFrame acts. Content should
  69802. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69803. * asynchronously from other displays and at differing refresh rates.
  69804. * @param callback Define the eaction to run next frame
  69805. * @returns the request handle it
  69806. */
  69807. requestAnimationFrame(callback: FrameRequestCallback): number;
  69808. /**
  69809. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69810. * Repeat calls while already presenting will update the VRLayers being displayed.
  69811. * @param layers Define the list of layer to present
  69812. * @returns a promise to know when the request has been fulfilled
  69813. */
  69814. requestPresent(layers: VRLayer[]): Promise<void>;
  69815. /**
  69816. * Reset the pose for this display, treating its current position and
  69817. * orientation as the "origin/zero" values. VRPose.position,
  69818. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69819. * updated when calling resetPose(). This should be called in only
  69820. * sitting-space experiences.
  69821. */
  69822. resetPose(): void;
  69823. /**
  69824. * The VRLayer provided to the VRDisplay will be captured and presented
  69825. * in the HMD. Calling this function has the same effect on the source
  69826. * canvas as any other operation that uses its source image, and canvases
  69827. * created without preserveDrawingBuffer set to true will be cleared.
  69828. * @param pose Define the pose to submit
  69829. */
  69830. submitFrame(pose?: VRPose): void;
  69831. }
  69832. declare var VRDisplay: {
  69833. prototype: VRDisplay;
  69834. new(): VRDisplay;
  69835. };
  69836. interface VRLayer {
  69837. leftBounds?: number[] | Float32Array | null;
  69838. rightBounds?: number[] | Float32Array | null;
  69839. source?: HTMLCanvasElement | null;
  69840. }
  69841. interface VRDisplayCapabilities {
  69842. readonly canPresent: boolean;
  69843. readonly hasExternalDisplay: boolean;
  69844. readonly hasOrientation: boolean;
  69845. readonly hasPosition: boolean;
  69846. readonly maxLayers: number;
  69847. }
  69848. interface VREyeParameters {
  69849. /** @deprecated */
  69850. readonly fieldOfView: VRFieldOfView;
  69851. readonly offset: Float32Array;
  69852. readonly renderHeight: number;
  69853. readonly renderWidth: number;
  69854. }
  69855. interface VRFieldOfView {
  69856. readonly downDegrees: number;
  69857. readonly leftDegrees: number;
  69858. readonly rightDegrees: number;
  69859. readonly upDegrees: number;
  69860. }
  69861. interface VRFrameData {
  69862. readonly leftProjectionMatrix: Float32Array;
  69863. readonly leftViewMatrix: Float32Array;
  69864. readonly pose: VRPose;
  69865. readonly rightProjectionMatrix: Float32Array;
  69866. readonly rightViewMatrix: Float32Array;
  69867. readonly timestamp: number;
  69868. }
  69869. interface VRPose {
  69870. readonly angularAcceleration: Float32Array | null;
  69871. readonly angularVelocity: Float32Array | null;
  69872. readonly linearAcceleration: Float32Array | null;
  69873. readonly linearVelocity: Float32Array | null;
  69874. readonly orientation: Float32Array | null;
  69875. readonly position: Float32Array | null;
  69876. readonly timestamp: number;
  69877. }
  69878. interface VRStageParameters {
  69879. sittingToStandingTransform?: Float32Array;
  69880. sizeX?: number;
  69881. sizeY?: number;
  69882. }
  69883. interface Navigator {
  69884. getVRDisplays(): Promise<VRDisplay[]>;
  69885. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69886. }
  69887. interface Window {
  69888. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69889. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69890. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69891. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69892. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69893. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69894. }
  69895. interface Gamepad {
  69896. readonly displayId: number;
  69897. }
  69898. type XRSessionMode =
  69899. | "inline"
  69900. | "immersive-vr"
  69901. | "immersive-ar";
  69902. type XRReferenceSpaceType =
  69903. | "viewer"
  69904. | "local"
  69905. | "local-floor"
  69906. | "bounded-floor"
  69907. | "unbounded";
  69908. type XREnvironmentBlendMode =
  69909. | "opaque"
  69910. | "additive"
  69911. | "alpha-blend";
  69912. type XRVisibilityState =
  69913. | "visible"
  69914. | "visible-blurred"
  69915. | "hidden";
  69916. type XRHandedness =
  69917. | "none"
  69918. | "left"
  69919. | "right";
  69920. type XRTargetRayMode =
  69921. | "gaze"
  69922. | "tracked-pointer"
  69923. | "screen";
  69924. type XREye =
  69925. | "none"
  69926. | "left"
  69927. | "right";
  69928. interface XRSpace extends EventTarget {
  69929. }
  69930. interface XRRenderState {
  69931. depthNear?: number;
  69932. depthFar?: number;
  69933. inlineVerticalFieldOfView?: number;
  69934. baseLayer?: XRWebGLLayer;
  69935. }
  69936. interface XRInputSource {
  69937. handedness: XRHandedness;
  69938. targetRayMode: XRTargetRayMode;
  69939. targetRaySpace: XRSpace;
  69940. gripSpace: XRSpace | undefined;
  69941. gamepad: Gamepad | undefined;
  69942. profiles: Array<string>;
  69943. }
  69944. interface XRSessionInit {
  69945. optionalFeatures?: XRReferenceSpaceType[];
  69946. requiredFeatures?: XRReferenceSpaceType[];
  69947. }
  69948. interface XRSession extends XRAnchorCreator {
  69949. addEventListener: Function;
  69950. removeEventListener: Function;
  69951. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69952. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69953. requestAnimationFrame: Function;
  69954. end(): Promise<void>;
  69955. renderState: XRRenderState;
  69956. inputSources: Array<XRInputSource>;
  69957. // AR hit test
  69958. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69959. updateWorldTrackingState(options: {
  69960. planeDetectionState?: { enabled: boolean; }
  69961. }): void;
  69962. }
  69963. interface XRReferenceSpace extends XRSpace {
  69964. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69965. onreset: any;
  69966. }
  69967. type XRPlaneSet = Set<XRPlane>;
  69968. type XRAnchorSet = Set<XRAnchor>;
  69969. interface XRFrame {
  69970. session: XRSession;
  69971. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69972. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69973. // Anchors
  69974. trackedAnchors?: XRAnchorSet;
  69975. // Planes
  69976. worldInformation: {
  69977. detectedPlanes?: XRPlaneSet;
  69978. };
  69979. }
  69980. interface XRViewerPose extends XRPose {
  69981. views: Array<XRView>;
  69982. }
  69983. interface XRPose {
  69984. transform: XRRigidTransform;
  69985. emulatedPosition: boolean;
  69986. }
  69987. interface XRWebGLLayerOptions {
  69988. antialias?: boolean;
  69989. depth?: boolean;
  69990. stencil?: boolean;
  69991. alpha?: boolean;
  69992. multiview?: boolean;
  69993. framebufferScaleFactor?: number;
  69994. }
  69995. declare var XRWebGLLayer: {
  69996. prototype: XRWebGLLayer;
  69997. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69998. };
  69999. interface XRWebGLLayer {
  70000. framebuffer: WebGLFramebuffer;
  70001. framebufferWidth: number;
  70002. framebufferHeight: number;
  70003. getViewport: Function;
  70004. }
  70005. declare class XRRigidTransform {
  70006. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70007. position: DOMPointReadOnly;
  70008. orientation: DOMPointReadOnly;
  70009. matrix: Float32Array;
  70010. inverse: XRRigidTransform;
  70011. }
  70012. interface XRView {
  70013. eye: XREye;
  70014. projectionMatrix: Float32Array;
  70015. transform: XRRigidTransform;
  70016. }
  70017. interface XRInputSourceChangeEvent {
  70018. session: XRSession;
  70019. removed: Array<XRInputSource>;
  70020. added: Array<XRInputSource>;
  70021. }
  70022. interface XRInputSourceEvent extends Event {
  70023. readonly frame: XRFrame;
  70024. readonly inputSource: XRInputSource;
  70025. }
  70026. // Experimental(er) features
  70027. declare class XRRay {
  70028. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70029. origin: DOMPointReadOnly;
  70030. direction: DOMPointReadOnly;
  70031. matrix: Float32Array;
  70032. }
  70033. interface XRHitResult {
  70034. hitMatrix: Float32Array;
  70035. }
  70036. interface XRAnchor {
  70037. // remove?
  70038. id?: string;
  70039. anchorSpace: XRSpace;
  70040. lastChangedTime: number;
  70041. detach(): void;
  70042. }
  70043. interface XRPlane extends XRAnchorCreator {
  70044. orientation: "Horizontal" | "Vertical";
  70045. planeSpace: XRSpace;
  70046. polygon: Array<DOMPointReadOnly>;
  70047. lastChangedTime: number;
  70048. }
  70049. interface XRAnchorCreator {
  70050. // AR Anchors
  70051. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70052. }
  70053. /**
  70054. * @ignore
  70055. */
  70056. declare module BABYLON.GLTF2.Exporter {
  70057. }
  70058. /**
  70059. * @ignore
  70060. */
  70061. declare module BABYLON.GLTF1 {
  70062. }
  70063. declare module BABYLON.GUI {
  70064. /**
  70065. * Class used to specific a value and its associated unit
  70066. */
  70067. export class ValueAndUnit {
  70068. /** defines the unit to store */
  70069. unit: number;
  70070. /** defines a boolean indicating if the value can be negative */
  70071. negativeValueAllowed: boolean;
  70072. private _value;
  70073. private _originalUnit;
  70074. /**
  70075. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70076. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70077. */
  70078. ignoreAdaptiveScaling: boolean;
  70079. /**
  70080. * Creates a new ValueAndUnit
  70081. * @param value defines the value to store
  70082. * @param unit defines the unit to store
  70083. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70084. */
  70085. constructor(value: number,
  70086. /** defines the unit to store */
  70087. unit?: number,
  70088. /** defines a boolean indicating if the value can be negative */
  70089. negativeValueAllowed?: boolean);
  70090. /** Gets a boolean indicating if the value is a percentage */
  70091. get isPercentage(): boolean;
  70092. /** Gets a boolean indicating if the value is store as pixel */
  70093. get isPixel(): boolean;
  70094. /** Gets direct internal value */
  70095. get internalValue(): number;
  70096. /**
  70097. * Gets value as pixel
  70098. * @param host defines the root host
  70099. * @param refValue defines the reference value for percentages
  70100. * @returns the value as pixel
  70101. */
  70102. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70103. /**
  70104. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70105. * @param value defines the value to store
  70106. * @param unit defines the unit to store
  70107. * @returns the current ValueAndUnit
  70108. */
  70109. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70110. /**
  70111. * Gets the value accordingly to its unit
  70112. * @param host defines the root host
  70113. * @returns the value
  70114. */
  70115. getValue(host: AdvancedDynamicTexture): number;
  70116. /**
  70117. * Gets a string representation of the value
  70118. * @param host defines the root host
  70119. * @param decimals defines an optional number of decimals to display
  70120. * @returns a string
  70121. */
  70122. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70123. /**
  70124. * Store a value parsed from a string
  70125. * @param source defines the source string
  70126. * @returns true if the value was successfully parsed
  70127. */
  70128. fromString(source: string | number): boolean;
  70129. private static _Regex;
  70130. private static _UNITMODE_PERCENTAGE;
  70131. private static _UNITMODE_PIXEL;
  70132. /** UNITMODE_PERCENTAGE */
  70133. static get UNITMODE_PERCENTAGE(): number;
  70134. /** UNITMODE_PIXEL */
  70135. static get UNITMODE_PIXEL(): number;
  70136. }
  70137. }
  70138. declare module BABYLON.GUI {
  70139. /**
  70140. * Define a style used by control to automatically setup properties based on a template.
  70141. * Only support font related properties so far
  70142. */
  70143. export class Style implements BABYLON.IDisposable {
  70144. private _fontFamily;
  70145. private _fontStyle;
  70146. private _fontWeight;
  70147. /** @hidden */
  70148. _host: AdvancedDynamicTexture;
  70149. /** @hidden */
  70150. _fontSize: ValueAndUnit;
  70151. /**
  70152. * BABYLON.Observable raised when the style values are changed
  70153. */
  70154. onChangedObservable: BABYLON.Observable<Style>;
  70155. /**
  70156. * Creates a new style object
  70157. * @param host defines the AdvancedDynamicTexture which hosts this style
  70158. */
  70159. constructor(host: AdvancedDynamicTexture);
  70160. /**
  70161. * Gets or sets the font size
  70162. */
  70163. get fontSize(): string | number;
  70164. set fontSize(value: string | number);
  70165. /**
  70166. * Gets or sets the font family
  70167. */
  70168. get fontFamily(): string;
  70169. set fontFamily(value: string);
  70170. /**
  70171. * Gets or sets the font style
  70172. */
  70173. get fontStyle(): string;
  70174. set fontStyle(value: string);
  70175. /** Gets or sets font weight */
  70176. get fontWeight(): string;
  70177. set fontWeight(value: string);
  70178. /** Dispose all associated resources */
  70179. dispose(): void;
  70180. }
  70181. }
  70182. declare module BABYLON.GUI {
  70183. /**
  70184. * Class used to transport BABYLON.Vector2 information for pointer events
  70185. */
  70186. export class Vector2WithInfo extends BABYLON.Vector2 {
  70187. /** defines the current mouse button index */
  70188. buttonIndex: number;
  70189. /**
  70190. * Creates a new Vector2WithInfo
  70191. * @param source defines the vector2 data to transport
  70192. * @param buttonIndex defines the current mouse button index
  70193. */
  70194. constructor(source: BABYLON.Vector2,
  70195. /** defines the current mouse button index */
  70196. buttonIndex?: number);
  70197. }
  70198. /** Class used to provide 2D matrix features */
  70199. export class Matrix2D {
  70200. /** Gets the internal array of 6 floats used to store matrix data */
  70201. m: Float32Array;
  70202. /**
  70203. * Creates a new matrix
  70204. * @param m00 defines value for (0, 0)
  70205. * @param m01 defines value for (0, 1)
  70206. * @param m10 defines value for (1, 0)
  70207. * @param m11 defines value for (1, 1)
  70208. * @param m20 defines value for (2, 0)
  70209. * @param m21 defines value for (2, 1)
  70210. */
  70211. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70212. /**
  70213. * Fills the matrix from direct values
  70214. * @param m00 defines value for (0, 0)
  70215. * @param m01 defines value for (0, 1)
  70216. * @param m10 defines value for (1, 0)
  70217. * @param m11 defines value for (1, 1)
  70218. * @param m20 defines value for (2, 0)
  70219. * @param m21 defines value for (2, 1)
  70220. * @returns the current modified matrix
  70221. */
  70222. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70223. /**
  70224. * Gets matrix determinant
  70225. * @returns the determinant
  70226. */
  70227. determinant(): number;
  70228. /**
  70229. * Inverses the matrix and stores it in a target matrix
  70230. * @param result defines the target matrix
  70231. * @returns the current matrix
  70232. */
  70233. invertToRef(result: Matrix2D): Matrix2D;
  70234. /**
  70235. * Multiplies the current matrix with another one
  70236. * @param other defines the second operand
  70237. * @param result defines the target matrix
  70238. * @returns the current matrix
  70239. */
  70240. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70241. /**
  70242. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70243. * @param x defines the x coordinate to transform
  70244. * @param y defines the x coordinate to transform
  70245. * @param result defines the target vector2
  70246. * @returns the current matrix
  70247. */
  70248. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70249. /**
  70250. * Creates an identity matrix
  70251. * @returns a new matrix
  70252. */
  70253. static Identity(): Matrix2D;
  70254. /**
  70255. * Creates a translation matrix and stores it in a target matrix
  70256. * @param x defines the x coordinate of the translation
  70257. * @param y defines the y coordinate of the translation
  70258. * @param result defines the target matrix
  70259. */
  70260. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70261. /**
  70262. * Creates a scaling matrix and stores it in a target matrix
  70263. * @param x defines the x coordinate of the scaling
  70264. * @param y defines the y coordinate of the scaling
  70265. * @param result defines the target matrix
  70266. */
  70267. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70268. /**
  70269. * Creates a rotation matrix and stores it in a target matrix
  70270. * @param angle defines the rotation angle
  70271. * @param result defines the target matrix
  70272. */
  70273. static RotationToRef(angle: number, result: Matrix2D): void;
  70274. private static _TempPreTranslationMatrix;
  70275. private static _TempPostTranslationMatrix;
  70276. private static _TempRotationMatrix;
  70277. private static _TempScalingMatrix;
  70278. private static _TempCompose0;
  70279. private static _TempCompose1;
  70280. private static _TempCompose2;
  70281. /**
  70282. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70283. * @param tx defines the x coordinate of the translation
  70284. * @param ty defines the y coordinate of the translation
  70285. * @param angle defines the rotation angle
  70286. * @param scaleX defines the x coordinate of the scaling
  70287. * @param scaleY defines the y coordinate of the scaling
  70288. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70289. * @param result defines the target matrix
  70290. */
  70291. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70292. }
  70293. }
  70294. declare module BABYLON.GUI {
  70295. /**
  70296. * Class used to store 2D control sizes
  70297. */
  70298. export class Measure {
  70299. /** defines left coordinate */
  70300. left: number;
  70301. /** defines top coordinate */
  70302. top: number;
  70303. /** defines width dimension */
  70304. width: number;
  70305. /** defines height dimension */
  70306. height: number;
  70307. /**
  70308. * Creates a new measure
  70309. * @param left defines left coordinate
  70310. * @param top defines top coordinate
  70311. * @param width defines width dimension
  70312. * @param height defines height dimension
  70313. */
  70314. constructor(
  70315. /** defines left coordinate */
  70316. left: number,
  70317. /** defines top coordinate */
  70318. top: number,
  70319. /** defines width dimension */
  70320. width: number,
  70321. /** defines height dimension */
  70322. height: number);
  70323. /**
  70324. * Copy from another measure
  70325. * @param other defines the other measure to copy from
  70326. */
  70327. copyFrom(other: Measure): void;
  70328. /**
  70329. * Copy from a group of 4 floats
  70330. * @param left defines left coordinate
  70331. * @param top defines top coordinate
  70332. * @param width defines width dimension
  70333. * @param height defines height dimension
  70334. */
  70335. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70336. /**
  70337. * Computes the axis aligned bounding box measure for two given measures
  70338. * @param a Input measure
  70339. * @param b Input measure
  70340. * @param result the resulting bounding measure
  70341. */
  70342. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70343. /**
  70344. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70345. * @param transform the matrix to transform the measure before computing the AABB
  70346. * @param result the resulting AABB
  70347. */
  70348. transformToRef(transform: Matrix2D, result: Measure): void;
  70349. /**
  70350. * Check equality between this measure and another one
  70351. * @param other defines the other measures
  70352. * @returns true if both measures are equals
  70353. */
  70354. isEqualsTo(other: Measure): boolean;
  70355. /**
  70356. * Creates an empty measure
  70357. * @returns a new measure
  70358. */
  70359. static Empty(): Measure;
  70360. }
  70361. }
  70362. declare module BABYLON.GUI {
  70363. /**
  70364. * Interface used to define a control that can receive focus
  70365. */
  70366. export interface IFocusableControl {
  70367. /**
  70368. * Function called when the control receives the focus
  70369. */
  70370. onFocus(): void;
  70371. /**
  70372. * Function called when the control loses the focus
  70373. */
  70374. onBlur(): void;
  70375. /**
  70376. * Function called to let the control handle keyboard events
  70377. * @param evt defines the current keyboard event
  70378. */
  70379. processKeyboard(evt: KeyboardEvent): void;
  70380. /**
  70381. * Function called to get the list of controls that should not steal the focus from this control
  70382. * @returns an array of controls
  70383. */
  70384. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70385. }
  70386. /**
  70387. * Class used to create texture to support 2D GUI elements
  70388. * @see http://doc.babylonjs.com/how_to/gui
  70389. */
  70390. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70391. private _isDirty;
  70392. private _renderObserver;
  70393. private _resizeObserver;
  70394. private _preKeyboardObserver;
  70395. private _pointerMoveObserver;
  70396. private _pointerObserver;
  70397. private _canvasPointerOutObserver;
  70398. private _background;
  70399. /** @hidden */
  70400. _rootContainer: Container;
  70401. /** @hidden */
  70402. _lastPickedControl: Control;
  70403. /** @hidden */
  70404. _lastControlOver: {
  70405. [pointerId: number]: Control;
  70406. };
  70407. /** @hidden */
  70408. _lastControlDown: {
  70409. [pointerId: number]: Control;
  70410. };
  70411. /** @hidden */
  70412. _capturingControl: {
  70413. [pointerId: number]: Control;
  70414. };
  70415. /** @hidden */
  70416. _shouldBlockPointer: boolean;
  70417. /** @hidden */
  70418. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70419. /** @hidden */
  70420. _linkedControls: Control[];
  70421. private _isFullscreen;
  70422. private _fullscreenViewport;
  70423. private _idealWidth;
  70424. private _idealHeight;
  70425. private _useSmallestIdeal;
  70426. private _renderAtIdealSize;
  70427. private _focusedControl;
  70428. private _blockNextFocusCheck;
  70429. private _renderScale;
  70430. private _rootElement;
  70431. private _cursorChanged;
  70432. /** @hidden */
  70433. _numLayoutCalls: number;
  70434. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70435. get numLayoutCalls(): number;
  70436. /** @hidden */
  70437. _numRenderCalls: number;
  70438. /** Gets the number of render calls made the last time the ADT has been rendered */
  70439. get numRenderCalls(): number;
  70440. /**
  70441. * Define type to string to ensure compatibility across browsers
  70442. * Safari doesn't support DataTransfer constructor
  70443. */
  70444. private _clipboardData;
  70445. /**
  70446. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70447. */
  70448. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70449. /**
  70450. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70451. */
  70452. onControlPickedObservable: BABYLON.Observable<Control>;
  70453. /**
  70454. * BABYLON.Observable event triggered before layout is evaluated
  70455. */
  70456. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70457. /**
  70458. * BABYLON.Observable event triggered after the layout was evaluated
  70459. */
  70460. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70461. /**
  70462. * BABYLON.Observable event triggered before the texture is rendered
  70463. */
  70464. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70465. /**
  70466. * BABYLON.Observable event triggered after the texture was rendered
  70467. */
  70468. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70469. /**
  70470. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70471. */
  70472. premulAlpha: boolean;
  70473. /**
  70474. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70475. * Useful when you want more antialiasing
  70476. */
  70477. get renderScale(): number;
  70478. set renderScale(value: number);
  70479. /** Gets or sets the background color */
  70480. get background(): string;
  70481. set background(value: string);
  70482. /**
  70483. * Gets or sets the ideal width used to design controls.
  70484. * The GUI will then rescale everything accordingly
  70485. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70486. */
  70487. get idealWidth(): number;
  70488. set idealWidth(value: number);
  70489. /**
  70490. * Gets or sets the ideal height used to design controls.
  70491. * The GUI will then rescale everything accordingly
  70492. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70493. */
  70494. get idealHeight(): number;
  70495. set idealHeight(value: number);
  70496. /**
  70497. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70498. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70499. */
  70500. get useSmallestIdeal(): boolean;
  70501. set useSmallestIdeal(value: boolean);
  70502. /**
  70503. * Gets or sets a boolean indicating if adaptive scaling must be used
  70504. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70505. */
  70506. get renderAtIdealSize(): boolean;
  70507. set renderAtIdealSize(value: boolean);
  70508. /**
  70509. * Gets the ratio used when in "ideal mode"
  70510. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70511. * */
  70512. get idealRatio(): number;
  70513. /**
  70514. * Gets the underlying layer used to render the texture when in fullscreen mode
  70515. */
  70516. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70517. /**
  70518. * Gets the root container control
  70519. */
  70520. get rootContainer(): Container;
  70521. /**
  70522. * Returns an array containing the root container.
  70523. * This is mostly used to let the Inspector introspects the ADT
  70524. * @returns an array containing the rootContainer
  70525. */
  70526. getChildren(): Array<Container>;
  70527. /**
  70528. * Will return all controls that are inside this texture
  70529. * @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
  70530. * @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
  70531. * @return all child controls
  70532. */
  70533. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70534. /**
  70535. * Gets or sets the current focused control
  70536. */
  70537. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70538. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70539. /**
  70540. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70541. */
  70542. get isForeground(): boolean;
  70543. set isForeground(value: boolean);
  70544. /**
  70545. * Gets or set information about clipboardData
  70546. */
  70547. get clipboardData(): string;
  70548. set clipboardData(value: string);
  70549. /**
  70550. * Creates a new AdvancedDynamicTexture
  70551. * @param name defines the name of the texture
  70552. * @param width defines the width of the texture
  70553. * @param height defines the height of the texture
  70554. * @param scene defines the hosting scene
  70555. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70556. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70557. */
  70558. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70559. /**
  70560. * Get the current class name of the texture useful for serialization or dynamic coding.
  70561. * @returns "AdvancedDynamicTexture"
  70562. */
  70563. getClassName(): string;
  70564. /**
  70565. * Function used to execute a function on all controls
  70566. * @param func defines the function to execute
  70567. * @param container defines the container where controls belong. If null the root container will be used
  70568. */
  70569. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70570. private _useInvalidateRectOptimization;
  70571. /**
  70572. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70573. */
  70574. get useInvalidateRectOptimization(): boolean;
  70575. set useInvalidateRectOptimization(value: boolean);
  70576. private _invalidatedRectangle;
  70577. /**
  70578. * Invalidates a rectangle area on the gui texture
  70579. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70580. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70581. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70582. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70583. */
  70584. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70585. /**
  70586. * Marks the texture as dirty forcing a complete update
  70587. */
  70588. markAsDirty(): void;
  70589. /**
  70590. * Helper function used to create a new style
  70591. * @returns a new style
  70592. * @see http://doc.babylonjs.com/how_to/gui#styles
  70593. */
  70594. createStyle(): Style;
  70595. /**
  70596. * Adds a new control to the root container
  70597. * @param control defines the control to add
  70598. * @returns the current texture
  70599. */
  70600. addControl(control: Control): AdvancedDynamicTexture;
  70601. /**
  70602. * Removes a control from the root container
  70603. * @param control defines the control to remove
  70604. * @returns the current texture
  70605. */
  70606. removeControl(control: Control): AdvancedDynamicTexture;
  70607. /**
  70608. * Release all resources
  70609. */
  70610. dispose(): void;
  70611. private _onResize;
  70612. /** @hidden */
  70613. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70614. /**
  70615. * Get screen coordinates for a vector3
  70616. * @param position defines the position to project
  70617. * @param worldMatrix defines the world matrix to use
  70618. * @returns the projected position
  70619. */
  70620. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70621. private _checkUpdate;
  70622. private _clearMeasure;
  70623. private _render;
  70624. /** @hidden */
  70625. _changeCursor(cursor: string): void;
  70626. /** @hidden */
  70627. _registerLastControlDown(control: Control, pointerId: number): void;
  70628. private _doPicking;
  70629. /** @hidden */
  70630. _cleanControlAfterRemovalFromList(list: {
  70631. [pointerId: number]: Control;
  70632. }, control: Control): void;
  70633. /** @hidden */
  70634. _cleanControlAfterRemoval(control: Control): void;
  70635. /** Attach to all scene events required to support pointer events */
  70636. attach(): void;
  70637. /** @hidden */
  70638. private onClipboardCopy;
  70639. /** @hidden */
  70640. private onClipboardCut;
  70641. /** @hidden */
  70642. private onClipboardPaste;
  70643. /**
  70644. * Register the clipboard Events onto the canvas
  70645. */
  70646. registerClipboardEvents(): void;
  70647. /**
  70648. * Unregister the clipboard Events from the canvas
  70649. */
  70650. unRegisterClipboardEvents(): void;
  70651. /**
  70652. * Connect the texture to a hosting mesh to enable interactions
  70653. * @param mesh defines the mesh to attach to
  70654. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70655. */
  70656. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70657. /**
  70658. * Move the focus to a specific control
  70659. * @param control defines the control which will receive the focus
  70660. */
  70661. moveFocusToControl(control: IFocusableControl): void;
  70662. private _manageFocus;
  70663. private _attachToOnPointerOut;
  70664. /**
  70665. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70666. * @param mesh defines the mesh which will receive the texture
  70667. * @param width defines the texture width (1024 by default)
  70668. * @param height defines the texture height (1024 by default)
  70669. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70670. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70671. * @returns a new AdvancedDynamicTexture
  70672. */
  70673. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70674. /**
  70675. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70676. * In this mode the texture will rely on a layer for its rendering.
  70677. * This allows it to be treated like any other layer.
  70678. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70679. * LayerMask is set through advancedTexture.layer.layerMask
  70680. * @param name defines name for the texture
  70681. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70682. * @param scene defines the hsoting scene
  70683. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70684. * @returns a new AdvancedDynamicTexture
  70685. */
  70686. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70687. }
  70688. }
  70689. declare module BABYLON.GUI {
  70690. /**
  70691. * Root class used for all 2D controls
  70692. * @see http://doc.babylonjs.com/how_to/gui#controls
  70693. */
  70694. export class Control {
  70695. /** defines the name of the control */
  70696. name?: string | undefined;
  70697. /**
  70698. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70699. */
  70700. static AllowAlphaInheritance: boolean;
  70701. private _alpha;
  70702. private _alphaSet;
  70703. private _zIndex;
  70704. /** @hidden */
  70705. _host: AdvancedDynamicTexture;
  70706. /** Gets or sets the control parent */
  70707. parent: BABYLON.Nullable<Container>;
  70708. /** @hidden */
  70709. _currentMeasure: Measure;
  70710. private _fontFamily;
  70711. private _fontStyle;
  70712. private _fontWeight;
  70713. private _fontSize;
  70714. private _font;
  70715. /** @hidden */
  70716. _width: ValueAndUnit;
  70717. /** @hidden */
  70718. _height: ValueAndUnit;
  70719. /** @hidden */
  70720. protected _fontOffset: {
  70721. ascent: number;
  70722. height: number;
  70723. descent: number;
  70724. };
  70725. private _color;
  70726. private _style;
  70727. private _styleObserver;
  70728. /** @hidden */
  70729. protected _horizontalAlignment: number;
  70730. /** @hidden */
  70731. protected _verticalAlignment: number;
  70732. /** @hidden */
  70733. protected _isDirty: boolean;
  70734. /** @hidden */
  70735. protected _wasDirty: boolean;
  70736. /** @hidden */
  70737. _tempParentMeasure: Measure;
  70738. /** @hidden */
  70739. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70740. /** @hidden */
  70741. protected _cachedParentMeasure: Measure;
  70742. private _paddingLeft;
  70743. private _paddingRight;
  70744. private _paddingTop;
  70745. private _paddingBottom;
  70746. /** @hidden */
  70747. _left: ValueAndUnit;
  70748. /** @hidden */
  70749. _top: ValueAndUnit;
  70750. private _scaleX;
  70751. private _scaleY;
  70752. private _rotation;
  70753. private _transformCenterX;
  70754. private _transformCenterY;
  70755. /** @hidden */
  70756. _transformMatrix: Matrix2D;
  70757. /** @hidden */
  70758. protected _invertTransformMatrix: Matrix2D;
  70759. /** @hidden */
  70760. protected _transformedPosition: BABYLON.Vector2;
  70761. private _isMatrixDirty;
  70762. private _cachedOffsetX;
  70763. private _cachedOffsetY;
  70764. private _isVisible;
  70765. private _isHighlighted;
  70766. /** @hidden */
  70767. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70768. private _fontSet;
  70769. private _dummyVector2;
  70770. private _downCount;
  70771. private _enterCount;
  70772. private _doNotRender;
  70773. private _downPointerIds;
  70774. protected _isEnabled: boolean;
  70775. protected _disabledColor: string;
  70776. /** @hidden */
  70777. protected _rebuildLayout: boolean;
  70778. /** @hidden */
  70779. _customData: any;
  70780. /** @hidden */
  70781. _isClipped: boolean;
  70782. /** @hidden */
  70783. _automaticSize: boolean;
  70784. /** @hidden */
  70785. _tag: any;
  70786. /**
  70787. * 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
  70788. */
  70789. uniqueId: number;
  70790. /**
  70791. * Gets or sets an object used to store user defined information for the node
  70792. */
  70793. metadata: any;
  70794. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70795. isHitTestVisible: boolean;
  70796. /** Gets or sets a boolean indicating if the control can block pointer events */
  70797. isPointerBlocker: boolean;
  70798. /** Gets or sets a boolean indicating if the control can be focusable */
  70799. isFocusInvisible: boolean;
  70800. /**
  70801. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70802. * 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
  70803. */
  70804. clipChildren: boolean;
  70805. /**
  70806. * Gets or sets a boolean indicating that control content must be clipped
  70807. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  70808. */
  70809. clipContent: boolean;
  70810. /**
  70811. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70812. */
  70813. useBitmapCache: boolean;
  70814. private _cacheData;
  70815. private _shadowOffsetX;
  70816. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70817. get shadowOffsetX(): number;
  70818. set shadowOffsetX(value: number);
  70819. private _shadowOffsetY;
  70820. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70821. get shadowOffsetY(): number;
  70822. set shadowOffsetY(value: number);
  70823. private _shadowBlur;
  70824. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70825. get shadowBlur(): number;
  70826. set shadowBlur(value: number);
  70827. private _shadowColor;
  70828. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70829. get shadowColor(): string;
  70830. set shadowColor(value: string);
  70831. /** Gets or sets the cursor to use when the control is hovered */
  70832. hoverCursor: string;
  70833. /** @hidden */
  70834. protected _linkOffsetX: ValueAndUnit;
  70835. /** @hidden */
  70836. protected _linkOffsetY: ValueAndUnit;
  70837. /** Gets the control type name */
  70838. get typeName(): string;
  70839. /**
  70840. * Get the current class name of the control.
  70841. * @returns current class name
  70842. */
  70843. getClassName(): string;
  70844. /**
  70845. * An event triggered when the pointer move over the control.
  70846. */
  70847. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70848. /**
  70849. * An event triggered when the pointer move out of the control.
  70850. */
  70851. onPointerOutObservable: BABYLON.Observable<Control>;
  70852. /**
  70853. * An event triggered when the pointer taps the control
  70854. */
  70855. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70856. /**
  70857. * An event triggered when pointer up
  70858. */
  70859. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70860. /**
  70861. * An event triggered when a control is clicked on
  70862. */
  70863. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70864. /**
  70865. * An event triggered when pointer enters the control
  70866. */
  70867. onPointerEnterObservable: BABYLON.Observable<Control>;
  70868. /**
  70869. * An event triggered when the control is marked as dirty
  70870. */
  70871. onDirtyObservable: BABYLON.Observable<Control>;
  70872. /**
  70873. * An event triggered before drawing the control
  70874. */
  70875. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70876. /**
  70877. * An event triggered after the control was drawn
  70878. */
  70879. onAfterDrawObservable: BABYLON.Observable<Control>;
  70880. /**
  70881. * Get the hosting AdvancedDynamicTexture
  70882. */
  70883. get host(): AdvancedDynamicTexture;
  70884. /** Gets or set information about font offsets (used to render and align text) */
  70885. get fontOffset(): {
  70886. ascent: number;
  70887. height: number;
  70888. descent: number;
  70889. };
  70890. set fontOffset(offset: {
  70891. ascent: number;
  70892. height: number;
  70893. descent: number;
  70894. });
  70895. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70896. get alpha(): number;
  70897. set alpha(value: number);
  70898. /**
  70899. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70900. */
  70901. get isHighlighted(): boolean;
  70902. set isHighlighted(value: boolean);
  70903. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70904. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70905. */
  70906. get scaleX(): number;
  70907. set scaleX(value: number);
  70908. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70909. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70910. */
  70911. get scaleY(): number;
  70912. set scaleY(value: number);
  70913. /** Gets or sets the rotation angle (0 by default)
  70914. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70915. */
  70916. get rotation(): number;
  70917. set rotation(value: number);
  70918. /** Gets or sets the transformation center on Y axis (0 by default)
  70919. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70920. */
  70921. get transformCenterY(): number;
  70922. set transformCenterY(value: number);
  70923. /** Gets or sets the transformation center on X axis (0 by default)
  70924. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70925. */
  70926. get transformCenterX(): number;
  70927. set transformCenterX(value: number);
  70928. /**
  70929. * Gets or sets the horizontal alignment
  70930. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70931. */
  70932. get horizontalAlignment(): number;
  70933. set horizontalAlignment(value: number);
  70934. /**
  70935. * Gets or sets the vertical alignment
  70936. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70937. */
  70938. get verticalAlignment(): number;
  70939. set verticalAlignment(value: number);
  70940. /**
  70941. * Gets or sets control width
  70942. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70943. */
  70944. get width(): string | number;
  70945. set width(value: string | number);
  70946. /**
  70947. * Gets or sets the control width in pixel
  70948. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70949. */
  70950. get widthInPixels(): number;
  70951. set widthInPixels(value: number);
  70952. /**
  70953. * Gets or sets control height
  70954. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70955. */
  70956. get height(): string | number;
  70957. set height(value: string | number);
  70958. /**
  70959. * Gets or sets control height in pixel
  70960. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70961. */
  70962. get heightInPixels(): number;
  70963. set heightInPixels(value: number);
  70964. /** Gets or set font family */
  70965. get fontFamily(): string;
  70966. set fontFamily(value: string);
  70967. /** Gets or sets font style */
  70968. get fontStyle(): string;
  70969. set fontStyle(value: string);
  70970. /** Gets or sets font weight */
  70971. get fontWeight(): string;
  70972. set fontWeight(value: string);
  70973. /**
  70974. * Gets or sets style
  70975. * @see http://doc.babylonjs.com/how_to/gui#styles
  70976. */
  70977. get style(): BABYLON.Nullable<Style>;
  70978. set style(value: BABYLON.Nullable<Style>);
  70979. /** @hidden */
  70980. get _isFontSizeInPercentage(): boolean;
  70981. /** Gets or sets font size in pixels */
  70982. get fontSizeInPixels(): number;
  70983. set fontSizeInPixels(value: number);
  70984. /** Gets or sets font size */
  70985. get fontSize(): string | number;
  70986. set fontSize(value: string | number);
  70987. /** Gets or sets foreground color */
  70988. get color(): string;
  70989. set color(value: string);
  70990. /** Gets or sets z index which is used to reorder controls on the z axis */
  70991. get zIndex(): number;
  70992. set zIndex(value: number);
  70993. /** Gets or sets a boolean indicating if the control can be rendered */
  70994. get notRenderable(): boolean;
  70995. set notRenderable(value: boolean);
  70996. /** Gets or sets a boolean indicating if the control is visible */
  70997. get isVisible(): boolean;
  70998. set isVisible(value: boolean);
  70999. /** Gets a boolean indicating that the control needs to update its rendering */
  71000. get isDirty(): boolean;
  71001. /**
  71002. * Gets the current linked mesh (or null if none)
  71003. */
  71004. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71005. /**
  71006. * Gets or sets a value indicating the padding to use on the left of the control
  71007. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71008. */
  71009. get paddingLeft(): string | number;
  71010. set paddingLeft(value: string | number);
  71011. /**
  71012. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71013. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71014. */
  71015. get paddingLeftInPixels(): number;
  71016. set paddingLeftInPixels(value: number);
  71017. /**
  71018. * Gets or sets a value indicating the padding to use on the right of the control
  71019. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71020. */
  71021. get paddingRight(): string | number;
  71022. set paddingRight(value: string | number);
  71023. /**
  71024. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71025. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71026. */
  71027. get paddingRightInPixels(): number;
  71028. set paddingRightInPixels(value: number);
  71029. /**
  71030. * Gets or sets a value indicating the padding to use on the top of the control
  71031. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71032. */
  71033. get paddingTop(): string | number;
  71034. set paddingTop(value: string | number);
  71035. /**
  71036. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71037. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71038. */
  71039. get paddingTopInPixels(): number;
  71040. set paddingTopInPixels(value: number);
  71041. /**
  71042. * Gets or sets a value indicating the padding to use on the bottom of the control
  71043. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71044. */
  71045. get paddingBottom(): string | number;
  71046. set paddingBottom(value: string | number);
  71047. /**
  71048. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71049. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71050. */
  71051. get paddingBottomInPixels(): number;
  71052. set paddingBottomInPixels(value: number);
  71053. /**
  71054. * Gets or sets a value indicating the left coordinate of the control
  71055. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71056. */
  71057. get left(): string | number;
  71058. set left(value: string | number);
  71059. /**
  71060. * Gets or sets a value indicating the left coordinate in pixels of the control
  71061. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71062. */
  71063. get leftInPixels(): number;
  71064. set leftInPixels(value: number);
  71065. /**
  71066. * Gets or sets a value indicating the top coordinate of the control
  71067. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71068. */
  71069. get top(): string | number;
  71070. set top(value: string | number);
  71071. /**
  71072. * Gets or sets a value indicating the top coordinate in pixels of the control
  71073. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71074. */
  71075. get topInPixels(): number;
  71076. set topInPixels(value: number);
  71077. /**
  71078. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71079. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71080. */
  71081. get linkOffsetX(): string | number;
  71082. set linkOffsetX(value: string | number);
  71083. /**
  71084. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71085. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71086. */
  71087. get linkOffsetXInPixels(): number;
  71088. set linkOffsetXInPixels(value: number);
  71089. /**
  71090. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71091. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71092. */
  71093. get linkOffsetY(): string | number;
  71094. set linkOffsetY(value: string | number);
  71095. /**
  71096. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71097. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71098. */
  71099. get linkOffsetYInPixels(): number;
  71100. set linkOffsetYInPixels(value: number);
  71101. /** Gets the center coordinate on X axis */
  71102. get centerX(): number;
  71103. /** Gets the center coordinate on Y axis */
  71104. get centerY(): number;
  71105. /** Gets or sets if control is Enabled*/
  71106. get isEnabled(): boolean;
  71107. set isEnabled(value: boolean);
  71108. /** Gets or sets background color of control if it's disabled*/
  71109. get disabledColor(): string;
  71110. set disabledColor(value: string);
  71111. /**
  71112. * Creates a new control
  71113. * @param name defines the name of the control
  71114. */
  71115. constructor(
  71116. /** defines the name of the control */
  71117. name?: string | undefined);
  71118. /** @hidden */
  71119. protected _getTypeName(): string;
  71120. /**
  71121. * Gets the first ascendant in the hierarchy of the given type
  71122. * @param className defines the required type
  71123. * @returns the ascendant or null if not found
  71124. */
  71125. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71126. /** @hidden */
  71127. _resetFontCache(): void;
  71128. /**
  71129. * Determines if a container is an ascendant of the current control
  71130. * @param container defines the container to look for
  71131. * @returns true if the container is one of the ascendant of the control
  71132. */
  71133. isAscendant(container: Control): boolean;
  71134. /**
  71135. * Gets coordinates in local control space
  71136. * @param globalCoordinates defines the coordinates to transform
  71137. * @returns the new coordinates in local space
  71138. */
  71139. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71140. /**
  71141. * Gets coordinates in local control space
  71142. * @param globalCoordinates defines the coordinates to transform
  71143. * @param result defines the target vector2 where to store the result
  71144. * @returns the current control
  71145. */
  71146. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71147. /**
  71148. * Gets coordinates in parent local control space
  71149. * @param globalCoordinates defines the coordinates to transform
  71150. * @returns the new coordinates in parent local space
  71151. */
  71152. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71153. /**
  71154. * Move the current control to a vector3 position projected onto the screen.
  71155. * @param position defines the target position
  71156. * @param scene defines the hosting scene
  71157. */
  71158. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71159. /**
  71160. * Will store all controls that have this control as ascendant in a given array
  71161. * @param results defines the array where to store the descendants
  71162. * @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
  71163. * @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
  71164. */
  71165. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71166. /**
  71167. * Will return all controls that have this control as ascendant
  71168. * @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
  71169. * @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
  71170. * @return all child controls
  71171. */
  71172. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71173. /**
  71174. * Link current control with a target mesh
  71175. * @param mesh defines the mesh to link with
  71176. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71177. */
  71178. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71179. /** @hidden */
  71180. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71181. /** @hidden */
  71182. _offsetLeft(offset: number): void;
  71183. /** @hidden */
  71184. _offsetTop(offset: number): void;
  71185. /** @hidden */
  71186. _markMatrixAsDirty(): void;
  71187. /** @hidden */
  71188. _flagDescendantsAsMatrixDirty(): void;
  71189. /** @hidden */
  71190. _intersectsRect(rect: Measure): boolean;
  71191. /** @hidden */
  71192. protected invalidateRect(): void;
  71193. /** @hidden */
  71194. _markAsDirty(force?: boolean): void;
  71195. /** @hidden */
  71196. _markAllAsDirty(): void;
  71197. /** @hidden */
  71198. _link(host: AdvancedDynamicTexture): void;
  71199. /** @hidden */
  71200. protected _transform(context?: CanvasRenderingContext2D): void;
  71201. /** @hidden */
  71202. _renderHighlight(context: CanvasRenderingContext2D): void;
  71203. /** @hidden */
  71204. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71205. /** @hidden */
  71206. protected _applyStates(context: CanvasRenderingContext2D): void;
  71207. /** @hidden */
  71208. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71209. /** @hidden */
  71210. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71211. protected _evaluateClippingState(parentMeasure: Measure): void;
  71212. /** @hidden */
  71213. _measure(): void;
  71214. /** @hidden */
  71215. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71216. /** @hidden */
  71217. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71218. /** @hidden */
  71219. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71220. /** @hidden */
  71221. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71222. private static _ClipMeasure;
  71223. private _tmpMeasureA;
  71224. private _clip;
  71225. /** @hidden */
  71226. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71227. /** @hidden */
  71228. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71229. /**
  71230. * Tests if a given coordinates belong to the current control
  71231. * @param x defines x coordinate to test
  71232. * @param y defines y coordinate to test
  71233. * @returns true if the coordinates are inside the control
  71234. */
  71235. contains(x: number, y: number): boolean;
  71236. /** @hidden */
  71237. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71238. /** @hidden */
  71239. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71240. /** @hidden */
  71241. _onPointerEnter(target: Control): boolean;
  71242. /** @hidden */
  71243. _onPointerOut(target: Control, force?: boolean): void;
  71244. /** @hidden */
  71245. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71246. /** @hidden */
  71247. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71248. /** @hidden */
  71249. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71250. /** @hidden */
  71251. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  71252. private _prepareFont;
  71253. /** Releases associated resources */
  71254. dispose(): void;
  71255. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71256. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71257. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71258. private static _VERTICAL_ALIGNMENT_TOP;
  71259. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71260. private static _VERTICAL_ALIGNMENT_CENTER;
  71261. /** HORIZONTAL_ALIGNMENT_LEFT */
  71262. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71263. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71264. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71265. /** HORIZONTAL_ALIGNMENT_CENTER */
  71266. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71267. /** VERTICAL_ALIGNMENT_TOP */
  71268. static get VERTICAL_ALIGNMENT_TOP(): number;
  71269. /** VERTICAL_ALIGNMENT_BOTTOM */
  71270. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71271. /** VERTICAL_ALIGNMENT_CENTER */
  71272. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71273. private static _FontHeightSizes;
  71274. /** @hidden */
  71275. static _GetFontOffset(font: string): {
  71276. ascent: number;
  71277. height: number;
  71278. descent: number;
  71279. };
  71280. /**
  71281. * Creates a stack panel that can be used to render headers
  71282. * @param control defines the control to associate with the header
  71283. * @param text defines the text of the header
  71284. * @param size defines the size of the header
  71285. * @param options defines options used to configure the header
  71286. * @returns a new StackPanel
  71287. * @ignore
  71288. * @hidden
  71289. */
  71290. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71291. isHorizontal: boolean;
  71292. controlFirst: boolean;
  71293. }) => any;
  71294. /** @hidden */
  71295. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71296. }
  71297. }
  71298. declare module BABYLON.GUI {
  71299. /**
  71300. * Root class for 2D containers
  71301. * @see http://doc.babylonjs.com/how_to/gui#containers
  71302. */
  71303. export class Container extends Control {
  71304. name?: string | undefined;
  71305. /** @hidden */
  71306. _children: Control[];
  71307. /** @hidden */
  71308. protected _measureForChildren: Measure;
  71309. /** @hidden */
  71310. protected _background: string;
  71311. /** @hidden */
  71312. protected _adaptWidthToChildren: boolean;
  71313. /** @hidden */
  71314. protected _adaptHeightToChildren: boolean;
  71315. /**
  71316. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71317. */
  71318. logLayoutCycleErrors: boolean;
  71319. /**
  71320. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71321. */
  71322. maxLayoutCycle: number;
  71323. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71324. get adaptHeightToChildren(): boolean;
  71325. set adaptHeightToChildren(value: boolean);
  71326. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71327. get adaptWidthToChildren(): boolean;
  71328. set adaptWidthToChildren(value: boolean);
  71329. /** Gets or sets background color */
  71330. get background(): string;
  71331. set background(value: string);
  71332. /** Gets the list of children */
  71333. get children(): Control[];
  71334. /**
  71335. * Creates a new Container
  71336. * @param name defines the name of the container
  71337. */
  71338. constructor(name?: string | undefined);
  71339. protected _getTypeName(): string;
  71340. _flagDescendantsAsMatrixDirty(): void;
  71341. /**
  71342. * Gets a child using its name
  71343. * @param name defines the child name to look for
  71344. * @returns the child control if found
  71345. */
  71346. getChildByName(name: string): BABYLON.Nullable<Control>;
  71347. /**
  71348. * Gets a child using its type and its name
  71349. * @param name defines the child name to look for
  71350. * @param type defines the child type to look for
  71351. * @returns the child control if found
  71352. */
  71353. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71354. /**
  71355. * Search for a specific control in children
  71356. * @param control defines the control to look for
  71357. * @returns true if the control is in child list
  71358. */
  71359. containsControl(control: Control): boolean;
  71360. /**
  71361. * Adds a new control to the current container
  71362. * @param control defines the control to add
  71363. * @returns the current container
  71364. */
  71365. addControl(control: BABYLON.Nullable<Control>): Container;
  71366. /**
  71367. * Removes all controls from the current container
  71368. * @returns the current container
  71369. */
  71370. clearControls(): Container;
  71371. /**
  71372. * Removes a control from the current container
  71373. * @param control defines the control to remove
  71374. * @returns the current container
  71375. */
  71376. removeControl(control: Control): Container;
  71377. /** @hidden */
  71378. _reOrderControl(control: Control): void;
  71379. /** @hidden */
  71380. _offsetLeft(offset: number): void;
  71381. /** @hidden */
  71382. _offsetTop(offset: number): void;
  71383. /** @hidden */
  71384. _markAllAsDirty(): void;
  71385. /** @hidden */
  71386. protected _localDraw(context: CanvasRenderingContext2D): void;
  71387. /** @hidden */
  71388. _link(host: AdvancedDynamicTexture): void;
  71389. /** @hidden */
  71390. protected _beforeLayout(): void;
  71391. /** @hidden */
  71392. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71393. /** @hidden */
  71394. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71395. protected _postMeasure(): void;
  71396. /** @hidden */
  71397. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71398. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71399. /** @hidden */
  71400. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71401. /** @hidden */
  71402. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71403. /** Releases associated resources */
  71404. dispose(): void;
  71405. }
  71406. }
  71407. declare module BABYLON.GUI {
  71408. /** Class used to create rectangle container */
  71409. export class Rectangle extends Container {
  71410. name?: string | undefined;
  71411. private _thickness;
  71412. private _cornerRadius;
  71413. /** Gets or sets border thickness */
  71414. get thickness(): number;
  71415. set thickness(value: number);
  71416. /** Gets or sets the corner radius angle */
  71417. get cornerRadius(): number;
  71418. set cornerRadius(value: number);
  71419. /**
  71420. * Creates a new Rectangle
  71421. * @param name defines the control name
  71422. */
  71423. constructor(name?: string | undefined);
  71424. protected _getTypeName(): string;
  71425. protected _localDraw(context: CanvasRenderingContext2D): void;
  71426. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71427. private _drawRoundedRect;
  71428. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71429. }
  71430. }
  71431. declare module BABYLON.GUI {
  71432. /**
  71433. * Enum that determines the text-wrapping mode to use.
  71434. */
  71435. export enum TextWrapping {
  71436. /**
  71437. * Clip the text when it's larger than Control.width; this is the default mode.
  71438. */
  71439. Clip = 0,
  71440. /**
  71441. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71442. */
  71443. WordWrap = 1,
  71444. /**
  71445. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71446. */
  71447. Ellipsis = 2
  71448. }
  71449. /**
  71450. * Class used to create text block control
  71451. */
  71452. export class TextBlock extends Control {
  71453. /**
  71454. * Defines the name of the control
  71455. */
  71456. name?: string | undefined;
  71457. private _text;
  71458. private _textWrapping;
  71459. private _textHorizontalAlignment;
  71460. private _textVerticalAlignment;
  71461. private _lines;
  71462. private _resizeToFit;
  71463. private _lineSpacing;
  71464. private _outlineWidth;
  71465. private _outlineColor;
  71466. /**
  71467. * An event triggered after the text is changed
  71468. */
  71469. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71470. /**
  71471. * An event triggered after the text was broken up into lines
  71472. */
  71473. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71474. /**
  71475. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71476. */
  71477. get lines(): any[];
  71478. /**
  71479. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71480. */
  71481. get resizeToFit(): boolean;
  71482. /**
  71483. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71484. */
  71485. set resizeToFit(value: boolean);
  71486. /**
  71487. * Gets or sets a boolean indicating if text must be wrapped
  71488. */
  71489. get textWrapping(): TextWrapping | boolean;
  71490. /**
  71491. * Gets or sets a boolean indicating if text must be wrapped
  71492. */
  71493. set textWrapping(value: TextWrapping | boolean);
  71494. /**
  71495. * Gets or sets text to display
  71496. */
  71497. get text(): string;
  71498. /**
  71499. * Gets or sets text to display
  71500. */
  71501. set text(value: string);
  71502. /**
  71503. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71504. */
  71505. get textHorizontalAlignment(): number;
  71506. /**
  71507. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71508. */
  71509. set textHorizontalAlignment(value: number);
  71510. /**
  71511. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71512. */
  71513. get textVerticalAlignment(): number;
  71514. /**
  71515. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71516. */
  71517. set textVerticalAlignment(value: number);
  71518. /**
  71519. * Gets or sets line spacing value
  71520. */
  71521. set lineSpacing(value: string | number);
  71522. /**
  71523. * Gets or sets line spacing value
  71524. */
  71525. get lineSpacing(): string | number;
  71526. /**
  71527. * Gets or sets outlineWidth of the text to display
  71528. */
  71529. get outlineWidth(): number;
  71530. /**
  71531. * Gets or sets outlineWidth of the text to display
  71532. */
  71533. set outlineWidth(value: number);
  71534. /**
  71535. * Gets or sets outlineColor of the text to display
  71536. */
  71537. get outlineColor(): string;
  71538. /**
  71539. * Gets or sets outlineColor of the text to display
  71540. */
  71541. set outlineColor(value: string);
  71542. /**
  71543. * Creates a new TextBlock object
  71544. * @param name defines the name of the control
  71545. * @param text defines the text to display (emptry string by default)
  71546. */
  71547. constructor(
  71548. /**
  71549. * Defines the name of the control
  71550. */
  71551. name?: string | undefined, text?: string);
  71552. protected _getTypeName(): string;
  71553. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71554. private _drawText;
  71555. /** @hidden */
  71556. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71557. protected _applyStates(context: CanvasRenderingContext2D): void;
  71558. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71559. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71560. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71561. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71562. protected _renderLines(context: CanvasRenderingContext2D): void;
  71563. /**
  71564. * Given a width constraint applied on the text block, find the expected height
  71565. * @returns expected height
  71566. */
  71567. computeExpectedHeight(): number;
  71568. dispose(): void;
  71569. }
  71570. }
  71571. declare module BABYLON.GUI {
  71572. /**
  71573. * Class used to create 2D images
  71574. */
  71575. export class Image extends Control {
  71576. name?: string | undefined;
  71577. private _workingCanvas;
  71578. private _domImage;
  71579. private _imageWidth;
  71580. private _imageHeight;
  71581. private _loaded;
  71582. private _stretch;
  71583. private _source;
  71584. private _autoScale;
  71585. private _sourceLeft;
  71586. private _sourceTop;
  71587. private _sourceWidth;
  71588. private _sourceHeight;
  71589. private _svgAttributesComputationCompleted;
  71590. private _isSVG;
  71591. private _cellWidth;
  71592. private _cellHeight;
  71593. private _cellId;
  71594. private _populateNinePatchSlicesFromImage;
  71595. private _sliceLeft;
  71596. private _sliceRight;
  71597. private _sliceTop;
  71598. private _sliceBottom;
  71599. private _detectPointerOnOpaqueOnly;
  71600. /**
  71601. * BABYLON.Observable notified when the content is loaded
  71602. */
  71603. onImageLoadedObservable: BABYLON.Observable<Image>;
  71604. /**
  71605. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71606. */
  71607. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71608. /**
  71609. * Gets a boolean indicating that the content is loaded
  71610. */
  71611. get isLoaded(): boolean;
  71612. /**
  71613. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71614. */
  71615. get populateNinePatchSlicesFromImage(): boolean;
  71616. set populateNinePatchSlicesFromImage(value: boolean);
  71617. /**
  71618. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71619. * Beware using this as this will comsume more memory as the image has to be stored twice
  71620. */
  71621. get detectPointerOnOpaqueOnly(): boolean;
  71622. set detectPointerOnOpaqueOnly(value: boolean);
  71623. /**
  71624. * Gets or sets the left value for slicing (9-patch)
  71625. */
  71626. get sliceLeft(): number;
  71627. set sliceLeft(value: number);
  71628. /**
  71629. * Gets or sets the right value for slicing (9-patch)
  71630. */
  71631. get sliceRight(): number;
  71632. set sliceRight(value: number);
  71633. /**
  71634. * Gets or sets the top value for slicing (9-patch)
  71635. */
  71636. get sliceTop(): number;
  71637. set sliceTop(value: number);
  71638. /**
  71639. * Gets or sets the bottom value for slicing (9-patch)
  71640. */
  71641. get sliceBottom(): number;
  71642. set sliceBottom(value: number);
  71643. /**
  71644. * Gets or sets the left coordinate in the source image
  71645. */
  71646. get sourceLeft(): number;
  71647. set sourceLeft(value: number);
  71648. /**
  71649. * Gets or sets the top coordinate in the source image
  71650. */
  71651. get sourceTop(): number;
  71652. set sourceTop(value: number);
  71653. /**
  71654. * Gets or sets the width to capture in the source image
  71655. */
  71656. get sourceWidth(): number;
  71657. set sourceWidth(value: number);
  71658. /**
  71659. * Gets or sets the height to capture in the source image
  71660. */
  71661. get sourceHeight(): number;
  71662. set sourceHeight(value: number);
  71663. /** Indicates if the format of the image is SVG */
  71664. get isSVG(): boolean;
  71665. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71666. get svgAttributesComputationCompleted(): boolean;
  71667. /**
  71668. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71669. * @see http://doc.babylonjs.com/how_to/gui#image
  71670. */
  71671. get autoScale(): boolean;
  71672. set autoScale(value: boolean);
  71673. /** Gets or sets the streching mode used by the image */
  71674. get stretch(): number;
  71675. set stretch(value: number);
  71676. /** @hidden */
  71677. _rotate90(n: number, preserveProperties?: boolean): Image;
  71678. private _handleRotationForSVGImage;
  71679. private _rotate90SourceProperties;
  71680. /**
  71681. * Gets or sets the internal DOM image used to render the control
  71682. */
  71683. set domImage(value: HTMLImageElement);
  71684. get domImage(): HTMLImageElement;
  71685. private _onImageLoaded;
  71686. private _extractNinePatchSliceDataFromImage;
  71687. /**
  71688. * Gets or sets image source url
  71689. */
  71690. set source(value: BABYLON.Nullable<string>);
  71691. /**
  71692. * Checks for svg document with icon id present
  71693. */
  71694. private _svgCheck;
  71695. /**
  71696. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71697. * given external svg file and icon id
  71698. */
  71699. private _getSVGAttribs;
  71700. /**
  71701. * Gets or sets the cell width to use when animation sheet is enabled
  71702. * @see http://doc.babylonjs.com/how_to/gui#image
  71703. */
  71704. get cellWidth(): number;
  71705. set cellWidth(value: number);
  71706. /**
  71707. * Gets or sets the cell height to use when animation sheet is enabled
  71708. * @see http://doc.babylonjs.com/how_to/gui#image
  71709. */
  71710. get cellHeight(): number;
  71711. set cellHeight(value: number);
  71712. /**
  71713. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71714. * @see http://doc.babylonjs.com/how_to/gui#image
  71715. */
  71716. get cellId(): number;
  71717. set cellId(value: number);
  71718. /**
  71719. * Creates a new Image
  71720. * @param name defines the control name
  71721. * @param url defines the image url
  71722. */
  71723. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71724. /**
  71725. * Tests if a given coordinates belong to the current control
  71726. * @param x defines x coordinate to test
  71727. * @param y defines y coordinate to test
  71728. * @returns true if the coordinates are inside the control
  71729. */
  71730. contains(x: number, y: number): boolean;
  71731. protected _getTypeName(): string;
  71732. /** Force the control to synchronize with its content */
  71733. synchronizeSizeWithContent(): void;
  71734. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71735. private _prepareWorkingCanvasForOpaqueDetection;
  71736. private _drawImage;
  71737. _draw(context: CanvasRenderingContext2D): void;
  71738. private _renderCornerPatch;
  71739. private _renderNinePatch;
  71740. dispose(): void;
  71741. /** STRETCH_NONE */
  71742. static readonly STRETCH_NONE: number;
  71743. /** STRETCH_FILL */
  71744. static readonly STRETCH_FILL: number;
  71745. /** STRETCH_UNIFORM */
  71746. static readonly STRETCH_UNIFORM: number;
  71747. /** STRETCH_EXTEND */
  71748. static readonly STRETCH_EXTEND: number;
  71749. /** NINE_PATCH */
  71750. static readonly STRETCH_NINE_PATCH: number;
  71751. }
  71752. }
  71753. declare module BABYLON.GUI {
  71754. /**
  71755. * Class used to create 2D buttons
  71756. */
  71757. export class Button extends Rectangle {
  71758. name?: string | undefined;
  71759. /**
  71760. * Function called to generate a pointer enter animation
  71761. */
  71762. pointerEnterAnimation: () => void;
  71763. /**
  71764. * Function called to generate a pointer out animation
  71765. */
  71766. pointerOutAnimation: () => void;
  71767. /**
  71768. * Function called to generate a pointer down animation
  71769. */
  71770. pointerDownAnimation: () => void;
  71771. /**
  71772. * Function called to generate a pointer up animation
  71773. */
  71774. pointerUpAnimation: () => void;
  71775. /**
  71776. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71777. */
  71778. delegatePickingToChildren: boolean;
  71779. private _image;
  71780. /**
  71781. * Returns the image part of the button (if any)
  71782. */
  71783. get image(): BABYLON.Nullable<Image>;
  71784. private _textBlock;
  71785. /**
  71786. * Returns the image part of the button (if any)
  71787. */
  71788. get textBlock(): BABYLON.Nullable<TextBlock>;
  71789. /**
  71790. * Creates a new Button
  71791. * @param name defines the name of the button
  71792. */
  71793. constructor(name?: string | undefined);
  71794. protected _getTypeName(): string;
  71795. /** @hidden */
  71796. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71797. /** @hidden */
  71798. _onPointerEnter(target: Control): boolean;
  71799. /** @hidden */
  71800. _onPointerOut(target: Control, force?: boolean): void;
  71801. /** @hidden */
  71802. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71803. /** @hidden */
  71804. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71805. /**
  71806. * Creates a new button made with an image and a text
  71807. * @param name defines the name of the button
  71808. * @param text defines the text of the button
  71809. * @param imageUrl defines the url of the image
  71810. * @returns a new Button
  71811. */
  71812. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71813. /**
  71814. * Creates a new button made with an image
  71815. * @param name defines the name of the button
  71816. * @param imageUrl defines the url of the image
  71817. * @returns a new Button
  71818. */
  71819. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71820. /**
  71821. * Creates a new button made with a text
  71822. * @param name defines the name of the button
  71823. * @param text defines the text of the button
  71824. * @returns a new Button
  71825. */
  71826. static CreateSimpleButton(name: string, text: string): Button;
  71827. /**
  71828. * Creates a new button made with an image and a centered text
  71829. * @param name defines the name of the button
  71830. * @param text defines the text of the button
  71831. * @param imageUrl defines the url of the image
  71832. * @returns a new Button
  71833. */
  71834. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71835. }
  71836. }
  71837. declare module BABYLON.GUI {
  71838. /**
  71839. * Class used to create a 2D stack panel container
  71840. */
  71841. export class StackPanel extends Container {
  71842. name?: string | undefined;
  71843. private _isVertical;
  71844. private _manualWidth;
  71845. private _manualHeight;
  71846. private _doNotTrackManualChanges;
  71847. /**
  71848. * Gets or sets a boolean indicating that layou warnings should be ignored
  71849. */
  71850. ignoreLayoutWarnings: boolean;
  71851. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71852. get isVertical(): boolean;
  71853. set isVertical(value: boolean);
  71854. /**
  71855. * Gets or sets panel width.
  71856. * This value should not be set when in horizontal mode as it will be computed automatically
  71857. */
  71858. set width(value: string | number);
  71859. get width(): string | number;
  71860. /**
  71861. * Gets or sets panel height.
  71862. * This value should not be set when in vertical mode as it will be computed automatically
  71863. */
  71864. set height(value: string | number);
  71865. get height(): string | number;
  71866. /**
  71867. * Creates a new StackPanel
  71868. * @param name defines control name
  71869. */
  71870. constructor(name?: string | undefined);
  71871. protected _getTypeName(): string;
  71872. /** @hidden */
  71873. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71874. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71875. protected _postMeasure(): void;
  71876. }
  71877. }
  71878. declare module BABYLON.GUI {
  71879. /**
  71880. * Class used to represent a 2D checkbox
  71881. */
  71882. export class Checkbox extends Control {
  71883. name?: string | undefined;
  71884. private _isChecked;
  71885. private _background;
  71886. private _checkSizeRatio;
  71887. private _thickness;
  71888. /** Gets or sets border thickness */
  71889. get thickness(): number;
  71890. set thickness(value: number);
  71891. /**
  71892. * BABYLON.Observable raised when isChecked property changes
  71893. */
  71894. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71895. /** Gets or sets a value indicating the ratio between overall size and check size */
  71896. get checkSizeRatio(): number;
  71897. set checkSizeRatio(value: number);
  71898. /** Gets or sets background color */
  71899. get background(): string;
  71900. set background(value: string);
  71901. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71902. get isChecked(): boolean;
  71903. set isChecked(value: boolean);
  71904. /**
  71905. * Creates a new CheckBox
  71906. * @param name defines the control name
  71907. */
  71908. constructor(name?: string | undefined);
  71909. protected _getTypeName(): string;
  71910. /** @hidden */
  71911. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71912. /** @hidden */
  71913. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71914. /**
  71915. * Utility function to easily create a checkbox with a header
  71916. * @param title defines the label to use for the header
  71917. * @param onValueChanged defines the callback to call when value changes
  71918. * @returns a StackPanel containing the checkbox and a textBlock
  71919. */
  71920. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71921. }
  71922. }
  71923. declare module BABYLON.GUI {
  71924. /**
  71925. * Class used to store key control properties
  71926. */
  71927. export class KeyPropertySet {
  71928. /** Width */
  71929. width?: string;
  71930. /** Height */
  71931. height?: string;
  71932. /** Left padding */
  71933. paddingLeft?: string;
  71934. /** Right padding */
  71935. paddingRight?: string;
  71936. /** Top padding */
  71937. paddingTop?: string;
  71938. /** Bottom padding */
  71939. paddingBottom?: string;
  71940. /** Foreground color */
  71941. color?: string;
  71942. /** Background color */
  71943. background?: string;
  71944. }
  71945. /**
  71946. * Class used to create virtual keyboard
  71947. */
  71948. export class VirtualKeyboard extends StackPanel {
  71949. /** BABYLON.Observable raised when a key is pressed */
  71950. onKeyPressObservable: BABYLON.Observable<string>;
  71951. /** Gets or sets default key button width */
  71952. defaultButtonWidth: string;
  71953. /** Gets or sets default key button height */
  71954. defaultButtonHeight: string;
  71955. /** Gets or sets default key button left padding */
  71956. defaultButtonPaddingLeft: string;
  71957. /** Gets or sets default key button right padding */
  71958. defaultButtonPaddingRight: string;
  71959. /** Gets or sets default key button top padding */
  71960. defaultButtonPaddingTop: string;
  71961. /** Gets or sets default key button bottom padding */
  71962. defaultButtonPaddingBottom: string;
  71963. /** Gets or sets default key button foreground color */
  71964. defaultButtonColor: string;
  71965. /** Gets or sets default key button background color */
  71966. defaultButtonBackground: string;
  71967. /** Gets or sets shift button foreground color */
  71968. shiftButtonColor: string;
  71969. /** Gets or sets shift button thickness*/
  71970. selectedShiftThickness: number;
  71971. /** Gets shift key state */
  71972. shiftState: number;
  71973. protected _getTypeName(): string;
  71974. private _createKey;
  71975. /**
  71976. * Adds a new row of keys
  71977. * @param keys defines the list of keys to add
  71978. * @param propertySets defines the associated property sets
  71979. */
  71980. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71981. /**
  71982. * Set the shift key to a specific state
  71983. * @param shiftState defines the new shift state
  71984. */
  71985. applyShiftState(shiftState: number): void;
  71986. private _currentlyConnectedInputText;
  71987. private _connectedInputTexts;
  71988. private _onKeyPressObserver;
  71989. /** Gets the input text control currently attached to the keyboard */
  71990. get connectedInputText(): BABYLON.Nullable<InputText>;
  71991. /**
  71992. * Connects the keyboard with an input text control
  71993. *
  71994. * @param input defines the target control
  71995. */
  71996. connect(input: InputText): void;
  71997. /**
  71998. * Disconnects the keyboard from connected InputText controls
  71999. *
  72000. * @param input optionally defines a target control, otherwise all are disconnected
  72001. */
  72002. disconnect(input?: InputText): void;
  72003. private _removeConnectedInputObservables;
  72004. /**
  72005. * Release all resources
  72006. */
  72007. dispose(): void;
  72008. /**
  72009. * Creates a new keyboard using a default layout
  72010. *
  72011. * @param name defines control name
  72012. * @returns a new VirtualKeyboard
  72013. */
  72014. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72015. }
  72016. }
  72017. declare module BABYLON.GUI {
  72018. /**
  72019. * Class used to create input text control
  72020. */
  72021. export class InputText extends Control implements IFocusableControl {
  72022. name?: string | undefined;
  72023. private _text;
  72024. private _placeholderText;
  72025. private _background;
  72026. private _focusedBackground;
  72027. private _focusedColor;
  72028. private _placeholderColor;
  72029. private _thickness;
  72030. private _margin;
  72031. private _autoStretchWidth;
  72032. private _maxWidth;
  72033. private _isFocused;
  72034. private _blinkTimeout;
  72035. private _blinkIsEven;
  72036. private _cursorOffset;
  72037. private _scrollLeft;
  72038. private _textWidth;
  72039. private _clickedCoordinate;
  72040. private _deadKey;
  72041. private _addKey;
  72042. private _currentKey;
  72043. private _isTextHighlightOn;
  72044. private _textHighlightColor;
  72045. private _highligherOpacity;
  72046. private _highlightedText;
  72047. private _startHighlightIndex;
  72048. private _endHighlightIndex;
  72049. private _cursorIndex;
  72050. private _onFocusSelectAll;
  72051. private _isPointerDown;
  72052. private _onClipboardObserver;
  72053. private _onPointerDblTapObserver;
  72054. /** @hidden */
  72055. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72056. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72057. promptMessage: string;
  72058. /** Force disable prompt on mobile device */
  72059. disableMobilePrompt: boolean;
  72060. /** BABYLON.Observable raised when the text changes */
  72061. onTextChangedObservable: BABYLON.Observable<InputText>;
  72062. /** BABYLON.Observable raised just before an entered character is to be added */
  72063. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72064. /** BABYLON.Observable raised when the control gets the focus */
  72065. onFocusObservable: BABYLON.Observable<InputText>;
  72066. /** BABYLON.Observable raised when the control loses the focus */
  72067. onBlurObservable: BABYLON.Observable<InputText>;
  72068. /**Observable raised when the text is highlighted */
  72069. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72070. /**Observable raised when copy event is triggered */
  72071. onTextCopyObservable: BABYLON.Observable<InputText>;
  72072. /** BABYLON.Observable raised when cut event is triggered */
  72073. onTextCutObservable: BABYLON.Observable<InputText>;
  72074. /** BABYLON.Observable raised when paste event is triggered */
  72075. onTextPasteObservable: BABYLON.Observable<InputText>;
  72076. /** BABYLON.Observable raised when a key event was processed */
  72077. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72078. /** Gets or sets the maximum width allowed by the control */
  72079. get maxWidth(): string | number;
  72080. /** Gets the maximum width allowed by the control in pixels */
  72081. get maxWidthInPixels(): number;
  72082. set maxWidth(value: string | number);
  72083. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72084. get highligherOpacity(): number;
  72085. set highligherOpacity(value: number);
  72086. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72087. get onFocusSelectAll(): boolean;
  72088. set onFocusSelectAll(value: boolean);
  72089. /** Gets or sets the text hightlight color */
  72090. get textHighlightColor(): string;
  72091. set textHighlightColor(value: string);
  72092. /** Gets or sets control margin */
  72093. get margin(): string;
  72094. /** Gets control margin in pixels */
  72095. get marginInPixels(): number;
  72096. set margin(value: string);
  72097. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72098. get autoStretchWidth(): boolean;
  72099. set autoStretchWidth(value: boolean);
  72100. /** Gets or sets border thickness */
  72101. get thickness(): number;
  72102. set thickness(value: number);
  72103. /** Gets or sets the background color when focused */
  72104. get focusedBackground(): string;
  72105. set focusedBackground(value: string);
  72106. /** Gets or sets the background color when focused */
  72107. get focusedColor(): string;
  72108. set focusedColor(value: string);
  72109. /** Gets or sets the background color */
  72110. get background(): string;
  72111. set background(value: string);
  72112. /** Gets or sets the placeholder color */
  72113. get placeholderColor(): string;
  72114. set placeholderColor(value: string);
  72115. /** Gets or sets the text displayed when the control is empty */
  72116. get placeholderText(): string;
  72117. set placeholderText(value: string);
  72118. /** Gets or sets the dead key flag */
  72119. get deadKey(): boolean;
  72120. set deadKey(flag: boolean);
  72121. /** Gets or sets the highlight text */
  72122. get highlightedText(): string;
  72123. set highlightedText(text: string);
  72124. /** Gets or sets if the current key should be added */
  72125. get addKey(): boolean;
  72126. set addKey(flag: boolean);
  72127. /** Gets or sets the value of the current key being entered */
  72128. get currentKey(): string;
  72129. set currentKey(key: string);
  72130. /** Gets or sets the text displayed in the control */
  72131. get text(): string;
  72132. set text(value: string);
  72133. /** Gets or sets control width */
  72134. get width(): string | number;
  72135. set width(value: string | number);
  72136. /**
  72137. * Creates a new InputText
  72138. * @param name defines the control name
  72139. * @param text defines the text of the control
  72140. */
  72141. constructor(name?: string | undefined, text?: string);
  72142. /** @hidden */
  72143. onBlur(): void;
  72144. /** @hidden */
  72145. onFocus(): void;
  72146. protected _getTypeName(): string;
  72147. /**
  72148. * Function called to get the list of controls that should not steal the focus from this control
  72149. * @returns an array of controls
  72150. */
  72151. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72152. /** @hidden */
  72153. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72154. /** @hidden */
  72155. private _updateValueFromCursorIndex;
  72156. /** @hidden */
  72157. private _processDblClick;
  72158. /** @hidden */
  72159. private _selectAllText;
  72160. /**
  72161. * Handles the keyboard event
  72162. * @param evt Defines the KeyboardEvent
  72163. */
  72164. processKeyboard(evt: KeyboardEvent): void;
  72165. /** @hidden */
  72166. private _onCopyText;
  72167. /** @hidden */
  72168. private _onCutText;
  72169. /** @hidden */
  72170. private _onPasteText;
  72171. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72172. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72173. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72174. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72175. protected _beforeRenderText(text: string): string;
  72176. dispose(): void;
  72177. }
  72178. }
  72179. declare module BABYLON.GUI {
  72180. /**
  72181. * Class used to create a 2D grid container
  72182. */
  72183. export class Grid extends Container {
  72184. name?: string | undefined;
  72185. private _rowDefinitions;
  72186. private _columnDefinitions;
  72187. private _cells;
  72188. private _childControls;
  72189. /**
  72190. * Gets the number of columns
  72191. */
  72192. get columnCount(): number;
  72193. /**
  72194. * Gets the number of rows
  72195. */
  72196. get rowCount(): number;
  72197. /** Gets the list of children */
  72198. get children(): Control[];
  72199. /** Gets the list of cells (e.g. the containers) */
  72200. get cells(): {
  72201. [key: string]: Container;
  72202. };
  72203. /**
  72204. * Gets the definition of a specific row
  72205. * @param index defines the index of the row
  72206. * @returns the row definition
  72207. */
  72208. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72209. /**
  72210. * Gets the definition of a specific column
  72211. * @param index defines the index of the column
  72212. * @returns the column definition
  72213. */
  72214. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72215. /**
  72216. * Adds a new row to the grid
  72217. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72218. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72219. * @returns the current grid
  72220. */
  72221. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72222. /**
  72223. * Adds a new column to the grid
  72224. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72225. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72226. * @returns the current grid
  72227. */
  72228. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72229. /**
  72230. * Update a row definition
  72231. * @param index defines the index of the row to update
  72232. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72233. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72234. * @returns the current grid
  72235. */
  72236. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72237. /**
  72238. * Update a column definition
  72239. * @param index defines the index of the column to update
  72240. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72241. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72242. * @returns the current grid
  72243. */
  72244. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72245. /**
  72246. * Gets the list of children stored in a specific cell
  72247. * @param row defines the row to check
  72248. * @param column defines the column to check
  72249. * @returns the list of controls
  72250. */
  72251. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72252. /**
  72253. * Gets a string representing the child cell info (row x column)
  72254. * @param child defines the control to get info from
  72255. * @returns a string containing the child cell info (row x column)
  72256. */
  72257. getChildCellInfo(child: Control): string;
  72258. private _removeCell;
  72259. private _offsetCell;
  72260. /**
  72261. * Remove a column definition at specified index
  72262. * @param index defines the index of the column to remove
  72263. * @returns the current grid
  72264. */
  72265. removeColumnDefinition(index: number): Grid;
  72266. /**
  72267. * Remove a row definition at specified index
  72268. * @param index defines the index of the row to remove
  72269. * @returns the current grid
  72270. */
  72271. removeRowDefinition(index: number): Grid;
  72272. /**
  72273. * Adds a new control to the current grid
  72274. * @param control defines the control to add
  72275. * @param row defines the row where to add the control (0 by default)
  72276. * @param column defines the column where to add the control (0 by default)
  72277. * @returns the current grid
  72278. */
  72279. addControl(control: Control, row?: number, column?: number): Grid;
  72280. /**
  72281. * Removes a control from the current container
  72282. * @param control defines the control to remove
  72283. * @returns the current container
  72284. */
  72285. removeControl(control: Control): Container;
  72286. /**
  72287. * Creates a new Grid
  72288. * @param name defines control name
  72289. */
  72290. constructor(name?: string | undefined);
  72291. protected _getTypeName(): string;
  72292. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72293. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72294. _flagDescendantsAsMatrixDirty(): void;
  72295. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72296. /** Releases associated resources */
  72297. dispose(): void;
  72298. }
  72299. }
  72300. declare module BABYLON.GUI {
  72301. /** Class used to create color pickers */
  72302. export class ColorPicker extends Control {
  72303. name?: string | undefined;
  72304. private static _Epsilon;
  72305. private _colorWheelCanvas;
  72306. private _value;
  72307. private _tmpColor;
  72308. private _pointerStartedOnSquare;
  72309. private _pointerStartedOnWheel;
  72310. private _squareLeft;
  72311. private _squareTop;
  72312. private _squareSize;
  72313. private _h;
  72314. private _s;
  72315. private _v;
  72316. private _lastPointerDownID;
  72317. /**
  72318. * BABYLON.Observable raised when the value changes
  72319. */
  72320. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72321. /** Gets or sets the color of the color picker */
  72322. get value(): BABYLON.Color3;
  72323. set value(value: BABYLON.Color3);
  72324. /**
  72325. * Gets or sets control width
  72326. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72327. */
  72328. get width(): string | number;
  72329. set width(value: string | number);
  72330. /**
  72331. * Gets or sets control height
  72332. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72333. */
  72334. get height(): string | number;
  72335. /** Gets or sets control height */
  72336. set height(value: string | number);
  72337. /** Gets or sets control size */
  72338. get size(): string | number;
  72339. set size(value: string | number);
  72340. /**
  72341. * Creates a new ColorPicker
  72342. * @param name defines the control name
  72343. */
  72344. constructor(name?: string | undefined);
  72345. protected _getTypeName(): string;
  72346. /** @hidden */
  72347. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72348. private _updateSquareProps;
  72349. private _drawGradientSquare;
  72350. private _drawCircle;
  72351. private _createColorWheelCanvas;
  72352. /** @hidden */
  72353. _draw(context: CanvasRenderingContext2D): void;
  72354. private _pointerIsDown;
  72355. private _updateValueFromPointer;
  72356. private _isPointOnSquare;
  72357. private _isPointOnWheel;
  72358. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72359. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72360. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72361. /**
  72362. * This function expands the color picker by creating a color picker dialog with manual
  72363. * color value input and the ability to save colors into an array to be used later in
  72364. * subsequent launches of the dialogue.
  72365. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72366. * @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.
  72367. * @returns picked color as a hex string and the saved colors array as hex strings.
  72368. */
  72369. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72370. pickerWidth?: string;
  72371. pickerHeight?: string;
  72372. headerHeight?: string;
  72373. lastColor?: string;
  72374. swatchLimit?: number;
  72375. numSwatchesPerLine?: number;
  72376. savedColors?: Array<string>;
  72377. }): Promise<{
  72378. savedColors?: string[];
  72379. pickedColor: string;
  72380. }>;
  72381. }
  72382. }
  72383. declare module BABYLON.GUI {
  72384. /** Class used to create 2D ellipse containers */
  72385. export class Ellipse extends Container {
  72386. name?: string | undefined;
  72387. private _thickness;
  72388. /** Gets or sets border thickness */
  72389. get thickness(): number;
  72390. set thickness(value: number);
  72391. /**
  72392. * Creates a new Ellipse
  72393. * @param name defines the control name
  72394. */
  72395. constructor(name?: string | undefined);
  72396. protected _getTypeName(): string;
  72397. protected _localDraw(context: CanvasRenderingContext2D): void;
  72398. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72399. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72400. }
  72401. }
  72402. declare module BABYLON.GUI {
  72403. /**
  72404. * Class used to create a password control
  72405. */
  72406. export class InputPassword extends InputText {
  72407. protected _beforeRenderText(text: string): string;
  72408. }
  72409. }
  72410. declare module BABYLON.GUI {
  72411. /** Class used to render 2D lines */
  72412. export class Line extends Control {
  72413. name?: string | undefined;
  72414. private _lineWidth;
  72415. private _x1;
  72416. private _y1;
  72417. private _x2;
  72418. private _y2;
  72419. private _dash;
  72420. private _connectedControl;
  72421. private _connectedControlDirtyObserver;
  72422. /** Gets or sets the dash pattern */
  72423. get dash(): Array<number>;
  72424. set dash(value: Array<number>);
  72425. /** Gets or sets the control connected with the line end */
  72426. get connectedControl(): Control;
  72427. set connectedControl(value: Control);
  72428. /** Gets or sets start coordinates on X axis */
  72429. get x1(): string | number;
  72430. set x1(value: string | number);
  72431. /** Gets or sets start coordinates on Y axis */
  72432. get y1(): string | number;
  72433. set y1(value: string | number);
  72434. /** Gets or sets end coordinates on X axis */
  72435. get x2(): string | number;
  72436. set x2(value: string | number);
  72437. /** Gets or sets end coordinates on Y axis */
  72438. get y2(): string | number;
  72439. set y2(value: string | number);
  72440. /** Gets or sets line width */
  72441. get lineWidth(): number;
  72442. set lineWidth(value: number);
  72443. /** Gets or sets horizontal alignment */
  72444. set horizontalAlignment(value: number);
  72445. /** Gets or sets vertical alignment */
  72446. set verticalAlignment(value: number);
  72447. private get _effectiveX2();
  72448. private get _effectiveY2();
  72449. /**
  72450. * Creates a new Line
  72451. * @param name defines the control name
  72452. */
  72453. constructor(name?: string | undefined);
  72454. protected _getTypeName(): string;
  72455. _draw(context: CanvasRenderingContext2D): void;
  72456. _measure(): void;
  72457. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72458. /**
  72459. * Move one end of the line given 3D cartesian coordinates.
  72460. * @param position Targeted world position
  72461. * @param scene BABYLON.Scene
  72462. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72463. */
  72464. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72465. /**
  72466. * Move one end of the line to a position in screen absolute space.
  72467. * @param projectedPosition Position in screen absolute space (X, Y)
  72468. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72469. */
  72470. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72471. }
  72472. }
  72473. declare module BABYLON.GUI {
  72474. /**
  72475. * Class used to store a point for a MultiLine object.
  72476. * The point can be pure 2D coordinates, a mesh or a control
  72477. */
  72478. export class MultiLinePoint {
  72479. private _multiLine;
  72480. private _x;
  72481. private _y;
  72482. private _control;
  72483. private _mesh;
  72484. private _controlObserver;
  72485. private _meshObserver;
  72486. /** @hidden */
  72487. _point: BABYLON.Vector2;
  72488. /**
  72489. * Creates a new MultiLinePoint
  72490. * @param multiLine defines the source MultiLine object
  72491. */
  72492. constructor(multiLine: MultiLine);
  72493. /** Gets or sets x coordinate */
  72494. get x(): string | number;
  72495. set x(value: string | number);
  72496. /** Gets or sets y coordinate */
  72497. get y(): string | number;
  72498. set y(value: string | number);
  72499. /** Gets or sets the control associated with this point */
  72500. get control(): BABYLON.Nullable<Control>;
  72501. set control(value: BABYLON.Nullable<Control>);
  72502. /** Gets or sets the mesh associated with this point */
  72503. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72504. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72505. /** Resets links */
  72506. resetLinks(): void;
  72507. /**
  72508. * Gets a translation vector
  72509. * @returns the translation vector
  72510. */
  72511. translate(): BABYLON.Vector2;
  72512. private _translatePoint;
  72513. /** Release associated resources */
  72514. dispose(): void;
  72515. }
  72516. }
  72517. declare module BABYLON.GUI {
  72518. /**
  72519. * Class used to create multi line control
  72520. */
  72521. export class MultiLine extends Control {
  72522. name?: string | undefined;
  72523. private _lineWidth;
  72524. private _dash;
  72525. private _points;
  72526. private _minX;
  72527. private _minY;
  72528. private _maxX;
  72529. private _maxY;
  72530. /**
  72531. * Creates a new MultiLine
  72532. * @param name defines the control name
  72533. */
  72534. constructor(name?: string | undefined);
  72535. /** Gets or sets dash pattern */
  72536. get dash(): Array<number>;
  72537. set dash(value: Array<number>);
  72538. /**
  72539. * Gets point stored at specified index
  72540. * @param index defines the index to look for
  72541. * @returns the requested point if found
  72542. */
  72543. getAt(index: number): MultiLinePoint;
  72544. /** Function called when a point is updated */
  72545. onPointUpdate: () => void;
  72546. /**
  72547. * Adds new points to the point collection
  72548. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72549. * @returns the list of created MultiLinePoint
  72550. */
  72551. add(...items: (AbstractMesh | Control | {
  72552. x: string | number;
  72553. y: string | number;
  72554. })[]): MultiLinePoint[];
  72555. /**
  72556. * Adds a new point to the point collection
  72557. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72558. * @returns the created MultiLinePoint
  72559. */
  72560. push(item?: (AbstractMesh | Control | {
  72561. x: string | number;
  72562. y: string | number;
  72563. })): MultiLinePoint;
  72564. /**
  72565. * Remove a specific value or point from the active point collection
  72566. * @param value defines the value or point to remove
  72567. */
  72568. remove(value: number | MultiLinePoint): void;
  72569. /**
  72570. * Resets this object to initial state (no point)
  72571. */
  72572. reset(): void;
  72573. /**
  72574. * Resets all links
  72575. */
  72576. resetLinks(): void;
  72577. /** Gets or sets line width */
  72578. get lineWidth(): number;
  72579. set lineWidth(value: number);
  72580. set horizontalAlignment(value: number);
  72581. set verticalAlignment(value: number);
  72582. protected _getTypeName(): string;
  72583. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72584. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72585. _measure(): void;
  72586. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72587. dispose(): void;
  72588. }
  72589. }
  72590. declare module BABYLON.GUI {
  72591. /**
  72592. * Class used to create radio button controls
  72593. */
  72594. export class RadioButton extends Control {
  72595. name?: string | undefined;
  72596. private _isChecked;
  72597. private _background;
  72598. private _checkSizeRatio;
  72599. private _thickness;
  72600. /** Gets or sets border thickness */
  72601. get thickness(): number;
  72602. set thickness(value: number);
  72603. /** Gets or sets group name */
  72604. group: string;
  72605. /** BABYLON.Observable raised when isChecked is changed */
  72606. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72607. /** Gets or sets a value indicating the ratio between overall size and check size */
  72608. get checkSizeRatio(): number;
  72609. set checkSizeRatio(value: number);
  72610. /** Gets or sets background color */
  72611. get background(): string;
  72612. set background(value: string);
  72613. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72614. get isChecked(): boolean;
  72615. set isChecked(value: boolean);
  72616. /**
  72617. * Creates a new RadioButton
  72618. * @param name defines the control name
  72619. */
  72620. constructor(name?: string | undefined);
  72621. protected _getTypeName(): string;
  72622. _draw(context: CanvasRenderingContext2D): void;
  72623. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72624. /**
  72625. * Utility function to easily create a radio button with a header
  72626. * @param title defines the label to use for the header
  72627. * @param group defines the group to use for the radio button
  72628. * @param isChecked defines the initial state of the radio button
  72629. * @param onValueChanged defines the callback to call when value changes
  72630. * @returns a StackPanel containing the radio button and a textBlock
  72631. */
  72632. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72633. }
  72634. }
  72635. declare module BABYLON.GUI {
  72636. /**
  72637. * Class used to create slider controls
  72638. */
  72639. export class BaseSlider extends Control {
  72640. name?: string | undefined;
  72641. protected _thumbWidth: ValueAndUnit;
  72642. private _minimum;
  72643. private _maximum;
  72644. private _value;
  72645. private _isVertical;
  72646. protected _barOffset: ValueAndUnit;
  72647. private _isThumbClamped;
  72648. protected _displayThumb: boolean;
  72649. private _step;
  72650. private _lastPointerDownID;
  72651. protected _effectiveBarOffset: number;
  72652. protected _renderLeft: number;
  72653. protected _renderTop: number;
  72654. protected _renderWidth: number;
  72655. protected _renderHeight: number;
  72656. protected _backgroundBoxLength: number;
  72657. protected _backgroundBoxThickness: number;
  72658. protected _effectiveThumbThickness: number;
  72659. /** BABYLON.Observable raised when the sldier value changes */
  72660. onValueChangedObservable: BABYLON.Observable<number>;
  72661. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72662. get displayThumb(): boolean;
  72663. set displayThumb(value: boolean);
  72664. /** Gets or sets a step to apply to values (0 by default) */
  72665. get step(): number;
  72666. set step(value: number);
  72667. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72668. get barOffset(): string | number;
  72669. /** Gets main bar offset in pixels*/
  72670. get barOffsetInPixels(): number;
  72671. set barOffset(value: string | number);
  72672. /** Gets or sets thumb width */
  72673. get thumbWidth(): string | number;
  72674. /** Gets thumb width in pixels */
  72675. get thumbWidthInPixels(): number;
  72676. set thumbWidth(value: string | number);
  72677. /** Gets or sets minimum value */
  72678. get minimum(): number;
  72679. set minimum(value: number);
  72680. /** Gets or sets maximum value */
  72681. get maximum(): number;
  72682. set maximum(value: number);
  72683. /** Gets or sets current value */
  72684. get value(): number;
  72685. set value(value: number);
  72686. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72687. get isVertical(): boolean;
  72688. set isVertical(value: boolean);
  72689. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72690. get isThumbClamped(): boolean;
  72691. set isThumbClamped(value: boolean);
  72692. /**
  72693. * Creates a new BaseSlider
  72694. * @param name defines the control name
  72695. */
  72696. constructor(name?: string | undefined);
  72697. protected _getTypeName(): string;
  72698. protected _getThumbPosition(): number;
  72699. protected _getThumbThickness(type: string): number;
  72700. protected _prepareRenderingData(type: string): void;
  72701. private _pointerIsDown;
  72702. /** @hidden */
  72703. protected _updateValueFromPointer(x: number, y: number): void;
  72704. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72705. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72706. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72707. }
  72708. }
  72709. declare module BABYLON.GUI {
  72710. /**
  72711. * Class used to create slider controls
  72712. */
  72713. export class Slider extends BaseSlider {
  72714. name?: string | undefined;
  72715. private _background;
  72716. private _borderColor;
  72717. private _isThumbCircle;
  72718. protected _displayValueBar: boolean;
  72719. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72720. get displayValueBar(): boolean;
  72721. set displayValueBar(value: boolean);
  72722. /** Gets or sets border color */
  72723. get borderColor(): string;
  72724. set borderColor(value: string);
  72725. /** Gets or sets background color */
  72726. get background(): string;
  72727. set background(value: string);
  72728. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72729. get isThumbCircle(): boolean;
  72730. set isThumbCircle(value: boolean);
  72731. /**
  72732. * Creates a new Slider
  72733. * @param name defines the control name
  72734. */
  72735. constructor(name?: string | undefined);
  72736. protected _getTypeName(): string;
  72737. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72738. }
  72739. }
  72740. declare module BABYLON.GUI {
  72741. /** Class used to create a RadioGroup
  72742. * which contains groups of radio buttons
  72743. */
  72744. export class SelectorGroup {
  72745. /** name of SelectorGroup */
  72746. name: string;
  72747. private _groupPanel;
  72748. private _selectors;
  72749. private _groupHeader;
  72750. /**
  72751. * Creates a new SelectorGroup
  72752. * @param name of group, used as a group heading
  72753. */
  72754. constructor(
  72755. /** name of SelectorGroup */
  72756. name: string);
  72757. /** Gets the groupPanel of the SelectorGroup */
  72758. get groupPanel(): StackPanel;
  72759. /** Gets the selectors array */
  72760. get selectors(): StackPanel[];
  72761. /** Gets and sets the group header */
  72762. get header(): string;
  72763. set header(label: string);
  72764. /** @hidden */
  72765. private _addGroupHeader;
  72766. /** @hidden*/
  72767. _getSelector(selectorNb: number): StackPanel | undefined;
  72768. /** Removes the selector at the given position
  72769. * @param selectorNb the position of the selector within the group
  72770. */
  72771. removeSelector(selectorNb: number): void;
  72772. }
  72773. /** Class used to create a CheckboxGroup
  72774. * which contains groups of checkbox buttons
  72775. */
  72776. export class CheckboxGroup extends SelectorGroup {
  72777. /** Adds a checkbox as a control
  72778. * @param text is the label for the selector
  72779. * @param func is the function called when the Selector is checked
  72780. * @param checked is true when Selector is checked
  72781. */
  72782. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72783. /** @hidden */
  72784. _setSelectorLabel(selectorNb: number, label: string): void;
  72785. /** @hidden */
  72786. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72787. /** @hidden */
  72788. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72789. /** @hidden */
  72790. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72791. }
  72792. /** Class used to create a RadioGroup
  72793. * which contains groups of radio buttons
  72794. */
  72795. export class RadioGroup extends SelectorGroup {
  72796. private _selectNb;
  72797. /** Adds a radio button as a control
  72798. * @param label is the label for the selector
  72799. * @param func is the function called when the Selector is checked
  72800. * @param checked is true when Selector is checked
  72801. */
  72802. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72803. /** @hidden */
  72804. _setSelectorLabel(selectorNb: number, label: string): void;
  72805. /** @hidden */
  72806. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72807. /** @hidden */
  72808. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72809. /** @hidden */
  72810. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72811. }
  72812. /** Class used to create a SliderGroup
  72813. * which contains groups of slider buttons
  72814. */
  72815. export class SliderGroup extends SelectorGroup {
  72816. /**
  72817. * Adds a slider to the SelectorGroup
  72818. * @param label is the label for the SliderBar
  72819. * @param func is the function called when the Slider moves
  72820. * @param unit is a string describing the units used, eg degrees or metres
  72821. * @param min is the minimum value for the Slider
  72822. * @param max is the maximum value for the Slider
  72823. * @param value is the start value for the Slider between min and max
  72824. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72825. */
  72826. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72827. /** @hidden */
  72828. _setSelectorLabel(selectorNb: number, label: string): void;
  72829. /** @hidden */
  72830. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72831. /** @hidden */
  72832. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72833. /** @hidden */
  72834. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72835. }
  72836. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72837. * @see http://doc.babylonjs.com/how_to/selector
  72838. */
  72839. export class SelectionPanel extends Rectangle {
  72840. /** name of SelectionPanel */
  72841. name: string;
  72842. /** an array of SelectionGroups */
  72843. groups: SelectorGroup[];
  72844. private _panel;
  72845. private _buttonColor;
  72846. private _buttonBackground;
  72847. private _headerColor;
  72848. private _barColor;
  72849. private _barHeight;
  72850. private _spacerHeight;
  72851. private _labelColor;
  72852. private _groups;
  72853. private _bars;
  72854. /**
  72855. * Creates a new SelectionPanel
  72856. * @param name of SelectionPanel
  72857. * @param groups is an array of SelectionGroups
  72858. */
  72859. constructor(
  72860. /** name of SelectionPanel */
  72861. name: string,
  72862. /** an array of SelectionGroups */
  72863. groups?: SelectorGroup[]);
  72864. protected _getTypeName(): string;
  72865. /** Gets or sets the headerColor */
  72866. get headerColor(): string;
  72867. set headerColor(color: string);
  72868. private _setHeaderColor;
  72869. /** Gets or sets the button color */
  72870. get buttonColor(): string;
  72871. set buttonColor(color: string);
  72872. private _setbuttonColor;
  72873. /** Gets or sets the label color */
  72874. get labelColor(): string;
  72875. set labelColor(color: string);
  72876. private _setLabelColor;
  72877. /** Gets or sets the button background */
  72878. get buttonBackground(): string;
  72879. set buttonBackground(color: string);
  72880. private _setButtonBackground;
  72881. /** Gets or sets the color of separator bar */
  72882. get barColor(): string;
  72883. set barColor(color: string);
  72884. private _setBarColor;
  72885. /** Gets or sets the height of separator bar */
  72886. get barHeight(): string;
  72887. set barHeight(value: string);
  72888. private _setBarHeight;
  72889. /** Gets or sets the height of spacers*/
  72890. get spacerHeight(): string;
  72891. set spacerHeight(value: string);
  72892. private _setSpacerHeight;
  72893. /** Adds a bar between groups */
  72894. private _addSpacer;
  72895. /** Add a group to the selection panel
  72896. * @param group is the selector group to add
  72897. */
  72898. addGroup(group: SelectorGroup): void;
  72899. /** Remove the group from the given position
  72900. * @param groupNb is the position of the group in the list
  72901. */
  72902. removeGroup(groupNb: number): void;
  72903. /** Change a group header label
  72904. * @param label is the new group header label
  72905. * @param groupNb is the number of the group to relabel
  72906. * */
  72907. setHeaderName(label: string, groupNb: number): void;
  72908. /** Change selector label to the one given
  72909. * @param label is the new selector label
  72910. * @param groupNb is the number of the groupcontaining the selector
  72911. * @param selectorNb is the number of the selector within a group to relabel
  72912. * */
  72913. relabel(label: string, groupNb: number, selectorNb: number): void;
  72914. /** For a given group position remove the selector at the given position
  72915. * @param groupNb is the number of the group to remove the selector from
  72916. * @param selectorNb is the number of the selector within the group
  72917. */
  72918. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72919. /** For a given group position of correct type add a checkbox button
  72920. * @param groupNb is the number of the group to remove the selector from
  72921. * @param label is the label for the selector
  72922. * @param func is the function called when the Selector is checked
  72923. * @param checked is true when Selector is checked
  72924. */
  72925. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72926. /** For a given group position of correct type add a radio button
  72927. * @param groupNb is the number of the group to remove the selector from
  72928. * @param label is the label for the selector
  72929. * @param func is the function called when the Selector is checked
  72930. * @param checked is true when Selector is checked
  72931. */
  72932. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72933. /**
  72934. * For a given slider group add a slider
  72935. * @param groupNb is the number of the group to add the slider to
  72936. * @param label is the label for the Slider
  72937. * @param func is the function called when the Slider moves
  72938. * @param unit is a string describing the units used, eg degrees or metres
  72939. * @param min is the minimum value for the Slider
  72940. * @param max is the maximum value for the Slider
  72941. * @param value is the start value for the Slider between min and max
  72942. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72943. */
  72944. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72945. }
  72946. }
  72947. declare module BABYLON.GUI {
  72948. /**
  72949. * Class used to hold a the container for ScrollViewer
  72950. * @hidden
  72951. */
  72952. export class _ScrollViewerWindow extends Container {
  72953. parentClientWidth: number;
  72954. parentClientHeight: number;
  72955. private _freezeControls;
  72956. private _parentMeasure;
  72957. private _oldLeft;
  72958. private _oldTop;
  72959. get freezeControls(): boolean;
  72960. set freezeControls(value: boolean);
  72961. private _bucketWidth;
  72962. private _bucketHeight;
  72963. private _buckets;
  72964. private _bucketLen;
  72965. get bucketWidth(): number;
  72966. get bucketHeight(): number;
  72967. setBucketSizes(width: number, height: number): void;
  72968. private _useBuckets;
  72969. private _makeBuckets;
  72970. private _dispatchInBuckets;
  72971. private _updateMeasures;
  72972. private _updateChildrenMeasures;
  72973. /**
  72974. * Creates a new ScrollViewerWindow
  72975. * @param name of ScrollViewerWindow
  72976. */
  72977. constructor(name?: string);
  72978. protected _getTypeName(): string;
  72979. /** @hidden */
  72980. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72981. /** @hidden */
  72982. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72983. private _scrollChildren;
  72984. private _scrollChildrenWithBuckets;
  72985. /** @hidden */
  72986. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72987. protected _postMeasure(): void;
  72988. }
  72989. }
  72990. declare module BABYLON.GUI {
  72991. /**
  72992. * Class used to create slider controls
  72993. */
  72994. export class ScrollBar extends BaseSlider {
  72995. name?: string | undefined;
  72996. private _background;
  72997. private _borderColor;
  72998. private _tempMeasure;
  72999. /** Gets or sets border color */
  73000. get borderColor(): string;
  73001. set borderColor(value: string);
  73002. /** Gets or sets background color */
  73003. get background(): string;
  73004. set background(value: string);
  73005. /**
  73006. * Creates a new Slider
  73007. * @param name defines the control name
  73008. */
  73009. constructor(name?: string | undefined);
  73010. protected _getTypeName(): string;
  73011. protected _getThumbThickness(): number;
  73012. _draw(context: CanvasRenderingContext2D): void;
  73013. private _first;
  73014. private _originX;
  73015. private _originY;
  73016. /** @hidden */
  73017. protected _updateValueFromPointer(x: number, y: number): void;
  73018. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73019. }
  73020. }
  73021. declare module BABYLON.GUI {
  73022. /**
  73023. * Class used to create slider controls
  73024. */
  73025. export class ImageScrollBar extends BaseSlider {
  73026. name?: string | undefined;
  73027. private _backgroundBaseImage;
  73028. private _backgroundImage;
  73029. private _thumbImage;
  73030. private _thumbBaseImage;
  73031. private _thumbLength;
  73032. private _thumbHeight;
  73033. private _barImageHeight;
  73034. private _tempMeasure;
  73035. /** Number of 90° rotation to apply on the images when in vertical mode */
  73036. num90RotationInVerticalMode: number;
  73037. /**
  73038. * Gets or sets the image used to render the background for horizontal bar
  73039. */
  73040. get backgroundImage(): Image;
  73041. set backgroundImage(value: Image);
  73042. /**
  73043. * Gets or sets the image used to render the thumb
  73044. */
  73045. get thumbImage(): Image;
  73046. set thumbImage(value: Image);
  73047. /**
  73048. * Gets or sets the length of the thumb
  73049. */
  73050. get thumbLength(): number;
  73051. set thumbLength(value: number);
  73052. /**
  73053. * Gets or sets the height of the thumb
  73054. */
  73055. get thumbHeight(): number;
  73056. set thumbHeight(value: number);
  73057. /**
  73058. * Gets or sets the height of the bar image
  73059. */
  73060. get barImageHeight(): number;
  73061. set barImageHeight(value: number);
  73062. /**
  73063. * Creates a new ImageScrollBar
  73064. * @param name defines the control name
  73065. */
  73066. constructor(name?: string | undefined);
  73067. protected _getTypeName(): string;
  73068. protected _getThumbThickness(): number;
  73069. _draw(context: CanvasRenderingContext2D): void;
  73070. private _first;
  73071. private _originX;
  73072. private _originY;
  73073. /** @hidden */
  73074. protected _updateValueFromPointer(x: number, y: number): void;
  73075. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73076. }
  73077. }
  73078. declare module BABYLON.GUI {
  73079. /**
  73080. * Class used to hold a viewer window and sliders in a grid
  73081. */
  73082. export class ScrollViewer extends Rectangle {
  73083. private _grid;
  73084. private _horizontalBarSpace;
  73085. private _verticalBarSpace;
  73086. private _dragSpace;
  73087. private _horizontalBar;
  73088. private _verticalBar;
  73089. private _barColor;
  73090. private _barBackground;
  73091. private _barImage;
  73092. private _horizontalBarImage;
  73093. private _verticalBarImage;
  73094. private _barBackgroundImage;
  73095. private _horizontalBarBackgroundImage;
  73096. private _verticalBarBackgroundImage;
  73097. private _barSize;
  73098. private _window;
  73099. private _pointerIsOver;
  73100. private _wheelPrecision;
  73101. private _onPointerObserver;
  73102. private _clientWidth;
  73103. private _clientHeight;
  73104. private _useImageBar;
  73105. private _thumbLength;
  73106. private _thumbHeight;
  73107. private _barImageHeight;
  73108. private _horizontalBarImageHeight;
  73109. private _verticalBarImageHeight;
  73110. /**
  73111. * Gets the horizontal scrollbar
  73112. */
  73113. get horizontalBar(): ScrollBar | ImageScrollBar;
  73114. /**
  73115. * Gets the vertical scrollbar
  73116. */
  73117. get verticalBar(): ScrollBar | ImageScrollBar;
  73118. /**
  73119. * Adds a new control to the current container
  73120. * @param control defines the control to add
  73121. * @returns the current container
  73122. */
  73123. addControl(control: BABYLON.Nullable<Control>): Container;
  73124. /**
  73125. * Removes a control from the current container
  73126. * @param control defines the control to remove
  73127. * @returns the current container
  73128. */
  73129. removeControl(control: Control): Container;
  73130. /** Gets the list of children */
  73131. get children(): Control[];
  73132. _flagDescendantsAsMatrixDirty(): void;
  73133. /**
  73134. * Freezes or unfreezes the controls in the window.
  73135. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73136. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73137. */
  73138. get freezeControls(): boolean;
  73139. set freezeControls(value: boolean);
  73140. /** Gets the bucket width */
  73141. get bucketWidth(): number;
  73142. /** Gets the bucket height */
  73143. get bucketHeight(): number;
  73144. /**
  73145. * Sets the bucket sizes.
  73146. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73147. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73148. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73149. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73150. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73151. * used), that's why it is not enabled by default.
  73152. * @param width width of the bucket
  73153. * @param height height of the bucket
  73154. */
  73155. setBucketSizes(width: number, height: number): void;
  73156. private _forceHorizontalBar;
  73157. private _forceVerticalBar;
  73158. /**
  73159. * Forces the horizontal scroll bar to be displayed
  73160. */
  73161. get forceHorizontalBar(): boolean;
  73162. set forceHorizontalBar(value: boolean);
  73163. /**
  73164. * Forces the vertical scroll bar to be displayed
  73165. */
  73166. get forceVerticalBar(): boolean;
  73167. set forceVerticalBar(value: boolean);
  73168. /**
  73169. * Creates a new ScrollViewer
  73170. * @param name of ScrollViewer
  73171. */
  73172. constructor(name?: string, isImageBased?: boolean);
  73173. /** Reset the scroll viewer window to initial size */
  73174. resetWindow(): void;
  73175. protected _getTypeName(): string;
  73176. private _buildClientSizes;
  73177. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73178. protected _postMeasure(): void;
  73179. /**
  73180. * Gets or sets the mouse wheel precision
  73181. * from 0 to 1 with a default value of 0.05
  73182. * */
  73183. get wheelPrecision(): number;
  73184. set wheelPrecision(value: number);
  73185. /** Gets or sets the scroll bar container background color */
  73186. get scrollBackground(): string;
  73187. set scrollBackground(color: string);
  73188. /** Gets or sets the bar color */
  73189. get barColor(): string;
  73190. set barColor(color: string);
  73191. /** Gets or sets the bar image */
  73192. get thumbImage(): Image;
  73193. set thumbImage(value: Image);
  73194. /** Gets or sets the horizontal bar image */
  73195. get horizontalThumbImage(): Image;
  73196. set horizontalThumbImage(value: Image);
  73197. /** Gets or sets the vertical bar image */
  73198. get verticalThumbImage(): Image;
  73199. set verticalThumbImage(value: Image);
  73200. /** Gets or sets the size of the bar */
  73201. get barSize(): number;
  73202. set barSize(value: number);
  73203. /** Gets or sets the length of the thumb */
  73204. get thumbLength(): number;
  73205. set thumbLength(value: number);
  73206. /** Gets or sets the height of the thumb */
  73207. get thumbHeight(): number;
  73208. set thumbHeight(value: number);
  73209. /** Gets or sets the height of the bar image */
  73210. get barImageHeight(): number;
  73211. set barImageHeight(value: number);
  73212. /** Gets or sets the height of the horizontal bar image */
  73213. get horizontalBarImageHeight(): number;
  73214. set horizontalBarImageHeight(value: number);
  73215. /** Gets or sets the height of the vertical bar image */
  73216. get verticalBarImageHeight(): number;
  73217. set verticalBarImageHeight(value: number);
  73218. /** Gets or sets the bar background */
  73219. get barBackground(): string;
  73220. set barBackground(color: string);
  73221. /** Gets or sets the bar background image */
  73222. get barImage(): Image;
  73223. set barImage(value: Image);
  73224. /** Gets or sets the horizontal bar background image */
  73225. get horizontalBarImage(): Image;
  73226. set horizontalBarImage(value: Image);
  73227. /** Gets or sets the vertical bar background image */
  73228. get verticalBarImage(): Image;
  73229. set verticalBarImage(value: Image);
  73230. private _setWindowPosition;
  73231. /** @hidden */
  73232. private _updateScroller;
  73233. _link(host: AdvancedDynamicTexture): void;
  73234. /** @hidden */
  73235. private _addBar;
  73236. /** @hidden */
  73237. private _attachWheel;
  73238. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73239. /** Releases associated resources */
  73240. dispose(): void;
  73241. }
  73242. }
  73243. declare module BABYLON.GUI {
  73244. /** Class used to render a grid */
  73245. export class DisplayGrid extends Control {
  73246. name?: string | undefined;
  73247. private _cellWidth;
  73248. private _cellHeight;
  73249. private _minorLineTickness;
  73250. private _minorLineColor;
  73251. private _majorLineTickness;
  73252. private _majorLineColor;
  73253. private _majorLineFrequency;
  73254. private _background;
  73255. private _displayMajorLines;
  73256. private _displayMinorLines;
  73257. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73258. get displayMinorLines(): boolean;
  73259. set displayMinorLines(value: boolean);
  73260. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73261. get displayMajorLines(): boolean;
  73262. set displayMajorLines(value: boolean);
  73263. /** Gets or sets background color (Black by default) */
  73264. get background(): string;
  73265. set background(value: string);
  73266. /** Gets or sets the width of each cell (20 by default) */
  73267. get cellWidth(): number;
  73268. set cellWidth(value: number);
  73269. /** Gets or sets the height of each cell (20 by default) */
  73270. get cellHeight(): number;
  73271. set cellHeight(value: number);
  73272. /** Gets or sets the tickness of minor lines (1 by default) */
  73273. get minorLineTickness(): number;
  73274. set minorLineTickness(value: number);
  73275. /** Gets or sets the color of minor lines (DarkGray by default) */
  73276. get minorLineColor(): string;
  73277. set minorLineColor(value: string);
  73278. /** Gets or sets the tickness of major lines (2 by default) */
  73279. get majorLineTickness(): number;
  73280. set majorLineTickness(value: number);
  73281. /** Gets or sets the color of major lines (White by default) */
  73282. get majorLineColor(): string;
  73283. set majorLineColor(value: string);
  73284. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73285. get majorLineFrequency(): number;
  73286. set majorLineFrequency(value: number);
  73287. /**
  73288. * Creates a new GridDisplayRectangle
  73289. * @param name defines the control name
  73290. */
  73291. constructor(name?: string | undefined);
  73292. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73293. protected _getTypeName(): string;
  73294. }
  73295. }
  73296. declare module BABYLON.GUI {
  73297. /**
  73298. * Class used to create slider controls based on images
  73299. */
  73300. export class ImageBasedSlider extends BaseSlider {
  73301. name?: string | undefined;
  73302. private _backgroundImage;
  73303. private _thumbImage;
  73304. private _valueBarImage;
  73305. private _tempMeasure;
  73306. get displayThumb(): boolean;
  73307. set displayThumb(value: boolean);
  73308. /**
  73309. * Gets or sets the image used to render the background
  73310. */
  73311. get backgroundImage(): Image;
  73312. set backgroundImage(value: Image);
  73313. /**
  73314. * Gets or sets the image used to render the value bar
  73315. */
  73316. get valueBarImage(): Image;
  73317. set valueBarImage(value: Image);
  73318. /**
  73319. * Gets or sets the image used to render the thumb
  73320. */
  73321. get thumbImage(): Image;
  73322. set thumbImage(value: Image);
  73323. /**
  73324. * Creates a new ImageBasedSlider
  73325. * @param name defines the control name
  73326. */
  73327. constructor(name?: string | undefined);
  73328. protected _getTypeName(): string;
  73329. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73330. }
  73331. }
  73332. declare module BABYLON.GUI {
  73333. /**
  73334. * Forcing an export so that this code will execute
  73335. * @hidden
  73336. */
  73337. const name = "Statics";
  73338. }
  73339. declare module BABYLON.GUI {
  73340. /**
  73341. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73342. */
  73343. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73344. /**
  73345. * Define the instrumented AdvancedDynamicTexture.
  73346. */
  73347. texture: AdvancedDynamicTexture;
  73348. private _captureRenderTime;
  73349. private _renderTime;
  73350. private _captureLayoutTime;
  73351. private _layoutTime;
  73352. private _onBeginRenderObserver;
  73353. private _onEndRenderObserver;
  73354. private _onBeginLayoutObserver;
  73355. private _onEndLayoutObserver;
  73356. /**
  73357. * Gets the perf counter used to capture render time
  73358. */
  73359. get renderTimeCounter(): BABYLON.PerfCounter;
  73360. /**
  73361. * Gets the perf counter used to capture layout time
  73362. */
  73363. get layoutTimeCounter(): BABYLON.PerfCounter;
  73364. /**
  73365. * Enable or disable the render time capture
  73366. */
  73367. get captureRenderTime(): boolean;
  73368. set captureRenderTime(value: boolean);
  73369. /**
  73370. * Enable or disable the layout time capture
  73371. */
  73372. get captureLayoutTime(): boolean;
  73373. set captureLayoutTime(value: boolean);
  73374. /**
  73375. * Instantiates a new advanced dynamic texture instrumentation.
  73376. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73377. * @param texture Defines the AdvancedDynamicTexture to instrument
  73378. */
  73379. constructor(
  73380. /**
  73381. * Define the instrumented AdvancedDynamicTexture.
  73382. */
  73383. texture: AdvancedDynamicTexture);
  73384. /**
  73385. * Dispose and release associated resources.
  73386. */
  73387. dispose(): void;
  73388. }
  73389. }
  73390. declare module BABYLON.GUI {
  73391. /**
  73392. * Class used to load GUI via XML.
  73393. */
  73394. export class XmlLoader {
  73395. private _nodes;
  73396. private _nodeTypes;
  73397. private _isLoaded;
  73398. private _objectAttributes;
  73399. private _parentClass;
  73400. /**
  73401. * Create a new xml loader
  73402. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73403. */
  73404. constructor(parentClass?: null);
  73405. private _getChainElement;
  73406. private _getClassAttribute;
  73407. private _createGuiElement;
  73408. private _parseGrid;
  73409. private _parseElement;
  73410. private _prepareSourceElement;
  73411. private _parseElementsFromSource;
  73412. private _parseXml;
  73413. /**
  73414. * Gets if the loading has finished.
  73415. * @returns whether the loading has finished or not
  73416. */
  73417. isLoaded(): boolean;
  73418. /**
  73419. * Gets a loaded node / control by id.
  73420. * @param id the Controls id set in the xml
  73421. * @returns element of type Control
  73422. */
  73423. getNodeById(id: string): any;
  73424. /**
  73425. * Gets all loaded nodes / controls
  73426. * @returns Array of controls
  73427. */
  73428. getNodes(): any;
  73429. /**
  73430. * Initiates the xml layout loading
  73431. * @param xmlFile defines the xml layout to load
  73432. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73433. * @param callback defines the callback called on layout load.
  73434. */
  73435. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73436. }
  73437. }
  73438. declare module BABYLON.GUI {
  73439. /**
  73440. * Class used to create containers for controls
  73441. */
  73442. export class Container3D extends Control3D {
  73443. private _blockLayout;
  73444. /**
  73445. * Gets the list of child controls
  73446. */
  73447. protected _children: Control3D[];
  73448. /**
  73449. * Gets the list of child controls
  73450. */
  73451. get children(): Array<Control3D>;
  73452. /**
  73453. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73454. * This is helpful to optimize layout operation when adding multiple children in a row
  73455. */
  73456. get blockLayout(): boolean;
  73457. set blockLayout(value: boolean);
  73458. /**
  73459. * Creates a new container
  73460. * @param name defines the container name
  73461. */
  73462. constructor(name?: string);
  73463. /**
  73464. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73465. * @returns the current container
  73466. */
  73467. updateLayout(): Container3D;
  73468. /**
  73469. * Gets a boolean indicating if the given control is in the children of this control
  73470. * @param control defines the control to check
  73471. * @returns true if the control is in the child list
  73472. */
  73473. containsControl(control: Control3D): boolean;
  73474. /**
  73475. * Adds a control to the children of this control
  73476. * @param control defines the control to add
  73477. * @returns the current container
  73478. */
  73479. addControl(control: Control3D): Container3D;
  73480. /**
  73481. * This function will be called everytime a new control is added
  73482. */
  73483. protected _arrangeChildren(): void;
  73484. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73485. /**
  73486. * Removes a control from the children of this control
  73487. * @param control defines the control to remove
  73488. * @returns the current container
  73489. */
  73490. removeControl(control: Control3D): Container3D;
  73491. protected _getTypeName(): string;
  73492. /**
  73493. * Releases all associated resources
  73494. */
  73495. dispose(): void;
  73496. /** Control rotation will remain unchanged */
  73497. static readonly UNSET_ORIENTATION: number;
  73498. /** Control will rotate to make it look at sphere central axis */
  73499. static readonly FACEORIGIN_ORIENTATION: number;
  73500. /** Control will rotate to make it look back at sphere central axis */
  73501. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73502. /** Control will rotate to look at z axis (0, 0, 1) */
  73503. static readonly FACEFORWARD_ORIENTATION: number;
  73504. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73505. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73506. }
  73507. }
  73508. declare module BABYLON.GUI {
  73509. /**
  73510. * Class used to manage 3D user interface
  73511. * @see http://doc.babylonjs.com/how_to/gui3d
  73512. */
  73513. export class GUI3DManager implements BABYLON.IDisposable {
  73514. private _scene;
  73515. private _sceneDisposeObserver;
  73516. private _utilityLayer;
  73517. private _rootContainer;
  73518. private _pointerObserver;
  73519. private _pointerOutObserver;
  73520. /** @hidden */
  73521. _lastPickedControl: Control3D;
  73522. /** @hidden */
  73523. _lastControlOver: {
  73524. [pointerId: number]: Control3D;
  73525. };
  73526. /** @hidden */
  73527. _lastControlDown: {
  73528. [pointerId: number]: Control3D;
  73529. };
  73530. /**
  73531. * BABYLON.Observable raised when the point picked by the pointer events changed
  73532. */
  73533. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73534. /** @hidden */
  73535. _sharedMaterials: {
  73536. [key: string]: BABYLON.Material;
  73537. };
  73538. /** Gets the hosting scene */
  73539. get scene(): BABYLON.Scene;
  73540. /** Gets associated utility layer */
  73541. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73542. /**
  73543. * Creates a new GUI3DManager
  73544. * @param scene
  73545. */
  73546. constructor(scene?: BABYLON.Scene);
  73547. private _handlePointerOut;
  73548. private _doPicking;
  73549. /**
  73550. * Gets the root container
  73551. */
  73552. get rootContainer(): Container3D;
  73553. /**
  73554. * Gets a boolean indicating if the given control is in the root child list
  73555. * @param control defines the control to check
  73556. * @returns true if the control is in the root child list
  73557. */
  73558. containsControl(control: Control3D): boolean;
  73559. /**
  73560. * Adds a control to the root child list
  73561. * @param control defines the control to add
  73562. * @returns the current manager
  73563. */
  73564. addControl(control: Control3D): GUI3DManager;
  73565. /**
  73566. * Removes a control from the root child list
  73567. * @param control defines the control to remove
  73568. * @returns the current container
  73569. */
  73570. removeControl(control: Control3D): GUI3DManager;
  73571. /**
  73572. * Releases all associated resources
  73573. */
  73574. dispose(): void;
  73575. }
  73576. }
  73577. declare module BABYLON.GUI {
  73578. /**
  73579. * Class used to transport BABYLON.Vector3 information for pointer events
  73580. */
  73581. export class Vector3WithInfo extends BABYLON.Vector3 {
  73582. /** defines the current mouse button index */
  73583. buttonIndex: number;
  73584. /**
  73585. * Creates a new Vector3WithInfo
  73586. * @param source defines the vector3 data to transport
  73587. * @param buttonIndex defines the current mouse button index
  73588. */
  73589. constructor(source: BABYLON.Vector3,
  73590. /** defines the current mouse button index */
  73591. buttonIndex?: number);
  73592. }
  73593. }
  73594. declare module BABYLON.GUI {
  73595. /**
  73596. * Class used as base class for controls
  73597. */
  73598. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73599. /** Defines the control name */
  73600. name?: string | undefined;
  73601. /** @hidden */
  73602. _host: GUI3DManager;
  73603. private _node;
  73604. private _downCount;
  73605. private _enterCount;
  73606. private _downPointerIds;
  73607. private _isVisible;
  73608. /** Gets or sets the control position in world space */
  73609. get position(): BABYLON.Vector3;
  73610. set position(value: BABYLON.Vector3);
  73611. /** Gets or sets the control scaling in world space */
  73612. get scaling(): BABYLON.Vector3;
  73613. set scaling(value: BABYLON.Vector3);
  73614. /** Callback used to start pointer enter animation */
  73615. pointerEnterAnimation: () => void;
  73616. /** Callback used to start pointer out animation */
  73617. pointerOutAnimation: () => void;
  73618. /** Callback used to start pointer down animation */
  73619. pointerDownAnimation: () => void;
  73620. /** Callback used to start pointer up animation */
  73621. pointerUpAnimation: () => void;
  73622. /**
  73623. * An event triggered when the pointer move over the control
  73624. */
  73625. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73626. /**
  73627. * An event triggered when the pointer move out of the control
  73628. */
  73629. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73630. /**
  73631. * An event triggered when the pointer taps the control
  73632. */
  73633. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73634. /**
  73635. * An event triggered when pointer is up
  73636. */
  73637. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73638. /**
  73639. * An event triggered when a control is clicked on (with a mouse)
  73640. */
  73641. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73642. /**
  73643. * An event triggered when pointer enters the control
  73644. */
  73645. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73646. /**
  73647. * Gets or sets the parent container
  73648. */
  73649. parent: BABYLON.Nullable<Container3D>;
  73650. private _behaviors;
  73651. /**
  73652. * Gets the list of attached behaviors
  73653. * @see http://doc.babylonjs.com/features/behaviour
  73654. */
  73655. get behaviors(): BABYLON.Behavior<Control3D>[];
  73656. /**
  73657. * Attach a behavior to the control
  73658. * @see http://doc.babylonjs.com/features/behaviour
  73659. * @param behavior defines the behavior to attach
  73660. * @returns the current control
  73661. */
  73662. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73663. /**
  73664. * Remove an attached behavior
  73665. * @see http://doc.babylonjs.com/features/behaviour
  73666. * @param behavior defines the behavior to attach
  73667. * @returns the current control
  73668. */
  73669. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73670. /**
  73671. * Gets an attached behavior by name
  73672. * @param name defines the name of the behavior to look for
  73673. * @see http://doc.babylonjs.com/features/behaviour
  73674. * @returns null if behavior was not found else the requested behavior
  73675. */
  73676. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73677. /** Gets or sets a boolean indicating if the control is visible */
  73678. get isVisible(): boolean;
  73679. set isVisible(value: boolean);
  73680. /**
  73681. * Creates a new control
  73682. * @param name defines the control name
  73683. */
  73684. constructor(
  73685. /** Defines the control name */
  73686. name?: string | undefined);
  73687. /**
  73688. * Gets a string representing the class name
  73689. */
  73690. get typeName(): string;
  73691. /**
  73692. * Get the current class name of the control.
  73693. * @returns current class name
  73694. */
  73695. getClassName(): string;
  73696. protected _getTypeName(): string;
  73697. /**
  73698. * Gets the transform node used by this control
  73699. */
  73700. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73701. /**
  73702. * Gets the mesh used to render this control
  73703. */
  73704. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73705. /**
  73706. * Link the control as child of the given node
  73707. * @param node defines the node to link to. Use null to unlink the control
  73708. * @returns the current control
  73709. */
  73710. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73711. /** @hidden **/
  73712. _prepareNode(scene: BABYLON.Scene): void;
  73713. /**
  73714. * Node creation.
  73715. * Can be overriden by children
  73716. * @param scene defines the scene where the node must be attached
  73717. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73718. */
  73719. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73720. /**
  73721. * Affect a material to the given mesh
  73722. * @param mesh defines the mesh which will represent the control
  73723. */
  73724. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73725. /** @hidden */
  73726. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73727. /** @hidden */
  73728. _onPointerEnter(target: Control3D): boolean;
  73729. /** @hidden */
  73730. _onPointerOut(target: Control3D): void;
  73731. /** @hidden */
  73732. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73733. /** @hidden */
  73734. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73735. /** @hidden */
  73736. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73737. /** @hidden */
  73738. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73739. /** @hidden */
  73740. _disposeNode(): void;
  73741. /**
  73742. * Releases all associated resources
  73743. */
  73744. dispose(): void;
  73745. }
  73746. }
  73747. declare module BABYLON.GUI {
  73748. /**
  73749. * Class used as a root to all buttons
  73750. */
  73751. export class AbstractButton3D extends Control3D {
  73752. /**
  73753. * Creates a new button
  73754. * @param name defines the control name
  73755. */
  73756. constructor(name?: string);
  73757. protected _getTypeName(): string;
  73758. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73759. }
  73760. }
  73761. declare module BABYLON.GUI {
  73762. /**
  73763. * Class used to create a button in 3D
  73764. */
  73765. export class Button3D extends AbstractButton3D {
  73766. /** @hidden */
  73767. protected _currentMaterial: BABYLON.Material;
  73768. private _facadeTexture;
  73769. private _content;
  73770. private _contentResolution;
  73771. private _contentScaleRatio;
  73772. /**
  73773. * Gets or sets the texture resolution used to render content (512 by default)
  73774. */
  73775. get contentResolution(): BABYLON.int;
  73776. set contentResolution(value: BABYLON.int);
  73777. /**
  73778. * Gets or sets the texture scale ratio used to render content (2 by default)
  73779. */
  73780. get contentScaleRatio(): number;
  73781. set contentScaleRatio(value: number);
  73782. protected _disposeFacadeTexture(): void;
  73783. protected _resetContent(): void;
  73784. /**
  73785. * Creates a new button
  73786. * @param name defines the control name
  73787. */
  73788. constructor(name?: string);
  73789. /**
  73790. * Gets or sets the GUI 2D content used to display the button's facade
  73791. */
  73792. get content(): Control;
  73793. set content(value: Control);
  73794. /**
  73795. * Apply the facade texture (created from the content property).
  73796. * This function can be overloaded by child classes
  73797. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73798. */
  73799. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73800. protected _getTypeName(): string;
  73801. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73802. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73803. /**
  73804. * Releases all associated resources
  73805. */
  73806. dispose(): void;
  73807. }
  73808. }
  73809. declare module BABYLON.GUI {
  73810. /**
  73811. * Abstract class used to create a container panel deployed on the surface of a volume
  73812. */
  73813. export abstract class VolumeBasedPanel extends Container3D {
  73814. private _columns;
  73815. private _rows;
  73816. private _rowThenColum;
  73817. private _orientation;
  73818. protected _cellWidth: number;
  73819. protected _cellHeight: number;
  73820. /**
  73821. * Gets or sets the distance between elements
  73822. */
  73823. margin: number;
  73824. /**
  73825. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73826. * | Value | Type | Description |
  73827. * | ----- | ----------------------------------- | ----------- |
  73828. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73829. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73830. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73831. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73832. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73833. */
  73834. get orientation(): number;
  73835. set orientation(value: number);
  73836. /**
  73837. * Gets or sets the number of columns requested (10 by default).
  73838. * The panel will automatically compute the number of rows based on number of child controls.
  73839. */
  73840. get columns(): BABYLON.int;
  73841. set columns(value: BABYLON.int);
  73842. /**
  73843. * Gets or sets a the number of rows requested.
  73844. * The panel will automatically compute the number of columns based on number of child controls.
  73845. */
  73846. get rows(): BABYLON.int;
  73847. set rows(value: BABYLON.int);
  73848. /**
  73849. * Creates new VolumeBasedPanel
  73850. */
  73851. constructor();
  73852. protected _arrangeChildren(): void;
  73853. /** Child classes must implement this function to provide correct control positioning */
  73854. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73855. /** Child classes can implement this function to provide additional processing */
  73856. protected _finalProcessing(): void;
  73857. }
  73858. }
  73859. declare module BABYLON.GUI {
  73860. /**
  73861. * Class used to create a container panel deployed on the surface of a cylinder
  73862. */
  73863. export class CylinderPanel extends VolumeBasedPanel {
  73864. private _radius;
  73865. /**
  73866. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73867. */
  73868. get radius(): BABYLON.float;
  73869. set radius(value: BABYLON.float);
  73870. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73871. private _cylindricalMapping;
  73872. }
  73873. }
  73874. declare module BABYLON.GUI {
  73875. /** @hidden */
  73876. export var fluentVertexShader: {
  73877. name: string;
  73878. shader: string;
  73879. };
  73880. }
  73881. declare module BABYLON.GUI {
  73882. /** @hidden */
  73883. export var fluentPixelShader: {
  73884. name: string;
  73885. shader: string;
  73886. };
  73887. }
  73888. declare module BABYLON.GUI {
  73889. /** @hidden */
  73890. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73891. INNERGLOW: boolean;
  73892. BORDER: boolean;
  73893. HOVERLIGHT: boolean;
  73894. TEXTURE: boolean;
  73895. constructor();
  73896. }
  73897. /**
  73898. * Class used to render controls with fluent desgin
  73899. */
  73900. export class FluentMaterial extends BABYLON.PushMaterial {
  73901. /**
  73902. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73903. */
  73904. innerGlowColorIntensity: number;
  73905. /**
  73906. * Gets or sets the inner glow color (white by default)
  73907. */
  73908. innerGlowColor: BABYLON.Color3;
  73909. /**
  73910. * Gets or sets alpha value (default is 1.0)
  73911. */
  73912. alpha: number;
  73913. /**
  73914. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73915. */
  73916. albedoColor: BABYLON.Color3;
  73917. /**
  73918. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73919. */
  73920. renderBorders: boolean;
  73921. /**
  73922. * Gets or sets border width (default is 0.5)
  73923. */
  73924. borderWidth: number;
  73925. /**
  73926. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73927. */
  73928. edgeSmoothingValue: number;
  73929. /**
  73930. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73931. */
  73932. borderMinValue: number;
  73933. /**
  73934. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73935. */
  73936. renderHoverLight: boolean;
  73937. /**
  73938. * Gets or sets the radius used to render the hover light (default is 1.0)
  73939. */
  73940. hoverRadius: number;
  73941. /**
  73942. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73943. */
  73944. hoverColor: BABYLON.Color4;
  73945. /**
  73946. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73947. */
  73948. hoverPosition: BABYLON.Vector3;
  73949. private _albedoTexture;
  73950. /** Gets or sets the texture to use for albedo color */
  73951. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73952. /**
  73953. * Creates a new Fluent material
  73954. * @param name defines the name of the material
  73955. * @param scene defines the hosting scene
  73956. */
  73957. constructor(name: string, scene: BABYLON.Scene);
  73958. needAlphaBlending(): boolean;
  73959. needAlphaTesting(): boolean;
  73960. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73963. getActiveTextures(): BABYLON.BaseTexture[];
  73964. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73965. dispose(forceDisposeEffect?: boolean): void;
  73966. clone(name: string): FluentMaterial;
  73967. serialize(): any;
  73968. getClassName(): string;
  73969. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73970. }
  73971. }
  73972. declare module BABYLON.GUI {
  73973. /**
  73974. * Class used to create a holographic button in 3D
  73975. */
  73976. export class HolographicButton extends Button3D {
  73977. private _backPlate;
  73978. private _textPlate;
  73979. private _frontPlate;
  73980. private _text;
  73981. private _imageUrl;
  73982. private _shareMaterials;
  73983. private _frontMaterial;
  73984. private _backMaterial;
  73985. private _plateMaterial;
  73986. private _pickedPointObserver;
  73987. private _tooltipFade;
  73988. private _tooltipTextBlock;
  73989. private _tooltipTexture;
  73990. private _tooltipMesh;
  73991. private _tooltipHoverObserver;
  73992. private _tooltipOutObserver;
  73993. private _disposeTooltip;
  73994. /**
  73995. * Rendering ground id of all the mesh in the button
  73996. */
  73997. set renderingGroupId(id: number);
  73998. get renderingGroupId(): number;
  73999. /**
  74000. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74001. */
  74002. set tooltipText(text: BABYLON.Nullable<string>);
  74003. get tooltipText(): BABYLON.Nullable<string>;
  74004. /**
  74005. * Gets or sets text for the button
  74006. */
  74007. get text(): string;
  74008. set text(value: string);
  74009. /**
  74010. * Gets or sets the image url for the button
  74011. */
  74012. get imageUrl(): string;
  74013. set imageUrl(value: string);
  74014. /**
  74015. * Gets the back material used by this button
  74016. */
  74017. get backMaterial(): FluentMaterial;
  74018. /**
  74019. * Gets the front material used by this button
  74020. */
  74021. get frontMaterial(): FluentMaterial;
  74022. /**
  74023. * Gets the plate material used by this button
  74024. */
  74025. get plateMaterial(): BABYLON.StandardMaterial;
  74026. /**
  74027. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74028. */
  74029. get shareMaterials(): boolean;
  74030. /**
  74031. * Creates a new button
  74032. * @param name defines the control name
  74033. */
  74034. constructor(name?: string, shareMaterials?: boolean);
  74035. protected _getTypeName(): string;
  74036. private _rebuildContent;
  74037. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74038. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74039. private _createBackMaterial;
  74040. private _createFrontMaterial;
  74041. private _createPlateMaterial;
  74042. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74043. /**
  74044. * Releases all associated resources
  74045. */
  74046. dispose(): void;
  74047. }
  74048. }
  74049. declare module BABYLON.GUI {
  74050. /**
  74051. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74052. */
  74053. export class MeshButton3D extends Button3D {
  74054. /** @hidden */
  74055. protected _currentMesh: BABYLON.Mesh;
  74056. /**
  74057. * Creates a new 3D button based on a mesh
  74058. * @param mesh mesh to become a 3D button
  74059. * @param name defines the control name
  74060. */
  74061. constructor(mesh: BABYLON.Mesh, name?: string);
  74062. protected _getTypeName(): string;
  74063. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74064. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74065. }
  74066. }
  74067. declare module BABYLON.GUI {
  74068. /**
  74069. * Class used to create a container panel deployed on the surface of a plane
  74070. */
  74071. export class PlanePanel extends VolumeBasedPanel {
  74072. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74073. }
  74074. }
  74075. declare module BABYLON.GUI {
  74076. /**
  74077. * Class used to create a container panel where items get randomized planar mapping
  74078. */
  74079. export class ScatterPanel extends VolumeBasedPanel {
  74080. private _iteration;
  74081. /**
  74082. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74083. */
  74084. get iteration(): BABYLON.float;
  74085. set iteration(value: BABYLON.float);
  74086. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74087. private _scatterMapping;
  74088. protected _finalProcessing(): void;
  74089. }
  74090. }
  74091. declare module BABYLON.GUI {
  74092. /**
  74093. * Class used to create a container panel deployed on the surface of a sphere
  74094. */
  74095. export class SpherePanel extends VolumeBasedPanel {
  74096. private _radius;
  74097. /**
  74098. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74099. */
  74100. get radius(): BABYLON.float;
  74101. set radius(value: BABYLON.float);
  74102. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74103. private _sphericalMapping;
  74104. }
  74105. }
  74106. declare module BABYLON.GUI {
  74107. /**
  74108. * Class used to create a stack panel in 3D on XY plane
  74109. */
  74110. export class StackPanel3D extends Container3D {
  74111. private _isVertical;
  74112. /**
  74113. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74114. */
  74115. get isVertical(): boolean;
  74116. set isVertical(value: boolean);
  74117. /**
  74118. * Gets or sets the distance between elements
  74119. */
  74120. margin: number;
  74121. /**
  74122. * Creates new StackPanel
  74123. * @param isVertical
  74124. */
  74125. constructor(isVertical?: boolean);
  74126. protected _arrangeChildren(): void;
  74127. }
  74128. }
  74129. declare module BABYLON {
  74130. /**
  74131. * Configuration for glTF validation
  74132. */
  74133. export interface IGLTFValidationConfiguration {
  74134. /**
  74135. * The url of the glTF validator.
  74136. */
  74137. url: string;
  74138. }
  74139. /**
  74140. * glTF validation
  74141. */
  74142. export class GLTFValidation {
  74143. /**
  74144. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74145. */
  74146. static Configuration: IGLTFValidationConfiguration;
  74147. private static _LoadScriptPromise;
  74148. /**
  74149. * Validate a glTF asset using the glTF-Validator.
  74150. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74151. * @param rootUrl The root url for the glTF
  74152. * @param fileName The file name for the glTF
  74153. * @param getExternalResource The callback to get external resources for the glTF validator
  74154. * @returns A promise that resolves with the glTF validation results once complete
  74155. */
  74156. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74157. }
  74158. }
  74159. declare module BABYLON {
  74160. /**
  74161. * Mode that determines the coordinate system to use.
  74162. */
  74163. export enum GLTFLoaderCoordinateSystemMode {
  74164. /**
  74165. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74166. */
  74167. AUTO = 0,
  74168. /**
  74169. * Sets the useRightHandedSystem flag on the scene.
  74170. */
  74171. FORCE_RIGHT_HANDED = 1
  74172. }
  74173. /**
  74174. * Mode that determines what animations will start.
  74175. */
  74176. export enum GLTFLoaderAnimationStartMode {
  74177. /**
  74178. * No animation will start.
  74179. */
  74180. NONE = 0,
  74181. /**
  74182. * The first animation will start.
  74183. */
  74184. FIRST = 1,
  74185. /**
  74186. * All animations will start.
  74187. */
  74188. ALL = 2
  74189. }
  74190. /**
  74191. * Interface that contains the data for the glTF asset.
  74192. */
  74193. export interface IGLTFLoaderData {
  74194. /**
  74195. * The object that represents the glTF JSON.
  74196. */
  74197. json: Object;
  74198. /**
  74199. * The BIN chunk of a binary glTF.
  74200. */
  74201. bin: Nullable<IDataBuffer>;
  74202. }
  74203. /**
  74204. * Interface for extending the loader.
  74205. */
  74206. export interface IGLTFLoaderExtension {
  74207. /**
  74208. * The name of this extension.
  74209. */
  74210. readonly name: string;
  74211. /**
  74212. * Defines whether this extension is enabled.
  74213. */
  74214. enabled: boolean;
  74215. /**
  74216. * Defines the order of this extension.
  74217. * The loader sorts the extensions using these values when loading.
  74218. */
  74219. order?: number;
  74220. }
  74221. /**
  74222. * Loader state.
  74223. */
  74224. export enum GLTFLoaderState {
  74225. /**
  74226. * The asset is loading.
  74227. */
  74228. LOADING = 0,
  74229. /**
  74230. * The asset is ready for rendering.
  74231. */
  74232. READY = 1,
  74233. /**
  74234. * The asset is completely loaded.
  74235. */
  74236. COMPLETE = 2
  74237. }
  74238. /** @hidden */
  74239. export interface IImportMeshAsyncOutput {
  74240. meshes: AbstractMesh[];
  74241. particleSystems: IParticleSystem[];
  74242. skeletons: Skeleton[];
  74243. animationGroups: AnimationGroup[];
  74244. lights: Light[];
  74245. transformNodes: TransformNode[];
  74246. }
  74247. /** @hidden */
  74248. export interface IGLTFLoader extends IDisposable {
  74249. readonly state: Nullable<GLTFLoaderState>;
  74250. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74251. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74252. }
  74253. /**
  74254. * File loader for loading glTF files into a scene.
  74255. */
  74256. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74257. /** @hidden */
  74258. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74259. /** @hidden */
  74260. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74261. /**
  74262. * Raised when the asset has been parsed
  74263. */
  74264. onParsedObservable: Observable<IGLTFLoaderData>;
  74265. private _onParsedObserver;
  74266. /**
  74267. * Raised when the asset has been parsed
  74268. */
  74269. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74270. /**
  74271. * 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.
  74272. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74273. * Defaults to true.
  74274. * @hidden
  74275. */
  74276. static IncrementalLoading: boolean;
  74277. /**
  74278. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74279. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74280. * @hidden
  74281. */
  74282. static HomogeneousCoordinates: boolean;
  74283. /**
  74284. * The coordinate system mode. Defaults to AUTO.
  74285. */
  74286. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74287. /**
  74288. * The animation start mode. Defaults to FIRST.
  74289. */
  74290. animationStartMode: GLTFLoaderAnimationStartMode;
  74291. /**
  74292. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74293. */
  74294. compileMaterials: boolean;
  74295. /**
  74296. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74297. */
  74298. useClipPlane: boolean;
  74299. /**
  74300. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74301. */
  74302. compileShadowGenerators: boolean;
  74303. /**
  74304. * Defines if the Alpha blended materials are only applied as coverage.
  74305. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74306. * If true, no extra effects are applied to transparent pixels.
  74307. */
  74308. transparencyAsCoverage: boolean;
  74309. /**
  74310. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74311. * Enabling will disable offline support and glTF validator.
  74312. * Defaults to false.
  74313. */
  74314. useRangeRequests: boolean;
  74315. /**
  74316. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74317. */
  74318. createInstances: boolean;
  74319. /**
  74320. * Function called before loading a url referenced by the asset.
  74321. */
  74322. preprocessUrlAsync: (url: string) => Promise<string>;
  74323. /**
  74324. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74325. */
  74326. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74327. private _onMeshLoadedObserver;
  74328. /**
  74329. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74330. */
  74331. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74332. /**
  74333. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74334. */
  74335. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74336. private _onTextureLoadedObserver;
  74337. /**
  74338. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74339. */
  74340. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74341. /**
  74342. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74343. */
  74344. readonly onMaterialLoadedObservable: Observable<Material>;
  74345. private _onMaterialLoadedObserver;
  74346. /**
  74347. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74348. */
  74349. set onMaterialLoaded(callback: (material: Material) => void);
  74350. /**
  74351. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74352. */
  74353. readonly onCameraLoadedObservable: Observable<Camera>;
  74354. private _onCameraLoadedObserver;
  74355. /**
  74356. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74357. */
  74358. set onCameraLoaded(callback: (camera: Camera) => void);
  74359. /**
  74360. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74361. * For assets with LODs, raised when all of the LODs are complete.
  74362. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74363. */
  74364. readonly onCompleteObservable: Observable<void>;
  74365. private _onCompleteObserver;
  74366. /**
  74367. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74368. * For assets with LODs, raised when all of the LODs are complete.
  74369. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74370. */
  74371. set onComplete(callback: () => void);
  74372. /**
  74373. * Observable raised when an error occurs.
  74374. */
  74375. readonly onErrorObservable: Observable<any>;
  74376. private _onErrorObserver;
  74377. /**
  74378. * Callback raised when an error occurs.
  74379. */
  74380. set onError(callback: (reason: any) => void);
  74381. /**
  74382. * Observable raised after the loader is disposed.
  74383. */
  74384. readonly onDisposeObservable: Observable<void>;
  74385. private _onDisposeObserver;
  74386. /**
  74387. * Callback raised after the loader is disposed.
  74388. */
  74389. set onDispose(callback: () => void);
  74390. /**
  74391. * Observable raised after a loader extension is created.
  74392. * Set additional options for a loader extension in this event.
  74393. */
  74394. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74395. private _onExtensionLoadedObserver;
  74396. /**
  74397. * Callback raised after a loader extension is created.
  74398. */
  74399. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74400. /**
  74401. * Defines if the loader logging is enabled.
  74402. */
  74403. get loggingEnabled(): boolean;
  74404. set loggingEnabled(value: boolean);
  74405. /**
  74406. * Defines if the loader should capture performance counters.
  74407. */
  74408. get capturePerformanceCounters(): boolean;
  74409. set capturePerformanceCounters(value: boolean);
  74410. /**
  74411. * Defines if the loader should validate the asset.
  74412. */
  74413. validate: boolean;
  74414. /**
  74415. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74416. */
  74417. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74418. private _onValidatedObserver;
  74419. /**
  74420. * Callback raised after a loader extension is created.
  74421. */
  74422. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74423. private _loader;
  74424. /**
  74425. * Name of the loader ("gltf")
  74426. */
  74427. name: string;
  74428. /** @hidden */
  74429. extensions: ISceneLoaderPluginExtensions;
  74430. /**
  74431. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74432. */
  74433. dispose(): void;
  74434. /** @hidden */
  74435. _clear(): void;
  74436. /** @hidden */
  74437. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74438. /** @hidden */
  74439. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74440. /** @hidden */
  74441. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74442. meshes: AbstractMesh[];
  74443. particleSystems: IParticleSystem[];
  74444. skeletons: Skeleton[];
  74445. animationGroups: AnimationGroup[];
  74446. }>;
  74447. /** @hidden */
  74448. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74449. /** @hidden */
  74450. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74451. /** @hidden */
  74452. canDirectLoad(data: string): boolean;
  74453. /** @hidden */
  74454. directLoad(scene: Scene, data: string): any;
  74455. /**
  74456. * The callback that allows custom handling of the root url based on the response url.
  74457. * @param rootUrl the original root url
  74458. * @param responseURL the response url if available
  74459. * @returns the new root url
  74460. */
  74461. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74462. /** @hidden */
  74463. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74464. /**
  74465. * The loader state or null if the loader is not active.
  74466. */
  74467. get loaderState(): Nullable<GLTFLoaderState>;
  74468. /**
  74469. * Returns a promise that resolves when the asset is completely loaded.
  74470. * @returns a promise that resolves when the asset is completely loaded.
  74471. */
  74472. whenCompleteAsync(): Promise<void>;
  74473. private _validate;
  74474. private _getLoader;
  74475. private _parseJson;
  74476. private _unpackBinaryAsync;
  74477. private _unpackBinaryV1Async;
  74478. private _unpackBinaryV2Async;
  74479. private static _parseVersion;
  74480. private static _compareVersion;
  74481. private static readonly _logSpaces;
  74482. private _logIndentLevel;
  74483. private _loggingEnabled;
  74484. /** @hidden */
  74485. _log: (message: string) => void;
  74486. /** @hidden */
  74487. _logOpen(message: string): void;
  74488. /** @hidden */
  74489. _logClose(): void;
  74490. private _logEnabled;
  74491. private _logDisabled;
  74492. private _capturePerformanceCounters;
  74493. /** @hidden */
  74494. _startPerformanceCounter: (counterName: string) => void;
  74495. /** @hidden */
  74496. _endPerformanceCounter: (counterName: string) => void;
  74497. private _startPerformanceCounterEnabled;
  74498. private _startPerformanceCounterDisabled;
  74499. private _endPerformanceCounterEnabled;
  74500. private _endPerformanceCounterDisabled;
  74501. }
  74502. }
  74503. declare module BABYLON.GLTF1 {
  74504. /**
  74505. * Enums
  74506. * @hidden
  74507. */
  74508. export enum EComponentType {
  74509. BYTE = 5120,
  74510. UNSIGNED_BYTE = 5121,
  74511. SHORT = 5122,
  74512. UNSIGNED_SHORT = 5123,
  74513. FLOAT = 5126
  74514. }
  74515. /** @hidden */
  74516. export enum EShaderType {
  74517. FRAGMENT = 35632,
  74518. VERTEX = 35633
  74519. }
  74520. /** @hidden */
  74521. export enum EParameterType {
  74522. BYTE = 5120,
  74523. UNSIGNED_BYTE = 5121,
  74524. SHORT = 5122,
  74525. UNSIGNED_SHORT = 5123,
  74526. INT = 5124,
  74527. UNSIGNED_INT = 5125,
  74528. FLOAT = 5126,
  74529. FLOAT_VEC2 = 35664,
  74530. FLOAT_VEC3 = 35665,
  74531. FLOAT_VEC4 = 35666,
  74532. INT_VEC2 = 35667,
  74533. INT_VEC3 = 35668,
  74534. INT_VEC4 = 35669,
  74535. BOOL = 35670,
  74536. BOOL_VEC2 = 35671,
  74537. BOOL_VEC3 = 35672,
  74538. BOOL_VEC4 = 35673,
  74539. FLOAT_MAT2 = 35674,
  74540. FLOAT_MAT3 = 35675,
  74541. FLOAT_MAT4 = 35676,
  74542. SAMPLER_2D = 35678
  74543. }
  74544. /** @hidden */
  74545. export enum ETextureWrapMode {
  74546. CLAMP_TO_EDGE = 33071,
  74547. MIRRORED_REPEAT = 33648,
  74548. REPEAT = 10497
  74549. }
  74550. /** @hidden */
  74551. export enum ETextureFilterType {
  74552. NEAREST = 9728,
  74553. LINEAR = 9728,
  74554. NEAREST_MIPMAP_NEAREST = 9984,
  74555. LINEAR_MIPMAP_NEAREST = 9985,
  74556. NEAREST_MIPMAP_LINEAR = 9986,
  74557. LINEAR_MIPMAP_LINEAR = 9987
  74558. }
  74559. /** @hidden */
  74560. export enum ETextureFormat {
  74561. ALPHA = 6406,
  74562. RGB = 6407,
  74563. RGBA = 6408,
  74564. LUMINANCE = 6409,
  74565. LUMINANCE_ALPHA = 6410
  74566. }
  74567. /** @hidden */
  74568. export enum ECullingType {
  74569. FRONT = 1028,
  74570. BACK = 1029,
  74571. FRONT_AND_BACK = 1032
  74572. }
  74573. /** @hidden */
  74574. export enum EBlendingFunction {
  74575. ZERO = 0,
  74576. ONE = 1,
  74577. SRC_COLOR = 768,
  74578. ONE_MINUS_SRC_COLOR = 769,
  74579. DST_COLOR = 774,
  74580. ONE_MINUS_DST_COLOR = 775,
  74581. SRC_ALPHA = 770,
  74582. ONE_MINUS_SRC_ALPHA = 771,
  74583. DST_ALPHA = 772,
  74584. ONE_MINUS_DST_ALPHA = 773,
  74585. CONSTANT_COLOR = 32769,
  74586. ONE_MINUS_CONSTANT_COLOR = 32770,
  74587. CONSTANT_ALPHA = 32771,
  74588. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74589. SRC_ALPHA_SATURATE = 776
  74590. }
  74591. /** @hidden */
  74592. export interface IGLTFProperty {
  74593. extensions?: {
  74594. [key: string]: any;
  74595. };
  74596. extras?: Object;
  74597. }
  74598. /** @hidden */
  74599. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74600. name?: string;
  74601. }
  74602. /** @hidden */
  74603. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74604. bufferView: string;
  74605. byteOffset: number;
  74606. byteStride: number;
  74607. count: number;
  74608. type: string;
  74609. componentType: EComponentType;
  74610. max?: number[];
  74611. min?: number[];
  74612. name?: string;
  74613. }
  74614. /** @hidden */
  74615. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74616. buffer: string;
  74617. byteOffset: number;
  74618. byteLength: number;
  74619. byteStride: number;
  74620. target?: number;
  74621. }
  74622. /** @hidden */
  74623. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74624. uri: string;
  74625. byteLength?: number;
  74626. type?: string;
  74627. }
  74628. /** @hidden */
  74629. export interface IGLTFShader extends IGLTFChildRootProperty {
  74630. uri: string;
  74631. type: EShaderType;
  74632. }
  74633. /** @hidden */
  74634. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74635. attributes: string[];
  74636. fragmentShader: string;
  74637. vertexShader: string;
  74638. }
  74639. /** @hidden */
  74640. export interface IGLTFTechniqueParameter {
  74641. type: number;
  74642. count?: number;
  74643. semantic?: string;
  74644. node?: string;
  74645. value?: number | boolean | string | Array<any>;
  74646. source?: string;
  74647. babylonValue?: any;
  74648. }
  74649. /** @hidden */
  74650. export interface IGLTFTechniqueCommonProfile {
  74651. lightingModel: string;
  74652. texcoordBindings: Object;
  74653. parameters?: Array<any>;
  74654. }
  74655. /** @hidden */
  74656. export interface IGLTFTechniqueStatesFunctions {
  74657. blendColor?: number[];
  74658. blendEquationSeparate?: number[];
  74659. blendFuncSeparate?: number[];
  74660. colorMask: boolean[];
  74661. cullFace: number[];
  74662. }
  74663. /** @hidden */
  74664. export interface IGLTFTechniqueStates {
  74665. enable: number[];
  74666. functions: IGLTFTechniqueStatesFunctions;
  74667. }
  74668. /** @hidden */
  74669. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74670. parameters: {
  74671. [key: string]: IGLTFTechniqueParameter;
  74672. };
  74673. program: string;
  74674. attributes: {
  74675. [key: string]: string;
  74676. };
  74677. uniforms: {
  74678. [key: string]: string;
  74679. };
  74680. states: IGLTFTechniqueStates;
  74681. }
  74682. /** @hidden */
  74683. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74684. technique?: string;
  74685. values: string[];
  74686. }
  74687. /** @hidden */
  74688. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74689. attributes: {
  74690. [key: string]: string;
  74691. };
  74692. indices: string;
  74693. material: string;
  74694. mode?: number;
  74695. }
  74696. /** @hidden */
  74697. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74698. primitives: IGLTFMeshPrimitive[];
  74699. }
  74700. /** @hidden */
  74701. export interface IGLTFImage extends IGLTFChildRootProperty {
  74702. uri: string;
  74703. }
  74704. /** @hidden */
  74705. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74706. magFilter?: number;
  74707. minFilter?: number;
  74708. wrapS?: number;
  74709. wrapT?: number;
  74710. }
  74711. /** @hidden */
  74712. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74713. sampler: string;
  74714. source: string;
  74715. format?: ETextureFormat;
  74716. internalFormat?: ETextureFormat;
  74717. target?: number;
  74718. type?: number;
  74719. babylonTexture?: Texture;
  74720. }
  74721. /** @hidden */
  74722. export interface IGLTFAmbienLight {
  74723. color?: number[];
  74724. }
  74725. /** @hidden */
  74726. export interface IGLTFDirectionalLight {
  74727. color?: number[];
  74728. }
  74729. /** @hidden */
  74730. export interface IGLTFPointLight {
  74731. color?: number[];
  74732. constantAttenuation?: number;
  74733. linearAttenuation?: number;
  74734. quadraticAttenuation?: number;
  74735. }
  74736. /** @hidden */
  74737. export interface IGLTFSpotLight {
  74738. color?: number[];
  74739. constantAttenuation?: number;
  74740. fallOfAngle?: number;
  74741. fallOffExponent?: number;
  74742. linearAttenuation?: number;
  74743. quadraticAttenuation?: number;
  74744. }
  74745. /** @hidden */
  74746. export interface IGLTFLight extends IGLTFChildRootProperty {
  74747. type: string;
  74748. }
  74749. /** @hidden */
  74750. export interface IGLTFCameraOrthographic {
  74751. xmag: number;
  74752. ymag: number;
  74753. zfar: number;
  74754. znear: number;
  74755. }
  74756. /** @hidden */
  74757. export interface IGLTFCameraPerspective {
  74758. aspectRatio: number;
  74759. yfov: number;
  74760. zfar: number;
  74761. znear: number;
  74762. }
  74763. /** @hidden */
  74764. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74765. type: string;
  74766. }
  74767. /** @hidden */
  74768. export interface IGLTFAnimationChannelTarget {
  74769. id: string;
  74770. path: string;
  74771. }
  74772. /** @hidden */
  74773. export interface IGLTFAnimationChannel {
  74774. sampler: string;
  74775. target: IGLTFAnimationChannelTarget;
  74776. }
  74777. /** @hidden */
  74778. export interface IGLTFAnimationSampler {
  74779. input: string;
  74780. output: string;
  74781. interpolation?: string;
  74782. }
  74783. /** @hidden */
  74784. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74785. channels?: IGLTFAnimationChannel[];
  74786. parameters?: {
  74787. [key: string]: string;
  74788. };
  74789. samplers?: {
  74790. [key: string]: IGLTFAnimationSampler;
  74791. };
  74792. }
  74793. /** @hidden */
  74794. export interface IGLTFNodeInstanceSkin {
  74795. skeletons: string[];
  74796. skin: string;
  74797. meshes: string[];
  74798. }
  74799. /** @hidden */
  74800. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74801. bindShapeMatrix: number[];
  74802. inverseBindMatrices: string;
  74803. jointNames: string[];
  74804. babylonSkeleton?: Skeleton;
  74805. }
  74806. /** @hidden */
  74807. export interface IGLTFNode extends IGLTFChildRootProperty {
  74808. camera?: string;
  74809. children: string[];
  74810. skin?: string;
  74811. jointName?: string;
  74812. light?: string;
  74813. matrix: number[];
  74814. mesh?: string;
  74815. meshes?: string[];
  74816. rotation?: number[];
  74817. scale?: number[];
  74818. translation?: number[];
  74819. babylonNode?: Node;
  74820. }
  74821. /** @hidden */
  74822. export interface IGLTFScene extends IGLTFChildRootProperty {
  74823. nodes: string[];
  74824. }
  74825. /** @hidden */
  74826. export interface IGLTFRuntime {
  74827. extensions: {
  74828. [key: string]: any;
  74829. };
  74830. accessors: {
  74831. [key: string]: IGLTFAccessor;
  74832. };
  74833. buffers: {
  74834. [key: string]: IGLTFBuffer;
  74835. };
  74836. bufferViews: {
  74837. [key: string]: IGLTFBufferView;
  74838. };
  74839. meshes: {
  74840. [key: string]: IGLTFMesh;
  74841. };
  74842. lights: {
  74843. [key: string]: IGLTFLight;
  74844. };
  74845. cameras: {
  74846. [key: string]: IGLTFCamera;
  74847. };
  74848. nodes: {
  74849. [key: string]: IGLTFNode;
  74850. };
  74851. images: {
  74852. [key: string]: IGLTFImage;
  74853. };
  74854. textures: {
  74855. [key: string]: IGLTFTexture;
  74856. };
  74857. shaders: {
  74858. [key: string]: IGLTFShader;
  74859. };
  74860. programs: {
  74861. [key: string]: IGLTFProgram;
  74862. };
  74863. samplers: {
  74864. [key: string]: IGLTFSampler;
  74865. };
  74866. techniques: {
  74867. [key: string]: IGLTFTechnique;
  74868. };
  74869. materials: {
  74870. [key: string]: IGLTFMaterial;
  74871. };
  74872. animations: {
  74873. [key: string]: IGLTFAnimation;
  74874. };
  74875. skins: {
  74876. [key: string]: IGLTFSkins;
  74877. };
  74878. currentScene?: Object;
  74879. scenes: {
  74880. [key: string]: IGLTFScene;
  74881. };
  74882. extensionsUsed: string[];
  74883. extensionsRequired?: string[];
  74884. buffersCount: number;
  74885. shaderscount: number;
  74886. scene: Scene;
  74887. rootUrl: string;
  74888. loadedBufferCount: number;
  74889. loadedBufferViews: {
  74890. [name: string]: ArrayBufferView;
  74891. };
  74892. loadedShaderCount: number;
  74893. importOnlyMeshes: boolean;
  74894. importMeshesNames?: string[];
  74895. dummyNodes: Node[];
  74896. forAssetContainer: boolean;
  74897. }
  74898. /** @hidden */
  74899. export interface INodeToRoot {
  74900. bone: Bone;
  74901. node: IGLTFNode;
  74902. id: string;
  74903. }
  74904. /** @hidden */
  74905. export interface IJointNode {
  74906. node: IGLTFNode;
  74907. id: string;
  74908. }
  74909. }
  74910. declare module BABYLON.GLTF1 {
  74911. /**
  74912. * Utils functions for GLTF
  74913. * @hidden
  74914. */
  74915. export class GLTFUtils {
  74916. /**
  74917. * Sets the given "parameter" matrix
  74918. * @param scene: the Scene object
  74919. * @param source: the source node where to pick the matrix
  74920. * @param parameter: the GLTF technique parameter
  74921. * @param uniformName: the name of the shader's uniform
  74922. * @param shaderMaterial: the shader material
  74923. */
  74924. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74925. /**
  74926. * Sets the given "parameter" matrix
  74927. * @param shaderMaterial: the shader material
  74928. * @param uniform: the name of the shader's uniform
  74929. * @param value: the value of the uniform
  74930. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74931. */
  74932. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74933. /**
  74934. * Returns the wrap mode of the texture
  74935. * @param mode: the mode value
  74936. */
  74937. static GetWrapMode(mode: number): number;
  74938. /**
  74939. * Returns the byte stride giving an accessor
  74940. * @param accessor: the GLTF accessor objet
  74941. */
  74942. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74943. /**
  74944. * Returns the texture filter mode giving a mode value
  74945. * @param mode: the filter mode value
  74946. */
  74947. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74948. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74949. /**
  74950. * Returns a buffer from its accessor
  74951. * @param gltfRuntime: the GLTF runtime
  74952. * @param accessor: the GLTF accessor
  74953. */
  74954. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74955. /**
  74956. * Decodes a buffer view into a string
  74957. * @param view: the buffer view
  74958. */
  74959. static DecodeBufferToText(view: ArrayBufferView): string;
  74960. /**
  74961. * Returns the default material of gltf. Related to
  74962. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74963. * @param scene: the Babylon.js scene
  74964. */
  74965. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74966. private static _DefaultMaterial;
  74967. }
  74968. }
  74969. declare module BABYLON.GLTF1 {
  74970. /**
  74971. * Implementation of the base glTF spec
  74972. * @hidden
  74973. */
  74974. export class GLTFLoaderBase {
  74975. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74976. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74977. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74978. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74979. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74980. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74981. }
  74982. /**
  74983. * glTF V1 Loader
  74984. * @hidden
  74985. */
  74986. export class GLTFLoader implements IGLTFLoader {
  74987. static Extensions: {
  74988. [name: string]: GLTFLoaderExtension;
  74989. };
  74990. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74991. state: Nullable<GLTFLoaderState>;
  74992. dispose(): void;
  74993. private _importMeshAsync;
  74994. /**
  74995. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74996. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74997. * @param scene the scene the meshes should be added to
  74998. * @param forAssetContainer defines if the entities must be stored in the scene
  74999. * @param data gltf data containing information of the meshes in a loaded file
  75000. * @param rootUrl root url to load from
  75001. * @param onProgress event that fires when loading progress has occured
  75002. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75003. */
  75004. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75005. private _loadAsync;
  75006. /**
  75007. * Imports all objects from a loaded gltf file and adds them to the scene
  75008. * @param scene the scene the objects should be added to
  75009. * @param data gltf data containing information of the meshes in a loaded file
  75010. * @param rootUrl root url to load from
  75011. * @param onProgress event that fires when loading progress has occured
  75012. * @returns a promise which completes when objects have been loaded to the scene
  75013. */
  75014. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75015. private _loadShadersAsync;
  75016. private _loadBuffersAsync;
  75017. private _createNodes;
  75018. }
  75019. /** @hidden */
  75020. export abstract class GLTFLoaderExtension {
  75021. private _name;
  75022. constructor(name: string);
  75023. get name(): string;
  75024. /**
  75025. * Defines an override for loading the runtime
  75026. * Return true to stop further extensions from loading the runtime
  75027. */
  75028. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75029. /**
  75030. * Defines an onverride for creating gltf runtime
  75031. * Return true to stop further extensions from creating the runtime
  75032. */
  75033. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75034. /**
  75035. * Defines an override for loading buffers
  75036. * Return true to stop further extensions from loading this buffer
  75037. */
  75038. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75039. /**
  75040. * Defines an override for loading texture buffers
  75041. * Return true to stop further extensions from loading this texture data
  75042. */
  75043. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75044. /**
  75045. * Defines an override for creating textures
  75046. * Return true to stop further extensions from loading this texture
  75047. */
  75048. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75049. /**
  75050. * Defines an override for loading shader strings
  75051. * Return true to stop further extensions from loading this shader data
  75052. */
  75053. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75054. /**
  75055. * Defines an override for loading materials
  75056. * Return true to stop further extensions from loading this material
  75057. */
  75058. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75059. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75060. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75061. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75062. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75063. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75064. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75065. private static LoadTextureBufferAsync;
  75066. private static CreateTextureAsync;
  75067. private static ApplyExtensions;
  75068. }
  75069. }
  75070. declare module BABYLON.GLTF1 {
  75071. /** @hidden */
  75072. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75073. private _bin;
  75074. constructor();
  75075. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75076. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75077. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75078. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75079. }
  75080. }
  75081. declare module BABYLON.GLTF1 {
  75082. /** @hidden */
  75083. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75084. constructor();
  75085. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75086. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75087. private _loadTexture;
  75088. }
  75089. }
  75090. declare module BABYLON.GLTF2.Loader {
  75091. /**
  75092. * Loader interface with an index field.
  75093. */
  75094. export interface IArrayItem {
  75095. /**
  75096. * The index of this item in the array.
  75097. */
  75098. index: number;
  75099. }
  75100. /**
  75101. * Loader interface with additional members.
  75102. */
  75103. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75104. /** @hidden */
  75105. _data?: Promise<ArrayBufferView>;
  75106. /** @hidden */
  75107. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75108. }
  75109. /**
  75110. * Loader interface with additional members.
  75111. */
  75112. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75113. }
  75114. /** @hidden */
  75115. export interface _IAnimationSamplerData {
  75116. input: Float32Array;
  75117. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75118. output: Float32Array;
  75119. }
  75120. /**
  75121. * Loader interface with additional members.
  75122. */
  75123. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75124. /** @hidden */
  75125. _data?: Promise<_IAnimationSamplerData>;
  75126. }
  75127. /**
  75128. * Loader interface with additional members.
  75129. */
  75130. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75131. channels: IAnimationChannel[];
  75132. samplers: IAnimationSampler[];
  75133. /** @hidden */
  75134. _babylonAnimationGroup?: AnimationGroup;
  75135. }
  75136. /**
  75137. * Loader interface with additional members.
  75138. */
  75139. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75140. /** @hidden */
  75141. _data?: Promise<ArrayBufferView>;
  75142. }
  75143. /**
  75144. * Loader interface with additional members.
  75145. */
  75146. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75147. /** @hidden */
  75148. _data?: Promise<ArrayBufferView>;
  75149. /** @hidden */
  75150. _babylonBuffer?: Promise<Buffer>;
  75151. }
  75152. /**
  75153. * Loader interface with additional members.
  75154. */
  75155. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75156. }
  75157. /**
  75158. * Loader interface with additional members.
  75159. */
  75160. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75161. /** @hidden */
  75162. _data?: Promise<ArrayBufferView>;
  75163. }
  75164. /**
  75165. * Loader interface with additional members.
  75166. */
  75167. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75168. }
  75169. /**
  75170. * Loader interface with additional members.
  75171. */
  75172. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75173. }
  75174. /**
  75175. * Loader interface with additional members.
  75176. */
  75177. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75178. baseColorTexture?: ITextureInfo;
  75179. metallicRoughnessTexture?: ITextureInfo;
  75180. }
  75181. /**
  75182. * Loader interface with additional members.
  75183. */
  75184. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75185. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75186. normalTexture?: IMaterialNormalTextureInfo;
  75187. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75188. emissiveTexture?: ITextureInfo;
  75189. /** @hidden */
  75190. _data?: {
  75191. [babylonDrawMode: number]: {
  75192. babylonMaterial: Material;
  75193. babylonMeshes: AbstractMesh[];
  75194. promise: Promise<void>;
  75195. };
  75196. };
  75197. }
  75198. /**
  75199. * Loader interface with additional members.
  75200. */
  75201. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75202. primitives: IMeshPrimitive[];
  75203. }
  75204. /**
  75205. * Loader interface with additional members.
  75206. */
  75207. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75208. /** @hidden */
  75209. _instanceData?: {
  75210. babylonSourceMesh: Mesh;
  75211. promise: Promise<any>;
  75212. };
  75213. }
  75214. /**
  75215. * Loader interface with additional members.
  75216. */
  75217. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75218. /**
  75219. * The parent glTF node.
  75220. */
  75221. parent?: INode;
  75222. /** @hidden */
  75223. _babylonTransformNode?: TransformNode;
  75224. /** @hidden */
  75225. _primitiveBabylonMeshes?: AbstractMesh[];
  75226. /** @hidden */
  75227. _babylonBones?: Bone[];
  75228. /** @hidden */
  75229. _numMorphTargets?: number;
  75230. }
  75231. /** @hidden */
  75232. export interface _ISamplerData {
  75233. noMipMaps: boolean;
  75234. samplingMode: number;
  75235. wrapU: number;
  75236. wrapV: number;
  75237. }
  75238. /**
  75239. * Loader interface with additional members.
  75240. */
  75241. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75242. /** @hidden */
  75243. _data?: _ISamplerData;
  75244. }
  75245. /**
  75246. * Loader interface with additional members.
  75247. */
  75248. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75249. }
  75250. /**
  75251. * Loader interface with additional members.
  75252. */
  75253. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75254. /** @hidden */
  75255. _data?: {
  75256. babylonSkeleton: Skeleton;
  75257. promise: Promise<void>;
  75258. };
  75259. }
  75260. /**
  75261. * Loader interface with additional members.
  75262. */
  75263. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75264. }
  75265. /**
  75266. * Loader interface with additional members.
  75267. */
  75268. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75269. }
  75270. /**
  75271. * Loader interface with additional members.
  75272. */
  75273. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75274. accessors?: IAccessor[];
  75275. animations?: IAnimation[];
  75276. buffers?: IBuffer[];
  75277. bufferViews?: IBufferView[];
  75278. cameras?: ICamera[];
  75279. images?: IImage[];
  75280. materials?: IMaterial[];
  75281. meshes?: IMesh[];
  75282. nodes?: INode[];
  75283. samplers?: ISampler[];
  75284. scenes?: IScene[];
  75285. skins?: ISkin[];
  75286. textures?: ITexture[];
  75287. }
  75288. }
  75289. declare module BABYLON.GLTF2 {
  75290. /**
  75291. * Interface for a glTF loader extension.
  75292. */
  75293. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75294. /**
  75295. * Called after the loader state changes to LOADING.
  75296. */
  75297. onLoading?(): void;
  75298. /**
  75299. * Called after the loader state changes to READY.
  75300. */
  75301. onReady?(): void;
  75302. /**
  75303. * Define this method to modify the default behavior when loading scenes.
  75304. * @param context The context when loading the asset
  75305. * @param scene The glTF scene property
  75306. * @returns A promise that resolves when the load is complete or null if not handled
  75307. */
  75308. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75309. /**
  75310. * Define this method to modify the default behavior when loading nodes.
  75311. * @param context The context when loading the asset
  75312. * @param node The glTF node property
  75313. * @param assign A function called synchronously after parsing the glTF properties
  75314. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75315. */
  75316. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75317. /**
  75318. * Define this method to modify the default behavior when loading cameras.
  75319. * @param context The context when loading the asset
  75320. * @param camera The glTF camera property
  75321. * @param assign A function called synchronously after parsing the glTF properties
  75322. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75323. */
  75324. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75325. /**
  75326. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75327. * @param context The context when loading the asset
  75328. * @param primitive The glTF mesh primitive property
  75329. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75330. */
  75331. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75332. /**
  75333. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75334. * @param context The context when loading the asset
  75335. * @param name The mesh name when loading the asset
  75336. * @param node The glTF node when loading the asset
  75337. * @param mesh The glTF mesh when loading the asset
  75338. * @param primitive The glTF mesh primitive property
  75339. * @param assign A function called synchronously after parsing the glTF properties
  75340. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75341. */
  75342. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75343. /**
  75344. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75345. * @param context The context when loading the asset
  75346. * @param material The glTF material property
  75347. * @param assign A function called synchronously after parsing the glTF properties
  75348. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75349. */
  75350. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75351. /**
  75352. * Define this method to modify the default behavior when creating materials.
  75353. * @param context The context when loading the asset
  75354. * @param material The glTF material property
  75355. * @param babylonDrawMode The draw mode for the Babylon material
  75356. * @returns The Babylon material or null if not handled
  75357. */
  75358. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75359. /**
  75360. * Define this method to modify the default behavior when loading material properties.
  75361. * @param context The context when loading the asset
  75362. * @param material The glTF material property
  75363. * @param babylonMaterial The Babylon material
  75364. * @returns A promise that resolves when the load is complete or null if not handled
  75365. */
  75366. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75367. /**
  75368. * Define this method to modify the default behavior when loading texture infos.
  75369. * @param context The context when loading the asset
  75370. * @param textureInfo The glTF texture info property
  75371. * @param assign A function called synchronously after parsing the glTF properties
  75372. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75373. */
  75374. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75375. /**
  75376. * Define this method to modify the default behavior when loading animations.
  75377. * @param context The context when loading the asset
  75378. * @param animation The glTF animation property
  75379. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75380. */
  75381. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75382. /**
  75383. * @hidden Define this method to modify the default behavior when loading skins.
  75384. * @param context The context when loading the asset
  75385. * @param node The glTF node property
  75386. * @param skin The glTF skin property
  75387. * @returns A promise that resolves when the load is complete or null if not handled
  75388. */
  75389. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75390. /**
  75391. * @hidden Define this method to modify the default behavior when loading uris.
  75392. * @param context The context when loading the asset
  75393. * @param property The glTF property associated with the uri
  75394. * @param uri The uri to load
  75395. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75396. */
  75397. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75398. /**
  75399. * Define this method to modify the default behavior when loading buffer views.
  75400. * @param context The context when loading the asset
  75401. * @param bufferView The glTF buffer view property
  75402. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75403. */
  75404. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75405. /**
  75406. * Define this method to modify the default behavior when loading buffers.
  75407. * @param context The context when loading the asset
  75408. * @param buffer The glTF buffer property
  75409. * @param byteOffset The byte offset to load
  75410. * @param byteLength The byte length to load
  75411. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75412. */
  75413. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75414. }
  75415. }
  75416. declare module BABYLON.GLTF2 {
  75417. /**
  75418. * Helper class for working with arrays when loading the glTF asset
  75419. */
  75420. export class ArrayItem {
  75421. /**
  75422. * Gets an item from the given array.
  75423. * @param context The context when loading the asset
  75424. * @param array The array to get the item from
  75425. * @param index The index to the array
  75426. * @returns The array item
  75427. */
  75428. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75429. /**
  75430. * Assign an `index` field to each item of the given array.
  75431. * @param array The array of items
  75432. */
  75433. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75434. }
  75435. /**
  75436. * The glTF 2.0 loader
  75437. */
  75438. export class GLTFLoader implements IGLTFLoader {
  75439. /** @hidden */
  75440. _completePromises: Promise<any>[];
  75441. /** @hidden */
  75442. _forAssetContainer: boolean;
  75443. /** Storage */
  75444. _babylonLights: Light[];
  75445. private _disposed;
  75446. private _parent;
  75447. private _state;
  75448. private _extensions;
  75449. private _rootUrl;
  75450. private _fileName;
  75451. private _uniqueRootUrl;
  75452. private _gltf;
  75453. private _bin;
  75454. private _babylonScene;
  75455. private _rootBabylonMesh;
  75456. private _defaultBabylonMaterialData;
  75457. private _progressCallback?;
  75458. private _requests;
  75459. private static readonly _DefaultSampler;
  75460. private static _RegisteredExtensions;
  75461. /**
  75462. * Registers a loader extension.
  75463. * @param name The name of the loader extension.
  75464. * @param factory The factory function that creates the loader extension.
  75465. */
  75466. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75467. /**
  75468. * Unregisters a loader extension.
  75469. * @param name The name of the loader extension.
  75470. * @returns A boolean indicating whether the extension has been unregistered
  75471. */
  75472. static UnregisterExtension(name: string): boolean;
  75473. /**
  75474. * Gets the loader state.
  75475. */
  75476. get state(): Nullable<GLTFLoaderState>;
  75477. /**
  75478. * The object that represents the glTF JSON.
  75479. */
  75480. get gltf(): IGLTF;
  75481. /**
  75482. * The BIN chunk of a binary glTF.
  75483. */
  75484. get bin(): Nullable<IDataBuffer>;
  75485. /**
  75486. * The parent file loader.
  75487. */
  75488. get parent(): GLTFFileLoader;
  75489. /**
  75490. * The Babylon scene when loading the asset.
  75491. */
  75492. get babylonScene(): Scene;
  75493. /**
  75494. * The root Babylon mesh when loading the asset.
  75495. */
  75496. get rootBabylonMesh(): Mesh;
  75497. /** @hidden */
  75498. constructor(parent: GLTFFileLoader);
  75499. /** @hidden */
  75500. dispose(): void;
  75501. /** @hidden */
  75502. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  75503. /** @hidden */
  75504. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75505. private _loadAsync;
  75506. private _loadData;
  75507. private _setupData;
  75508. private _loadExtensions;
  75509. private _checkExtensions;
  75510. private _setState;
  75511. private _createRootNode;
  75512. /**
  75513. * Loads a glTF scene.
  75514. * @param context The context when loading the asset
  75515. * @param scene The glTF scene property
  75516. * @returns A promise that resolves when the load is complete
  75517. */
  75518. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75519. private _forEachPrimitive;
  75520. private _getMeshes;
  75521. private _getTransformNodes;
  75522. private _getSkeletons;
  75523. private _getAnimationGroups;
  75524. private _startAnimations;
  75525. /**
  75526. * Loads a glTF node.
  75527. * @param context The context when loading the asset
  75528. * @param node The glTF node property
  75529. * @param assign A function called synchronously after parsing the glTF properties
  75530. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75531. */
  75532. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75533. private _loadMeshAsync;
  75534. /**
  75535. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75536. * @param context The context when loading the asset
  75537. * @param name The mesh name when loading the asset
  75538. * @param node The glTF node when loading the asset
  75539. * @param mesh The glTF mesh when loading the asset
  75540. * @param primitive The glTF mesh primitive property
  75541. * @param assign A function called synchronously after parsing the glTF properties
  75542. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75543. */
  75544. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75545. private _loadVertexDataAsync;
  75546. private _createMorphTargets;
  75547. private _loadMorphTargetsAsync;
  75548. private _loadMorphTargetVertexDataAsync;
  75549. private static _LoadTransform;
  75550. private _loadSkinAsync;
  75551. private _loadBones;
  75552. private _loadBone;
  75553. private _loadSkinInverseBindMatricesDataAsync;
  75554. private _updateBoneMatrices;
  75555. private _getNodeMatrix;
  75556. /**
  75557. * Loads a glTF camera.
  75558. * @param context The context when loading the asset
  75559. * @param camera The glTF camera property
  75560. * @param assign A function called synchronously after parsing the glTF properties
  75561. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75562. */
  75563. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75564. private _loadAnimationsAsync;
  75565. /**
  75566. * Loads a glTF animation.
  75567. * @param context The context when loading the asset
  75568. * @param animation The glTF animation property
  75569. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75570. */
  75571. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75572. /**
  75573. * @hidden Loads a glTF animation channel.
  75574. * @param context The context when loading the asset
  75575. * @param animationContext The context of the animation when loading the asset
  75576. * @param animation The glTF animation property
  75577. * @param channel The glTF animation channel property
  75578. * @param babylonAnimationGroup The babylon animation group property
  75579. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75580. * @returns A void promise when the channel load is complete
  75581. */
  75582. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75583. private _loadAnimationSamplerAsync;
  75584. private _loadBufferAsync;
  75585. /**
  75586. * Loads a glTF buffer view.
  75587. * @param context The context when loading the asset
  75588. * @param bufferView The glTF buffer view property
  75589. * @returns A promise that resolves with the loaded data when the load is complete
  75590. */
  75591. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75592. private _loadAccessorAsync;
  75593. private _loadFloatAccessorAsync;
  75594. private _loadIndicesAccessorAsync;
  75595. private _loadVertexBufferViewAsync;
  75596. private _loadVertexAccessorAsync;
  75597. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75598. /** @hidden */
  75599. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75600. private _createDefaultMaterial;
  75601. /**
  75602. * Creates a Babylon material from a glTF material.
  75603. * @param context The context when loading the asset
  75604. * @param material The glTF material property
  75605. * @param babylonDrawMode The draw mode for the Babylon material
  75606. * @returns The Babylon material
  75607. */
  75608. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75609. /**
  75610. * Loads properties from a glTF material into a Babylon material.
  75611. * @param context The context when loading the asset
  75612. * @param material The glTF material property
  75613. * @param babylonMaterial The Babylon material
  75614. * @returns A promise that resolves when the load is complete
  75615. */
  75616. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75617. /**
  75618. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75619. * @param context The context when loading the asset
  75620. * @param material The glTF material property
  75621. * @param babylonMaterial The Babylon material
  75622. * @returns A promise that resolves when the load is complete
  75623. */
  75624. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75625. /**
  75626. * Loads the alpha properties from a glTF material into a Babylon material.
  75627. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75628. * @param context The context when loading the asset
  75629. * @param material The glTF material property
  75630. * @param babylonMaterial The Babylon material
  75631. */
  75632. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75633. /**
  75634. * Loads a glTF texture info.
  75635. * @param context The context when loading the asset
  75636. * @param textureInfo The glTF texture info property
  75637. * @param assign A function called synchronously after parsing the glTF properties
  75638. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75639. */
  75640. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75641. private _loadTextureAsync;
  75642. private _loadSampler;
  75643. /**
  75644. * Loads a glTF image.
  75645. * @param context The context when loading the asset
  75646. * @param image The glTF image property
  75647. * @returns A promise that resolves with the loaded data when the load is complete
  75648. */
  75649. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75650. /**
  75651. * Loads a glTF uri.
  75652. * @param context The context when loading the asset
  75653. * @param property The glTF property associated with the uri
  75654. * @param uri The base64 or relative uri
  75655. * @returns A promise that resolves with the loaded data when the load is complete
  75656. */
  75657. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75658. private _onProgress;
  75659. /**
  75660. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75661. * @param babylonObject the Babylon object with metadata
  75662. * @param pointer the JSON pointer
  75663. */
  75664. static AddPointerMetadata(babylonObject: {
  75665. metadata: any;
  75666. }, pointer: string): void;
  75667. private static _GetTextureWrapMode;
  75668. private static _GetTextureSamplingMode;
  75669. private static _GetTypedArrayConstructor;
  75670. private static _GetTypedArray;
  75671. private static _GetNumComponents;
  75672. private static _ValidateUri;
  75673. private static _GetDrawMode;
  75674. private _compileMaterialsAsync;
  75675. private _compileShadowGeneratorsAsync;
  75676. private _forEachExtensions;
  75677. private _applyExtensions;
  75678. private _extensionsOnLoading;
  75679. private _extensionsOnReady;
  75680. private _extensionsLoadSceneAsync;
  75681. private _extensionsLoadNodeAsync;
  75682. private _extensionsLoadCameraAsync;
  75683. private _extensionsLoadVertexDataAsync;
  75684. private _extensionsLoadMeshPrimitiveAsync;
  75685. private _extensionsLoadMaterialAsync;
  75686. private _extensionsCreateMaterial;
  75687. private _extensionsLoadMaterialPropertiesAsync;
  75688. private _extensionsLoadTextureInfoAsync;
  75689. private _extensionsLoadAnimationAsync;
  75690. private _extensionsLoadSkinAsync;
  75691. private _extensionsLoadUriAsync;
  75692. private _extensionsLoadBufferViewAsync;
  75693. private _extensionsLoadBufferAsync;
  75694. /**
  75695. * Helper method called by a loader extension to load an glTF extension.
  75696. * @param context The context when loading the asset
  75697. * @param property The glTF property to load the extension from
  75698. * @param extensionName The name of the extension to load
  75699. * @param actionAsync The action to run
  75700. * @returns The promise returned by actionAsync or null if the extension does not exist
  75701. */
  75702. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75703. /**
  75704. * Helper method called by a loader extension to load a glTF extra.
  75705. * @param context The context when loading the asset
  75706. * @param property The glTF property to load the extra from
  75707. * @param extensionName The name of the extension to load
  75708. * @param actionAsync The action to run
  75709. * @returns The promise returned by actionAsync or null if the extra does not exist
  75710. */
  75711. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75712. /**
  75713. * Checks for presence of an extension.
  75714. * @param name The name of the extension to check
  75715. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75716. */
  75717. isExtensionUsed(name: string): boolean;
  75718. /**
  75719. * Increments the indentation level and logs a message.
  75720. * @param message The message to log
  75721. */
  75722. logOpen(message: string): void;
  75723. /**
  75724. * Decrements the indentation level.
  75725. */
  75726. logClose(): void;
  75727. /**
  75728. * Logs a message
  75729. * @param message The message to log
  75730. */
  75731. log(message: string): void;
  75732. /**
  75733. * Starts a performance counter.
  75734. * @param counterName The name of the performance counter
  75735. */
  75736. startPerformanceCounter(counterName: string): void;
  75737. /**
  75738. * Ends a performance counter.
  75739. * @param counterName The name of the performance counter
  75740. */
  75741. endPerformanceCounter(counterName: string): void;
  75742. }
  75743. }
  75744. declare module BABYLON.GLTF2.Loader.Extensions {
  75745. /**
  75746. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75747. */
  75748. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75749. /**
  75750. * The name of this extension.
  75751. */
  75752. readonly name: string;
  75753. /**
  75754. * Defines whether this extension is enabled.
  75755. */
  75756. enabled: boolean;
  75757. private _loader;
  75758. private _lights?;
  75759. /** @hidden */
  75760. constructor(loader: GLTFLoader);
  75761. /** @hidden */
  75762. dispose(): void;
  75763. /** @hidden */
  75764. onLoading(): void;
  75765. /** @hidden */
  75766. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75767. private _loadLightAsync;
  75768. }
  75769. }
  75770. declare module BABYLON.GLTF2.Loader.Extensions {
  75771. /**
  75772. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75773. */
  75774. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75775. /**
  75776. * The name of this extension.
  75777. */
  75778. readonly name: string;
  75779. /**
  75780. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75781. */
  75782. dracoCompression?: DracoCompression;
  75783. /**
  75784. * Defines whether this extension is enabled.
  75785. */
  75786. enabled: boolean;
  75787. private _loader;
  75788. /** @hidden */
  75789. constructor(loader: GLTFLoader);
  75790. /** @hidden */
  75791. dispose(): void;
  75792. /** @hidden */
  75793. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75794. }
  75795. }
  75796. declare module BABYLON.GLTF2.Loader.Extensions {
  75797. /**
  75798. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75799. */
  75800. export class KHR_lights implements IGLTFLoaderExtension {
  75801. /**
  75802. * The name of this extension.
  75803. */
  75804. readonly name: string;
  75805. /**
  75806. * Defines whether this extension is enabled.
  75807. */
  75808. enabled: boolean;
  75809. private _loader;
  75810. private _lights?;
  75811. /** @hidden */
  75812. constructor(loader: GLTFLoader);
  75813. /** @hidden */
  75814. dispose(): void;
  75815. /** @hidden */
  75816. onLoading(): void;
  75817. /** @hidden */
  75818. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75819. }
  75820. }
  75821. declare module BABYLON.GLTF2.Loader.Extensions {
  75822. /**
  75823. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75824. */
  75825. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75826. /**
  75827. * The name of this extension.
  75828. */
  75829. readonly name: string;
  75830. /**
  75831. * Defines whether this extension is enabled.
  75832. */
  75833. enabled: boolean;
  75834. /**
  75835. * Defines a number that determines the order the extensions are applied.
  75836. */
  75837. order: number;
  75838. private _loader;
  75839. /** @hidden */
  75840. constructor(loader: GLTFLoader);
  75841. /** @hidden */
  75842. dispose(): void;
  75843. /** @hidden */
  75844. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75845. private _loadSpecularGlossinessPropertiesAsync;
  75846. }
  75847. }
  75848. declare module BABYLON.GLTF2.Loader.Extensions {
  75849. /**
  75850. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75851. */
  75852. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75853. /**
  75854. * The name of this extension.
  75855. */
  75856. readonly name: string;
  75857. /**
  75858. * Defines whether this extension is enabled.
  75859. */
  75860. enabled: boolean;
  75861. /**
  75862. * Defines a number that determines the order the extensions are applied.
  75863. */
  75864. order: number;
  75865. private _loader;
  75866. /** @hidden */
  75867. constructor(loader: GLTFLoader);
  75868. /** @hidden */
  75869. dispose(): void;
  75870. /** @hidden */
  75871. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75872. private _loadUnlitPropertiesAsync;
  75873. }
  75874. }
  75875. declare module BABYLON.GLTF2.Loader.Extensions {
  75876. /**
  75877. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75878. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75879. * !!! Experimental Extension Subject to Changes !!!
  75880. */
  75881. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75882. /**
  75883. * The name of this extension.
  75884. */
  75885. readonly name: string;
  75886. /**
  75887. * Defines whether this extension is enabled.
  75888. */
  75889. enabled: boolean;
  75890. /**
  75891. * Defines a number that determines the order the extensions are applied.
  75892. */
  75893. order: number;
  75894. private _loader;
  75895. /** @hidden */
  75896. constructor(loader: GLTFLoader);
  75897. /** @hidden */
  75898. dispose(): void;
  75899. /** @hidden */
  75900. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75901. private _loadClearCoatPropertiesAsync;
  75902. }
  75903. }
  75904. declare module BABYLON.GLTF2.Loader.Extensions {
  75905. /**
  75906. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75907. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75908. * !!! Experimental Extension Subject to Changes !!!
  75909. */
  75910. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75911. /**
  75912. * The name of this extension.
  75913. */
  75914. readonly name: string;
  75915. /**
  75916. * Defines whether this extension is enabled.
  75917. */
  75918. enabled: boolean;
  75919. /**
  75920. * Defines a number that determines the order the extensions are applied.
  75921. */
  75922. order: number;
  75923. private _loader;
  75924. /** @hidden */
  75925. constructor(loader: GLTFLoader);
  75926. /** @hidden */
  75927. dispose(): void;
  75928. /** @hidden */
  75929. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75930. private _loadSheenPropertiesAsync;
  75931. }
  75932. }
  75933. declare module BABYLON.GLTF2.Loader.Extensions {
  75934. /**
  75935. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75936. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75937. * !!! Experimental Extension Subject to Changes !!!
  75938. */
  75939. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75940. /**
  75941. * The name of this extension.
  75942. */
  75943. readonly name: string;
  75944. /**
  75945. * Defines whether this extension is enabled.
  75946. */
  75947. enabled: boolean;
  75948. /**
  75949. * Defines a number that determines the order the extensions are applied.
  75950. */
  75951. order: number;
  75952. private _loader;
  75953. /** @hidden */
  75954. constructor(loader: GLTFLoader);
  75955. /** @hidden */
  75956. dispose(): void;
  75957. /** @hidden */
  75958. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75959. private _loadSpecularPropertiesAsync;
  75960. }
  75961. }
  75962. declare module BABYLON.GLTF2.Loader.Extensions {
  75963. /**
  75964. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75965. */
  75966. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75967. /**
  75968. * The name of this extension.
  75969. */
  75970. readonly name: string;
  75971. /**
  75972. * Defines whether this extension is enabled.
  75973. */
  75974. enabled: boolean;
  75975. /** @hidden */
  75976. constructor(loader: GLTFLoader);
  75977. /** @hidden */
  75978. dispose(): void;
  75979. }
  75980. }
  75981. declare module BABYLON.GLTF2.Loader.Extensions {
  75982. /**
  75983. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75984. */
  75985. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75986. /**
  75987. * The name of this extension.
  75988. */
  75989. readonly name: string;
  75990. /**
  75991. * Defines whether this extension is enabled.
  75992. */
  75993. enabled: boolean;
  75994. private _loader;
  75995. /** @hidden */
  75996. constructor(loader: GLTFLoader);
  75997. /** @hidden */
  75998. dispose(): void;
  75999. /** @hidden */
  76000. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76001. }
  76002. }
  76003. declare module BABYLON.GLTF2.Loader.Extensions {
  76004. /**
  76005. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76006. */
  76007. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76008. /**
  76009. * The name of this extension.
  76010. */
  76011. readonly name: string;
  76012. /**
  76013. * Defines whether this extension is enabled.
  76014. */
  76015. enabled: boolean;
  76016. private _loader;
  76017. private _clips;
  76018. private _emitters;
  76019. /** @hidden */
  76020. constructor(loader: GLTFLoader);
  76021. /** @hidden */
  76022. dispose(): void;
  76023. /** @hidden */
  76024. onLoading(): void;
  76025. /** @hidden */
  76026. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76027. /** @hidden */
  76028. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76029. /** @hidden */
  76030. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76031. private _loadClipAsync;
  76032. private _loadEmitterAsync;
  76033. private _getEventAction;
  76034. private _loadAnimationEventAsync;
  76035. }
  76036. }
  76037. declare module BABYLON.GLTF2.Loader.Extensions {
  76038. /**
  76039. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76040. */
  76041. export class MSFT_lod implements IGLTFLoaderExtension {
  76042. /**
  76043. * The name of this extension.
  76044. */
  76045. readonly name: string;
  76046. /**
  76047. * Defines whether this extension is enabled.
  76048. */
  76049. enabled: boolean;
  76050. /**
  76051. * Defines a number that determines the order the extensions are applied.
  76052. */
  76053. order: number;
  76054. /**
  76055. * Maximum number of LODs to load, starting from the lowest LOD.
  76056. */
  76057. maxLODsToLoad: number;
  76058. /**
  76059. * Observable raised when all node LODs of one level are loaded.
  76060. * The event data is the index of the loaded LOD starting from zero.
  76061. * Dispose the loader to cancel the loading of the next level of LODs.
  76062. */
  76063. onNodeLODsLoadedObservable: Observable<number>;
  76064. /**
  76065. * Observable raised when all material LODs of one level are loaded.
  76066. * The event data is the index of the loaded LOD starting from zero.
  76067. * Dispose the loader to cancel the loading of the next level of LODs.
  76068. */
  76069. onMaterialLODsLoadedObservable: Observable<number>;
  76070. private _loader;
  76071. private _nodeIndexLOD;
  76072. private _nodeSignalLODs;
  76073. private _nodePromiseLODs;
  76074. private _materialIndexLOD;
  76075. private _materialSignalLODs;
  76076. private _materialPromiseLODs;
  76077. private _indexLOD;
  76078. private _bufferLODs;
  76079. /** @hidden */
  76080. constructor(loader: GLTFLoader);
  76081. /** @hidden */
  76082. dispose(): void;
  76083. /** @hidden */
  76084. onReady(): void;
  76085. /** @hidden */
  76086. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76087. /** @hidden */
  76088. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76089. /** @hidden */
  76090. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76091. /** @hidden */
  76092. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76093. /** @hidden */
  76094. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76095. private _loadBufferLOD;
  76096. /**
  76097. * Gets an array of LOD properties from lowest to highest.
  76098. */
  76099. private _getLODs;
  76100. private _disposeUnusedMaterials;
  76101. }
  76102. }
  76103. declare module BABYLON.GLTF2.Loader.Extensions {
  76104. /** @hidden */
  76105. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76106. readonly name: string;
  76107. enabled: boolean;
  76108. private _loader;
  76109. constructor(loader: GLTFLoader);
  76110. dispose(): void;
  76111. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76112. }
  76113. }
  76114. declare module BABYLON.GLTF2.Loader.Extensions {
  76115. /** @hidden */
  76116. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76117. readonly name: string;
  76118. enabled: boolean;
  76119. private _loader;
  76120. constructor(loader: GLTFLoader);
  76121. dispose(): void;
  76122. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76123. }
  76124. }
  76125. declare module BABYLON.GLTF2.Loader.Extensions {
  76126. /**
  76127. * Store glTF extras (if present) in BJS objects' metadata
  76128. */
  76129. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76130. /**
  76131. * The name of this extension.
  76132. */
  76133. readonly name: string;
  76134. /**
  76135. * Defines whether this extension is enabled.
  76136. */
  76137. enabled: boolean;
  76138. private _loader;
  76139. private _assignExtras;
  76140. /** @hidden */
  76141. constructor(loader: GLTFLoader);
  76142. /** @hidden */
  76143. dispose(): void;
  76144. /** @hidden */
  76145. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76146. /** @hidden */
  76147. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76148. /** @hidden */
  76149. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76150. }
  76151. }
  76152. declare module BABYLON {
  76153. /**
  76154. * Class reading and parsing the MTL file bundled with the obj file.
  76155. */
  76156. export class MTLFileLoader {
  76157. /**
  76158. * Invert Y-Axis of referenced textures on load
  76159. */
  76160. static INVERT_TEXTURE_Y: boolean;
  76161. /**
  76162. * All material loaded from the mtl will be set here
  76163. */
  76164. materials: StandardMaterial[];
  76165. /**
  76166. * This function will read the mtl file and create each material described inside
  76167. * This function could be improve by adding :
  76168. * -some component missing (Ni, Tf...)
  76169. * -including the specific options available
  76170. *
  76171. * @param scene defines the scene the material will be created in
  76172. * @param data defines the mtl data to parse
  76173. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76174. * @param forAssetContainer defines if the material should be registered in the scene
  76175. */
  76176. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76177. /**
  76178. * Gets the texture for the material.
  76179. *
  76180. * If the material is imported from input file,
  76181. * We sanitize the url to ensure it takes the textre from aside the material.
  76182. *
  76183. * @param rootUrl The root url to load from
  76184. * @param value The value stored in the mtl
  76185. * @return The Texture
  76186. */
  76187. private static _getTexture;
  76188. }
  76189. }
  76190. declare module BABYLON {
  76191. /**
  76192. * Options for loading OBJ/MTL files
  76193. */
  76194. type MeshLoadOptions = {
  76195. /**
  76196. * Defines if UVs are optimized by default during load.
  76197. */
  76198. OptimizeWithUV: boolean;
  76199. /**
  76200. * Defines custom scaling of UV coordinates of loaded meshes.
  76201. */
  76202. UVScaling: Vector2;
  76203. /**
  76204. * Invert model on y-axis (does a model scaling inversion)
  76205. */
  76206. InvertY: boolean;
  76207. /**
  76208. * Invert Y-Axis of referenced textures on load
  76209. */
  76210. InvertTextureY: boolean;
  76211. /**
  76212. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76213. */
  76214. ImportVertexColors: boolean;
  76215. /**
  76216. * Compute the normals for the model, even if normals are present in the file.
  76217. */
  76218. ComputeNormals: boolean;
  76219. /**
  76220. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76221. */
  76222. SkipMaterials: boolean;
  76223. /**
  76224. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76225. */
  76226. MaterialLoadingFailsSilently: boolean;
  76227. };
  76228. /**
  76229. * OBJ file type loader.
  76230. * This is a babylon scene loader plugin.
  76231. */
  76232. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76233. /**
  76234. * Defines if UVs are optimized by default during load.
  76235. */
  76236. static OPTIMIZE_WITH_UV: boolean;
  76237. /**
  76238. * Invert model on y-axis (does a model scaling inversion)
  76239. */
  76240. static INVERT_Y: boolean;
  76241. /**
  76242. * Invert Y-Axis of referenced textures on load
  76243. */
  76244. static get INVERT_TEXTURE_Y(): boolean;
  76245. static set INVERT_TEXTURE_Y(value: boolean);
  76246. /**
  76247. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76248. */
  76249. static IMPORT_VERTEX_COLORS: boolean;
  76250. /**
  76251. * Compute the normals for the model, even if normals are present in the file.
  76252. */
  76253. static COMPUTE_NORMALS: boolean;
  76254. /**
  76255. * Defines custom scaling of UV coordinates of loaded meshes.
  76256. */
  76257. static UV_SCALING: Vector2;
  76258. /**
  76259. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76260. */
  76261. static SKIP_MATERIALS: boolean;
  76262. /**
  76263. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76264. *
  76265. * Defaults to true for backwards compatibility.
  76266. */
  76267. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76268. /**
  76269. * Defines the name of the plugin.
  76270. */
  76271. name: string;
  76272. /**
  76273. * Defines the extension the plugin is able to load.
  76274. */
  76275. extensions: string;
  76276. /** @hidden */
  76277. obj: RegExp;
  76278. /** @hidden */
  76279. group: RegExp;
  76280. /** @hidden */
  76281. mtllib: RegExp;
  76282. /** @hidden */
  76283. usemtl: RegExp;
  76284. /** @hidden */
  76285. smooth: RegExp;
  76286. /** @hidden */
  76287. vertexPattern: RegExp;
  76288. /** @hidden */
  76289. normalPattern: RegExp;
  76290. /** @hidden */
  76291. uvPattern: RegExp;
  76292. /** @hidden */
  76293. facePattern1: RegExp;
  76294. /** @hidden */
  76295. facePattern2: RegExp;
  76296. /** @hidden */
  76297. facePattern3: RegExp;
  76298. /** @hidden */
  76299. facePattern4: RegExp;
  76300. /** @hidden */
  76301. facePattern5: RegExp;
  76302. private _forAssetContainer;
  76303. private _meshLoadOptions;
  76304. /**
  76305. * Creates loader for .OBJ files
  76306. *
  76307. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76308. */
  76309. constructor(meshLoadOptions?: MeshLoadOptions);
  76310. private static get currentMeshLoadOptions();
  76311. /**
  76312. * Calls synchronously the MTL file attached to this obj.
  76313. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76314. * Without this function materials are not displayed in the first frame (but displayed after).
  76315. * In consequence it is impossible to get material information in your HTML file
  76316. *
  76317. * @param url The URL of the MTL file
  76318. * @param rootUrl
  76319. * @param onSuccess Callback function to be called when the MTL file is loaded
  76320. * @private
  76321. */
  76322. private _loadMTL;
  76323. /**
  76324. * Instantiates a OBJ file loader plugin.
  76325. * @returns the created plugin
  76326. */
  76327. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76328. /**
  76329. * If the data string can be loaded directly.
  76330. *
  76331. * @param data string containing the file data
  76332. * @returns if the data can be loaded directly
  76333. */
  76334. canDirectLoad(data: string): boolean;
  76335. /**
  76336. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76337. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76338. * @param scene the scene the meshes should be added to
  76339. * @param data the OBJ data to load
  76340. * @param rootUrl root url to load from
  76341. * @param onProgress event that fires when loading progress has occured
  76342. * @param fileName Defines the name of the file to load
  76343. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76344. */
  76345. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76346. meshes: AbstractMesh[];
  76347. particleSystems: IParticleSystem[];
  76348. skeletons: Skeleton[];
  76349. animationGroups: AnimationGroup[];
  76350. }>;
  76351. /**
  76352. * Imports all objects from the loaded OBJ data and adds them to the scene
  76353. * @param scene the scene the objects should be added to
  76354. * @param data the OBJ data to load
  76355. * @param rootUrl root url to load from
  76356. * @param onProgress event that fires when loading progress has occured
  76357. * @param fileName Defines the name of the file to load
  76358. * @returns a promise which completes when objects have been loaded to the scene
  76359. */
  76360. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76361. /**
  76362. * Load into an asset container.
  76363. * @param scene The scene to load into
  76364. * @param data The data to import
  76365. * @param rootUrl The root url for scene and resources
  76366. * @param onProgress The callback when the load progresses
  76367. * @param fileName Defines the name of the file to load
  76368. * @returns The loaded asset container
  76369. */
  76370. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76371. /**
  76372. * Read the OBJ file and create an Array of meshes.
  76373. * Each mesh contains all information given by the OBJ and the MTL file.
  76374. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76375. *
  76376. * @param meshesNames
  76377. * @param scene Scene The scene where are displayed the data
  76378. * @param data String The content of the obj file
  76379. * @param rootUrl String The path to the folder
  76380. * @returns Array<AbstractMesh>
  76381. * @private
  76382. */
  76383. private _parseSolid;
  76384. }
  76385. }
  76386. declare module BABYLON {
  76387. /**
  76388. * STL file type loader.
  76389. * This is a babylon scene loader plugin.
  76390. */
  76391. export class STLFileLoader implements ISceneLoaderPlugin {
  76392. /** @hidden */
  76393. solidPattern: RegExp;
  76394. /** @hidden */
  76395. facetsPattern: RegExp;
  76396. /** @hidden */
  76397. normalPattern: RegExp;
  76398. /** @hidden */
  76399. vertexPattern: RegExp;
  76400. /**
  76401. * Defines the name of the plugin.
  76402. */
  76403. name: string;
  76404. /**
  76405. * Defines the extensions the stl loader is able to load.
  76406. * force data to come in as an ArrayBuffer
  76407. * we'll convert to string if it looks like it's an ASCII .stl
  76408. */
  76409. extensions: ISceneLoaderPluginExtensions;
  76410. /**
  76411. * Import meshes into a scene.
  76412. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76413. * @param scene The scene to import into
  76414. * @param data The data to import
  76415. * @param rootUrl The root url for scene and resources
  76416. * @param meshes The meshes array to import into
  76417. * @param particleSystems The particle systems array to import into
  76418. * @param skeletons The skeletons array to import into
  76419. * @param onError The callback when import fails
  76420. * @returns True if successful or false otherwise
  76421. */
  76422. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76423. /**
  76424. * Load into a scene.
  76425. * @param scene The scene to load into
  76426. * @param data The data to import
  76427. * @param rootUrl The root url for scene and resources
  76428. * @param onError The callback when import fails
  76429. * @returns true if successful or false otherwise
  76430. */
  76431. load(scene: Scene, data: any, rootUrl: string): boolean;
  76432. /**
  76433. * Load into an asset container.
  76434. * @param scene The scene to load into
  76435. * @param data The data to import
  76436. * @param rootUrl The root url for scene and resources
  76437. * @param onError The callback when import fails
  76438. * @returns The loaded asset container
  76439. */
  76440. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76441. private _isBinary;
  76442. private _parseBinary;
  76443. private _parseASCII;
  76444. }
  76445. }
  76446. declare module BABYLON {
  76447. /**
  76448. * Class for generating OBJ data from a Babylon scene.
  76449. */
  76450. export class OBJExport {
  76451. /**
  76452. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76453. * @param mesh defines the list of meshes to serialize
  76454. * @param materials defines if materials should be exported
  76455. * @param matlibname defines the name of the associated mtl file
  76456. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76457. * @returns the OBJ content
  76458. */
  76459. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76460. /**
  76461. * Exports the material(s) of a mesh in .MTL file format (text)
  76462. * @param mesh defines the mesh to extract the material from
  76463. * @returns the mtl content
  76464. */
  76465. static MTL(mesh: Mesh): string;
  76466. }
  76467. }
  76468. declare module BABYLON {
  76469. /** @hidden */
  76470. export var __IGLTFExporterExtension: number;
  76471. /**
  76472. * Interface for extending the exporter
  76473. * @hidden
  76474. */
  76475. export interface IGLTFExporterExtension {
  76476. /**
  76477. * The name of this extension
  76478. */
  76479. readonly name: string;
  76480. /**
  76481. * Defines whether this extension is enabled
  76482. */
  76483. enabled: boolean;
  76484. /**
  76485. * Defines whether this extension is required
  76486. */
  76487. required: boolean;
  76488. }
  76489. }
  76490. declare module BABYLON.GLTF2.Exporter {
  76491. /** @hidden */
  76492. export var __IGLTFExporterExtensionV2: number;
  76493. /**
  76494. * Interface for a glTF exporter extension
  76495. * @hidden
  76496. */
  76497. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76498. /**
  76499. * Define this method to modify the default behavior before exporting a texture
  76500. * @param context The context when loading the asset
  76501. * @param babylonTexture The Babylon.js texture
  76502. * @param mimeType The mime-type of the generated image
  76503. * @returns A promise that resolves with the exported texture
  76504. */
  76505. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76506. /**
  76507. * Define this method to get notified when a texture info is created
  76508. * @param context The context when loading the asset
  76509. * @param textureInfo The glTF texture info
  76510. * @param babylonTexture The Babylon.js texture
  76511. */
  76512. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76513. /**
  76514. * Define this method to modify the default behavior when exporting texture info
  76515. * @param context The context when loading the asset
  76516. * @param meshPrimitive glTF mesh primitive
  76517. * @param babylonSubMesh Babylon submesh
  76518. * @param binaryWriter glTF serializer binary writer instance
  76519. * @returns nullable IMeshPrimitive promise
  76520. */
  76521. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76522. /**
  76523. * Define this method to modify the default behavior when exporting a node
  76524. * @param context The context when exporting the node
  76525. * @param node glTF node
  76526. * @param babylonNode BabylonJS node
  76527. * @returns nullable INode promise
  76528. */
  76529. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76530. /**
  76531. * Define this method to modify the default behavior when exporting a material
  76532. * @param material glTF material
  76533. * @param babylonMaterial BabylonJS material
  76534. * @returns nullable IMaterial promise
  76535. */
  76536. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76537. /**
  76538. * Define this method to return additional textures to export from a material
  76539. * @param material glTF material
  76540. * @param babylonMaterial BabylonJS material
  76541. * @returns List of textures
  76542. */
  76543. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76544. /** Gets a boolean indicating that this extension was used */
  76545. wasUsed: boolean;
  76546. /** Gets a boolean indicating that this extension is required for the file to work */
  76547. required: boolean;
  76548. /**
  76549. * Called after the exporter state changes to EXPORTING
  76550. */
  76551. onExporting?(): void;
  76552. }
  76553. }
  76554. declare module BABYLON.GLTF2.Exporter {
  76555. /**
  76556. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76557. * @hidden
  76558. */
  76559. export class _GLTFMaterialExporter {
  76560. /**
  76561. * Represents the dielectric specular values for R, G and B
  76562. */
  76563. private static readonly _DielectricSpecular;
  76564. /**
  76565. * Allows the maximum specular power to be defined for material calculations
  76566. */
  76567. private static readonly _MaxSpecularPower;
  76568. /**
  76569. * Mapping to store textures
  76570. */
  76571. private _textureMap;
  76572. /**
  76573. * Numeric tolerance value
  76574. */
  76575. private static readonly _Epsilon;
  76576. /**
  76577. * Reference to the glTF Exporter
  76578. */
  76579. private _exporter;
  76580. constructor(exporter: _Exporter);
  76581. /**
  76582. * Specifies if two colors are approximately equal in value
  76583. * @param color1 first color to compare to
  76584. * @param color2 second color to compare to
  76585. * @param epsilon threshold value
  76586. */
  76587. private static FuzzyEquals;
  76588. /**
  76589. * Gets the materials from a Babylon scene and converts them to glTF materials
  76590. * @param scene babylonjs scene
  76591. * @param mimeType texture mime type
  76592. * @param images array of images
  76593. * @param textures array of textures
  76594. * @param materials array of materials
  76595. * @param imageData mapping of texture names to base64 textures
  76596. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76597. */
  76598. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76599. /**
  76600. * Makes a copy of the glTF material without the texture parameters
  76601. * @param originalMaterial original glTF material
  76602. * @returns glTF material without texture parameters
  76603. */
  76604. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76605. /**
  76606. * Specifies if the material has any texture parameters present
  76607. * @param material glTF Material
  76608. * @returns boolean specifying if texture parameters are present
  76609. */
  76610. _hasTexturesPresent(material: IMaterial): boolean;
  76611. /**
  76612. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76613. * @param babylonStandardMaterial
  76614. * @returns glTF Metallic Roughness Material representation
  76615. */
  76616. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76617. /**
  76618. * Computes the metallic factor
  76619. * @param diffuse diffused value
  76620. * @param specular specular value
  76621. * @param oneMinusSpecularStrength one minus the specular strength
  76622. * @returns metallic value
  76623. */
  76624. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76625. /**
  76626. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76627. * @param glTFMaterial glTF material
  76628. * @param babylonMaterial Babylon material
  76629. */
  76630. private static _SetAlphaMode;
  76631. /**
  76632. * Converts a Babylon Standard Material to a glTF Material
  76633. * @param babylonStandardMaterial BJS Standard Material
  76634. * @param mimeType mime type to use for the textures
  76635. * @param images array of glTF image interfaces
  76636. * @param textures array of glTF texture interfaces
  76637. * @param materials array of glTF material interfaces
  76638. * @param imageData map of image file name to data
  76639. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76640. */
  76641. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76642. private _finishMaterial;
  76643. /**
  76644. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76645. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76646. * @param mimeType mime type to use for the textures
  76647. * @param images array of glTF image interfaces
  76648. * @param textures array of glTF texture interfaces
  76649. * @param materials array of glTF material interfaces
  76650. * @param imageData map of image file name to data
  76651. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76652. */
  76653. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76654. /**
  76655. * Converts an image typed array buffer to a base64 image
  76656. * @param buffer typed array buffer
  76657. * @param width width of the image
  76658. * @param height height of the image
  76659. * @param mimeType mimetype of the image
  76660. * @returns base64 image string
  76661. */
  76662. private _createBase64FromCanvasAsync;
  76663. /**
  76664. * Generates a white texture based on the specified width and height
  76665. * @param width width of the texture in pixels
  76666. * @param height height of the texture in pixels
  76667. * @param scene babylonjs scene
  76668. * @returns white texture
  76669. */
  76670. private _createWhiteTexture;
  76671. /**
  76672. * 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
  76673. * @param texture1 first texture to resize
  76674. * @param texture2 second texture to resize
  76675. * @param scene babylonjs scene
  76676. * @returns resized textures or null
  76677. */
  76678. private _resizeTexturesToSameDimensions;
  76679. /**
  76680. * Converts an array of pixels to a Float32Array
  76681. * Throws an error if the pixel format is not supported
  76682. * @param pixels - array buffer containing pixel values
  76683. * @returns Float32 of pixels
  76684. */
  76685. private _convertPixelArrayToFloat32;
  76686. /**
  76687. * Convert Specular Glossiness Textures to Metallic Roughness
  76688. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76689. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76690. * @param diffuseTexture texture used to store diffuse information
  76691. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76692. * @param factors specular glossiness material factors
  76693. * @param mimeType the mime type to use for the texture
  76694. * @returns pbr metallic roughness interface or null
  76695. */
  76696. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76697. /**
  76698. * Converts specular glossiness material properties to metallic roughness
  76699. * @param specularGlossiness interface with specular glossiness material properties
  76700. * @returns interface with metallic roughness material properties
  76701. */
  76702. private _convertSpecularGlossinessToMetallicRoughness;
  76703. /**
  76704. * Calculates the surface reflectance, independent of lighting conditions
  76705. * @param color Color source to calculate brightness from
  76706. * @returns number representing the perceived brightness, or zero if color is undefined
  76707. */
  76708. private _getPerceivedBrightness;
  76709. /**
  76710. * Returns the maximum color component value
  76711. * @param color
  76712. * @returns maximum color component value, or zero if color is null or undefined
  76713. */
  76714. private _getMaxComponent;
  76715. /**
  76716. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76717. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76718. * @param mimeType mime type to use for the textures
  76719. * @param images array of glTF image interfaces
  76720. * @param textures array of glTF texture interfaces
  76721. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76722. * @param imageData map of image file name to data
  76723. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76724. * @returns glTF PBR Metallic Roughness factors
  76725. */
  76726. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76727. private _getGLTFTextureSampler;
  76728. private _getGLTFTextureWrapMode;
  76729. private _getGLTFTextureWrapModesSampler;
  76730. /**
  76731. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76732. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76733. * @param mimeType mime type to use for the textures
  76734. * @param images array of glTF image interfaces
  76735. * @param textures array of glTF texture interfaces
  76736. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76737. * @param imageData map of image file name to data
  76738. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76739. * @returns glTF PBR Metallic Roughness factors
  76740. */
  76741. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76742. /**
  76743. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76744. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76745. * @param mimeType mime type to use for the textures
  76746. * @param images array of glTF image interfaces
  76747. * @param textures array of glTF texture interfaces
  76748. * @param materials array of glTF material interfaces
  76749. * @param imageData map of image file name to data
  76750. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76751. */
  76752. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76753. private setMetallicRoughnessPbrMaterial;
  76754. private getPixelsFromTexture;
  76755. /**
  76756. * Extracts a texture from a Babylon texture into file data and glTF data
  76757. * @param babylonTexture Babylon texture to extract
  76758. * @param mimeType Mime Type of the babylonTexture
  76759. * @return glTF texture info, or null if the texture format is not supported
  76760. */
  76761. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76762. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76763. /**
  76764. * Builds a texture from base64 string
  76765. * @param base64Texture base64 texture string
  76766. * @param baseTextureName Name to use for the texture
  76767. * @param mimeType image mime type for the texture
  76768. * @param images array of images
  76769. * @param textures array of textures
  76770. * @param imageData map of image data
  76771. * @returns glTF texture info, or null if the texture format is not supported
  76772. */
  76773. private _getTextureInfoFromBase64;
  76774. }
  76775. }
  76776. declare module BABYLON {
  76777. /**
  76778. * Class for holding and downloading glTF file data
  76779. */
  76780. export class GLTFData {
  76781. /**
  76782. * Object which contains the file name as the key and its data as the value
  76783. */
  76784. glTFFiles: {
  76785. [fileName: string]: string | Blob;
  76786. };
  76787. /**
  76788. * Initializes the glTF file object
  76789. */
  76790. constructor();
  76791. /**
  76792. * Downloads the glTF data as files based on their names and data
  76793. */
  76794. downloadFiles(): void;
  76795. }
  76796. }
  76797. declare module BABYLON {
  76798. /**
  76799. * Holds a collection of exporter options and parameters
  76800. */
  76801. export interface IExportOptions {
  76802. /**
  76803. * Function which indicates whether a babylon node should be exported or not
  76804. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76805. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76806. */
  76807. shouldExportNode?(node: Node): boolean;
  76808. /**
  76809. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76810. * @param metadata source metadata to read from
  76811. * @returns the data to store to glTF node extras
  76812. */
  76813. metadataSelector?(metadata: any): any;
  76814. /**
  76815. * The sample rate to bake animation curves
  76816. */
  76817. animationSampleRate?: number;
  76818. /**
  76819. * Begin serialization without waiting for the scene to be ready
  76820. */
  76821. exportWithoutWaitingForScene?: boolean;
  76822. }
  76823. /**
  76824. * Class for generating glTF data from a Babylon scene.
  76825. */
  76826. export class GLTF2Export {
  76827. /**
  76828. * Exports the geometry of the scene to .gltf file format asynchronously
  76829. * @param scene Babylon scene with scene hierarchy information
  76830. * @param filePrefix File prefix to use when generating the glTF file
  76831. * @param options Exporter options
  76832. * @returns Returns an object with a .gltf file and associates texture names
  76833. * as keys and their data and paths as values
  76834. */
  76835. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76836. private static _PreExportAsync;
  76837. private static _PostExportAsync;
  76838. /**
  76839. * Exports the geometry of the scene to .glb file format asychronously
  76840. * @param scene Babylon scene with scene hierarchy information
  76841. * @param filePrefix File prefix to use when generating glb file
  76842. * @param options Exporter options
  76843. * @returns Returns an object with a .glb filename as key and data as value
  76844. */
  76845. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76846. }
  76847. }
  76848. declare module BABYLON.GLTF2.Exporter {
  76849. /**
  76850. * @hidden
  76851. */
  76852. export class _GLTFUtilities {
  76853. /**
  76854. * Creates a buffer view based on the supplied arguments
  76855. * @param bufferIndex index value of the specified buffer
  76856. * @param byteOffset byte offset value
  76857. * @param byteLength byte length of the bufferView
  76858. * @param byteStride byte distance between conequential elements
  76859. * @param name name of the buffer view
  76860. * @returns bufferView for glTF
  76861. */
  76862. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76863. /**
  76864. * Creates an accessor based on the supplied arguments
  76865. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76866. * @param name The name of the accessor
  76867. * @param type The type of the accessor
  76868. * @param componentType The datatype of components in the attribute
  76869. * @param count The number of attributes referenced by this accessor
  76870. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76871. * @param min Minimum value of each component in this attribute
  76872. * @param max Maximum value of each component in this attribute
  76873. * @returns accessor for glTF
  76874. */
  76875. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76876. /**
  76877. * Calculates the minimum and maximum values of an array of position floats
  76878. * @param positions Positions array of a mesh
  76879. * @param vertexStart Starting vertex offset to calculate min and max values
  76880. * @param vertexCount Number of vertices to check for min and max values
  76881. * @returns min number array and max number array
  76882. */
  76883. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76884. min: number[];
  76885. max: number[];
  76886. };
  76887. /**
  76888. * Converts a new right-handed Vector3
  76889. * @param vector vector3 array
  76890. * @returns right-handed Vector3
  76891. */
  76892. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76893. /**
  76894. * Converts a Vector3 to right-handed
  76895. * @param vector Vector3 to convert to right-handed
  76896. */
  76897. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76898. /**
  76899. * Converts a three element number array to right-handed
  76900. * @param vector number array to convert to right-handed
  76901. */
  76902. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76903. /**
  76904. * Converts a new right-handed Vector3
  76905. * @param vector vector3 array
  76906. * @returns right-handed Vector3
  76907. */
  76908. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76909. /**
  76910. * Converts a Vector3 to right-handed
  76911. * @param vector Vector3 to convert to right-handed
  76912. */
  76913. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76914. /**
  76915. * Converts a three element number array to right-handed
  76916. * @param vector number array to convert to right-handed
  76917. */
  76918. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76919. /**
  76920. * Converts a Vector4 to right-handed
  76921. * @param vector Vector4 to convert to right-handed
  76922. */
  76923. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76924. /**
  76925. * Converts a Vector4 to right-handed
  76926. * @param vector Vector4 to convert to right-handed
  76927. */
  76928. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76929. /**
  76930. * Converts a Quaternion to right-handed
  76931. * @param quaternion Source quaternion to convert to right-handed
  76932. */
  76933. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76934. /**
  76935. * Converts a Quaternion to right-handed
  76936. * @param quaternion Source quaternion to convert to right-handed
  76937. */
  76938. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76939. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76940. }
  76941. }
  76942. declare module BABYLON.GLTF2.Exporter {
  76943. /**
  76944. * Converts Babylon Scene into glTF 2.0.
  76945. * @hidden
  76946. */
  76947. export class _Exporter {
  76948. /**
  76949. * Stores the glTF to export
  76950. */
  76951. _glTF: IGLTF;
  76952. /**
  76953. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76954. */
  76955. _bufferViews: IBufferView[];
  76956. /**
  76957. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76958. */
  76959. _accessors: IAccessor[];
  76960. /**
  76961. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76962. */
  76963. private _nodes;
  76964. /**
  76965. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76966. */
  76967. private _scenes;
  76968. /**
  76969. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76970. */
  76971. private _meshes;
  76972. /**
  76973. * Stores all the generated material information, which represents the appearance of each primitive
  76974. */
  76975. _materials: IMaterial[];
  76976. _materialMap: {
  76977. [materialID: number]: number;
  76978. };
  76979. /**
  76980. * Stores all the generated texture information, which is referenced by glTF materials
  76981. */
  76982. _textures: ITexture[];
  76983. /**
  76984. * Stores all the generated image information, which is referenced by glTF textures
  76985. */
  76986. _images: IImage[];
  76987. /**
  76988. * Stores all the texture samplers
  76989. */
  76990. _samplers: ISampler[];
  76991. /**
  76992. * Stores all the generated animation samplers, which is referenced by glTF animations
  76993. */
  76994. /**
  76995. * Stores the animations for glTF models
  76996. */
  76997. private _animations;
  76998. /**
  76999. * Stores the total amount of bytes stored in the glTF buffer
  77000. */
  77001. private _totalByteLength;
  77002. /**
  77003. * Stores a reference to the Babylon scene containing the source geometry and material information
  77004. */
  77005. _babylonScene: Scene;
  77006. /**
  77007. * Stores a map of the image data, where the key is the file name and the value
  77008. * is the image data
  77009. */
  77010. _imageData: {
  77011. [fileName: string]: {
  77012. data: Uint8Array;
  77013. mimeType: ImageMimeType;
  77014. };
  77015. };
  77016. /**
  77017. * Stores a map of the unique id of a node to its index in the node array
  77018. */
  77019. private _nodeMap;
  77020. /**
  77021. * Specifies if the Babylon scene should be converted to right-handed on export
  77022. */
  77023. _convertToRightHandedSystem: boolean;
  77024. /**
  77025. * Baked animation sample rate
  77026. */
  77027. private _animationSampleRate;
  77028. private _options;
  77029. private _localEngine;
  77030. _glTFMaterialExporter: _GLTFMaterialExporter;
  77031. private _extensions;
  77032. private static _ExtensionNames;
  77033. private static _ExtensionFactories;
  77034. private _applyExtension;
  77035. private _applyExtensions;
  77036. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77037. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77038. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  77039. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77040. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77041. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77042. private _forEachExtensions;
  77043. private _extensionsOnExporting;
  77044. /**
  77045. * Load glTF serializer extensions
  77046. */
  77047. private _loadExtensions;
  77048. /**
  77049. * Creates a glTF Exporter instance, which can accept optional exporter options
  77050. * @param babylonScene Babylon scene object
  77051. * @param options Options to modify the behavior of the exporter
  77052. */
  77053. constructor(babylonScene: Scene, options?: IExportOptions);
  77054. dispose(): void;
  77055. /**
  77056. * Registers a glTF exporter extension
  77057. * @param name Name of the extension to export
  77058. * @param factory The factory function that creates the exporter extension
  77059. */
  77060. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77061. /**
  77062. * Un-registers an exporter extension
  77063. * @param name The name fo the exporter extension
  77064. * @returns A boolean indicating whether the extension has been un-registered
  77065. */
  77066. static UnregisterExtension(name: string): boolean;
  77067. /**
  77068. * Lazy load a local engine
  77069. */
  77070. _getLocalEngine(): Engine;
  77071. private reorderIndicesBasedOnPrimitiveMode;
  77072. /**
  77073. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77074. * clock-wise during export to glTF
  77075. * @param submesh BabylonJS submesh
  77076. * @param primitiveMode Primitive mode of the mesh
  77077. * @param sideOrientation the winding order of the submesh
  77078. * @param vertexBufferKind The type of vertex attribute
  77079. * @param meshAttributeArray The vertex attribute data
  77080. * @param byteOffset The offset to the binary data
  77081. * @param binaryWriter The binary data for the glTF file
  77082. */
  77083. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77084. /**
  77085. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77086. * clock-wise during export to glTF
  77087. * @param submesh BabylonJS submesh
  77088. * @param primitiveMode Primitive mode of the mesh
  77089. * @param sideOrientation the winding order of the submesh
  77090. * @param vertexBufferKind The type of vertex attribute
  77091. * @param meshAttributeArray The vertex attribute data
  77092. * @param byteOffset The offset to the binary data
  77093. * @param binaryWriter The binary data for the glTF file
  77094. */
  77095. private reorderTriangleFillMode;
  77096. /**
  77097. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77098. * clock-wise during export to glTF
  77099. * @param submesh BabylonJS submesh
  77100. * @param primitiveMode Primitive mode of the mesh
  77101. * @param sideOrientation the winding order of the submesh
  77102. * @param vertexBufferKind The type of vertex attribute
  77103. * @param meshAttributeArray The vertex attribute data
  77104. * @param byteOffset The offset to the binary data
  77105. * @param binaryWriter The binary data for the glTF file
  77106. */
  77107. private reorderTriangleStripDrawMode;
  77108. /**
  77109. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77110. * clock-wise during export to glTF
  77111. * @param submesh BabylonJS submesh
  77112. * @param primitiveMode Primitive mode of the mesh
  77113. * @param sideOrientation the winding order of the submesh
  77114. * @param vertexBufferKind The type of vertex attribute
  77115. * @param meshAttributeArray The vertex attribute data
  77116. * @param byteOffset The offset to the binary data
  77117. * @param binaryWriter The binary data for the glTF file
  77118. */
  77119. private reorderTriangleFanMode;
  77120. /**
  77121. * Writes the vertex attribute data to binary
  77122. * @param vertices The vertices to write to the binary writer
  77123. * @param byteOffset The offset into the binary writer to overwrite binary data
  77124. * @param vertexAttributeKind The vertex attribute type
  77125. * @param meshAttributeArray The vertex attribute data
  77126. * @param binaryWriter The writer containing the binary data
  77127. */
  77128. private writeVertexAttributeData;
  77129. /**
  77130. * Writes mesh attribute data to a data buffer
  77131. * Returns the bytelength of the data
  77132. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77133. * @param meshAttributeArray Array containing the attribute data
  77134. * @param binaryWriter The buffer to write the binary data to
  77135. * @param indices Used to specify the order of the vertex data
  77136. */
  77137. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  77138. /**
  77139. * Generates glTF json data
  77140. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77141. * @param glTFPrefix Text to use when prefixing a glTF file
  77142. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77143. * @returns json data as string
  77144. */
  77145. private generateJSON;
  77146. /**
  77147. * Generates data for .gltf and .bin files based on the glTF prefix string
  77148. * @param glTFPrefix Text to use when prefixing a glTF file
  77149. * @param dispose Dispose the exporter
  77150. * @returns GLTFData with glTF file data
  77151. */
  77152. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77153. /**
  77154. * Creates a binary buffer for glTF
  77155. * @returns array buffer for binary data
  77156. */
  77157. private _generateBinaryAsync;
  77158. /**
  77159. * Pads the number to a multiple of 4
  77160. * @param num number to pad
  77161. * @returns padded number
  77162. */
  77163. private _getPadding;
  77164. /**
  77165. * @hidden
  77166. */
  77167. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77168. /**
  77169. * Sets the TRS for each node
  77170. * @param node glTF Node for storing the transformation data
  77171. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77172. */
  77173. private setNodeTransformation;
  77174. private getVertexBufferFromMesh;
  77175. /**
  77176. * Creates a bufferview based on the vertices type for the Babylon mesh
  77177. * @param kind Indicates the type of vertices data
  77178. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77179. * @param binaryWriter The buffer to write the bufferview data to
  77180. */
  77181. private createBufferViewKind;
  77182. /**
  77183. * The primitive mode of the Babylon mesh
  77184. * @param babylonMesh The BabylonJS mesh
  77185. */
  77186. private getMeshPrimitiveMode;
  77187. /**
  77188. * Sets the primitive mode of the glTF mesh primitive
  77189. * @param meshPrimitive glTF mesh primitive
  77190. * @param primitiveMode The primitive mode
  77191. */
  77192. private setPrimitiveMode;
  77193. /**
  77194. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77195. * @param meshPrimitive glTF mesh primitive
  77196. * @param attributeKind vertex attribute
  77197. * @returns boolean specifying if uv coordinates are present
  77198. */
  77199. private setAttributeKind;
  77200. /**
  77201. * Sets data for the primitive attributes of each submesh
  77202. * @param mesh glTF Mesh object to store the primitive attribute information
  77203. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77204. * @param binaryWriter Buffer to write the attribute data to
  77205. */
  77206. private setPrimitiveAttributesAsync;
  77207. /**
  77208. * Creates a glTF scene based on the array of meshes
  77209. * Returns the the total byte offset
  77210. * @param babylonScene Babylon scene to get the mesh data from
  77211. * @param binaryWriter Buffer to write binary data to
  77212. */
  77213. private createSceneAsync;
  77214. /**
  77215. * Creates a mapping of Node unique id to node index and handles animations
  77216. * @param babylonScene Babylon Scene
  77217. * @param nodes Babylon transform nodes
  77218. * @param binaryWriter Buffer to write binary data to
  77219. * @returns Node mapping of unique id to index
  77220. */
  77221. private createNodeMapAndAnimationsAsync;
  77222. /**
  77223. * Creates a glTF node from a Babylon mesh
  77224. * @param babylonMesh Source Babylon mesh
  77225. * @param binaryWriter Buffer for storing geometry data
  77226. * @returns glTF node
  77227. */
  77228. private createNodeAsync;
  77229. }
  77230. /**
  77231. * @hidden
  77232. *
  77233. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77234. */
  77235. export class _BinaryWriter {
  77236. /**
  77237. * Array buffer which stores all binary data
  77238. */
  77239. private _arrayBuffer;
  77240. /**
  77241. * View of the array buffer
  77242. */
  77243. private _dataView;
  77244. /**
  77245. * byte offset of data in array buffer
  77246. */
  77247. private _byteOffset;
  77248. /**
  77249. * Initialize binary writer with an initial byte length
  77250. * @param byteLength Initial byte length of the array buffer
  77251. */
  77252. constructor(byteLength: number);
  77253. /**
  77254. * Resize the array buffer to the specified byte length
  77255. * @param byteLength
  77256. */
  77257. private resizeBuffer;
  77258. /**
  77259. * Get an array buffer with the length of the byte offset
  77260. * @returns ArrayBuffer resized to the byte offset
  77261. */
  77262. getArrayBuffer(): ArrayBuffer;
  77263. /**
  77264. * Get the byte offset of the array buffer
  77265. * @returns byte offset
  77266. */
  77267. getByteOffset(): number;
  77268. /**
  77269. * Stores an UInt8 in the array buffer
  77270. * @param entry
  77271. * @param byteOffset If defined, specifies where to set the value as an offset.
  77272. */
  77273. setUInt8(entry: number, byteOffset?: number): void;
  77274. /**
  77275. * Gets an UInt32 in the array buffer
  77276. * @param entry
  77277. * @param byteOffset If defined, specifies where to set the value as an offset.
  77278. */
  77279. getUInt32(byteOffset: number): number;
  77280. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77281. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77282. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77283. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77284. /**
  77285. * Stores a Float32 in the array buffer
  77286. * @param entry
  77287. */
  77288. setFloat32(entry: number, byteOffset?: number): void;
  77289. /**
  77290. * Stores an UInt32 in the array buffer
  77291. * @param entry
  77292. * @param byteOffset If defined, specifies where to set the value as an offset.
  77293. */
  77294. setUInt32(entry: number, byteOffset?: number): void;
  77295. }
  77296. }
  77297. declare module BABYLON.GLTF2.Exporter {
  77298. /**
  77299. * @hidden
  77300. * Interface to store animation data.
  77301. */
  77302. export interface _IAnimationData {
  77303. /**
  77304. * Keyframe data.
  77305. */
  77306. inputs: number[];
  77307. /**
  77308. * Value data.
  77309. */
  77310. outputs: number[][];
  77311. /**
  77312. * Animation interpolation data.
  77313. */
  77314. samplerInterpolation: AnimationSamplerInterpolation;
  77315. /**
  77316. * Minimum keyframe value.
  77317. */
  77318. inputsMin: number;
  77319. /**
  77320. * Maximum keyframe value.
  77321. */
  77322. inputsMax: number;
  77323. }
  77324. /**
  77325. * @hidden
  77326. */
  77327. export interface _IAnimationInfo {
  77328. /**
  77329. * The target channel for the animation
  77330. */
  77331. animationChannelTargetPath: AnimationChannelTargetPath;
  77332. /**
  77333. * The glTF accessor type for the data.
  77334. */
  77335. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77336. /**
  77337. * Specifies if quaternions should be used.
  77338. */
  77339. useQuaternion: boolean;
  77340. }
  77341. /**
  77342. * @hidden
  77343. * Utility class for generating glTF animation data from BabylonJS.
  77344. */
  77345. export class _GLTFAnimation {
  77346. /**
  77347. * @ignore
  77348. *
  77349. * Creates glTF channel animation from BabylonJS animation.
  77350. * @param babylonTransformNode - BabylonJS mesh.
  77351. * @param animation - animation.
  77352. * @param animationChannelTargetPath - The target animation channel.
  77353. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77354. * @param useQuaternion - Specifies if quaternions are used.
  77355. * @returns nullable IAnimationData
  77356. */
  77357. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77358. private static _DeduceAnimationInfo;
  77359. /**
  77360. * @ignore
  77361. * Create node animations from the transform node animations
  77362. * @param babylonNode
  77363. * @param runtimeGLTFAnimation
  77364. * @param idleGLTFAnimations
  77365. * @param nodeMap
  77366. * @param nodes
  77367. * @param binaryWriter
  77368. * @param bufferViews
  77369. * @param accessors
  77370. * @param convertToRightHandedSystem
  77371. */
  77372. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77373. [key: number]: number;
  77374. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77375. /**
  77376. * @ignore
  77377. * Create node animations from the animation groups
  77378. * @param babylonScene
  77379. * @param glTFAnimations
  77380. * @param nodeMap
  77381. * @param nodes
  77382. * @param binaryWriter
  77383. * @param bufferViews
  77384. * @param accessors
  77385. * @param convertToRightHandedSystem
  77386. */
  77387. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77388. [key: number]: number;
  77389. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77390. private static AddAnimation;
  77391. /**
  77392. * Create a baked animation
  77393. * @param babylonTransformNode BabylonJS mesh
  77394. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77395. * @param animationChannelTargetPath animation target channel
  77396. * @param minFrame minimum animation frame
  77397. * @param maxFrame maximum animation frame
  77398. * @param fps frames per second of the animation
  77399. * @param inputs input key frames of the animation
  77400. * @param outputs output key frame data of the animation
  77401. * @param convertToRightHandedSystem converts the values to right-handed
  77402. * @param useQuaternion specifies if quaternions should be used
  77403. */
  77404. private static _CreateBakedAnimation;
  77405. private static _ConvertFactorToVector3OrQuaternion;
  77406. private static _SetInterpolatedValue;
  77407. /**
  77408. * Creates linear animation from the animation key frames
  77409. * @param babylonTransformNode BabylonJS mesh
  77410. * @param animation BabylonJS animation
  77411. * @param animationChannelTargetPath The target animation channel
  77412. * @param frameDelta The difference between the last and first frame of the animation
  77413. * @param inputs Array to store the key frame times
  77414. * @param outputs Array to store the key frame data
  77415. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77416. * @param useQuaternion Specifies if quaternions are used in the animation
  77417. */
  77418. private static _CreateLinearOrStepAnimation;
  77419. /**
  77420. * Creates cubic spline animation from the animation key frames
  77421. * @param babylonTransformNode BabylonJS mesh
  77422. * @param animation BabylonJS animation
  77423. * @param animationChannelTargetPath The target animation channel
  77424. * @param frameDelta The difference between the last and first frame of the animation
  77425. * @param inputs Array to store the key frame times
  77426. * @param outputs Array to store the key frame data
  77427. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77428. * @param useQuaternion Specifies if quaternions are used in the animation
  77429. */
  77430. private static _CreateCubicSplineAnimation;
  77431. private static _GetBasePositionRotationOrScale;
  77432. /**
  77433. * Adds a key frame value
  77434. * @param keyFrame
  77435. * @param animation
  77436. * @param outputs
  77437. * @param animationChannelTargetPath
  77438. * @param basePositionRotationOrScale
  77439. * @param convertToRightHandedSystem
  77440. * @param useQuaternion
  77441. */
  77442. private static _AddKeyframeValue;
  77443. /**
  77444. * Determine the interpolation based on the key frames
  77445. * @param keyFrames
  77446. * @param animationChannelTargetPath
  77447. * @param useQuaternion
  77448. */
  77449. private static _DeduceInterpolation;
  77450. /**
  77451. * Adds an input tangent or output tangent to the output data
  77452. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77453. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77454. * @param outputs The animation data by keyframe
  77455. * @param animationChannelTargetPath The target animation channel
  77456. * @param interpolation The interpolation type
  77457. * @param keyFrame The key frame with the animation data
  77458. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77459. * @param useQuaternion Specifies if quaternions are used
  77460. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77461. */
  77462. private static AddSplineTangent;
  77463. /**
  77464. * Get the minimum and maximum key frames' frame values
  77465. * @param keyFrames animation key frames
  77466. * @returns the minimum and maximum key frame value
  77467. */
  77468. private static calculateMinMaxKeyFrames;
  77469. }
  77470. }
  77471. declare module BABYLON.GLTF2.Exporter {
  77472. /** @hidden */
  77473. export var textureTransformPixelShader: {
  77474. name: string;
  77475. shader: string;
  77476. };
  77477. }
  77478. declare module BABYLON.GLTF2.Exporter.Extensions {
  77479. /**
  77480. * @hidden
  77481. */
  77482. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77483. private _recordedTextures;
  77484. /** Name of this extension */
  77485. readonly name: string;
  77486. /** Defines whether this extension is enabled */
  77487. enabled: boolean;
  77488. /** Defines whether this extension is required */
  77489. required: boolean;
  77490. /** Reference to the glTF exporter */
  77491. private _wasUsed;
  77492. constructor(exporter: _Exporter);
  77493. dispose(): void;
  77494. /** @hidden */
  77495. get wasUsed(): boolean;
  77496. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77497. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77498. /**
  77499. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77500. * @param babylonTexture
  77501. * @param offset
  77502. * @param rotation
  77503. * @param scale
  77504. * @param scene
  77505. */
  77506. private _textureTransformTextureAsync;
  77507. }
  77508. }
  77509. declare module BABYLON.GLTF2.Exporter.Extensions {
  77510. /**
  77511. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77512. */
  77513. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77514. /** The name of this extension. */
  77515. readonly name: string;
  77516. /** Defines whether this extension is enabled. */
  77517. enabled: boolean;
  77518. /** Defines whether this extension is required */
  77519. required: boolean;
  77520. /** Reference to the glTF exporter */
  77521. private _exporter;
  77522. private _lights;
  77523. /** @hidden */
  77524. constructor(exporter: _Exporter);
  77525. /** @hidden */
  77526. dispose(): void;
  77527. /** @hidden */
  77528. get wasUsed(): boolean;
  77529. /** @hidden */
  77530. onExporting(): void;
  77531. /**
  77532. * Define this method to modify the default behavior when exporting a node
  77533. * @param context The context when exporting the node
  77534. * @param node glTF node
  77535. * @param babylonNode BabylonJS node
  77536. * @returns nullable INode promise
  77537. */
  77538. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  77539. }
  77540. }
  77541. declare module BABYLON.GLTF2.Exporter.Extensions {
  77542. /**
  77543. * @hidden
  77544. */
  77545. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77546. /** Name of this extension */
  77547. readonly name: string;
  77548. /** Defines whether this extension is enabled */
  77549. enabled: boolean;
  77550. /** Defines whether this extension is required */
  77551. required: boolean;
  77552. /** Reference to the glTF exporter */
  77553. private _textureInfos;
  77554. private _exportedTextures;
  77555. private _wasUsed;
  77556. constructor(exporter: _Exporter);
  77557. dispose(): void;
  77558. /** @hidden */
  77559. get wasUsed(): boolean;
  77560. private _getTextureIndex;
  77561. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77562. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77563. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77564. }
  77565. }
  77566. declare module BABYLON {
  77567. /**
  77568. * Class for generating STL data from a Babylon scene.
  77569. */
  77570. export class STLExport {
  77571. /**
  77572. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77573. * @param meshes list defines the mesh to serialize
  77574. * @param download triggers the automatic download of the file.
  77575. * @param fileName changes the downloads fileName.
  77576. * @param binary changes the STL to a binary type.
  77577. * @param isLittleEndian toggle for binary type exporter.
  77578. * @returns the STL as UTF8 string
  77579. */
  77580. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77581. }
  77582. }
  77583. declare module "babylonjs-gltf2interface" {
  77584. export = BABYLON.GLTF2;
  77585. }
  77586. /**
  77587. * Module for glTF 2.0 Interface
  77588. */
  77589. declare module BABYLON.GLTF2 {
  77590. /**
  77591. * The datatype of the components in the attribute
  77592. */
  77593. const enum AccessorComponentType {
  77594. /**
  77595. * Byte
  77596. */
  77597. BYTE = 5120,
  77598. /**
  77599. * Unsigned Byte
  77600. */
  77601. UNSIGNED_BYTE = 5121,
  77602. /**
  77603. * Short
  77604. */
  77605. SHORT = 5122,
  77606. /**
  77607. * Unsigned Short
  77608. */
  77609. UNSIGNED_SHORT = 5123,
  77610. /**
  77611. * Unsigned Int
  77612. */
  77613. UNSIGNED_INT = 5125,
  77614. /**
  77615. * Float
  77616. */
  77617. FLOAT = 5126,
  77618. }
  77619. /**
  77620. * Specifies if the attirbute is a scalar, vector, or matrix
  77621. */
  77622. const enum AccessorType {
  77623. /**
  77624. * Scalar
  77625. */
  77626. SCALAR = "SCALAR",
  77627. /**
  77628. * Vector2
  77629. */
  77630. VEC2 = "VEC2",
  77631. /**
  77632. * Vector3
  77633. */
  77634. VEC3 = "VEC3",
  77635. /**
  77636. * Vector4
  77637. */
  77638. VEC4 = "VEC4",
  77639. /**
  77640. * Matrix2x2
  77641. */
  77642. MAT2 = "MAT2",
  77643. /**
  77644. * Matrix3x3
  77645. */
  77646. MAT3 = "MAT3",
  77647. /**
  77648. * Matrix4x4
  77649. */
  77650. MAT4 = "MAT4",
  77651. }
  77652. /**
  77653. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77654. */
  77655. const enum AnimationChannelTargetPath {
  77656. /**
  77657. * Translation
  77658. */
  77659. TRANSLATION = "translation",
  77660. /**
  77661. * Rotation
  77662. */
  77663. ROTATION = "rotation",
  77664. /**
  77665. * Scale
  77666. */
  77667. SCALE = "scale",
  77668. /**
  77669. * Weights
  77670. */
  77671. WEIGHTS = "weights",
  77672. }
  77673. /**
  77674. * Interpolation algorithm
  77675. */
  77676. const enum AnimationSamplerInterpolation {
  77677. /**
  77678. * The animated values are linearly interpolated between keyframes
  77679. */
  77680. LINEAR = "LINEAR",
  77681. /**
  77682. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77683. */
  77684. STEP = "STEP",
  77685. /**
  77686. * The animation's interpolation is computed using a cubic spline with specified tangents
  77687. */
  77688. CUBICSPLINE = "CUBICSPLINE",
  77689. }
  77690. /**
  77691. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77692. */
  77693. const enum CameraType {
  77694. /**
  77695. * A perspective camera containing properties to create a perspective projection matrix
  77696. */
  77697. PERSPECTIVE = "perspective",
  77698. /**
  77699. * An orthographic camera containing properties to create an orthographic projection matrix
  77700. */
  77701. ORTHOGRAPHIC = "orthographic",
  77702. }
  77703. /**
  77704. * The mime-type of the image
  77705. */
  77706. const enum ImageMimeType {
  77707. /**
  77708. * JPEG Mime-type
  77709. */
  77710. JPEG = "image/jpeg",
  77711. /**
  77712. * PNG Mime-type
  77713. */
  77714. PNG = "image/png",
  77715. }
  77716. /**
  77717. * The alpha rendering mode of the material
  77718. */
  77719. const enum MaterialAlphaMode {
  77720. /**
  77721. * The alpha value is ignored and the rendered output is fully opaque
  77722. */
  77723. OPAQUE = "OPAQUE",
  77724. /**
  77725. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77726. */
  77727. MASK = "MASK",
  77728. /**
  77729. * 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)
  77730. */
  77731. BLEND = "BLEND",
  77732. }
  77733. /**
  77734. * The type of the primitives to render
  77735. */
  77736. const enum MeshPrimitiveMode {
  77737. /**
  77738. * Points
  77739. */
  77740. POINTS = 0,
  77741. /**
  77742. * Lines
  77743. */
  77744. LINES = 1,
  77745. /**
  77746. * Line Loop
  77747. */
  77748. LINE_LOOP = 2,
  77749. /**
  77750. * Line Strip
  77751. */
  77752. LINE_STRIP = 3,
  77753. /**
  77754. * Triangles
  77755. */
  77756. TRIANGLES = 4,
  77757. /**
  77758. * Triangle Strip
  77759. */
  77760. TRIANGLE_STRIP = 5,
  77761. /**
  77762. * Triangle Fan
  77763. */
  77764. TRIANGLE_FAN = 6,
  77765. }
  77766. /**
  77767. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77768. */
  77769. const enum TextureMagFilter {
  77770. /**
  77771. * Nearest
  77772. */
  77773. NEAREST = 9728,
  77774. /**
  77775. * Linear
  77776. */
  77777. LINEAR = 9729,
  77778. }
  77779. /**
  77780. * Minification filter. All valid values correspond to WebGL enums
  77781. */
  77782. const enum TextureMinFilter {
  77783. /**
  77784. * Nearest
  77785. */
  77786. NEAREST = 9728,
  77787. /**
  77788. * Linear
  77789. */
  77790. LINEAR = 9729,
  77791. /**
  77792. * Nearest Mip-Map Nearest
  77793. */
  77794. NEAREST_MIPMAP_NEAREST = 9984,
  77795. /**
  77796. * Linear Mipmap Nearest
  77797. */
  77798. LINEAR_MIPMAP_NEAREST = 9985,
  77799. /**
  77800. * Nearest Mipmap Linear
  77801. */
  77802. NEAREST_MIPMAP_LINEAR = 9986,
  77803. /**
  77804. * Linear Mipmap Linear
  77805. */
  77806. LINEAR_MIPMAP_LINEAR = 9987,
  77807. }
  77808. /**
  77809. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77810. */
  77811. const enum TextureWrapMode {
  77812. /**
  77813. * Clamp to Edge
  77814. */
  77815. CLAMP_TO_EDGE = 33071,
  77816. /**
  77817. * Mirrored Repeat
  77818. */
  77819. MIRRORED_REPEAT = 33648,
  77820. /**
  77821. * Repeat
  77822. */
  77823. REPEAT = 10497,
  77824. }
  77825. /**
  77826. * glTF Property
  77827. */
  77828. interface IProperty {
  77829. /**
  77830. * Dictionary object with extension-specific objects
  77831. */
  77832. extensions?: {
  77833. [key: string]: any;
  77834. };
  77835. /**
  77836. * Application-Specific data
  77837. */
  77838. extras?: any;
  77839. }
  77840. /**
  77841. * glTF Child of Root Property
  77842. */
  77843. interface IChildRootProperty extends IProperty {
  77844. /**
  77845. * The user-defined name of this object
  77846. */
  77847. name?: string;
  77848. }
  77849. /**
  77850. * Indices of those attributes that deviate from their initialization value
  77851. */
  77852. interface IAccessorSparseIndices extends IProperty {
  77853. /**
  77854. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77855. */
  77856. bufferView: number;
  77857. /**
  77858. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77859. */
  77860. byteOffset?: number;
  77861. /**
  77862. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77863. */
  77864. componentType: AccessorComponentType;
  77865. }
  77866. /**
  77867. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77868. */
  77869. interface IAccessorSparseValues extends IProperty {
  77870. /**
  77871. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77872. */
  77873. bufferView: number;
  77874. /**
  77875. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77876. */
  77877. byteOffset?: number;
  77878. }
  77879. /**
  77880. * Sparse storage of attributes that deviate from their initialization value
  77881. */
  77882. interface IAccessorSparse extends IProperty {
  77883. /**
  77884. * The number of attributes encoded in this sparse accessor
  77885. */
  77886. count: number;
  77887. /**
  77888. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77889. */
  77890. indices: IAccessorSparseIndices;
  77891. /**
  77892. * 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
  77893. */
  77894. values: IAccessorSparseValues;
  77895. }
  77896. /**
  77897. * 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
  77898. */
  77899. interface IAccessor extends IChildRootProperty {
  77900. /**
  77901. * The index of the bufferview
  77902. */
  77903. bufferView?: number;
  77904. /**
  77905. * The offset relative to the start of the bufferView in bytes
  77906. */
  77907. byteOffset?: number;
  77908. /**
  77909. * The datatype of components in the attribute
  77910. */
  77911. componentType: AccessorComponentType;
  77912. /**
  77913. * Specifies whether integer data values should be normalized
  77914. */
  77915. normalized?: boolean;
  77916. /**
  77917. * The number of attributes referenced by this accessor
  77918. */
  77919. count: number;
  77920. /**
  77921. * Specifies if the attribute is a scalar, vector, or matrix
  77922. */
  77923. type: AccessorType;
  77924. /**
  77925. * Maximum value of each component in this attribute
  77926. */
  77927. max?: number[];
  77928. /**
  77929. * Minimum value of each component in this attribute
  77930. */
  77931. min?: number[];
  77932. /**
  77933. * Sparse storage of attributes that deviate from their initialization value
  77934. */
  77935. sparse?: IAccessorSparse;
  77936. }
  77937. /**
  77938. * Targets an animation's sampler at a node's property
  77939. */
  77940. interface IAnimationChannel extends IProperty {
  77941. /**
  77942. * The index of a sampler in this animation used to compute the value for the target
  77943. */
  77944. sampler: number;
  77945. /**
  77946. * The index of the node and TRS property to target
  77947. */
  77948. target: IAnimationChannelTarget;
  77949. }
  77950. /**
  77951. * The index of the node and TRS property that an animation channel targets
  77952. */
  77953. interface IAnimationChannelTarget extends IProperty {
  77954. /**
  77955. * The index of the node to target
  77956. */
  77957. node: number;
  77958. /**
  77959. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77960. */
  77961. path: AnimationChannelTargetPath;
  77962. }
  77963. /**
  77964. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77965. */
  77966. interface IAnimationSampler extends IProperty {
  77967. /**
  77968. * The index of an accessor containing keyframe input values, e.g., time
  77969. */
  77970. input: number;
  77971. /**
  77972. * Interpolation algorithm
  77973. */
  77974. interpolation?: AnimationSamplerInterpolation;
  77975. /**
  77976. * The index of an accessor, containing keyframe output values
  77977. */
  77978. output: number;
  77979. }
  77980. /**
  77981. * A keyframe animation
  77982. */
  77983. interface IAnimation extends IChildRootProperty {
  77984. /**
  77985. * An array of channels, each of which targets an animation's sampler at a node's property
  77986. */
  77987. channels: IAnimationChannel[];
  77988. /**
  77989. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77990. */
  77991. samplers: IAnimationSampler[];
  77992. }
  77993. /**
  77994. * Metadata about the glTF asset
  77995. */
  77996. interface IAsset extends IChildRootProperty {
  77997. /**
  77998. * A copyright message suitable for display to credit the content creator
  77999. */
  78000. copyright?: string;
  78001. /**
  78002. * Tool that generated this glTF model. Useful for debugging
  78003. */
  78004. generator?: string;
  78005. /**
  78006. * The glTF version that this asset targets
  78007. */
  78008. version: string;
  78009. /**
  78010. * The minimum glTF version that this asset targets
  78011. */
  78012. minVersion?: string;
  78013. }
  78014. /**
  78015. * A buffer points to binary geometry, animation, or skins
  78016. */
  78017. interface IBuffer extends IChildRootProperty {
  78018. /**
  78019. * 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
  78020. */
  78021. uri?: string;
  78022. /**
  78023. * The length of the buffer in bytes
  78024. */
  78025. byteLength: number;
  78026. }
  78027. /**
  78028. * A view into a buffer generally representing a subset of the buffer
  78029. */
  78030. interface IBufferView extends IChildRootProperty {
  78031. /**
  78032. * The index of the buffer
  78033. */
  78034. buffer: number;
  78035. /**
  78036. * The offset into the buffer in bytes
  78037. */
  78038. byteOffset?: number;
  78039. /**
  78040. * The lenth of the bufferView in bytes
  78041. */
  78042. byteLength: number;
  78043. /**
  78044. * The stride, in bytes
  78045. */
  78046. byteStride?: number;
  78047. }
  78048. /**
  78049. * An orthographic camera containing properties to create an orthographic projection matrix
  78050. */
  78051. interface ICameraOrthographic extends IProperty {
  78052. /**
  78053. * The floating-point horizontal magnification of the view. Must not be zero
  78054. */
  78055. xmag: number;
  78056. /**
  78057. * The floating-point vertical magnification of the view. Must not be zero
  78058. */
  78059. ymag: number;
  78060. /**
  78061. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78062. */
  78063. zfar: number;
  78064. /**
  78065. * The floating-point distance to the near clipping plane
  78066. */
  78067. znear: number;
  78068. }
  78069. /**
  78070. * A perspective camera containing properties to create a perspective projection matrix
  78071. */
  78072. interface ICameraPerspective extends IProperty {
  78073. /**
  78074. * The floating-point aspect ratio of the field of view
  78075. */
  78076. aspectRatio?: number;
  78077. /**
  78078. * The floating-point vertical field of view in radians
  78079. */
  78080. yfov: number;
  78081. /**
  78082. * The floating-point distance to the far clipping plane
  78083. */
  78084. zfar?: number;
  78085. /**
  78086. * The floating-point distance to the near clipping plane
  78087. */
  78088. znear: number;
  78089. }
  78090. /**
  78091. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78092. */
  78093. interface ICamera extends IChildRootProperty {
  78094. /**
  78095. * An orthographic camera containing properties to create an orthographic projection matrix
  78096. */
  78097. orthographic?: ICameraOrthographic;
  78098. /**
  78099. * A perspective camera containing properties to create a perspective projection matrix
  78100. */
  78101. perspective?: ICameraPerspective;
  78102. /**
  78103. * Specifies if the camera uses a perspective or orthographic projection
  78104. */
  78105. type: CameraType;
  78106. }
  78107. /**
  78108. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78109. */
  78110. interface IImage extends IChildRootProperty {
  78111. /**
  78112. * 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
  78113. */
  78114. uri?: string;
  78115. /**
  78116. * The image's MIME type
  78117. */
  78118. mimeType?: ImageMimeType;
  78119. /**
  78120. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78121. */
  78122. bufferView?: number;
  78123. }
  78124. /**
  78125. * Material Normal Texture Info
  78126. */
  78127. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78128. /**
  78129. * The scalar multiplier applied to each normal vector of the normal texture
  78130. */
  78131. scale?: number;
  78132. }
  78133. /**
  78134. * Material Occlusion Texture Info
  78135. */
  78136. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78137. /**
  78138. * A scalar multiplier controlling the amount of occlusion applied
  78139. */
  78140. strength?: number;
  78141. }
  78142. /**
  78143. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78144. */
  78145. interface IMaterialPbrMetallicRoughness {
  78146. /**
  78147. * The material's base color factor
  78148. */
  78149. baseColorFactor?: number[];
  78150. /**
  78151. * The base color texture
  78152. */
  78153. baseColorTexture?: ITextureInfo;
  78154. /**
  78155. * The metalness of the material
  78156. */
  78157. metallicFactor?: number;
  78158. /**
  78159. * The roughness of the material
  78160. */
  78161. roughnessFactor?: number;
  78162. /**
  78163. * The metallic-roughness texture
  78164. */
  78165. metallicRoughnessTexture?: ITextureInfo;
  78166. }
  78167. /**
  78168. * The material appearance of a primitive
  78169. */
  78170. interface IMaterial extends IChildRootProperty {
  78171. /**
  78172. * 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
  78173. */
  78174. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78175. /**
  78176. * The normal map texture
  78177. */
  78178. normalTexture?: IMaterialNormalTextureInfo;
  78179. /**
  78180. * The occlusion map texture
  78181. */
  78182. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78183. /**
  78184. * The emissive map texture
  78185. */
  78186. emissiveTexture?: ITextureInfo;
  78187. /**
  78188. * 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
  78189. */
  78190. emissiveFactor?: number[];
  78191. /**
  78192. * The alpha rendering mode of the material
  78193. */
  78194. alphaMode?: MaterialAlphaMode;
  78195. /**
  78196. * The alpha cutoff value of the material
  78197. */
  78198. alphaCutoff?: number;
  78199. /**
  78200. * Specifies whether the material is double sided
  78201. */
  78202. doubleSided?: boolean;
  78203. }
  78204. /**
  78205. * Geometry to be rendered with the given material
  78206. */
  78207. interface IMeshPrimitive extends IProperty {
  78208. /**
  78209. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78210. */
  78211. attributes: {
  78212. [name: string]: number;
  78213. };
  78214. /**
  78215. * The index of the accessor that contains the indices
  78216. */
  78217. indices?: number;
  78218. /**
  78219. * The index of the material to apply to this primitive when rendering
  78220. */
  78221. material?: number;
  78222. /**
  78223. * The type of primitives to render. All valid values correspond to WebGL enums
  78224. */
  78225. mode?: MeshPrimitiveMode;
  78226. /**
  78227. * 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
  78228. */
  78229. targets?: {
  78230. [name: string]: number;
  78231. }[];
  78232. }
  78233. /**
  78234. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78235. */
  78236. interface IMesh extends IChildRootProperty {
  78237. /**
  78238. * An array of primitives, each defining geometry to be rendered with a material
  78239. */
  78240. primitives: IMeshPrimitive[];
  78241. /**
  78242. * Array of weights to be applied to the Morph Targets
  78243. */
  78244. weights?: number[];
  78245. }
  78246. /**
  78247. * A node in the node hierarchy
  78248. */
  78249. interface INode extends IChildRootProperty {
  78250. /**
  78251. * The index of the camera referenced by this node
  78252. */
  78253. camera?: number;
  78254. /**
  78255. * The indices of this node's children
  78256. */
  78257. children?: number[];
  78258. /**
  78259. * The index of the skin referenced by this node
  78260. */
  78261. skin?: number;
  78262. /**
  78263. * A floating-point 4x4 transformation matrix stored in column-major order
  78264. */
  78265. matrix?: number[];
  78266. /**
  78267. * The index of the mesh in this node
  78268. */
  78269. mesh?: number;
  78270. /**
  78271. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78272. */
  78273. rotation?: number[];
  78274. /**
  78275. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78276. */
  78277. scale?: number[];
  78278. /**
  78279. * The node's translation along the x, y, and z axes
  78280. */
  78281. translation?: number[];
  78282. /**
  78283. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78284. */
  78285. weights?: number[];
  78286. }
  78287. /**
  78288. * Texture sampler properties for filtering and wrapping modes
  78289. */
  78290. interface ISampler extends IChildRootProperty {
  78291. /**
  78292. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78293. */
  78294. magFilter?: TextureMagFilter;
  78295. /**
  78296. * Minification filter. All valid values correspond to WebGL enums
  78297. */
  78298. minFilter?: TextureMinFilter;
  78299. /**
  78300. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78301. */
  78302. wrapS?: TextureWrapMode;
  78303. /**
  78304. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78305. */
  78306. wrapT?: TextureWrapMode;
  78307. }
  78308. /**
  78309. * The root nodes of a scene
  78310. */
  78311. interface IScene extends IChildRootProperty {
  78312. /**
  78313. * The indices of each root node
  78314. */
  78315. nodes: number[];
  78316. }
  78317. /**
  78318. * Joints and matrices defining a skin
  78319. */
  78320. interface ISkin extends IChildRootProperty {
  78321. /**
  78322. * 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
  78323. */
  78324. inverseBindMatrices?: number;
  78325. /**
  78326. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78327. */
  78328. skeleton?: number;
  78329. /**
  78330. * 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)
  78331. */
  78332. joints: number[];
  78333. }
  78334. /**
  78335. * A texture and its sampler
  78336. */
  78337. interface ITexture extends IChildRootProperty {
  78338. /**
  78339. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78340. */
  78341. sampler?: number;
  78342. /**
  78343. * The index of the image used by this texture
  78344. */
  78345. source: number;
  78346. }
  78347. /**
  78348. * Reference to a texture
  78349. */
  78350. interface ITextureInfo extends IProperty {
  78351. /**
  78352. * The index of the texture
  78353. */
  78354. index: number;
  78355. /**
  78356. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78357. */
  78358. texCoord?: number;
  78359. }
  78360. /**
  78361. * The root object for a glTF asset
  78362. */
  78363. interface IGLTF extends IProperty {
  78364. /**
  78365. * An array of accessors. An accessor is a typed view into a bufferView
  78366. */
  78367. accessors?: IAccessor[];
  78368. /**
  78369. * An array of keyframe animations
  78370. */
  78371. animations?: IAnimation[];
  78372. /**
  78373. * Metadata about the glTF asset
  78374. */
  78375. asset: IAsset;
  78376. /**
  78377. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78378. */
  78379. buffers?: IBuffer[];
  78380. /**
  78381. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78382. */
  78383. bufferViews?: IBufferView[];
  78384. /**
  78385. * An array of cameras
  78386. */
  78387. cameras?: ICamera[];
  78388. /**
  78389. * Names of glTF extensions used somewhere in this asset
  78390. */
  78391. extensionsUsed?: string[];
  78392. /**
  78393. * Names of glTF extensions required to properly load this asset
  78394. */
  78395. extensionsRequired?: string[];
  78396. /**
  78397. * An array of images. An image defines data used to create a texture
  78398. */
  78399. images?: IImage[];
  78400. /**
  78401. * An array of materials. A material defines the appearance of a primitive
  78402. */
  78403. materials?: IMaterial[];
  78404. /**
  78405. * An array of meshes. A mesh is a set of primitives to be rendered
  78406. */
  78407. meshes?: IMesh[];
  78408. /**
  78409. * An array of nodes
  78410. */
  78411. nodes?: INode[];
  78412. /**
  78413. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78414. */
  78415. samplers?: ISampler[];
  78416. /**
  78417. * The index of the default scene
  78418. */
  78419. scene?: number;
  78420. /**
  78421. * An array of scenes
  78422. */
  78423. scenes?: IScene[];
  78424. /**
  78425. * An array of skins. A skin is defined by joints and matrices
  78426. */
  78427. skins?: ISkin[];
  78428. /**
  78429. * An array of textures
  78430. */
  78431. textures?: ITexture[];
  78432. }
  78433. /**
  78434. * The glTF validation results
  78435. * @ignore
  78436. */
  78437. interface IGLTFValidationResults {
  78438. info: {
  78439. generator: string;
  78440. hasAnimations: boolean;
  78441. hasDefaultScene: boolean;
  78442. hasMaterials: boolean;
  78443. hasMorphTargets: boolean;
  78444. hasSkins: boolean;
  78445. hasTextures: boolean;
  78446. maxAttributesUsed: number;
  78447. primitivesCount: number
  78448. };
  78449. issues: {
  78450. messages: Array<string>;
  78451. numErrors: number;
  78452. numHints: number;
  78453. numInfos: number;
  78454. numWarnings: number;
  78455. truncated: boolean
  78456. };
  78457. mimeType: string;
  78458. uri: string;
  78459. validatedAt: string;
  78460. validatorVersion: string;
  78461. }
  78462. /**
  78463. * The glTF validation options
  78464. */
  78465. interface IGLTFValidationOptions {
  78466. /** Uri to use */
  78467. uri?: string;
  78468. /** Function used to load external resources */
  78469. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78470. /** Boolean indicating that we need to validate accessor data */
  78471. validateAccessorData?: boolean;
  78472. /** max number of issues allowed */
  78473. maxIssues?: number;
  78474. /** Ignored issues */
  78475. ignoredIssues?: Array<string>;
  78476. /** Value to override severy settings */
  78477. severityOverrides?: Object;
  78478. }
  78479. /**
  78480. * The glTF validator object
  78481. * @ignore
  78482. */
  78483. interface IGLTFValidator {
  78484. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78485. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78486. }
  78487. }
  78488. declare module BABYLON {
  78489. /** @hidden */
  78490. export var cellPixelShader: {
  78491. name: string;
  78492. shader: string;
  78493. };
  78494. }
  78495. declare module BABYLON {
  78496. /** @hidden */
  78497. export var cellVertexShader: {
  78498. name: string;
  78499. shader: string;
  78500. };
  78501. }
  78502. declare module BABYLON {
  78503. export class CellMaterial extends BABYLON.PushMaterial {
  78504. private _diffuseTexture;
  78505. diffuseTexture: BABYLON.BaseTexture;
  78506. diffuseColor: BABYLON.Color3;
  78507. _computeHighLevel: boolean;
  78508. computeHighLevel: boolean;
  78509. private _disableLighting;
  78510. disableLighting: boolean;
  78511. private _maxSimultaneousLights;
  78512. maxSimultaneousLights: number;
  78513. private _renderId;
  78514. constructor(name: string, scene: BABYLON.Scene);
  78515. needAlphaBlending(): boolean;
  78516. needAlphaTesting(): boolean;
  78517. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78518. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78519. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78520. getAnimatables(): BABYLON.IAnimatable[];
  78521. getActiveTextures(): BABYLON.BaseTexture[];
  78522. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78523. dispose(forceDisposeEffect?: boolean): void;
  78524. getClassName(): string;
  78525. clone(name: string): CellMaterial;
  78526. serialize(): any;
  78527. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78528. }
  78529. }
  78530. declare module BABYLON {
  78531. export class CustomShaderStructure {
  78532. FragmentStore: string;
  78533. VertexStore: string;
  78534. constructor();
  78535. }
  78536. export class ShaderSpecialParts {
  78537. constructor();
  78538. Fragment_Begin: string;
  78539. Fragment_Definitions: string;
  78540. Fragment_MainBegin: string;
  78541. Fragment_Custom_Diffuse: string;
  78542. Fragment_Before_Lights: string;
  78543. Fragment_Before_Fog: string;
  78544. Fragment_Custom_Alpha: string;
  78545. Fragment_Before_FragColor: string;
  78546. Vertex_Begin: string;
  78547. Vertex_Definitions: string;
  78548. Vertex_MainBegin: string;
  78549. Vertex_Before_PositionUpdated: string;
  78550. Vertex_Before_NormalUpdated: string;
  78551. Vertex_MainEnd: string;
  78552. }
  78553. export class CustomMaterial extends BABYLON.StandardMaterial {
  78554. static ShaderIndexer: number;
  78555. CustomParts: ShaderSpecialParts;
  78556. _isCreatedShader: boolean;
  78557. _createdShaderName: string;
  78558. _customUniform: string[];
  78559. _newUniforms: string[];
  78560. _newUniformInstances: any[];
  78561. _newSamplerInstances: BABYLON.Texture[];
  78562. FragmentShader: string;
  78563. VertexShader: string;
  78564. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78565. ReviewUniform(name: string, arr: string[]): string[];
  78566. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78567. constructor(name: string, scene: BABYLON.Scene);
  78568. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78569. Fragment_Begin(shaderPart: string): CustomMaterial;
  78570. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78571. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78572. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78573. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78574. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78575. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78576. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78577. Vertex_Begin(shaderPart: string): CustomMaterial;
  78578. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78579. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78580. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78581. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78582. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78583. }
  78584. }
  78585. declare module BABYLON {
  78586. export class ShaderAlebdoParts {
  78587. constructor();
  78588. Fragment_Begin: string;
  78589. Fragment_Definitions: string;
  78590. Fragment_MainBegin: string;
  78591. Fragment_Custom_Albedo: string;
  78592. Fragment_Before_Lights: string;
  78593. Fragment_Custom_MetallicRoughness: string;
  78594. Fragment_Custom_MicroSurface: string;
  78595. Fragment_Before_Fog: string;
  78596. Fragment_Custom_Alpha: string;
  78597. Fragment_Before_FragColor: string;
  78598. Vertex_Begin: string;
  78599. Vertex_Definitions: string;
  78600. Vertex_MainBegin: string;
  78601. Vertex_Before_PositionUpdated: string;
  78602. Vertex_Before_NormalUpdated: string;
  78603. Vertex_MainEnd: string;
  78604. }
  78605. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78606. static ShaderIndexer: number;
  78607. CustomParts: ShaderAlebdoParts;
  78608. _isCreatedShader: boolean;
  78609. _createdShaderName: string;
  78610. _customUniform: string[];
  78611. _newUniforms: string[];
  78612. _newUniformInstances: any[];
  78613. _newSamplerInstances: BABYLON.Texture[];
  78614. FragmentShader: string;
  78615. VertexShader: string;
  78616. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78617. ReviewUniform(name: string, arr: string[]): string[];
  78618. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78619. constructor(name: string, scene: BABYLON.Scene);
  78620. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78621. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78622. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78623. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78624. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78625. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78626. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78627. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78628. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78629. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78630. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78631. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78632. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78633. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78634. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78635. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78636. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78637. }
  78638. }
  78639. declare module BABYLON {
  78640. /** @hidden */
  78641. export var firePixelShader: {
  78642. name: string;
  78643. shader: string;
  78644. };
  78645. }
  78646. declare module BABYLON {
  78647. /** @hidden */
  78648. export var fireVertexShader: {
  78649. name: string;
  78650. shader: string;
  78651. };
  78652. }
  78653. declare module BABYLON {
  78654. export class FireMaterial extends BABYLON.PushMaterial {
  78655. private _diffuseTexture;
  78656. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78657. private _distortionTexture;
  78658. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78659. private _opacityTexture;
  78660. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78661. diffuseColor: BABYLON.Color3;
  78662. speed: number;
  78663. private _scaledDiffuse;
  78664. private _renderId;
  78665. private _lastTime;
  78666. constructor(name: string, scene: BABYLON.Scene);
  78667. needAlphaBlending(): boolean;
  78668. needAlphaTesting(): boolean;
  78669. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78670. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78671. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78672. getAnimatables(): BABYLON.IAnimatable[];
  78673. getActiveTextures(): BABYLON.BaseTexture[];
  78674. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78675. getClassName(): string;
  78676. dispose(forceDisposeEffect?: boolean): void;
  78677. clone(name: string): FireMaterial;
  78678. serialize(): any;
  78679. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78680. }
  78681. }
  78682. declare module BABYLON {
  78683. /** @hidden */
  78684. export var furPixelShader: {
  78685. name: string;
  78686. shader: string;
  78687. };
  78688. }
  78689. declare module BABYLON {
  78690. /** @hidden */
  78691. export var furVertexShader: {
  78692. name: string;
  78693. shader: string;
  78694. };
  78695. }
  78696. declare module BABYLON {
  78697. export class FurMaterial extends BABYLON.PushMaterial {
  78698. private _diffuseTexture;
  78699. diffuseTexture: BABYLON.BaseTexture;
  78700. private _heightTexture;
  78701. heightTexture: BABYLON.BaseTexture;
  78702. diffuseColor: BABYLON.Color3;
  78703. furLength: number;
  78704. furAngle: number;
  78705. furColor: BABYLON.Color3;
  78706. furOffset: number;
  78707. furSpacing: number;
  78708. furGravity: BABYLON.Vector3;
  78709. furSpeed: number;
  78710. furDensity: number;
  78711. furOcclusion: number;
  78712. furTexture: BABYLON.DynamicTexture;
  78713. private _disableLighting;
  78714. disableLighting: boolean;
  78715. private _maxSimultaneousLights;
  78716. maxSimultaneousLights: number;
  78717. highLevelFur: boolean;
  78718. _meshes: BABYLON.AbstractMesh[];
  78719. private _renderId;
  78720. private _furTime;
  78721. constructor(name: string, scene: BABYLON.Scene);
  78722. get furTime(): number;
  78723. set furTime(furTime: number);
  78724. needAlphaBlending(): boolean;
  78725. needAlphaTesting(): boolean;
  78726. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78727. updateFur(): void;
  78728. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78729. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78730. getAnimatables(): BABYLON.IAnimatable[];
  78731. getActiveTextures(): BABYLON.BaseTexture[];
  78732. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78733. dispose(forceDisposeEffect?: boolean): void;
  78734. clone(name: string): FurMaterial;
  78735. serialize(): any;
  78736. getClassName(): string;
  78737. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78738. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78739. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78740. }
  78741. }
  78742. declare module BABYLON {
  78743. /** @hidden */
  78744. export var gradientPixelShader: {
  78745. name: string;
  78746. shader: string;
  78747. };
  78748. }
  78749. declare module BABYLON {
  78750. /** @hidden */
  78751. export var gradientVertexShader: {
  78752. name: string;
  78753. shader: string;
  78754. };
  78755. }
  78756. declare module BABYLON {
  78757. export class GradientMaterial extends BABYLON.PushMaterial {
  78758. private _maxSimultaneousLights;
  78759. maxSimultaneousLights: number;
  78760. topColor: BABYLON.Color3;
  78761. topColorAlpha: number;
  78762. bottomColor: BABYLON.Color3;
  78763. bottomColorAlpha: number;
  78764. offset: number;
  78765. scale: number;
  78766. smoothness: number;
  78767. private _disableLighting;
  78768. disableLighting: boolean;
  78769. private _renderId;
  78770. constructor(name: string, scene: BABYLON.Scene);
  78771. needAlphaBlending(): boolean;
  78772. needAlphaTesting(): boolean;
  78773. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78774. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78775. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78776. getAnimatables(): BABYLON.IAnimatable[];
  78777. dispose(forceDisposeEffect?: boolean): void;
  78778. clone(name: string): GradientMaterial;
  78779. serialize(): any;
  78780. getClassName(): string;
  78781. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78782. }
  78783. }
  78784. declare module BABYLON {
  78785. /** @hidden */
  78786. export var gridPixelShader: {
  78787. name: string;
  78788. shader: string;
  78789. };
  78790. }
  78791. declare module BABYLON {
  78792. /** @hidden */
  78793. export var gridVertexShader: {
  78794. name: string;
  78795. shader: string;
  78796. };
  78797. }
  78798. declare module BABYLON {
  78799. /**
  78800. * The grid materials allows you to wrap any shape with a grid.
  78801. * Colors are customizable.
  78802. */
  78803. export class GridMaterial extends BABYLON.PushMaterial {
  78804. /**
  78805. * Main color of the grid (e.g. between lines)
  78806. */
  78807. mainColor: BABYLON.Color3;
  78808. /**
  78809. * Color of the grid lines.
  78810. */
  78811. lineColor: BABYLON.Color3;
  78812. /**
  78813. * The scale of the grid compared to unit.
  78814. */
  78815. gridRatio: number;
  78816. /**
  78817. * Allows setting an offset for the grid lines.
  78818. */
  78819. gridOffset: BABYLON.Vector3;
  78820. /**
  78821. * The frequency of thicker lines.
  78822. */
  78823. majorUnitFrequency: number;
  78824. /**
  78825. * The visibility of minor units in the grid.
  78826. */
  78827. minorUnitVisibility: number;
  78828. /**
  78829. * The grid opacity outside of the lines.
  78830. */
  78831. opacity: number;
  78832. /**
  78833. * Determine RBG output is premultiplied by alpha value.
  78834. */
  78835. preMultiplyAlpha: boolean;
  78836. private _opacityTexture;
  78837. opacityTexture: BABYLON.BaseTexture;
  78838. private _gridControl;
  78839. private _renderId;
  78840. /**
  78841. * constructor
  78842. * @param name The name given to the material in order to identify it afterwards.
  78843. * @param scene The scene the material is used in.
  78844. */
  78845. constructor(name: string, scene: BABYLON.Scene);
  78846. /**
  78847. * Returns wehter or not the grid requires alpha blending.
  78848. */
  78849. needAlphaBlending(): boolean;
  78850. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78851. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78852. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78853. /**
  78854. * Dispose the material and its associated resources.
  78855. * @param forceDisposeEffect will also dispose the used effect when true
  78856. */
  78857. dispose(forceDisposeEffect?: boolean): void;
  78858. clone(name: string): GridMaterial;
  78859. serialize(): any;
  78860. getClassName(): string;
  78861. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78862. }
  78863. }
  78864. declare module BABYLON {
  78865. /** @hidden */
  78866. export var lavaPixelShader: {
  78867. name: string;
  78868. shader: string;
  78869. };
  78870. }
  78871. declare module BABYLON {
  78872. /** @hidden */
  78873. export var lavaVertexShader: {
  78874. name: string;
  78875. shader: string;
  78876. };
  78877. }
  78878. declare module BABYLON {
  78879. export class LavaMaterial extends BABYLON.PushMaterial {
  78880. private _diffuseTexture;
  78881. diffuseTexture: BABYLON.BaseTexture;
  78882. noiseTexture: BABYLON.BaseTexture;
  78883. fogColor: BABYLON.Color3;
  78884. speed: number;
  78885. movingSpeed: number;
  78886. lowFrequencySpeed: number;
  78887. fogDensity: number;
  78888. private _lastTime;
  78889. diffuseColor: BABYLON.Color3;
  78890. private _disableLighting;
  78891. disableLighting: boolean;
  78892. private _unlit;
  78893. unlit: boolean;
  78894. private _maxSimultaneousLights;
  78895. maxSimultaneousLights: number;
  78896. private _scaledDiffuse;
  78897. private _renderId;
  78898. constructor(name: string, scene: BABYLON.Scene);
  78899. needAlphaBlending(): boolean;
  78900. needAlphaTesting(): boolean;
  78901. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78902. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78903. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78904. getAnimatables(): BABYLON.IAnimatable[];
  78905. getActiveTextures(): BABYLON.BaseTexture[];
  78906. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78907. dispose(forceDisposeEffect?: boolean): void;
  78908. clone(name: string): LavaMaterial;
  78909. serialize(): any;
  78910. getClassName(): string;
  78911. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78912. }
  78913. }
  78914. declare module BABYLON {
  78915. /** @hidden */
  78916. export var mixPixelShader: {
  78917. name: string;
  78918. shader: string;
  78919. };
  78920. }
  78921. declare module BABYLON {
  78922. /** @hidden */
  78923. export var mixVertexShader: {
  78924. name: string;
  78925. shader: string;
  78926. };
  78927. }
  78928. declare module BABYLON {
  78929. export class MixMaterial extends BABYLON.PushMaterial {
  78930. /**
  78931. * Mix textures
  78932. */
  78933. private _mixTexture1;
  78934. mixTexture1: BABYLON.BaseTexture;
  78935. private _mixTexture2;
  78936. mixTexture2: BABYLON.BaseTexture;
  78937. /**
  78938. * Diffuse textures
  78939. */
  78940. private _diffuseTexture1;
  78941. diffuseTexture1: BABYLON.Texture;
  78942. private _diffuseTexture2;
  78943. diffuseTexture2: BABYLON.Texture;
  78944. private _diffuseTexture3;
  78945. diffuseTexture3: BABYLON.Texture;
  78946. private _diffuseTexture4;
  78947. diffuseTexture4: BABYLON.Texture;
  78948. private _diffuseTexture5;
  78949. diffuseTexture5: BABYLON.Texture;
  78950. private _diffuseTexture6;
  78951. diffuseTexture6: BABYLON.Texture;
  78952. private _diffuseTexture7;
  78953. diffuseTexture7: BABYLON.Texture;
  78954. private _diffuseTexture8;
  78955. diffuseTexture8: BABYLON.Texture;
  78956. /**
  78957. * Uniforms
  78958. */
  78959. diffuseColor: BABYLON.Color3;
  78960. specularColor: BABYLON.Color3;
  78961. specularPower: number;
  78962. private _disableLighting;
  78963. disableLighting: boolean;
  78964. private _maxSimultaneousLights;
  78965. maxSimultaneousLights: number;
  78966. private _renderId;
  78967. constructor(name: string, scene: BABYLON.Scene);
  78968. needAlphaBlending(): boolean;
  78969. needAlphaTesting(): boolean;
  78970. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78971. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78972. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78973. getAnimatables(): BABYLON.IAnimatable[];
  78974. getActiveTextures(): BABYLON.BaseTexture[];
  78975. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78976. dispose(forceDisposeEffect?: boolean): void;
  78977. clone(name: string): MixMaterial;
  78978. serialize(): any;
  78979. getClassName(): string;
  78980. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78981. }
  78982. }
  78983. declare module BABYLON {
  78984. /** @hidden */
  78985. export var normalPixelShader: {
  78986. name: string;
  78987. shader: string;
  78988. };
  78989. }
  78990. declare module BABYLON {
  78991. /** @hidden */
  78992. export var normalVertexShader: {
  78993. name: string;
  78994. shader: string;
  78995. };
  78996. }
  78997. declare module BABYLON {
  78998. export class NormalMaterial extends BABYLON.PushMaterial {
  78999. private _diffuseTexture;
  79000. diffuseTexture: BABYLON.BaseTexture;
  79001. diffuseColor: BABYLON.Color3;
  79002. private _disableLighting;
  79003. disableLighting: boolean;
  79004. private _maxSimultaneousLights;
  79005. maxSimultaneousLights: number;
  79006. private _renderId;
  79007. constructor(name: string, scene: BABYLON.Scene);
  79008. needAlphaBlending(): boolean;
  79009. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79010. needAlphaTesting(): boolean;
  79011. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79012. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79013. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79014. getAnimatables(): BABYLON.IAnimatable[];
  79015. getActiveTextures(): BABYLON.BaseTexture[];
  79016. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79017. dispose(forceDisposeEffect?: boolean): void;
  79018. clone(name: string): NormalMaterial;
  79019. serialize(): any;
  79020. getClassName(): string;
  79021. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79022. }
  79023. }
  79024. declare module BABYLON {
  79025. /** @hidden */
  79026. export var shadowOnlyPixelShader: {
  79027. name: string;
  79028. shader: string;
  79029. };
  79030. }
  79031. declare module BABYLON {
  79032. /** @hidden */
  79033. export var shadowOnlyVertexShader: {
  79034. name: string;
  79035. shader: string;
  79036. };
  79037. }
  79038. declare module BABYLON {
  79039. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79040. private _renderId;
  79041. private _activeLight;
  79042. constructor(name: string, scene: BABYLON.Scene);
  79043. shadowColor: BABYLON.Color3;
  79044. needAlphaBlending(): boolean;
  79045. needAlphaTesting(): boolean;
  79046. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79047. get activeLight(): BABYLON.IShadowLight;
  79048. set activeLight(light: BABYLON.IShadowLight);
  79049. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79050. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79051. clone(name: string): ShadowOnlyMaterial;
  79052. serialize(): any;
  79053. getClassName(): string;
  79054. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79055. }
  79056. }
  79057. declare module BABYLON {
  79058. /** @hidden */
  79059. export var simplePixelShader: {
  79060. name: string;
  79061. shader: string;
  79062. };
  79063. }
  79064. declare module BABYLON {
  79065. /** @hidden */
  79066. export var simpleVertexShader: {
  79067. name: string;
  79068. shader: string;
  79069. };
  79070. }
  79071. declare module BABYLON {
  79072. export class SimpleMaterial extends BABYLON.PushMaterial {
  79073. private _diffuseTexture;
  79074. diffuseTexture: BABYLON.BaseTexture;
  79075. diffuseColor: BABYLON.Color3;
  79076. private _disableLighting;
  79077. disableLighting: boolean;
  79078. private _maxSimultaneousLights;
  79079. maxSimultaneousLights: number;
  79080. private _renderId;
  79081. constructor(name: string, scene: BABYLON.Scene);
  79082. needAlphaBlending(): boolean;
  79083. needAlphaTesting(): boolean;
  79084. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79085. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79086. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79087. getAnimatables(): BABYLON.IAnimatable[];
  79088. getActiveTextures(): BABYLON.BaseTexture[];
  79089. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79090. dispose(forceDisposeEffect?: boolean): void;
  79091. clone(name: string): SimpleMaterial;
  79092. serialize(): any;
  79093. getClassName(): string;
  79094. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79095. }
  79096. }
  79097. declare module BABYLON {
  79098. /** @hidden */
  79099. export var skyPixelShader: {
  79100. name: string;
  79101. shader: string;
  79102. };
  79103. }
  79104. declare module BABYLON {
  79105. /** @hidden */
  79106. export var skyVertexShader: {
  79107. name: string;
  79108. shader: string;
  79109. };
  79110. }
  79111. declare module BABYLON {
  79112. /**
  79113. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79114. * @see https://doc.babylonjs.com/extensions/sky
  79115. */
  79116. export class SkyMaterial extends BABYLON.PushMaterial {
  79117. /**
  79118. * Defines the overall luminance of sky in interval ]0, 1[.
  79119. */
  79120. luminance: number;
  79121. /**
  79122. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79123. */
  79124. turbidity: number;
  79125. /**
  79126. * Defines the sky appearance (light intensity).
  79127. */
  79128. rayleigh: number;
  79129. /**
  79130. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79131. */
  79132. mieCoefficient: number;
  79133. /**
  79134. * Defines the amount of haze particles following the Mie scattering theory.
  79135. */
  79136. mieDirectionalG: number;
  79137. /**
  79138. * Defines the distance of the sun according to the active scene camera.
  79139. */
  79140. distance: number;
  79141. /**
  79142. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79143. * "inclined".
  79144. */
  79145. inclination: number;
  79146. /**
  79147. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79148. * an object direction and a reference direction.
  79149. */
  79150. azimuth: number;
  79151. /**
  79152. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79153. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79154. */
  79155. sunPosition: BABYLON.Vector3;
  79156. /**
  79157. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79158. * .sunPosition property.
  79159. */
  79160. useSunPosition: boolean;
  79161. /**
  79162. * Defines an offset vector used to get a horizon offset.
  79163. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79164. */
  79165. cameraOffset: BABYLON.Vector3;
  79166. private _cameraPosition;
  79167. private _renderId;
  79168. /**
  79169. * Instantiates a new sky material.
  79170. * This material allows to create dynamic and texture free
  79171. * effects for skyboxes by taking care of the atmosphere state.
  79172. * @see https://doc.babylonjs.com/extensions/sky
  79173. * @param name Define the name of the material in the scene
  79174. * @param scene Define the scene the material belong to
  79175. */
  79176. constructor(name: string, scene: BABYLON.Scene);
  79177. /**
  79178. * Specifies if the material will require alpha blending
  79179. * @returns a boolean specifying if alpha blending is needed
  79180. */
  79181. needAlphaBlending(): boolean;
  79182. /**
  79183. * Specifies if this material should be rendered in alpha test mode
  79184. * @returns false as the sky material doesn't need alpha testing.
  79185. */
  79186. needAlphaTesting(): boolean;
  79187. /**
  79188. * Get the texture used for alpha test purpose.
  79189. * @returns null as the sky material has no texture.
  79190. */
  79191. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79192. /**
  79193. * Get if the submesh is ready to be used and all its information available.
  79194. * Child classes can use it to update shaders
  79195. * @param mesh defines the mesh to check
  79196. * @param subMesh defines which submesh to check
  79197. * @param useInstances specifies that instances should be used
  79198. * @returns a boolean indicating that the submesh is ready or not
  79199. */
  79200. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79201. /**
  79202. * Binds the submesh to this material by preparing the effect and shader to draw
  79203. * @param world defines the world transformation matrix
  79204. * @param mesh defines the mesh containing the submesh
  79205. * @param subMesh defines the submesh to bind the material to
  79206. */
  79207. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79208. /**
  79209. * Get the list of animatables in the material.
  79210. * @returns the list of animatables object used in the material
  79211. */
  79212. getAnimatables(): BABYLON.IAnimatable[];
  79213. /**
  79214. * Disposes the material
  79215. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79216. */
  79217. dispose(forceDisposeEffect?: boolean): void;
  79218. /**
  79219. * Makes a duplicate of the material, and gives it a new name
  79220. * @param name defines the new name for the duplicated material
  79221. * @returns the cloned material
  79222. */
  79223. clone(name: string): SkyMaterial;
  79224. /**
  79225. * Serializes this material in a JSON representation
  79226. * @returns the serialized material object
  79227. */
  79228. serialize(): any;
  79229. /**
  79230. * Gets the current class name of the material e.g. "SkyMaterial"
  79231. * Mainly use in serialization.
  79232. * @returns the class name
  79233. */
  79234. getClassName(): string;
  79235. /**
  79236. * Creates a sky material from parsed material data
  79237. * @param source defines the JSON representation of the material
  79238. * @param scene defines the hosting scene
  79239. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79240. * @returns a new sky material
  79241. */
  79242. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79243. }
  79244. }
  79245. declare module BABYLON {
  79246. /** @hidden */
  79247. export var terrainPixelShader: {
  79248. name: string;
  79249. shader: string;
  79250. };
  79251. }
  79252. declare module BABYLON {
  79253. /** @hidden */
  79254. export var terrainVertexShader: {
  79255. name: string;
  79256. shader: string;
  79257. };
  79258. }
  79259. declare module BABYLON {
  79260. export class TerrainMaterial extends BABYLON.PushMaterial {
  79261. private _mixTexture;
  79262. mixTexture: BABYLON.BaseTexture;
  79263. private _diffuseTexture1;
  79264. diffuseTexture1: BABYLON.Texture;
  79265. private _diffuseTexture2;
  79266. diffuseTexture2: BABYLON.Texture;
  79267. private _diffuseTexture3;
  79268. diffuseTexture3: BABYLON.Texture;
  79269. private _bumpTexture1;
  79270. bumpTexture1: BABYLON.Texture;
  79271. private _bumpTexture2;
  79272. bumpTexture2: BABYLON.Texture;
  79273. private _bumpTexture3;
  79274. bumpTexture3: BABYLON.Texture;
  79275. diffuseColor: BABYLON.Color3;
  79276. specularColor: BABYLON.Color3;
  79277. specularPower: number;
  79278. private _disableLighting;
  79279. disableLighting: boolean;
  79280. private _maxSimultaneousLights;
  79281. maxSimultaneousLights: number;
  79282. private _renderId;
  79283. constructor(name: string, scene: BABYLON.Scene);
  79284. needAlphaBlending(): boolean;
  79285. needAlphaTesting(): boolean;
  79286. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79287. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79288. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79289. getAnimatables(): BABYLON.IAnimatable[];
  79290. getActiveTextures(): BABYLON.BaseTexture[];
  79291. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79292. dispose(forceDisposeEffect?: boolean): void;
  79293. clone(name: string): TerrainMaterial;
  79294. serialize(): any;
  79295. getClassName(): string;
  79296. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79297. }
  79298. }
  79299. declare module BABYLON {
  79300. /** @hidden */
  79301. export var triplanarPixelShader: {
  79302. name: string;
  79303. shader: string;
  79304. };
  79305. }
  79306. declare module BABYLON {
  79307. /** @hidden */
  79308. export var triplanarVertexShader: {
  79309. name: string;
  79310. shader: string;
  79311. };
  79312. }
  79313. declare module BABYLON {
  79314. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79315. mixTexture: BABYLON.BaseTexture;
  79316. private _diffuseTextureX;
  79317. diffuseTextureX: BABYLON.BaseTexture;
  79318. private _diffuseTextureY;
  79319. diffuseTextureY: BABYLON.BaseTexture;
  79320. private _diffuseTextureZ;
  79321. diffuseTextureZ: BABYLON.BaseTexture;
  79322. private _normalTextureX;
  79323. normalTextureX: BABYLON.BaseTexture;
  79324. private _normalTextureY;
  79325. normalTextureY: BABYLON.BaseTexture;
  79326. private _normalTextureZ;
  79327. normalTextureZ: BABYLON.BaseTexture;
  79328. tileSize: number;
  79329. diffuseColor: BABYLON.Color3;
  79330. specularColor: BABYLON.Color3;
  79331. specularPower: number;
  79332. private _disableLighting;
  79333. disableLighting: boolean;
  79334. private _maxSimultaneousLights;
  79335. maxSimultaneousLights: number;
  79336. private _renderId;
  79337. constructor(name: string, scene: BABYLON.Scene);
  79338. needAlphaBlending(): boolean;
  79339. needAlphaTesting(): boolean;
  79340. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79341. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79342. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79343. getAnimatables(): BABYLON.IAnimatable[];
  79344. getActiveTextures(): BABYLON.BaseTexture[];
  79345. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79346. dispose(forceDisposeEffect?: boolean): void;
  79347. clone(name: string): TriPlanarMaterial;
  79348. serialize(): any;
  79349. getClassName(): string;
  79350. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79351. }
  79352. }
  79353. declare module BABYLON {
  79354. /** @hidden */
  79355. export var waterPixelShader: {
  79356. name: string;
  79357. shader: string;
  79358. };
  79359. }
  79360. declare module BABYLON {
  79361. /** @hidden */
  79362. export var waterVertexShader: {
  79363. name: string;
  79364. shader: string;
  79365. };
  79366. }
  79367. declare module BABYLON {
  79368. export class WaterMaterial extends BABYLON.PushMaterial {
  79369. renderTargetSize: BABYLON.Vector2;
  79370. private _bumpTexture;
  79371. bumpTexture: BABYLON.BaseTexture;
  79372. diffuseColor: BABYLON.Color3;
  79373. specularColor: BABYLON.Color3;
  79374. specularPower: number;
  79375. private _disableLighting;
  79376. disableLighting: boolean;
  79377. private _maxSimultaneousLights;
  79378. maxSimultaneousLights: number;
  79379. /**
  79380. * @param {number}: Represents the wind force
  79381. */
  79382. windForce: number;
  79383. /**
  79384. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79385. */
  79386. windDirection: BABYLON.Vector2;
  79387. /**
  79388. * @param {number}: Wave height, represents the height of the waves
  79389. */
  79390. waveHeight: number;
  79391. /**
  79392. * @param {number}: Bump height, represents the bump height related to the bump map
  79393. */
  79394. bumpHeight: number;
  79395. /**
  79396. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79397. */
  79398. private _bumpSuperimpose;
  79399. bumpSuperimpose: boolean;
  79400. /**
  79401. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79402. */
  79403. private _fresnelSeparate;
  79404. fresnelSeparate: boolean;
  79405. /**
  79406. * @param {boolean}: bump Waves modify the reflection.
  79407. */
  79408. private _bumpAffectsReflection;
  79409. bumpAffectsReflection: boolean;
  79410. /**
  79411. * @param {number}: The water color blended with the refraction (near)
  79412. */
  79413. waterColor: BABYLON.Color3;
  79414. /**
  79415. * @param {number}: The blend factor related to the water color
  79416. */
  79417. colorBlendFactor: number;
  79418. /**
  79419. * @param {number}: The water color blended with the reflection (far)
  79420. */
  79421. waterColor2: BABYLON.Color3;
  79422. /**
  79423. * @param {number}: The blend factor related to the water color (reflection, far)
  79424. */
  79425. colorBlendFactor2: number;
  79426. /**
  79427. * @param {number}: Represents the maximum length of a wave
  79428. */
  79429. waveLength: number;
  79430. /**
  79431. * @param {number}: Defines the waves speed
  79432. */
  79433. waveSpeed: number;
  79434. /**
  79435. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79436. * will avoid calculating useless pixels in the pixel shader of the water material.
  79437. */
  79438. disableClipPlane: boolean;
  79439. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79440. private _mesh;
  79441. private _refractionRTT;
  79442. private _reflectionRTT;
  79443. private _reflectionTransform;
  79444. private _lastTime;
  79445. private _lastDeltaTime;
  79446. private _renderId;
  79447. private _useLogarithmicDepth;
  79448. private _waitingRenderList;
  79449. private _imageProcessingConfiguration;
  79450. private _imageProcessingObserver;
  79451. /**
  79452. * Gets a boolean indicating that current material needs to register RTT
  79453. */
  79454. get hasRenderTargetTextures(): boolean;
  79455. /**
  79456. * Constructor
  79457. */
  79458. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79459. get useLogarithmicDepth(): boolean;
  79460. set useLogarithmicDepth(value: boolean);
  79461. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79462. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79463. addToRenderList(node: any): void;
  79464. enableRenderTargets(enable: boolean): void;
  79465. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79466. get renderTargetsEnabled(): boolean;
  79467. needAlphaBlending(): boolean;
  79468. needAlphaTesting(): boolean;
  79469. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79470. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79471. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79472. private _createRenderTargets;
  79473. getAnimatables(): BABYLON.IAnimatable[];
  79474. getActiveTextures(): BABYLON.BaseTexture[];
  79475. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79476. dispose(forceDisposeEffect?: boolean): void;
  79477. clone(name: string): WaterMaterial;
  79478. serialize(): any;
  79479. getClassName(): string;
  79480. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79481. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79482. }
  79483. }
  79484. declare module BABYLON {
  79485. /** @hidden */
  79486. export var asciiartPixelShader: {
  79487. name: string;
  79488. shader: string;
  79489. };
  79490. }
  79491. declare module BABYLON {
  79492. /**
  79493. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79494. *
  79495. * It basically takes care rendering the font front the given font size to a texture.
  79496. * This is used later on in the postprocess.
  79497. */
  79498. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79499. private _font;
  79500. private _text;
  79501. private _charSize;
  79502. /**
  79503. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79504. */
  79505. get charSize(): number;
  79506. /**
  79507. * Create a new instance of the Ascii Art FontTexture class
  79508. * @param name the name of the texture
  79509. * @param font the font to use, use the W3C CSS notation
  79510. * @param text the caracter set to use in the rendering.
  79511. * @param scene the scene that owns the texture
  79512. */
  79513. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79514. /**
  79515. * Gets the max char width of a font.
  79516. * @param font the font to use, use the W3C CSS notation
  79517. * @return the max char width
  79518. */
  79519. private getFontWidth;
  79520. /**
  79521. * Gets the max char height of a font.
  79522. * @param font the font to use, use the W3C CSS notation
  79523. * @return the max char height
  79524. */
  79525. private getFontHeight;
  79526. /**
  79527. * Clones the current AsciiArtTexture.
  79528. * @return the clone of the texture.
  79529. */
  79530. clone(): AsciiArtFontTexture;
  79531. /**
  79532. * Parses a json object representing the texture and returns an instance of it.
  79533. * @param source the source JSON representation
  79534. * @param scene the scene to create the texture for
  79535. * @return the parsed texture
  79536. */
  79537. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79538. }
  79539. /**
  79540. * Option available in the Ascii Art Post Process.
  79541. */
  79542. export interface IAsciiArtPostProcessOptions {
  79543. /**
  79544. * The font to use following the w3c font definition.
  79545. */
  79546. font?: string;
  79547. /**
  79548. * The character set to use in the postprocess.
  79549. */
  79550. characterSet?: string;
  79551. /**
  79552. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79553. * This number is defined between 0 and 1;
  79554. */
  79555. mixToTile?: number;
  79556. /**
  79557. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79558. * This number is defined between 0 and 1;
  79559. */
  79560. mixToNormal?: number;
  79561. }
  79562. /**
  79563. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79564. *
  79565. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79566. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79567. */
  79568. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79569. /**
  79570. * The font texture used to render the char in the post process.
  79571. */
  79572. private _asciiArtFontTexture;
  79573. /**
  79574. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79575. * This number is defined between 0 and 1;
  79576. */
  79577. mixToTile: number;
  79578. /**
  79579. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79580. * This number is defined between 0 and 1;
  79581. */
  79582. mixToNormal: number;
  79583. /**
  79584. * Instantiates a new Ascii Art Post Process.
  79585. * @param name the name to give to the postprocess
  79586. * @camera the camera to apply the post process to.
  79587. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79588. */
  79589. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79590. }
  79591. }
  79592. declare module BABYLON {
  79593. /** @hidden */
  79594. export var digitalrainPixelShader: {
  79595. name: string;
  79596. shader: string;
  79597. };
  79598. }
  79599. declare module BABYLON {
  79600. /**
  79601. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79602. *
  79603. * It basically takes care rendering the font front the given font size to a texture.
  79604. * This is used later on in the postprocess.
  79605. */
  79606. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79607. private _font;
  79608. private _text;
  79609. private _charSize;
  79610. /**
  79611. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79612. */
  79613. get charSize(): number;
  79614. /**
  79615. * Create a new instance of the Digital Rain FontTexture class
  79616. * @param name the name of the texture
  79617. * @param font the font to use, use the W3C CSS notation
  79618. * @param text the caracter set to use in the rendering.
  79619. * @param scene the scene that owns the texture
  79620. */
  79621. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79622. /**
  79623. * Gets the max char width of a font.
  79624. * @param font the font to use, use the W3C CSS notation
  79625. * @return the max char width
  79626. */
  79627. private getFontWidth;
  79628. /**
  79629. * Gets the max char height of a font.
  79630. * @param font the font to use, use the W3C CSS notation
  79631. * @return the max char height
  79632. */
  79633. private getFontHeight;
  79634. /**
  79635. * Clones the current DigitalRainFontTexture.
  79636. * @return the clone of the texture.
  79637. */
  79638. clone(): DigitalRainFontTexture;
  79639. /**
  79640. * Parses a json object representing the texture and returns an instance of it.
  79641. * @param source the source JSON representation
  79642. * @param scene the scene to create the texture for
  79643. * @return the parsed texture
  79644. */
  79645. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79646. }
  79647. /**
  79648. * Option available in the Digital Rain Post Process.
  79649. */
  79650. export interface IDigitalRainPostProcessOptions {
  79651. /**
  79652. * The font to use following the w3c font definition.
  79653. */
  79654. font?: string;
  79655. /**
  79656. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79657. * This number is defined between 0 and 1;
  79658. */
  79659. mixToTile?: number;
  79660. /**
  79661. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79662. * This number is defined between 0 and 1;
  79663. */
  79664. mixToNormal?: number;
  79665. }
  79666. /**
  79667. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79668. *
  79669. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79670. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79671. */
  79672. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79673. /**
  79674. * The font texture used to render the char in the post process.
  79675. */
  79676. private _digitalRainFontTexture;
  79677. /**
  79678. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79679. * This number is defined between 0 and 1;
  79680. */
  79681. mixToTile: number;
  79682. /**
  79683. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79684. * This number is defined between 0 and 1;
  79685. */
  79686. mixToNormal: number;
  79687. /**
  79688. * Instantiates a new Digital Rain Post Process.
  79689. * @param name the name to give to the postprocess
  79690. * @camera the camera to apply the post process to.
  79691. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79692. */
  79693. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79694. }
  79695. }
  79696. declare module BABYLON {
  79697. /** @hidden */
  79698. export var brickProceduralTexturePixelShader: {
  79699. name: string;
  79700. shader: string;
  79701. };
  79702. }
  79703. declare module BABYLON {
  79704. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79705. private _numberOfBricksHeight;
  79706. private _numberOfBricksWidth;
  79707. private _jointColor;
  79708. private _brickColor;
  79709. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79710. updateShaderUniforms(): void;
  79711. get numberOfBricksHeight(): number;
  79712. set numberOfBricksHeight(value: number);
  79713. get numberOfBricksWidth(): number;
  79714. set numberOfBricksWidth(value: number);
  79715. get jointColor(): BABYLON.Color3;
  79716. set jointColor(value: BABYLON.Color3);
  79717. get brickColor(): BABYLON.Color3;
  79718. set brickColor(value: BABYLON.Color3);
  79719. /**
  79720. * Serializes this brick procedural texture
  79721. * @returns a serialized brick procedural texture object
  79722. */
  79723. serialize(): any;
  79724. /**
  79725. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79726. * @param parsedTexture defines parsed texture data
  79727. * @param scene defines the current scene
  79728. * @param rootUrl defines the root URL containing brick procedural texture information
  79729. * @returns a parsed Brick Procedural BABYLON.Texture
  79730. */
  79731. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79732. }
  79733. }
  79734. declare module BABYLON {
  79735. /** @hidden */
  79736. export var cloudProceduralTexturePixelShader: {
  79737. name: string;
  79738. shader: string;
  79739. };
  79740. }
  79741. declare module BABYLON {
  79742. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79743. private _skyColor;
  79744. private _cloudColor;
  79745. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79746. updateShaderUniforms(): void;
  79747. get skyColor(): BABYLON.Color4;
  79748. set skyColor(value: BABYLON.Color4);
  79749. get cloudColor(): BABYLON.Color4;
  79750. set cloudColor(value: BABYLON.Color4);
  79751. /**
  79752. * Serializes this cloud procedural texture
  79753. * @returns a serialized cloud procedural texture object
  79754. */
  79755. serialize(): any;
  79756. /**
  79757. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79758. * @param parsedTexture defines parsed texture data
  79759. * @param scene defines the current scene
  79760. * @param rootUrl defines the root URL containing cloud procedural texture information
  79761. * @returns a parsed Cloud Procedural BABYLON.Texture
  79762. */
  79763. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79764. }
  79765. }
  79766. declare module BABYLON {
  79767. /** @hidden */
  79768. export var fireProceduralTexturePixelShader: {
  79769. name: string;
  79770. shader: string;
  79771. };
  79772. }
  79773. declare module BABYLON {
  79774. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79775. private _time;
  79776. private _speed;
  79777. private _autoGenerateTime;
  79778. private _fireColors;
  79779. private _alphaThreshold;
  79780. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79781. updateShaderUniforms(): void;
  79782. render(useCameraPostProcess?: boolean): void;
  79783. static get PurpleFireColors(): BABYLON.Color3[];
  79784. static get GreenFireColors(): BABYLON.Color3[];
  79785. static get RedFireColors(): BABYLON.Color3[];
  79786. static get BlueFireColors(): BABYLON.Color3[];
  79787. get autoGenerateTime(): boolean;
  79788. set autoGenerateTime(value: boolean);
  79789. get fireColors(): BABYLON.Color3[];
  79790. set fireColors(value: BABYLON.Color3[]);
  79791. get time(): number;
  79792. set time(value: number);
  79793. get speed(): BABYLON.Vector2;
  79794. set speed(value: BABYLON.Vector2);
  79795. get alphaThreshold(): number;
  79796. set alphaThreshold(value: number);
  79797. /**
  79798. * Serializes this fire procedural texture
  79799. * @returns a serialized fire procedural texture object
  79800. */
  79801. serialize(): any;
  79802. /**
  79803. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79804. * @param parsedTexture defines parsed texture data
  79805. * @param scene defines the current scene
  79806. * @param rootUrl defines the root URL containing fire procedural texture information
  79807. * @returns a parsed Fire Procedural BABYLON.Texture
  79808. */
  79809. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79810. }
  79811. }
  79812. declare module BABYLON {
  79813. /** @hidden */
  79814. export var grassProceduralTexturePixelShader: {
  79815. name: string;
  79816. shader: string;
  79817. };
  79818. }
  79819. declare module BABYLON {
  79820. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79821. private _grassColors;
  79822. private _groundColor;
  79823. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79824. updateShaderUniforms(): void;
  79825. get grassColors(): BABYLON.Color3[];
  79826. set grassColors(value: BABYLON.Color3[]);
  79827. get groundColor(): BABYLON.Color3;
  79828. set groundColor(value: BABYLON.Color3);
  79829. /**
  79830. * Serializes this grass procedural texture
  79831. * @returns a serialized grass procedural texture object
  79832. */
  79833. serialize(): any;
  79834. /**
  79835. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79836. * @param parsedTexture defines parsed texture data
  79837. * @param scene defines the current scene
  79838. * @param rootUrl defines the root URL containing grass procedural texture information
  79839. * @returns a parsed Grass Procedural BABYLON.Texture
  79840. */
  79841. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79842. }
  79843. }
  79844. declare module BABYLON {
  79845. /** @hidden */
  79846. export var marbleProceduralTexturePixelShader: {
  79847. name: string;
  79848. shader: string;
  79849. };
  79850. }
  79851. declare module BABYLON {
  79852. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79853. private _numberOfTilesHeight;
  79854. private _numberOfTilesWidth;
  79855. private _amplitude;
  79856. private _jointColor;
  79857. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79858. updateShaderUniforms(): void;
  79859. get numberOfTilesHeight(): number;
  79860. set numberOfTilesHeight(value: number);
  79861. get amplitude(): number;
  79862. set amplitude(value: number);
  79863. get numberOfTilesWidth(): number;
  79864. set numberOfTilesWidth(value: number);
  79865. get jointColor(): BABYLON.Color3;
  79866. set jointColor(value: BABYLON.Color3);
  79867. /**
  79868. * Serializes this marble procedural texture
  79869. * @returns a serialized marble procedural texture object
  79870. */
  79871. serialize(): any;
  79872. /**
  79873. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79874. * @param parsedTexture defines parsed texture data
  79875. * @param scene defines the current scene
  79876. * @param rootUrl defines the root URL containing marble procedural texture information
  79877. * @returns a parsed Marble Procedural BABYLON.Texture
  79878. */
  79879. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79880. }
  79881. }
  79882. declare module BABYLON {
  79883. /** @hidden */
  79884. export var normalMapProceduralTexturePixelShader: {
  79885. name: string;
  79886. shader: string;
  79887. };
  79888. }
  79889. declare module BABYLON {
  79890. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79891. private _baseTexture;
  79892. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79893. updateShaderUniforms(): void;
  79894. render(useCameraPostProcess?: boolean): void;
  79895. resize(size: any, generateMipMaps: any): void;
  79896. get baseTexture(): BABYLON.Texture;
  79897. set baseTexture(texture: BABYLON.Texture);
  79898. /**
  79899. * Serializes this normal map procedural texture
  79900. * @returns a serialized normal map procedural texture object
  79901. */
  79902. serialize(): any;
  79903. /**
  79904. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79905. * @param parsedTexture defines parsed texture data
  79906. * @param scene defines the current scene
  79907. * @param rootUrl defines the root URL containing normal map procedural texture information
  79908. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79909. */
  79910. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79911. }
  79912. }
  79913. declare module BABYLON {
  79914. /** @hidden */
  79915. export var perlinNoiseProceduralTexturePixelShader: {
  79916. name: string;
  79917. shader: string;
  79918. };
  79919. }
  79920. declare module BABYLON {
  79921. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79922. time: number;
  79923. timeScale: number;
  79924. translationSpeed: number;
  79925. private _currentTranslation;
  79926. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79927. updateShaderUniforms(): void;
  79928. render(useCameraPostProcess?: boolean): void;
  79929. resize(size: any, generateMipMaps: any): void;
  79930. /**
  79931. * Serializes this perlin noise procedural texture
  79932. * @returns a serialized perlin noise procedural texture object
  79933. */
  79934. serialize(): any;
  79935. /**
  79936. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79937. * @param parsedTexture defines parsed texture data
  79938. * @param scene defines the current scene
  79939. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79940. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79941. */
  79942. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79943. }
  79944. }
  79945. declare module BABYLON {
  79946. /** @hidden */
  79947. export var roadProceduralTexturePixelShader: {
  79948. name: string;
  79949. shader: string;
  79950. };
  79951. }
  79952. declare module BABYLON {
  79953. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79954. private _roadColor;
  79955. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79956. updateShaderUniforms(): void;
  79957. get roadColor(): BABYLON.Color3;
  79958. set roadColor(value: BABYLON.Color3);
  79959. /**
  79960. * Serializes this road procedural texture
  79961. * @returns a serialized road procedural texture object
  79962. */
  79963. serialize(): any;
  79964. /**
  79965. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79966. * @param parsedTexture defines parsed texture data
  79967. * @param scene defines the current scene
  79968. * @param rootUrl defines the root URL containing road procedural texture information
  79969. * @returns a parsed Road Procedural BABYLON.Texture
  79970. */
  79971. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79972. }
  79973. }
  79974. declare module BABYLON {
  79975. /** @hidden */
  79976. export var starfieldProceduralTexturePixelShader: {
  79977. name: string;
  79978. shader: string;
  79979. };
  79980. }
  79981. declare module BABYLON {
  79982. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79983. private _time;
  79984. private _alpha;
  79985. private _beta;
  79986. private _zoom;
  79987. private _formuparam;
  79988. private _stepsize;
  79989. private _tile;
  79990. private _brightness;
  79991. private _darkmatter;
  79992. private _distfading;
  79993. private _saturation;
  79994. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79995. updateShaderUniforms(): void;
  79996. get time(): number;
  79997. set time(value: number);
  79998. get alpha(): number;
  79999. set alpha(value: number);
  80000. get beta(): number;
  80001. set beta(value: number);
  80002. get formuparam(): number;
  80003. set formuparam(value: number);
  80004. get stepsize(): number;
  80005. set stepsize(value: number);
  80006. get zoom(): number;
  80007. set zoom(value: number);
  80008. get tile(): number;
  80009. set tile(value: number);
  80010. get brightness(): number;
  80011. set brightness(value: number);
  80012. get darkmatter(): number;
  80013. set darkmatter(value: number);
  80014. get distfading(): number;
  80015. set distfading(value: number);
  80016. get saturation(): number;
  80017. set saturation(value: number);
  80018. /**
  80019. * Serializes this starfield procedural texture
  80020. * @returns a serialized starfield procedural texture object
  80021. */
  80022. serialize(): any;
  80023. /**
  80024. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80025. * @param parsedTexture defines parsed texture data
  80026. * @param scene defines the current scene
  80027. * @param rootUrl defines the root URL containing startfield procedural texture information
  80028. * @returns a parsed Starfield Procedural BABYLON.Texture
  80029. */
  80030. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80031. }
  80032. }
  80033. declare module BABYLON {
  80034. /** @hidden */
  80035. export var woodProceduralTexturePixelShader: {
  80036. name: string;
  80037. shader: string;
  80038. };
  80039. }
  80040. declare module BABYLON {
  80041. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80042. private _ampScale;
  80043. private _woodColor;
  80044. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80045. updateShaderUniforms(): void;
  80046. get ampScale(): number;
  80047. set ampScale(value: number);
  80048. get woodColor(): BABYLON.Color3;
  80049. set woodColor(value: BABYLON.Color3);
  80050. /**
  80051. * Serializes this wood procedural texture
  80052. * @returns a serialized wood procedural texture object
  80053. */
  80054. serialize(): any;
  80055. /**
  80056. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80057. * @param parsedTexture defines parsed texture data
  80058. * @param scene defines the current scene
  80059. * @param rootUrl defines the root URL containing wood procedural texture information
  80060. * @returns a parsed Wood Procedural BABYLON.Texture
  80061. */
  80062. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80063. }
  80064. }