documentation.d.ts 3.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210
  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. * @returns true if the loader can load the specified file
  1047. */
  1048. canLoad(extension: string): boolean;
  1049. /**
  1050. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1051. * @param data contains the texture data
  1052. * @param texture defines the BabylonJS internal texture
  1053. * @param createPolynomials will be true if polynomials have been requested
  1054. * @param onLoad defines the callback to trigger once the texture is ready
  1055. * @param onError defines the callback to trigger in case of error
  1056. */
  1057. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1058. /**
  1059. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1060. * @param data contains the texture data
  1061. * @param texture defines the BabylonJS internal texture
  1062. * @param callback defines the method to call once ready to upload
  1063. */
  1064. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1065. }
  1066. }
  1067. declare module BABYLON {
  1068. /**
  1069. * Class used to store and describe the pipeline context associated with an effect
  1070. */
  1071. export interface IPipelineContext {
  1072. /**
  1073. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1074. */
  1075. isAsync: boolean;
  1076. /**
  1077. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1078. */
  1079. isReady: boolean;
  1080. /** @hidden */
  1081. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1082. }
  1083. }
  1084. declare module BABYLON {
  1085. /**
  1086. * Class used to store gfx data (like WebGLBuffer)
  1087. */
  1088. export class DataBuffer {
  1089. /**
  1090. * Gets or sets the number of objects referencing this buffer
  1091. */
  1092. references: number;
  1093. /** Gets or sets the size of the underlying buffer */
  1094. capacity: number;
  1095. /**
  1096. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1097. */
  1098. is32Bits: boolean;
  1099. /**
  1100. * Gets the underlying buffer
  1101. */
  1102. get underlyingResource(): any;
  1103. }
  1104. }
  1105. declare module BABYLON {
  1106. /** @hidden */
  1107. export interface IShaderProcessor {
  1108. attributeProcessor?: (attribute: string) => string;
  1109. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1110. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1111. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1112. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1113. lineProcessor?: (line: string, isFragment: boolean) => string;
  1114. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1115. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1116. }
  1117. }
  1118. declare module BABYLON {
  1119. /** @hidden */
  1120. export interface ProcessingOptions {
  1121. defines: string[];
  1122. indexParameters: any;
  1123. isFragment: boolean;
  1124. shouldUseHighPrecisionShader: boolean;
  1125. supportsUniformBuffers: boolean;
  1126. shadersRepository: string;
  1127. includesShadersStore: {
  1128. [key: string]: string;
  1129. };
  1130. processor?: IShaderProcessor;
  1131. version: string;
  1132. platformName: string;
  1133. lookForClosingBracketForUniformBuffer?: boolean;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export class ShaderCodeNode {
  1139. line: string;
  1140. children: ShaderCodeNode[];
  1141. additionalDefineKey?: string;
  1142. additionalDefineValue?: string;
  1143. isValid(preprocessors: {
  1144. [key: string]: string;
  1145. }): boolean;
  1146. process(preprocessors: {
  1147. [key: string]: string;
  1148. }, options: ProcessingOptions): string;
  1149. }
  1150. }
  1151. declare module BABYLON {
  1152. /** @hidden */
  1153. export class ShaderCodeCursor {
  1154. private _lines;
  1155. lineIndex: number;
  1156. get currentLine(): string;
  1157. get canRead(): boolean;
  1158. set lines(value: string[]);
  1159. }
  1160. }
  1161. declare module BABYLON {
  1162. /** @hidden */
  1163. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1164. process(preprocessors: {
  1165. [key: string]: string;
  1166. }, options: ProcessingOptions): string;
  1167. }
  1168. }
  1169. declare module BABYLON {
  1170. /** @hidden */
  1171. export class ShaderDefineExpression {
  1172. isTrue(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeTestNode extends ShaderCodeNode {
  1180. testExpression: ShaderDefineExpression;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. }
  1185. }
  1186. declare module BABYLON {
  1187. /** @hidden */
  1188. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1189. define: string;
  1190. not: boolean;
  1191. constructor(define: string, not?: boolean);
  1192. isTrue(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1200. leftOperand: ShaderDefineExpression;
  1201. rightOperand: ShaderDefineExpression;
  1202. isTrue(preprocessors: {
  1203. [key: string]: string;
  1204. }): boolean;
  1205. }
  1206. }
  1207. declare module BABYLON {
  1208. /** @hidden */
  1209. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1210. leftOperand: ShaderDefineExpression;
  1211. rightOperand: ShaderDefineExpression;
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1220. define: string;
  1221. operand: string;
  1222. testValue: string;
  1223. constructor(define: string, operand: string, testValue: string);
  1224. isTrue(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /**
  1231. * Class used to enable access to offline support
  1232. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1233. */
  1234. export interface IOfflineProvider {
  1235. /**
  1236. * Gets a boolean indicating if scene must be saved in the database
  1237. */
  1238. enableSceneOffline: boolean;
  1239. /**
  1240. * Gets a boolean indicating if textures must be saved in the database
  1241. */
  1242. enableTexturesOffline: boolean;
  1243. /**
  1244. * Open the offline support and make it available
  1245. * @param successCallback defines the callback to call on success
  1246. * @param errorCallback defines the callback to call on error
  1247. */
  1248. open(successCallback: () => void, errorCallback: () => void): void;
  1249. /**
  1250. * Loads an image from the offline support
  1251. * @param url defines the url to load from
  1252. * @param image defines the target DOM image
  1253. */
  1254. loadImage(url: string, image: HTMLImageElement): void;
  1255. /**
  1256. * Loads a file from offline support
  1257. * @param url defines the URL to load from
  1258. * @param sceneLoaded defines a callback to call on success
  1259. * @param progressCallBack defines a callback to call when progress changed
  1260. * @param errorCallback defines a callback to call on error
  1261. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1262. */
  1263. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1264. }
  1265. }
  1266. declare module BABYLON {
  1267. /**
  1268. * Class used to help managing file picking and drag'n'drop
  1269. * File Storage
  1270. */
  1271. export class FilesInputStore {
  1272. /**
  1273. * List of files ready to be loaded
  1274. */
  1275. static FilesToLoad: {
  1276. [key: string]: File;
  1277. };
  1278. }
  1279. }
  1280. declare module BABYLON {
  1281. /**
  1282. * Class used to define a retry strategy when error happens while loading assets
  1283. */
  1284. export class RetryStrategy {
  1285. /**
  1286. * Function used to defines an exponential back off strategy
  1287. * @param maxRetries defines the maximum number of retries (3 by default)
  1288. * @param baseInterval defines the interval between retries
  1289. * @returns the strategy function to use
  1290. */
  1291. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * @ignore
  1297. * Application error to support additional information when loading a file
  1298. */
  1299. export abstract class BaseError extends Error {
  1300. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /** @ignore */
  1305. export class LoadFileError extends BaseError {
  1306. request?: WebRequest;
  1307. file?: File;
  1308. /**
  1309. * Creates a new LoadFileError
  1310. * @param message defines the message of the error
  1311. * @param request defines the optional web request
  1312. * @param file defines the optional file
  1313. */
  1314. constructor(message: string, object?: WebRequest | File);
  1315. }
  1316. /** @ignore */
  1317. export class RequestFileError extends BaseError {
  1318. request: WebRequest;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. */
  1324. constructor(message: string, request: WebRequest);
  1325. }
  1326. /** @ignore */
  1327. export class ReadFileError extends BaseError {
  1328. file: File;
  1329. /**
  1330. * Creates a new ReadFileError
  1331. * @param message defines the message of the error
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, file: File);
  1335. }
  1336. /**
  1337. * @hidden
  1338. */
  1339. export class FileTools {
  1340. /**
  1341. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1342. */
  1343. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1344. /**
  1345. * Gets or sets the base URL to use to load assets
  1346. */
  1347. static BaseUrl: string;
  1348. /**
  1349. * Default behaviour for cors in the application.
  1350. * It can be a string if the expected behavior is identical in the entire app.
  1351. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1352. */
  1353. static CorsBehavior: string | ((url: string | string[]) => string);
  1354. /**
  1355. * Gets or sets a function used to pre-process url before using them to load assets
  1356. */
  1357. static PreprocessUrl: (url: string) => string;
  1358. /**
  1359. * Removes unwanted characters from an url
  1360. * @param url defines the url to clean
  1361. * @returns the cleaned url
  1362. */
  1363. private static _CleanUrl;
  1364. /**
  1365. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1366. * @param url define the url we are trying
  1367. * @param element define the dom element where to configure the cors policy
  1368. */
  1369. static SetCorsBehavior(url: string | string[], element: {
  1370. crossOrigin: string | null;
  1371. }): void;
  1372. /**
  1373. * Loads an image as an HTMLImageElement.
  1374. * @param input url string, ArrayBuffer, or Blob to load
  1375. * @param onLoad callback called when the image successfully loads
  1376. * @param onError callback called when the image fails to load
  1377. * @param offlineProvider offline provider for caching
  1378. * @param mimeType optional mime type
  1379. * @returns the HTMLImageElement of the loaded image
  1380. */
  1381. 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>;
  1382. /**
  1383. * Reads a file from a File object
  1384. * @param file defines the file to load
  1385. * @param onSuccess defines the callback to call when data is loaded
  1386. * @param onProgress defines the callback to call during loading process
  1387. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1388. * @param onError defines the callback to call when an error occurs
  1389. * @returns a file request object
  1390. */
  1391. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1392. /**
  1393. * Loads a file from a url
  1394. * @param url url to load
  1395. * @param onSuccess callback called when the file successfully loads
  1396. * @param onProgress callback called while file is loading (if the server supports this mode)
  1397. * @param offlineProvider defines the offline provider for caching
  1398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1399. * @param onError callback called when the file fails to load
  1400. * @returns a file request object
  1401. */
  1402. 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;
  1403. /**
  1404. * Loads a file
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1409. * @param onError callback called when the file fails to load
  1410. * @param onOpened callback called when the web request is opened
  1411. * @returns a file request object
  1412. */
  1413. 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;
  1414. /**
  1415. * Checks if the loaded document was accessed via `file:`-Protocol.
  1416. * @returns boolean
  1417. */
  1418. static IsFileURL(): boolean;
  1419. }
  1420. }
  1421. declare module BABYLON {
  1422. /** @hidden */
  1423. export class ShaderProcessor {
  1424. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1425. private static _ProcessPrecision;
  1426. private static _ExtractOperation;
  1427. private static _BuildSubExpression;
  1428. private static _BuildExpression;
  1429. private static _MoveCursorWithinIf;
  1430. private static _MoveCursor;
  1431. private static _EvaluatePreProcessors;
  1432. private static _PreparePreProcessors;
  1433. private static _ProcessShaderConversion;
  1434. private static _ProcessIncludes;
  1435. /**
  1436. * Loads a file from a url
  1437. * @param url url to load
  1438. * @param onSuccess callback called when the file successfully loads
  1439. * @param onProgress callback called while file is loading (if the server supports this mode)
  1440. * @param offlineProvider defines the offline provider for caching
  1441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1442. * @param onError callback called when the file fails to load
  1443. * @returns a file request object
  1444. * @hidden
  1445. */
  1446. 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;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /**
  1451. * @hidden
  1452. */
  1453. export interface IColor4Like {
  1454. r: float;
  1455. g: float;
  1456. b: float;
  1457. a: float;
  1458. }
  1459. /**
  1460. * @hidden
  1461. */
  1462. export interface IColor3Like {
  1463. r: float;
  1464. g: float;
  1465. b: float;
  1466. }
  1467. /**
  1468. * @hidden
  1469. */
  1470. export interface IVector4Like {
  1471. x: float;
  1472. y: float;
  1473. z: float;
  1474. w: float;
  1475. }
  1476. /**
  1477. * @hidden
  1478. */
  1479. export interface IVector3Like {
  1480. x: float;
  1481. y: float;
  1482. z: float;
  1483. }
  1484. /**
  1485. * @hidden
  1486. */
  1487. export interface IVector2Like {
  1488. x: float;
  1489. y: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IMatrixLike {
  1495. toArray(): DeepImmutable<Float32Array>;
  1496. updateFlag: int;
  1497. }
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IViewportLike {
  1502. x: float;
  1503. y: float;
  1504. width: float;
  1505. height: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IPlaneLike {
  1511. normal: IVector3Like;
  1512. d: float;
  1513. normalize(): void;
  1514. }
  1515. }
  1516. declare module BABYLON {
  1517. /**
  1518. * Interface used to define common properties for effect fallbacks
  1519. */
  1520. export interface IEffectFallbacks {
  1521. /**
  1522. * Removes the defines that should be removed when falling back.
  1523. * @param currentDefines defines the current define statements for the shader.
  1524. * @param effect defines the current effect we try to compile
  1525. * @returns The resulting defines with defines of the current rank removed.
  1526. */
  1527. reduce(currentDefines: string, effect: Effect): string;
  1528. /**
  1529. * Removes the fallback from the bound mesh.
  1530. */
  1531. unBindMesh(): void;
  1532. /**
  1533. * Checks to see if more fallbacks are still availible.
  1534. */
  1535. hasMoreFallbacks: boolean;
  1536. }
  1537. }
  1538. declare module BABYLON {
  1539. /**
  1540. * Class used to evalaute queries containing `and` and `or` operators
  1541. */
  1542. export class AndOrNotEvaluator {
  1543. /**
  1544. * Evaluate a query
  1545. * @param query defines the query to evaluate
  1546. * @param evaluateCallback defines the callback used to filter result
  1547. * @returns true if the query matches
  1548. */
  1549. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1550. private static _HandleParenthesisContent;
  1551. private static _SimplifyNegation;
  1552. }
  1553. }
  1554. declare module BABYLON {
  1555. /**
  1556. * Class used to store custom tags
  1557. */
  1558. export class Tags {
  1559. /**
  1560. * Adds support for tags on the given object
  1561. * @param obj defines the object to use
  1562. */
  1563. static EnableFor(obj: any): void;
  1564. /**
  1565. * Removes tags support
  1566. * @param obj defines the object to use
  1567. */
  1568. static DisableFor(obj: any): void;
  1569. /**
  1570. * Gets a boolean indicating if the given object has tags
  1571. * @param obj defines the object to use
  1572. * @returns a boolean
  1573. */
  1574. static HasTags(obj: any): boolean;
  1575. /**
  1576. * Gets the tags available on a given object
  1577. * @param obj defines the object to use
  1578. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1579. * @returns the tags
  1580. */
  1581. static GetTags(obj: any, asString?: boolean): any;
  1582. /**
  1583. * Adds tags to an object
  1584. * @param obj defines the object to use
  1585. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1586. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1587. */
  1588. static AddTagsTo(obj: any, tagsString: string): void;
  1589. /**
  1590. * @hidden
  1591. */
  1592. static _AddTagTo(obj: any, tag: string): void;
  1593. /**
  1594. * Removes specific tags from a specific object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tags to remove
  1597. */
  1598. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1599. /**
  1600. * @hidden
  1601. */
  1602. static _RemoveTagFrom(obj: any, tag: string): void;
  1603. /**
  1604. * Defines if tags hosted on an object match a given query
  1605. * @param obj defines the object to use
  1606. * @param tagsQuery defines the tag query
  1607. * @returns a boolean
  1608. */
  1609. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /**
  1614. * Scalar computation library
  1615. */
  1616. export class Scalar {
  1617. /**
  1618. * Two pi constants convenient for computation.
  1619. */
  1620. static TwoPi: number;
  1621. /**
  1622. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1623. * @param a number
  1624. * @param b number
  1625. * @param epsilon (default = 1.401298E-45)
  1626. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1627. */
  1628. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1629. /**
  1630. * Returns a string : the upper case translation of the number i to hexadecimal.
  1631. * @param i number
  1632. * @returns the upper case translation of the number i to hexadecimal.
  1633. */
  1634. static ToHex(i: number): string;
  1635. /**
  1636. * Returns -1 if value is negative and +1 is value is positive.
  1637. * @param value the value
  1638. * @returns the value itself if it's equal to zero.
  1639. */
  1640. static Sign(value: number): number;
  1641. /**
  1642. * Returns the value itself if it's between min and max.
  1643. * Returns min if the value is lower than min.
  1644. * Returns max if the value is greater than max.
  1645. * @param value the value to clmap
  1646. * @param min the min value to clamp to (default: 0)
  1647. * @param max the max value to clamp to (default: 1)
  1648. * @returns the clamped value
  1649. */
  1650. static Clamp(value: number, min?: number, max?: number): number;
  1651. /**
  1652. * the log2 of value.
  1653. * @param value the value to compute log2 of
  1654. * @returns the log2 of value.
  1655. */
  1656. static Log2(value: number): number;
  1657. /**
  1658. * Loops the value, so that it is never larger than length and never smaller than 0.
  1659. *
  1660. * This is similar to the modulo operator but it works with floating point numbers.
  1661. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1662. * With t = 5 and length = 2.5, the result would be 0.0.
  1663. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1664. * @param value the value
  1665. * @param length the length
  1666. * @returns the looped value
  1667. */
  1668. static Repeat(value: number, length: number): number;
  1669. /**
  1670. * Normalize the value between 0.0 and 1.0 using min and max values
  1671. * @param value value to normalize
  1672. * @param min max to normalize between
  1673. * @param max min to normalize between
  1674. * @returns the normalized value
  1675. */
  1676. static Normalize(value: number, min: number, max: number): number;
  1677. /**
  1678. * Denormalize the value from 0.0 and 1.0 using min and max values
  1679. * @param normalized value to denormalize
  1680. * @param min max to denormalize between
  1681. * @param max min to denormalize between
  1682. * @returns the denormalized value
  1683. */
  1684. static Denormalize(normalized: number, min: number, max: number): number;
  1685. /**
  1686. * Calculates the shortest difference between two given angles given in degrees.
  1687. * @param current current angle in degrees
  1688. * @param target target angle in degrees
  1689. * @returns the delta
  1690. */
  1691. static DeltaAngle(current: number, target: number): number;
  1692. /**
  1693. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1694. * @param tx value
  1695. * @param length length
  1696. * @returns The returned value will move back and forth between 0 and length
  1697. */
  1698. static PingPong(tx: number, length: number): number;
  1699. /**
  1700. * Interpolates between min and max with smoothing at the limits.
  1701. *
  1702. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1703. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1704. * @param from from
  1705. * @param to to
  1706. * @param tx value
  1707. * @returns the smooth stepped value
  1708. */
  1709. static SmoothStep(from: number, to: number, tx: number): number;
  1710. /**
  1711. * Moves a value current towards target.
  1712. *
  1713. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1714. * Negative values of maxDelta pushes the value away from target.
  1715. * @param current current value
  1716. * @param target target value
  1717. * @param maxDelta max distance to move
  1718. * @returns resulting value
  1719. */
  1720. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1721. /**
  1722. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1723. *
  1724. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1725. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting angle
  1730. */
  1731. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1734. * @param start start value
  1735. * @param end target value
  1736. * @param amount amount to lerp between
  1737. * @returns the lerped value
  1738. */
  1739. static Lerp(start: number, end: number, amount: number): number;
  1740. /**
  1741. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1742. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1743. * @param start start value
  1744. * @param end target value
  1745. * @param amount amount to lerp between
  1746. * @returns the lerped value
  1747. */
  1748. static LerpAngle(start: number, end: number, amount: number): number;
  1749. /**
  1750. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1751. * @param a start value
  1752. * @param b target value
  1753. * @param value value between a and b
  1754. * @returns the inverseLerp value
  1755. */
  1756. static InverseLerp(a: number, b: number, value: number): number;
  1757. /**
  1758. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1759. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1760. * @param value1 spline value
  1761. * @param tangent1 spline value
  1762. * @param value2 spline value
  1763. * @param tangent2 spline value
  1764. * @param amount input value
  1765. * @returns hermite result
  1766. */
  1767. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1768. /**
  1769. * Returns a random float number between and min and max values
  1770. * @param min min value of random
  1771. * @param max max value of random
  1772. * @returns random value
  1773. */
  1774. static RandomRange(min: number, max: number): number;
  1775. /**
  1776. * This function returns percentage of a number in a given range.
  1777. *
  1778. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1779. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1780. * @param number to convert to percentage
  1781. * @param min min range
  1782. * @param max max range
  1783. * @returns the percentage
  1784. */
  1785. static RangeToPercent(number: number, min: number, max: number): number;
  1786. /**
  1787. * This function returns number that corresponds to the percentage in a given range.
  1788. *
  1789. * PercentToRange(0.34,0,100) will return 34.
  1790. * @param percent to convert to number
  1791. * @param min min range
  1792. * @param max max range
  1793. * @returns the number
  1794. */
  1795. static PercentToRange(percent: number, min: number, max: number): number;
  1796. /**
  1797. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1798. * @param angle The angle to normalize in radian.
  1799. * @return The converted angle.
  1800. */
  1801. static NormalizeRadians(angle: number): number;
  1802. }
  1803. }
  1804. declare module BABYLON {
  1805. /**
  1806. * Constant used to convert a value to gamma space
  1807. * @ignorenaming
  1808. */
  1809. export const ToGammaSpace: number;
  1810. /**
  1811. * Constant used to convert a value to linear space
  1812. * @ignorenaming
  1813. */
  1814. export const ToLinearSpace = 2.2;
  1815. /**
  1816. * Constant used to define the minimal number value in Babylon.js
  1817. * @ignorenaming
  1818. */
  1819. let Epsilon: number;
  1820. }
  1821. declare module BABYLON {
  1822. /**
  1823. * Class used to represent a viewport on screen
  1824. */
  1825. export class Viewport {
  1826. /** viewport left coordinate */
  1827. x: number;
  1828. /** viewport top coordinate */
  1829. y: number;
  1830. /**viewport width */
  1831. width: number;
  1832. /** viewport height */
  1833. height: number;
  1834. /**
  1835. * Creates a Viewport object located at (x, y) and sized (width, height)
  1836. * @param x defines viewport left coordinate
  1837. * @param y defines viewport top coordinate
  1838. * @param width defines the viewport width
  1839. * @param height defines the viewport height
  1840. */
  1841. constructor(
  1842. /** viewport left coordinate */
  1843. x: number,
  1844. /** viewport top coordinate */
  1845. y: number,
  1846. /**viewport width */
  1847. width: number,
  1848. /** viewport height */
  1849. height: number);
  1850. /**
  1851. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1852. * @param renderWidth defines the rendering width
  1853. * @param renderHeight defines the rendering height
  1854. * @returns a new Viewport
  1855. */
  1856. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1857. /**
  1858. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1859. * @param renderWidth defines the rendering width
  1860. * @param renderHeight defines the rendering height
  1861. * @param ref defines the target viewport
  1862. * @returns the current viewport
  1863. */
  1864. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1865. /**
  1866. * Returns a new Viewport copied from the current one
  1867. * @returns a new Viewport
  1868. */
  1869. clone(): Viewport;
  1870. }
  1871. }
  1872. declare module BABYLON {
  1873. /**
  1874. * Class containing a set of static utilities functions for arrays.
  1875. */
  1876. export class ArrayTools {
  1877. /**
  1878. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1879. * @param size the number of element to construct and put in the array
  1880. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1881. * @returns a new array filled with new objects
  1882. */
  1883. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1884. }
  1885. }
  1886. declare module BABYLON {
  1887. /**
  1888. * Class representing a vector containing 2 coordinates
  1889. */
  1890. export class Vector2 {
  1891. /** defines the first coordinate */
  1892. x: number;
  1893. /** defines the second coordinate */
  1894. y: number;
  1895. /**
  1896. * Creates a new Vector2 from the given x and y coordinates
  1897. * @param x defines the first coordinate
  1898. * @param y defines the second coordinate
  1899. */
  1900. constructor(
  1901. /** defines the first coordinate */
  1902. x?: number,
  1903. /** defines the second coordinate */
  1904. y?: number);
  1905. /**
  1906. * Gets a string with the Vector2 coordinates
  1907. * @returns a string with the Vector2 coordinates
  1908. */
  1909. toString(): string;
  1910. /**
  1911. * Gets class name
  1912. * @returns the string "Vector2"
  1913. */
  1914. getClassName(): string;
  1915. /**
  1916. * Gets current vector hash code
  1917. * @returns the Vector2 hash code as a number
  1918. */
  1919. getHashCode(): number;
  1920. /**
  1921. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1922. * @param array defines the source array
  1923. * @param index defines the offset in source array
  1924. * @returns the current Vector2
  1925. */
  1926. toArray(array: FloatArray, index?: number): Vector2;
  1927. /**
  1928. * Copy the current vector to an array
  1929. * @returns a new array with 2 elements: the Vector2 coordinates.
  1930. */
  1931. asArray(): number[];
  1932. /**
  1933. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1934. * @param source defines the source Vector2
  1935. * @returns the current updated Vector2
  1936. */
  1937. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1938. /**
  1939. * Sets the Vector2 coordinates with the given floats
  1940. * @param x defines the first coordinate
  1941. * @param y defines the second coordinate
  1942. * @returns the current updated Vector2
  1943. */
  1944. copyFromFloats(x: number, y: number): Vector2;
  1945. /**
  1946. * Sets the Vector2 coordinates with the given floats
  1947. * @param x defines the first coordinate
  1948. * @param y defines the second coordinate
  1949. * @returns the current updated Vector2
  1950. */
  1951. set(x: number, y: number): Vector2;
  1952. /**
  1953. * Add another vector with the current one
  1954. * @param otherVector defines the other vector
  1955. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1956. */
  1957. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1960. * @param otherVector defines the other vector
  1961. * @param result defines the target vector
  1962. * @returns the unmodified current Vector2
  1963. */
  1964. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1965. /**
  1966. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1967. * @param otherVector defines the other vector
  1968. * @returns the current updated Vector2
  1969. */
  1970. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1971. /**
  1972. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1973. * @param otherVector defines the other vector
  1974. * @returns a new Vector2
  1975. */
  1976. addVector3(otherVector: Vector3): Vector2;
  1977. /**
  1978. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1979. * @param otherVector defines the other vector
  1980. * @returns a new Vector2
  1981. */
  1982. subtract(otherVector: Vector2): Vector2;
  1983. /**
  1984. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1985. * @param otherVector defines the other vector
  1986. * @param result defines the target vector
  1987. * @returns the unmodified current Vector2
  1988. */
  1989. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1990. /**
  1991. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1992. * @param otherVector defines the other vector
  1993. * @returns the current updated Vector2
  1994. */
  1995. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1996. /**
  1997. * Multiplies in place the current Vector2 coordinates by the given ones
  1998. * @param otherVector defines the other vector
  1999. * @returns the current updated Vector2
  2000. */
  2001. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2002. /**
  2003. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2004. * @param otherVector defines the other vector
  2005. * @returns a new Vector2
  2006. */
  2007. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2008. /**
  2009. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @param result defines the target vector
  2012. * @returns the unmodified current Vector2
  2013. */
  2014. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2015. /**
  2016. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2017. * @param x defines the first coordinate
  2018. * @param y defines the second coordinate
  2019. * @returns a new Vector2
  2020. */
  2021. multiplyByFloats(x: number, y: number): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. divide(otherVector: Vector2): Vector2;
  2028. /**
  2029. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Divides the current Vector2 coordinates by the given ones
  2037. * @param otherVector defines the other vector
  2038. * @returns the current updated Vector2
  2039. */
  2040. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Gets a new Vector2 with current Vector2 negated coordinates
  2043. * @returns a new Vector2
  2044. */
  2045. negate(): Vector2;
  2046. /**
  2047. * Negate this vector in place
  2048. * @returns this
  2049. */
  2050. negateInPlace(): Vector2;
  2051. /**
  2052. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2053. * @param result defines the Vector3 object where to store the result
  2054. * @returns the current Vector2
  2055. */
  2056. negateToRef(result: Vector2): Vector2;
  2057. /**
  2058. * Multiply the Vector2 coordinates by scale
  2059. * @param scale defines the scaling factor
  2060. * @returns the current updated Vector2
  2061. */
  2062. scaleInPlace(scale: number): Vector2;
  2063. /**
  2064. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2065. * @param scale defines the scaling factor
  2066. * @returns a new Vector2
  2067. */
  2068. scale(scale: number): Vector2;
  2069. /**
  2070. * Scale the current Vector2 values by a factor to a given Vector2
  2071. * @param scale defines the scale factor
  2072. * @param result defines the Vector2 object where to store the result
  2073. * @returns the unmodified current Vector2
  2074. */
  2075. scaleToRef(scale: number, result: Vector2): Vector2;
  2076. /**
  2077. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2078. * @param scale defines the scale factor
  2079. * @param result defines the Vector2 object where to store the result
  2080. * @returns the unmodified current Vector2
  2081. */
  2082. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2083. /**
  2084. * Gets a boolean if two vectors are equals
  2085. * @param otherVector defines the other vector
  2086. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2087. */
  2088. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2089. /**
  2090. * Gets a boolean if two vectors are equals (using an epsilon value)
  2091. * @param otherVector defines the other vector
  2092. * @param epsilon defines the minimal distance to consider equality
  2093. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2094. */
  2095. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2096. /**
  2097. * Gets a new Vector2 from current Vector2 floored values
  2098. * @returns a new Vector2
  2099. */
  2100. floor(): Vector2;
  2101. /**
  2102. * Gets a new Vector2 from current Vector2 floored values
  2103. * @returns a new Vector2
  2104. */
  2105. fract(): Vector2;
  2106. /**
  2107. * Gets the length of the vector
  2108. * @returns the vector length (float)
  2109. */
  2110. length(): number;
  2111. /**
  2112. * Gets the vector squared length
  2113. * @returns the vector squared length (float)
  2114. */
  2115. lengthSquared(): number;
  2116. /**
  2117. * Normalize the vector
  2118. * @returns the current updated Vector2
  2119. */
  2120. normalize(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 copied from the Vector2
  2123. * @returns a new Vector2
  2124. */
  2125. clone(): Vector2;
  2126. /**
  2127. * Gets a new Vector2(0, 0)
  2128. * @returns a new Vector2
  2129. */
  2130. static Zero(): Vector2;
  2131. /**
  2132. * Gets a new Vector2(1, 1)
  2133. * @returns a new Vector2
  2134. */
  2135. static One(): Vector2;
  2136. /**
  2137. * Gets a new Vector2 set from the given index element of the given array
  2138. * @param array defines the data source
  2139. * @param offset defines the offset in the data source
  2140. * @returns a new Vector2
  2141. */
  2142. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2143. /**
  2144. * Sets "result" from the given index element of the given array
  2145. * @param array defines the data source
  2146. * @param offset defines the offset in the data source
  2147. * @param result defines the target vector
  2148. */
  2149. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2150. /**
  2151. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2152. * @param value1 defines 1st point of control
  2153. * @param value2 defines 2nd point of control
  2154. * @param value3 defines 3rd point of control
  2155. * @param value4 defines 4th point of control
  2156. * @param amount defines the interpolation factor
  2157. * @returns a new Vector2
  2158. */
  2159. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2160. /**
  2161. * 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".
  2162. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2163. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2164. * @param value defines the value to clamp
  2165. * @param min defines the lower limit
  2166. * @param max defines the upper limit
  2167. * @returns a new Vector2
  2168. */
  2169. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2170. /**
  2171. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2172. * @param value1 defines the 1st control point
  2173. * @param tangent1 defines the outgoing tangent
  2174. * @param value2 defines the 2nd control point
  2175. * @param tangent2 defines the incoming tangent
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2182. * @param start defines the start vector
  2183. * @param end defines the end vector
  2184. * @param amount defines the interpolation factor
  2185. * @returns a new Vector2
  2186. */
  2187. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2188. /**
  2189. * Gets the dot product of the vector "left" and the vector "right"
  2190. * @param left defines first vector
  2191. * @param right defines second vector
  2192. * @returns the dot product (float)
  2193. */
  2194. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2195. /**
  2196. * Returns a new Vector2 equal to the normalized given vector
  2197. * @param vector defines the vector to normalize
  2198. * @returns a new Vector2
  2199. */
  2200. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2203. * @param left defines 1st vector
  2204. * @param right defines 2nd vector
  2205. * @returns a new Vector2
  2206. */
  2207. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2210. * @param left defines 1st vector
  2211. * @param right defines 2nd vector
  2212. * @returns a new Vector2
  2213. */
  2214. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2215. /**
  2216. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2217. * @param vector defines the vector to transform
  2218. * @param transformation defines the matrix to apply
  2219. * @returns a new Vector2
  2220. */
  2221. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2222. /**
  2223. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2224. * @param vector defines the vector to transform
  2225. * @param transformation defines the matrix to apply
  2226. * @param result defines the target vector
  2227. */
  2228. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2229. /**
  2230. * Determines if a given vector is included in a triangle
  2231. * @param p defines the vector to test
  2232. * @param p0 defines 1st triangle point
  2233. * @param p1 defines 2nd triangle point
  2234. * @param p2 defines 3rd triangle point
  2235. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2236. */
  2237. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2238. /**
  2239. * Gets the distance between the vectors "value1" and "value2"
  2240. * @param value1 defines first vector
  2241. * @param value2 defines second vector
  2242. * @returns the distance between vectors
  2243. */
  2244. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2245. /**
  2246. * Returns the squared distance between the vectors "value1" and "value2"
  2247. * @param value1 defines first vector
  2248. * @param value2 defines second vector
  2249. * @returns the squared distance between vectors
  2250. */
  2251. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2252. /**
  2253. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2254. * @param value1 defines first vector
  2255. * @param value2 defines second vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2261. * @param p defines the middle point
  2262. * @param segA defines one point of the segment
  2263. * @param segB defines the other point of the segment
  2264. * @returns the shortest distance
  2265. */
  2266. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2267. }
  2268. /**
  2269. * Class used to store (x,y,z) vector representation
  2270. * A Vector3 is the main object used in 3D geometry
  2271. * It can represent etiher the coordinates of a point the space, either a direction
  2272. * Reminder: js uses a left handed forward facing system
  2273. */
  2274. export class Vector3 {
  2275. /**
  2276. * Defines the first coordinates (on X axis)
  2277. */
  2278. x: number;
  2279. /**
  2280. * Defines the second coordinates (on Y axis)
  2281. */
  2282. y: number;
  2283. /**
  2284. * Defines the third coordinates (on Z axis)
  2285. */
  2286. z: number;
  2287. private static _UpReadOnly;
  2288. private static _ZeroReadOnly;
  2289. /**
  2290. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2291. * @param x defines the first coordinates (on X axis)
  2292. * @param y defines the second coordinates (on Y axis)
  2293. * @param z defines the third coordinates (on Z axis)
  2294. */
  2295. constructor(
  2296. /**
  2297. * Defines the first coordinates (on X axis)
  2298. */
  2299. x?: number,
  2300. /**
  2301. * Defines the second coordinates (on Y axis)
  2302. */
  2303. y?: number,
  2304. /**
  2305. * Defines the third coordinates (on Z axis)
  2306. */
  2307. z?: number);
  2308. /**
  2309. * Creates a string representation of the Vector3
  2310. * @returns a string with the Vector3 coordinates.
  2311. */
  2312. toString(): string;
  2313. /**
  2314. * Gets the class name
  2315. * @returns the string "Vector3"
  2316. */
  2317. getClassName(): string;
  2318. /**
  2319. * Creates the Vector3 hash code
  2320. * @returns a number which tends to be unique between Vector3 instances
  2321. */
  2322. getHashCode(): number;
  2323. /**
  2324. * Creates an array containing three elements : the coordinates of the Vector3
  2325. * @returns a new array of numbers
  2326. */
  2327. asArray(): number[];
  2328. /**
  2329. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2330. * @param array defines the destination array
  2331. * @param index defines the offset in the destination array
  2332. * @returns the current Vector3
  2333. */
  2334. toArray(array: FloatArray, index?: number): Vector3;
  2335. /**
  2336. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2337. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2338. */
  2339. toQuaternion(): Quaternion;
  2340. /**
  2341. * Adds the given vector to the current Vector3
  2342. * @param otherVector defines the second operand
  2343. * @returns the current updated Vector3
  2344. */
  2345. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2346. /**
  2347. * Adds the given coordinates to the current Vector3
  2348. * @param x defines the x coordinate of the operand
  2349. * @param y defines the y coordinate of the operand
  2350. * @param z defines the z coordinate of the operand
  2351. * @returns the current updated Vector3
  2352. */
  2353. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2354. /**
  2355. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2356. * @param otherVector defines the second operand
  2357. * @returns the resulting Vector3
  2358. */
  2359. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2360. /**
  2361. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2362. * @param otherVector defines the second operand
  2363. * @param result defines the Vector3 object where to store the result
  2364. * @returns the current Vector3
  2365. */
  2366. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2367. /**
  2368. * Subtract the given vector from the current Vector3
  2369. * @param otherVector defines the second operand
  2370. * @returns the current updated Vector3
  2371. */
  2372. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the resulting Vector3
  2377. */
  2378. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2381. * @param otherVector defines the second operand
  2382. * @param result defines the Vector3 object where to store the result
  2383. * @returns the current Vector3
  2384. */
  2385. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2386. /**
  2387. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2388. * @param x defines the x coordinate of the operand
  2389. * @param y defines the y coordinate of the operand
  2390. * @param z defines the z coordinate of the operand
  2391. * @returns the resulting Vector3
  2392. */
  2393. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2394. /**
  2395. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2396. * @param x defines the x coordinate of the operand
  2397. * @param y defines the y coordinate of the operand
  2398. * @param z defines the z coordinate of the operand
  2399. * @param result defines the Vector3 object where to store the result
  2400. * @returns the current Vector3
  2401. */
  2402. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2403. /**
  2404. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2405. * @returns a new Vector3
  2406. */
  2407. negate(): Vector3;
  2408. /**
  2409. * Negate this vector in place
  2410. * @returns this
  2411. */
  2412. negateInPlace(): Vector3;
  2413. /**
  2414. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. negateToRef(result: Vector3): Vector3;
  2419. /**
  2420. * Multiplies the Vector3 coordinates by the float "scale"
  2421. * @param scale defines the multiplier factor
  2422. * @returns the current updated Vector3
  2423. */
  2424. scaleInPlace(scale: number): Vector3;
  2425. /**
  2426. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2427. * @param scale defines the multiplier factor
  2428. * @returns a new Vector3
  2429. */
  2430. scale(scale: number): Vector3;
  2431. /**
  2432. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2433. * @param scale defines the multiplier factor
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the current Vector3
  2436. */
  2437. scaleToRef(scale: number, result: Vector3): Vector3;
  2438. /**
  2439. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2440. * @param scale defines the scale factor
  2441. * @param result defines the Vector3 object where to store the result
  2442. * @returns the unmodified current Vector3
  2443. */
  2444. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2445. /**
  2446. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2447. * @param otherVector defines the second operand
  2448. * @returns true if both vectors are equals
  2449. */
  2450. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2451. /**
  2452. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2453. * @param otherVector defines the second operand
  2454. * @param epsilon defines the minimal distance to define values as equals
  2455. * @returns true if both vectors are distant less than epsilon
  2456. */
  2457. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2458. /**
  2459. * Returns true if the current Vector3 coordinates equals the given floats
  2460. * @param x defines the x coordinate of the operand
  2461. * @param y defines the y coordinate of the operand
  2462. * @param z defines the z coordinate of the operand
  2463. * @returns true if both vectors are equals
  2464. */
  2465. equalsToFloats(x: number, y: number, z: number): boolean;
  2466. /**
  2467. * Multiplies the current Vector3 coordinates by the given ones
  2468. * @param otherVector defines the second operand
  2469. * @returns the current updated Vector3
  2470. */
  2471. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2472. /**
  2473. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2474. * @param otherVector defines the second operand
  2475. * @returns the new Vector3
  2476. */
  2477. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2478. /**
  2479. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2480. * @param otherVector defines the second operand
  2481. * @param result defines the Vector3 object where to store the result
  2482. * @returns the current Vector3
  2483. */
  2484. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2485. /**
  2486. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2487. * @param x defines the x coordinate of the operand
  2488. * @param y defines the y coordinate of the operand
  2489. * @param z defines the z coordinate of the operand
  2490. * @returns the new Vector3
  2491. */
  2492. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2493. /**
  2494. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2495. * @param otherVector defines the second operand
  2496. * @returns the new Vector3
  2497. */
  2498. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2499. /**
  2500. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2501. * @param otherVector defines the second operand
  2502. * @param result defines the Vector3 object where to store the result
  2503. * @returns the current Vector3
  2504. */
  2505. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2506. /**
  2507. * Divides the current Vector3 coordinates by the given ones.
  2508. * @param otherVector defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. divideInPlace(otherVector: Vector3): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2514. * @param other defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2520. * @param other defines the second operand
  2521. * @returns the current updated Vector3
  2522. */
  2523. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2526. * @param x defines the x coordinate of the operand
  2527. * @param y defines the y coordinate of the operand
  2528. * @param z defines the z coordinate of the operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2534. * @param x defines the x coordinate of the operand
  2535. * @param y defines the y coordinate of the operand
  2536. * @param z defines the z coordinate of the operand
  2537. * @returns the current updated Vector3
  2538. */
  2539. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2540. /**
  2541. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2542. * Check if is non uniform within a certain amount of decimal places to account for this
  2543. * @param epsilon the amount the values can differ
  2544. * @returns if the the vector is non uniform to a certain number of decimal places
  2545. */
  2546. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2547. /**
  2548. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2549. */
  2550. get isNonUniform(): boolean;
  2551. /**
  2552. * Gets a new Vector3 from current Vector3 floored values
  2553. * @returns a new Vector3
  2554. */
  2555. floor(): Vector3;
  2556. /**
  2557. * Gets a new Vector3 from current Vector3 floored values
  2558. * @returns a new Vector3
  2559. */
  2560. fract(): Vector3;
  2561. /**
  2562. * Gets the length of the Vector3
  2563. * @returns the length of the Vector3
  2564. */
  2565. length(): number;
  2566. /**
  2567. * Gets the squared length of the Vector3
  2568. * @returns squared length of the Vector3
  2569. */
  2570. lengthSquared(): number;
  2571. /**
  2572. * Normalize the current Vector3.
  2573. * Please note that this is an in place operation.
  2574. * @returns the current updated Vector3
  2575. */
  2576. normalize(): Vector3;
  2577. /**
  2578. * Reorders the x y z properties of the vector in place
  2579. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2580. * @returns the current updated vector
  2581. */
  2582. reorderInPlace(order: string): this;
  2583. /**
  2584. * Rotates the vector around 0,0,0 by a quaternion
  2585. * @param quaternion the rotation quaternion
  2586. * @param result vector to store the result
  2587. * @returns the resulting vector
  2588. */
  2589. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2590. /**
  2591. * Rotates a vector around a given point
  2592. * @param quaternion the rotation quaternion
  2593. * @param point the point to rotate around
  2594. * @param result vector to store the result
  2595. * @returns the resulting vector
  2596. */
  2597. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2598. /**
  2599. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2600. * The cross product is then orthogonal to both current and "other"
  2601. * @param other defines the right operand
  2602. * @returns the cross product
  2603. */
  2604. cross(other: Vector3): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 with the given input length.
  2607. * Please note that this is an in place operation.
  2608. * @param len the length of the vector
  2609. * @returns the current updated Vector3
  2610. */
  2611. normalizeFromLength(len: number): Vector3;
  2612. /**
  2613. * Normalize the current Vector3 to a new vector
  2614. * @returns the new Vector3
  2615. */
  2616. normalizeToNew(): Vector3;
  2617. /**
  2618. * Normalize the current Vector3 to the reference
  2619. * @param reference define the Vector3 to update
  2620. * @returns the updated Vector3
  2621. */
  2622. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2623. /**
  2624. * Creates a new Vector3 copied from the current Vector3
  2625. * @returns the new Vector3
  2626. */
  2627. clone(): Vector3;
  2628. /**
  2629. * Copies the given vector coordinates to the current Vector3 ones
  2630. * @param source defines the source Vector3
  2631. * @returns the current updated Vector3
  2632. */
  2633. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Copies the given floats to the current Vector3 coordinates
  2636. * @param x defines the x coordinate of the operand
  2637. * @param y defines the y coordinate of the operand
  2638. * @param z defines the z coordinate of the operand
  2639. * @returns the current updated Vector3
  2640. */
  2641. copyFromFloats(x: number, y: number, z: number): Vector3;
  2642. /**
  2643. * Copies the given floats to the current Vector3 coordinates
  2644. * @param x defines the x coordinate of the operand
  2645. * @param y defines the y coordinate of the operand
  2646. * @param z defines the z coordinate of the operand
  2647. * @returns the current updated Vector3
  2648. */
  2649. set(x: number, y: number, z: number): Vector3;
  2650. /**
  2651. * Copies the given float to the current Vector3 coordinates
  2652. * @param v defines the x, y and z coordinates of the operand
  2653. * @returns the current updated Vector3
  2654. */
  2655. setAll(v: number): Vector3;
  2656. /**
  2657. * Get the clip factor between two vectors
  2658. * @param vector0 defines the first operand
  2659. * @param vector1 defines the second operand
  2660. * @param axis defines the axis to use
  2661. * @param size defines the size along the axis
  2662. * @returns the clip factor
  2663. */
  2664. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2665. /**
  2666. * Get angle between two vectors
  2667. * @param vector0 angle between vector0 and vector1
  2668. * @param vector1 angle between vector0 and vector1
  2669. * @param normal direction of the normal
  2670. * @return the angle between vector0 and vector1
  2671. */
  2672. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2673. /**
  2674. * Returns a new Vector3 set from the index "offset" of the given array
  2675. * @param array defines the source array
  2676. * @param offset defines the offset in the source array
  2677. * @returns the new Vector3
  2678. */
  2679. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2680. /**
  2681. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2682. * @param array defines the source array
  2683. * @param offset defines the offset in the source array
  2684. * @returns the new Vector3
  2685. * @deprecated Please use FromArray instead.
  2686. */
  2687. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2688. /**
  2689. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2690. * @param array defines the source array
  2691. * @param offset defines the offset in the source array
  2692. * @param result defines the Vector3 where to store the result
  2693. */
  2694. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2695. /**
  2696. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2697. * @param array defines the source array
  2698. * @param offset defines the offset in the source array
  2699. * @param result defines the Vector3 where to store the result
  2700. * @deprecated Please use FromArrayToRef instead.
  2701. */
  2702. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2703. /**
  2704. * Sets the given vector "result" with the given floats.
  2705. * @param x defines the x coordinate of the source
  2706. * @param y defines the y coordinate of the source
  2707. * @param z defines the z coordinate of the source
  2708. * @param result defines the Vector3 where to store the result
  2709. */
  2710. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2711. /**
  2712. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2713. * @returns a new empty Vector3
  2714. */
  2715. static Zero(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2718. * @returns a new unit Vector3
  2719. */
  2720. static One(): Vector3;
  2721. /**
  2722. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2723. * @returns a new up Vector3
  2724. */
  2725. static Up(): Vector3;
  2726. /**
  2727. * Gets a up Vector3 that must not be updated
  2728. */
  2729. static get UpReadOnly(): DeepImmutable<Vector3>;
  2730. /**
  2731. * Gets a zero Vector3 that must not be updated
  2732. */
  2733. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2736. * @returns a new down Vector3
  2737. */
  2738. static Down(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2741. * @returns a new forward Vector3
  2742. */
  2743. static Forward(): Vector3;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2746. * @returns a new forward Vector3
  2747. */
  2748. static Backward(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2751. * @returns a new right Vector3
  2752. */
  2753. static Right(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2756. * @returns a new left Vector3
  2757. */
  2758. static Left(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2761. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2762. * @param vector defines the Vector3 to transform
  2763. * @param transformation defines the transformation matrix
  2764. * @returns the transformed Vector3
  2765. */
  2766. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2767. /**
  2768. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2769. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2770. * @param vector defines the Vector3 to transform
  2771. * @param transformation defines the transformation matrix
  2772. * @param result defines the Vector3 where to store the result
  2773. */
  2774. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2775. /**
  2776. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2777. * This method computes tranformed coordinates only, not transformed direction vectors
  2778. * @param x define the x coordinate of the source vector
  2779. * @param y define the y coordinate of the source vector
  2780. * @param z define the z coordinate of the source vector
  2781. * @param transformation defines the transformation matrix
  2782. * @param result defines the Vector3 where to store the result
  2783. */
  2784. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2785. /**
  2786. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2787. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @returns the new Vector3
  2791. */
  2792. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2793. /**
  2794. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2795. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2796. * @param vector defines the Vector3 to transform
  2797. * @param transformation defines the transformation matrix
  2798. * @param result defines the Vector3 where to store the result
  2799. */
  2800. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2801. /**
  2802. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2803. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2804. * @param x define the x coordinate of the source vector
  2805. * @param y define the y coordinate of the source vector
  2806. * @param z define the z coordinate of the source vector
  2807. * @param transformation defines the transformation matrix
  2808. * @param result defines the Vector3 where to store the result
  2809. */
  2810. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2811. /**
  2812. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2813. * @param value1 defines the first control point
  2814. * @param value2 defines the second control point
  2815. * @param value3 defines the third control point
  2816. * @param value4 defines the fourth control point
  2817. * @param amount defines the amount on the spline to use
  2818. * @returns the new Vector3
  2819. */
  2820. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2821. /**
  2822. * 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"
  2823. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2824. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2825. * @param value defines the current value
  2826. * @param min defines the lower range value
  2827. * @param max defines the upper range value
  2828. * @returns the new Vector3
  2829. */
  2830. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2831. /**
  2832. * 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"
  2833. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2834. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2835. * @param value defines the current value
  2836. * @param min defines the lower range value
  2837. * @param max defines the upper range value
  2838. * @param result defines the Vector3 where to store the result
  2839. */
  2840. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2841. /**
  2842. * Checks if a given vector is inside a specific range
  2843. * @param v defines the vector to test
  2844. * @param min defines the minimum range
  2845. * @param max defines the maximum range
  2846. */
  2847. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2848. /**
  2849. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2850. * @param value1 defines the first control point
  2851. * @param tangent1 defines the first tangent vector
  2852. * @param value2 defines the second control point
  2853. * @param tangent2 defines the second tangent vector
  2854. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2855. * @returns the new Vector3
  2856. */
  2857. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2858. /**
  2859. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2860. * @param start defines the start value
  2861. * @param end defines the end value
  2862. * @param amount max defines amount between both (between 0 and 1)
  2863. * @returns the new Vector3
  2864. */
  2865. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2866. /**
  2867. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2868. * @param start defines the start value
  2869. * @param end defines the end value
  2870. * @param amount max defines amount between both (between 0 and 1)
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2874. /**
  2875. * Returns the dot product (float) between the vectors "left" and "right"
  2876. * @param left defines the left operand
  2877. * @param right defines the right operand
  2878. * @returns the dot product
  2879. */
  2880. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2881. /**
  2882. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2883. * The cross product is then orthogonal to both "left" and "right"
  2884. * @param left defines the left operand
  2885. * @param right defines the right operand
  2886. * @returns the cross product
  2887. */
  2888. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2889. /**
  2890. * Sets the given vector "result" with the cross product of "left" and "right"
  2891. * The cross product is then orthogonal to both "left" and "right"
  2892. * @param left defines the left operand
  2893. * @param right defines the right operand
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2897. /**
  2898. * Returns a new Vector3 as the normalization of the given vector
  2899. * @param vector defines the Vector3 to normalize
  2900. * @returns the new Vector3
  2901. */
  2902. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2903. /**
  2904. * Sets the given vector "result" with the normalization of the given first vector
  2905. * @param vector defines the Vector3 to normalize
  2906. * @param result defines the Vector3 where to store the result
  2907. */
  2908. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2909. /**
  2910. * Project a Vector3 onto screen space
  2911. * @param vector defines the Vector3 to project
  2912. * @param world defines the world matrix to use
  2913. * @param transform defines the transform (view x projection) matrix to use
  2914. * @param viewport defines the screen viewport to use
  2915. * @returns the new Vector3
  2916. */
  2917. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2918. /** @hidden */
  2919. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2920. /**
  2921. * Unproject from screen space to object space
  2922. * @param source defines the screen space Vector3 to use
  2923. * @param viewportWidth defines the current width of the viewport
  2924. * @param viewportHeight defines the current height of the viewport
  2925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2926. * @param transform defines the transform (view x projection) matrix to use
  2927. * @returns the new Vector3
  2928. */
  2929. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2930. /**
  2931. * Unproject from screen space to object space
  2932. * @param source defines the screen space Vector3 to use
  2933. * @param viewportWidth defines the current width of the viewport
  2934. * @param viewportHeight defines the current height of the viewport
  2935. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2936. * @param view defines the view matrix to use
  2937. * @param projection defines the projection matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @param result defines the Vector3 where to store the result
  2950. */
  2951. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param sourceX defines the screen space x coordinate to use
  2955. * @param sourceY defines the screen space y coordinate to use
  2956. * @param sourceZ defines the screen space z coordinate to use
  2957. * @param viewportWidth defines the current width of the viewport
  2958. * @param viewportHeight defines the current height of the viewport
  2959. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2960. * @param view defines the view matrix to use
  2961. * @param projection defines the projection matrix to use
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2965. /**
  2966. * Gets the minimal coordinate values between two Vector3
  2967. * @param left defines the first operand
  2968. * @param right defines the second operand
  2969. * @returns the new Vector3
  2970. */
  2971. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2972. /**
  2973. * Gets the maximal coordinate values between two Vector3
  2974. * @param left defines the first operand
  2975. * @param right defines the second operand
  2976. * @returns the new Vector3
  2977. */
  2978. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2979. /**
  2980. * Returns the distance between the vectors "value1" and "value2"
  2981. * @param value1 defines the first operand
  2982. * @param value2 defines the second operand
  2983. * @returns the distance
  2984. */
  2985. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2986. /**
  2987. * Returns the squared distance between the vectors "value1" and "value2"
  2988. * @param value1 defines the first operand
  2989. * @param value2 defines the second operand
  2990. * @returns the squared distance
  2991. */
  2992. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2993. /**
  2994. * Returns a new Vector3 located at the center between "value1" and "value2"
  2995. * @param value1 defines the first operand
  2996. * @param value2 defines the second operand
  2997. * @returns the new Vector3
  2998. */
  2999. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3000. /**
  3001. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3002. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3003. * to something in order to rotate it from its local system to the given target system
  3004. * Note: axis1, axis2 and axis3 are normalized during this operation
  3005. * @param axis1 defines the first axis
  3006. * @param axis2 defines the second axis
  3007. * @param axis3 defines the third axis
  3008. * @returns a new Vector3
  3009. */
  3010. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3013. * @param axis1 defines the first axis
  3014. * @param axis2 defines the second axis
  3015. * @param axis3 defines the third axis
  3016. * @param ref defines the Vector3 where to store the result
  3017. */
  3018. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3019. }
  3020. /**
  3021. * Vector4 class created for EulerAngle class conversion to Quaternion
  3022. */
  3023. export class Vector4 {
  3024. /** x value of the vector */
  3025. x: number;
  3026. /** y value of the vector */
  3027. y: number;
  3028. /** z value of the vector */
  3029. z: number;
  3030. /** w value of the vector */
  3031. w: number;
  3032. /**
  3033. * Creates a Vector4 object from the given floats.
  3034. * @param x x value of the vector
  3035. * @param y y value of the vector
  3036. * @param z z value of the vector
  3037. * @param w w value of the vector
  3038. */
  3039. constructor(
  3040. /** x value of the vector */
  3041. x: number,
  3042. /** y value of the vector */
  3043. y: number,
  3044. /** z value of the vector */
  3045. z: number,
  3046. /** w value of the vector */
  3047. w: number);
  3048. /**
  3049. * Returns the string with the Vector4 coordinates.
  3050. * @returns a string containing all the vector values
  3051. */
  3052. toString(): string;
  3053. /**
  3054. * Returns the string "Vector4".
  3055. * @returns "Vector4"
  3056. */
  3057. getClassName(): string;
  3058. /**
  3059. * Returns the Vector4 hash code.
  3060. * @returns a unique hash code
  3061. */
  3062. getHashCode(): number;
  3063. /**
  3064. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3065. * @returns the resulting array
  3066. */
  3067. asArray(): number[];
  3068. /**
  3069. * Populates the given array from the given index with the Vector4 coordinates.
  3070. * @param array array to populate
  3071. * @param index index of the array to start at (default: 0)
  3072. * @returns the Vector4.
  3073. */
  3074. toArray(array: FloatArray, index?: number): Vector4;
  3075. /**
  3076. * Adds the given vector to the current Vector4.
  3077. * @param otherVector the vector to add
  3078. * @returns the updated Vector4.
  3079. */
  3080. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3081. /**
  3082. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3083. * @param otherVector the vector to add
  3084. * @returns the resulting vector
  3085. */
  3086. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3087. /**
  3088. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3089. * @param otherVector the vector to add
  3090. * @param result the vector to store the result
  3091. * @returns the current Vector4.
  3092. */
  3093. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3094. /**
  3095. * Subtract in place the given vector from the current Vector4.
  3096. * @param otherVector the vector to subtract
  3097. * @returns the updated Vector4.
  3098. */
  3099. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3100. /**
  3101. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3102. * @param otherVector the vector to add
  3103. * @returns the new vector with the result
  3104. */
  3105. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3106. /**
  3107. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3108. * @param otherVector the vector to subtract
  3109. * @param result the vector to store the result
  3110. * @returns the current Vector4.
  3111. */
  3112. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3113. /**
  3114. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3115. */
  3116. /**
  3117. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3118. * @param x value to subtract
  3119. * @param y value to subtract
  3120. * @param z value to subtract
  3121. * @param w value to subtract
  3122. * @returns new vector containing the result
  3123. */
  3124. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3125. /**
  3126. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3127. * @param x value to subtract
  3128. * @param y value to subtract
  3129. * @param z value to subtract
  3130. * @param w value to subtract
  3131. * @param result the vector to store the result in
  3132. * @returns the current Vector4.
  3133. */
  3134. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3135. /**
  3136. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3137. * @returns a new vector with the negated values
  3138. */
  3139. negate(): Vector4;
  3140. /**
  3141. * Negate this vector in place
  3142. * @returns this
  3143. */
  3144. negateInPlace(): Vector4;
  3145. /**
  3146. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3147. * @param result defines the Vector3 object where to store the result
  3148. * @returns the current Vector4
  3149. */
  3150. negateToRef(result: Vector4): Vector4;
  3151. /**
  3152. * Multiplies the current Vector4 coordinates by scale (float).
  3153. * @param scale the number to scale with
  3154. * @returns the updated Vector4.
  3155. */
  3156. scaleInPlace(scale: number): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3159. * @param scale the number to scale with
  3160. * @returns a new vector with the result
  3161. */
  3162. scale(scale: number): Vector4;
  3163. /**
  3164. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3165. * @param scale the number to scale with
  3166. * @param result a vector to store the result in
  3167. * @returns the current Vector4.
  3168. */
  3169. scaleToRef(scale: number, result: Vector4): Vector4;
  3170. /**
  3171. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3172. * @param scale defines the scale factor
  3173. * @param result defines the Vector4 object where to store the result
  3174. * @returns the unmodified current Vector4
  3175. */
  3176. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3179. * @param otherVector the vector to compare against
  3180. * @returns true if they are equal
  3181. */
  3182. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3183. /**
  3184. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3185. * @param otherVector vector to compare against
  3186. * @param epsilon (Default: very small number)
  3187. * @returns true if they are equal
  3188. */
  3189. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3190. /**
  3191. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3192. * @param x x value to compare against
  3193. * @param y y value to compare against
  3194. * @param z z value to compare against
  3195. * @param w w value to compare against
  3196. * @returns true if equal
  3197. */
  3198. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3199. /**
  3200. * Multiplies in place the current Vector4 by the given one.
  3201. * @param otherVector vector to multiple with
  3202. * @returns the updated Vector4.
  3203. */
  3204. multiplyInPlace(otherVector: Vector4): Vector4;
  3205. /**
  3206. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3207. * @param otherVector vector to multiple with
  3208. * @returns resulting new vector
  3209. */
  3210. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3211. /**
  3212. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3213. * @param otherVector vector to multiple with
  3214. * @param result vector to store the result
  3215. * @returns the current Vector4.
  3216. */
  3217. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3218. /**
  3219. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3220. * @param x x value multiply with
  3221. * @param y y value multiply with
  3222. * @param z z value multiply with
  3223. * @param w w value multiply with
  3224. * @returns resulting new vector
  3225. */
  3226. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3227. /**
  3228. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3229. * @param otherVector vector to devide with
  3230. * @returns resulting new vector
  3231. */
  3232. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3235. * @param otherVector vector to devide with
  3236. * @param result vector to store the result
  3237. * @returns the current Vector4.
  3238. */
  3239. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3240. /**
  3241. * Divides the current Vector3 coordinates by the given ones.
  3242. * @param otherVector vector to devide with
  3243. * @returns the updated Vector3.
  3244. */
  3245. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3246. /**
  3247. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3248. * @param other defines the second operand
  3249. * @returns the current updated Vector4
  3250. */
  3251. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3254. * @param other defines the second operand
  3255. * @returns the current updated Vector4
  3256. */
  3257. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Gets a new Vector4 from current Vector4 floored values
  3260. * @returns a new Vector4
  3261. */
  3262. floor(): Vector4;
  3263. /**
  3264. * Gets a new Vector4 from current Vector3 floored values
  3265. * @returns a new Vector4
  3266. */
  3267. fract(): Vector4;
  3268. /**
  3269. * Returns the Vector4 length (float).
  3270. * @returns the length
  3271. */
  3272. length(): number;
  3273. /**
  3274. * Returns the Vector4 squared length (float).
  3275. * @returns the length squared
  3276. */
  3277. lengthSquared(): number;
  3278. /**
  3279. * Normalizes in place the Vector4.
  3280. * @returns the updated Vector4.
  3281. */
  3282. normalize(): Vector4;
  3283. /**
  3284. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3285. * @returns this converted to a new vector3
  3286. */
  3287. toVector3(): Vector3;
  3288. /**
  3289. * Returns a new Vector4 copied from the current one.
  3290. * @returns the new cloned vector
  3291. */
  3292. clone(): Vector4;
  3293. /**
  3294. * Updates the current Vector4 with the given one coordinates.
  3295. * @param source the source vector to copy from
  3296. * @returns the updated Vector4.
  3297. */
  3298. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3299. /**
  3300. * Updates the current Vector4 coordinates with the given floats.
  3301. * @param x float to copy from
  3302. * @param y float to copy from
  3303. * @param z float to copy from
  3304. * @param w float to copy from
  3305. * @returns the updated Vector4.
  3306. */
  3307. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3308. /**
  3309. * Updates the current Vector4 coordinates with the given floats.
  3310. * @param x float to set from
  3311. * @param y float to set from
  3312. * @param z float to set from
  3313. * @param w float to set from
  3314. * @returns the updated Vector4.
  3315. */
  3316. set(x: number, y: number, z: number, w: number): Vector4;
  3317. /**
  3318. * Copies the given float to the current Vector3 coordinates
  3319. * @param v defines the x, y, z and w coordinates of the operand
  3320. * @returns the current updated Vector3
  3321. */
  3322. setAll(v: number): Vector4;
  3323. /**
  3324. * Returns a new Vector4 set from the starting index of the given array.
  3325. * @param array the array to pull values from
  3326. * @param offset the offset into the array to start at
  3327. * @returns the new vector
  3328. */
  3329. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3330. /**
  3331. * Updates the given vector "result" from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @param result the vector to store the result in
  3335. */
  3336. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given Float32Array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" coordinates from the given floats.
  3346. * @param x float to set from
  3347. * @param y float to set from
  3348. * @param z float to set from
  3349. * @param w float to set from
  3350. * @param result the vector to the floats in
  3351. */
  3352. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3353. /**
  3354. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3355. * @returns the new vector
  3356. */
  3357. static Zero(): Vector4;
  3358. /**
  3359. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3360. * @returns the new vector
  3361. */
  3362. static One(): Vector4;
  3363. /**
  3364. * Returns a new normalized Vector4 from the given one.
  3365. * @param vector the vector to normalize
  3366. * @returns the vector
  3367. */
  3368. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3369. /**
  3370. * Updates the given vector "result" from the normalization of the given one.
  3371. * @param vector the vector to normalize
  3372. * @param result the vector to store the result in
  3373. */
  3374. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3375. /**
  3376. * Returns a vector with the minimum values from the left and right vectors
  3377. * @param left left vector to minimize
  3378. * @param right right vector to minimize
  3379. * @returns a new vector with the minimum of the left and right vector values
  3380. */
  3381. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3382. /**
  3383. * Returns a vector with the maximum values from the left and right vectors
  3384. * @param left left vector to maximize
  3385. * @param right right vector to maximize
  3386. * @returns a new vector with the maximum of the left and right vector values
  3387. */
  3388. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns the distance (float) between the vectors "value1" and "value2".
  3391. * @param value1 value to calulate the distance between
  3392. * @param value2 value to calulate the distance between
  3393. * @return the distance between the two vectors
  3394. */
  3395. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3396. /**
  3397. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors squared
  3401. */
  3402. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the center between
  3406. * @param value2 value to calulate the center between
  3407. * @return the center between the two vectors
  3408. */
  3409. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3412. * This methods computes transformed normalized direction vectors only.
  3413. * @param vector the vector to transform
  3414. * @param transformation the transformation matrix to apply
  3415. * @returns the new vector
  3416. */
  3417. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3418. /**
  3419. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3420. * This methods computes transformed normalized direction vectors only.
  3421. * @param vector the vector to transform
  3422. * @param transformation the transformation matrix to apply
  3423. * @param result the vector to store the result in
  3424. */
  3425. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3426. /**
  3427. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3428. * This methods computes transformed normalized direction vectors only.
  3429. * @param x value to transform
  3430. * @param y value to transform
  3431. * @param z value to transform
  3432. * @param w value to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the results in
  3435. */
  3436. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Creates a new Vector4 from a Vector3
  3439. * @param source defines the source data
  3440. * @param w defines the 4th component (default is 0)
  3441. * @returns a new Vector4
  3442. */
  3443. static FromVector3(source: Vector3, w?: number): Vector4;
  3444. }
  3445. /**
  3446. * Class used to store quaternion data
  3447. * @see https://en.wikipedia.org/wiki/Quaternion
  3448. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3449. */
  3450. export class Quaternion {
  3451. /** defines the first component (0 by default) */
  3452. x: number;
  3453. /** defines the second component (0 by default) */
  3454. y: number;
  3455. /** defines the third component (0 by default) */
  3456. z: number;
  3457. /** defines the fourth component (1.0 by default) */
  3458. w: number;
  3459. /**
  3460. * Creates a new Quaternion from the given floats
  3461. * @param x defines the first component (0 by default)
  3462. * @param y defines the second component (0 by default)
  3463. * @param z defines the third component (0 by default)
  3464. * @param w defines the fourth component (1.0 by default)
  3465. */
  3466. constructor(
  3467. /** defines the first component (0 by default) */
  3468. x?: number,
  3469. /** defines the second component (0 by default) */
  3470. y?: number,
  3471. /** defines the third component (0 by default) */
  3472. z?: number,
  3473. /** defines the fourth component (1.0 by default) */
  3474. w?: number);
  3475. /**
  3476. * Gets a string representation for the current quaternion
  3477. * @returns a string with the Quaternion coordinates
  3478. */
  3479. toString(): string;
  3480. /**
  3481. * Gets the class name of the quaternion
  3482. * @returns the string "Quaternion"
  3483. */
  3484. getClassName(): string;
  3485. /**
  3486. * Gets a hash code for this quaternion
  3487. * @returns the quaternion hash code
  3488. */
  3489. getHashCode(): number;
  3490. /**
  3491. * Copy the quaternion to an array
  3492. * @returns a new array populated with 4 elements from the quaternion coordinates
  3493. */
  3494. asArray(): number[];
  3495. /**
  3496. * Check if two quaternions are equals
  3497. * @param otherQuaternion defines the second operand
  3498. * @return true if the current quaternion and the given one coordinates are strictly equals
  3499. */
  3500. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3501. /**
  3502. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3503. * @param otherQuaternion defines the other quaternion
  3504. * @param epsilon defines the minimal distance to consider equality
  3505. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3506. */
  3507. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. get m(): DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, 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 right 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 LookAtRH(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 right 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 LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module BABYLON {
  4617. /**
  4618. * Defines potential orientation for back face culling
  4619. */
  4620. export enum Orientation {
  4621. /**
  4622. * Clockwise
  4623. */
  4624. CW = 0,
  4625. /** Counter clockwise */
  4626. CCW = 1
  4627. }
  4628. /** Class used to represent a Bezier curve */
  4629. export class BezierCurve {
  4630. /**
  4631. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4632. * @param t defines the time
  4633. * @param x1 defines the left coordinate on X axis
  4634. * @param y1 defines the left coordinate on Y axis
  4635. * @param x2 defines the right coordinate on X axis
  4636. * @param y2 defines the right coordinate on Y axis
  4637. * @returns the interpolated value
  4638. */
  4639. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4640. }
  4641. /**
  4642. * Defines angle representation
  4643. */
  4644. export class Angle {
  4645. private _radians;
  4646. /**
  4647. * Creates an Angle object of "radians" radians (float).
  4648. * @param radians the angle in radians
  4649. */
  4650. constructor(radians: number);
  4651. /**
  4652. * Get value in degrees
  4653. * @returns the Angle value in degrees (float)
  4654. */
  4655. degrees(): number;
  4656. /**
  4657. * Get value in radians
  4658. * @returns the Angle value in radians (float)
  4659. */
  4660. radians(): number;
  4661. /**
  4662. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4663. * @param a defines first vector
  4664. * @param b defines second vector
  4665. * @returns a new Angle
  4666. */
  4667. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4668. /**
  4669. * Gets a new Angle object from the given float in radians
  4670. * @param radians defines the angle value in radians
  4671. * @returns a new Angle
  4672. */
  4673. static FromRadians(radians: number): Angle;
  4674. /**
  4675. * Gets a new Angle object from the given float in degrees
  4676. * @param degrees defines the angle value in degrees
  4677. * @returns a new Angle
  4678. */
  4679. static FromDegrees(degrees: number): Angle;
  4680. }
  4681. /**
  4682. * This represents an arc in a 2d space.
  4683. */
  4684. export class Arc2 {
  4685. /** Defines the start point of the arc */
  4686. startPoint: Vector2;
  4687. /** Defines the mid point of the arc */
  4688. midPoint: Vector2;
  4689. /** Defines the end point of the arc */
  4690. endPoint: Vector2;
  4691. /**
  4692. * Defines the center point of the arc.
  4693. */
  4694. centerPoint: Vector2;
  4695. /**
  4696. * Defines the radius of the arc.
  4697. */
  4698. radius: number;
  4699. /**
  4700. * Defines the angle of the arc (from mid point to end point).
  4701. */
  4702. angle: Angle;
  4703. /**
  4704. * Defines the start angle of the arc (from start point to middle point).
  4705. */
  4706. startAngle: Angle;
  4707. /**
  4708. * Defines the orientation of the arc (clock wise/counter clock wise).
  4709. */
  4710. orientation: Orientation;
  4711. /**
  4712. * Creates an Arc object from the three given points : start, middle and end.
  4713. * @param startPoint Defines the start point of the arc
  4714. * @param midPoint Defines the midlle point of the arc
  4715. * @param endPoint Defines the end point of the arc
  4716. */
  4717. constructor(
  4718. /** Defines the start point of the arc */
  4719. startPoint: Vector2,
  4720. /** Defines the mid point of the arc */
  4721. midPoint: Vector2,
  4722. /** Defines the end point of the arc */
  4723. endPoint: Vector2);
  4724. }
  4725. /**
  4726. * Represents a 2D path made up of multiple 2D points
  4727. */
  4728. export class Path2 {
  4729. private _points;
  4730. private _length;
  4731. /**
  4732. * If the path start and end point are the same
  4733. */
  4734. closed: boolean;
  4735. /**
  4736. * Creates a Path2 object from the starting 2D coordinates x and y.
  4737. * @param x the starting points x value
  4738. * @param y the starting points y value
  4739. */
  4740. constructor(x: number, y: number);
  4741. /**
  4742. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4743. * @param x the added points x value
  4744. * @param y the added points y value
  4745. * @returns the updated Path2.
  4746. */
  4747. addLineTo(x: number, y: number): Path2;
  4748. /**
  4749. * 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.
  4750. * @param midX middle point x value
  4751. * @param midY middle point y value
  4752. * @param endX end point x value
  4753. * @param endY end point y value
  4754. * @param numberOfSegments (default: 36)
  4755. * @returns the updated Path2.
  4756. */
  4757. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4758. /**
  4759. * Closes the Path2.
  4760. * @returns the Path2.
  4761. */
  4762. close(): Path2;
  4763. /**
  4764. * Gets the sum of the distance between each sequential point in the path
  4765. * @returns the Path2 total length (float).
  4766. */
  4767. length(): number;
  4768. /**
  4769. * Gets the points which construct the path
  4770. * @returns the Path2 internal array of points.
  4771. */
  4772. getPoints(): Vector2[];
  4773. /**
  4774. * Retreives the point at the distance aways from the starting point
  4775. * @param normalizedLengthPosition the length along the path to retreive the point from
  4776. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4777. */
  4778. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4779. /**
  4780. * Creates a new path starting from an x and y position
  4781. * @param x starting x value
  4782. * @param y starting y value
  4783. * @returns a new Path2 starting at the coordinates (x, y).
  4784. */
  4785. static StartingAt(x: number, y: number): Path2;
  4786. }
  4787. /**
  4788. * Represents a 3D path made up of multiple 3D points
  4789. */
  4790. export class Path3D {
  4791. /**
  4792. * an array of Vector3, the curve axis of the Path3D
  4793. */
  4794. path: Vector3[];
  4795. private _curve;
  4796. private _distances;
  4797. private _tangents;
  4798. private _normals;
  4799. private _binormals;
  4800. private _raw;
  4801. private _alignTangentsWithPath;
  4802. private readonly _pointAtData;
  4803. /**
  4804. * new Path3D(path, normal, raw)
  4805. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4806. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4807. * @param path an array of Vector3, the curve axis of the Path3D
  4808. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4809. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4810. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4811. */
  4812. constructor(
  4813. /**
  4814. * an array of Vector3, the curve axis of the Path3D
  4815. */
  4816. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4817. /**
  4818. * Returns the Path3D array of successive Vector3 designing its curve.
  4819. * @returns the Path3D array of successive Vector3 designing its curve.
  4820. */
  4821. getCurve(): Vector3[];
  4822. /**
  4823. * Returns the Path3D array of successive Vector3 designing its curve.
  4824. * @returns the Path3D array of successive Vector3 designing its curve.
  4825. */
  4826. getPoints(): Vector3[];
  4827. /**
  4828. * @returns the computed length (float) of the path.
  4829. */
  4830. length(): number;
  4831. /**
  4832. * Returns an array populated with tangent vectors on each Path3D curve point.
  4833. * @returns an array populated with tangent vectors on each Path3D curve point.
  4834. */
  4835. getTangents(): Vector3[];
  4836. /**
  4837. * Returns an array populated with normal vectors on each Path3D curve point.
  4838. * @returns an array populated with normal vectors on each Path3D curve point.
  4839. */
  4840. getNormals(): Vector3[];
  4841. /**
  4842. * Returns an array populated with binormal vectors on each Path3D curve point.
  4843. * @returns an array populated with binormal vectors on each Path3D curve point.
  4844. */
  4845. getBinormals(): Vector3[];
  4846. /**
  4847. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4848. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4849. */
  4850. getDistances(): number[];
  4851. /**
  4852. * Returns an interpolated point along this path
  4853. * @param position the position of the point along this path, from 0.0 to 1.0
  4854. * @returns a new Vector3 as the point
  4855. */
  4856. getPointAt(position: number): Vector3;
  4857. /**
  4858. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4859. * @param position the position of the point along this path, from 0.0 to 1.0
  4860. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4861. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4862. */
  4863. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4864. /**
  4865. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4866. * @param position the position of the point along this path, from 0.0 to 1.0
  4867. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4868. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4869. */
  4870. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4871. /**
  4872. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4873. * @param position the position of the point along this path, from 0.0 to 1.0
  4874. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4875. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4876. */
  4877. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4878. /**
  4879. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4882. */
  4883. getDistanceAt(position: number): number;
  4884. /**
  4885. * Returns the array index of the previous point of an interpolated point along this path
  4886. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4887. * @returns the array index
  4888. */
  4889. getPreviousPointIndexAt(position: number): number;
  4890. /**
  4891. * 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)
  4892. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4893. * @returns the sub position
  4894. */
  4895. getSubPositionAt(position: number): number;
  4896. /**
  4897. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4898. * @param target the vector of which to get the closest position to
  4899. * @returns the position of the closest virtual point on this path to the target vector
  4900. */
  4901. getClosestPositionTo(target: Vector3): number;
  4902. /**
  4903. * Returns a sub path (slice) of this path
  4904. * @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
  4905. * @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
  4906. * @returns a sub path (slice) of this path
  4907. */
  4908. slice(start?: number, end?: number): Path3D;
  4909. /**
  4910. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4911. * @param path path which all values are copied into the curves points
  4912. * @param firstNormal which should be projected onto the curve
  4913. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4914. * @returns the same object updated.
  4915. */
  4916. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4917. private _compute;
  4918. private _getFirstNonNullVector;
  4919. private _getLastNonNullVector;
  4920. private _normalVector;
  4921. /**
  4922. * Updates the point at data for an interpolated point along this curve
  4923. * @param position the position of the point along this curve, from 0.0 to 1.0
  4924. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4925. * @returns the (updated) point at data
  4926. */
  4927. private _updatePointAtData;
  4928. /**
  4929. * Updates the point at data from the specified parameters
  4930. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4931. * @param point the interpolated point
  4932. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4933. */
  4934. private _setPointAtData;
  4935. /**
  4936. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4937. */
  4938. private _updateInterpolationMatrix;
  4939. }
  4940. /**
  4941. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4942. * A Curve3 is designed from a series of successive Vector3.
  4943. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4944. */
  4945. export class Curve3 {
  4946. private _points;
  4947. private _length;
  4948. /**
  4949. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4950. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4951. * @param v1 (Vector3) the control point
  4952. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4953. * @param nbPoints (integer) the wanted number of points in the curve
  4954. * @returns the created Curve3
  4955. */
  4956. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4957. /**
  4958. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4959. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4960. * @param v1 (Vector3) the first control point
  4961. * @param v2 (Vector3) the second control point
  4962. * @param v3 (Vector3) the end point of the Cubic Bezier
  4963. * @param nbPoints (integer) the wanted number of points in the curve
  4964. * @returns the created Curve3
  4965. */
  4966. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4967. /**
  4968. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4969. * @param p1 (Vector3) the origin point of the Hermite Spline
  4970. * @param t1 (Vector3) the tangent vector at the origin point
  4971. * @param p2 (Vector3) the end point of the Hermite Spline
  4972. * @param t2 (Vector3) the tangent vector at the end point
  4973. * @param nbPoints (integer) the wanted number of points in the curve
  4974. * @returns the created Curve3
  4975. */
  4976. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4977. /**
  4978. * Returns a Curve3 object along a CatmullRom Spline curve :
  4979. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4980. * @param nbPoints (integer) the wanted number of points between each curve control points
  4981. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4985. /**
  4986. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4987. * A Curve3 is designed from a series of successive Vector3.
  4988. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4989. * @param points points which make up the curve
  4990. */
  4991. constructor(points: Vector3[]);
  4992. /**
  4993. * @returns the Curve3 stored array of successive Vector3
  4994. */
  4995. getPoints(): Vector3[];
  4996. /**
  4997. * @returns the computed length (float) of the curve.
  4998. */
  4999. length(): number;
  5000. /**
  5001. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5002. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5003. * curveA and curveB keep unchanged.
  5004. * @param curve the curve to continue from this curve
  5005. * @returns the newly constructed curve
  5006. */
  5007. continue(curve: DeepImmutable<Curve3>): Curve3;
  5008. private _computeLength;
  5009. }
  5010. }
  5011. declare module BABYLON {
  5012. /**
  5013. * This represents the main contract an easing function should follow.
  5014. * Easing functions are used throughout the animation system.
  5015. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5016. */
  5017. export interface IEasingFunction {
  5018. /**
  5019. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5020. * of the easing function.
  5021. * The link below provides some of the most common examples of easing functions.
  5022. * @see https://easings.net/
  5023. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5024. * @returns the corresponding value on the curve defined by the easing function
  5025. */
  5026. ease(gradient: number): number;
  5027. }
  5028. /**
  5029. * Base class used for every default easing function.
  5030. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5031. */
  5032. export class EasingFunction implements IEasingFunction {
  5033. /**
  5034. * Interpolation follows the mathematical formula associated with the easing function.
  5035. */
  5036. static readonly EASINGMODE_EASEIN: number;
  5037. /**
  5038. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5039. */
  5040. static readonly EASINGMODE_EASEOUT: number;
  5041. /**
  5042. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5043. */
  5044. static readonly EASINGMODE_EASEINOUT: number;
  5045. private _easingMode;
  5046. /**
  5047. * Sets the easing mode of the current function.
  5048. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5049. */
  5050. setEasingMode(easingMode: number): void;
  5051. /**
  5052. * Gets the current easing mode.
  5053. * @returns the easing mode
  5054. */
  5055. getEasingMode(): number;
  5056. /**
  5057. * @hidden
  5058. */
  5059. easeInCore(gradient: number): number;
  5060. /**
  5061. * Given an input gradient between 0 and 1, this returns the corresponding value
  5062. * of the easing function.
  5063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5064. * @returns the corresponding value on the curve defined by the easing function
  5065. */
  5066. ease(gradient: number): number;
  5067. }
  5068. /**
  5069. * Easing function with a circle shape (see link below).
  5070. * @see https://easings.net/#easeInCirc
  5071. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5072. */
  5073. export class CircleEase extends EasingFunction implements IEasingFunction {
  5074. /** @hidden */
  5075. easeInCore(gradient: number): number;
  5076. }
  5077. /**
  5078. * Easing function with a ease back shape (see link below).
  5079. * @see https://easings.net/#easeInBack
  5080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5081. */
  5082. export class BackEase extends EasingFunction implements IEasingFunction {
  5083. /** Defines the amplitude of the function */
  5084. amplitude: number;
  5085. /**
  5086. * Instantiates a back ease easing
  5087. * @see https://easings.net/#easeInBack
  5088. * @param amplitude Defines the amplitude of the function
  5089. */
  5090. constructor(
  5091. /** Defines the amplitude of the function */
  5092. amplitude?: number);
  5093. /** @hidden */
  5094. easeInCore(gradient: number): number;
  5095. }
  5096. /**
  5097. * Easing function with a bouncing shape (see link below).
  5098. * @see https://easings.net/#easeInBounce
  5099. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5100. */
  5101. export class BounceEase extends EasingFunction implements IEasingFunction {
  5102. /** Defines the number of bounces */
  5103. bounces: number;
  5104. /** Defines the amplitude of the bounce */
  5105. bounciness: number;
  5106. /**
  5107. * Instantiates a bounce easing
  5108. * @see https://easings.net/#easeInBounce
  5109. * @param bounces Defines the number of bounces
  5110. * @param bounciness Defines the amplitude of the bounce
  5111. */
  5112. constructor(
  5113. /** Defines the number of bounces */
  5114. bounces?: number,
  5115. /** Defines the amplitude of the bounce */
  5116. bounciness?: number);
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a power of 3 shape (see link below).
  5122. * @see https://easings.net/#easeInCubic
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class CubicEase extends EasingFunction implements IEasingFunction {
  5126. /** @hidden */
  5127. easeInCore(gradient: number): number;
  5128. }
  5129. /**
  5130. * Easing function with an elastic shape (see link below).
  5131. * @see https://easings.net/#easeInElastic
  5132. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5133. */
  5134. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5135. /** Defines the number of oscillations*/
  5136. oscillations: number;
  5137. /** Defines the amplitude of the oscillations*/
  5138. springiness: number;
  5139. /**
  5140. * Instantiates an elastic easing function
  5141. * @see https://easings.net/#easeInElastic
  5142. * @param oscillations Defines the number of oscillations
  5143. * @param springiness Defines the amplitude of the oscillations
  5144. */
  5145. constructor(
  5146. /** Defines the number of oscillations*/
  5147. oscillations?: number,
  5148. /** Defines the amplitude of the oscillations*/
  5149. springiness?: number);
  5150. /** @hidden */
  5151. easeInCore(gradient: number): number;
  5152. }
  5153. /**
  5154. * Easing function with an exponential shape (see link below).
  5155. * @see https://easings.net/#easeInExpo
  5156. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5157. */
  5158. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5159. /** Defines the exponent of the function */
  5160. exponent: number;
  5161. /**
  5162. * Instantiates an exponential easing function
  5163. * @see https://easings.net/#easeInExpo
  5164. * @param exponent Defines the exponent of the function
  5165. */
  5166. constructor(
  5167. /** Defines the exponent of the function */
  5168. exponent?: number);
  5169. /** @hidden */
  5170. easeInCore(gradient: number): number;
  5171. }
  5172. /**
  5173. * Easing function with a power shape (see link below).
  5174. * @see https://easings.net/#easeInQuad
  5175. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5176. */
  5177. export class PowerEase extends EasingFunction implements IEasingFunction {
  5178. /** Defines the power of the function */
  5179. power: number;
  5180. /**
  5181. * Instantiates an power base easing function
  5182. * @see https://easings.net/#easeInQuad
  5183. * @param power Defines the power of the function
  5184. */
  5185. constructor(
  5186. /** Defines the power of the function */
  5187. power?: number);
  5188. /** @hidden */
  5189. easeInCore(gradient: number): number;
  5190. }
  5191. /**
  5192. * Easing function with a power of 2 shape (see link below).
  5193. * @see https://easings.net/#easeInQuad
  5194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5195. */
  5196. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a power of 4 shape (see link below).
  5202. * @see https://easings.net/#easeInQuart
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 5 shape (see link below).
  5211. * @see https://easings.net/#easeInQuint
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a sin shape (see link below).
  5220. * @see https://easings.net/#easeInSine
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class SineEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a bezier shape (see link below).
  5229. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5233. /** Defines the x component of the start tangent in the bezier curve */
  5234. x1: number;
  5235. /** Defines the y component of the start tangent in the bezier curve */
  5236. y1: number;
  5237. /** Defines the x component of the end tangent in the bezier curve */
  5238. x2: number;
  5239. /** Defines the y component of the end tangent in the bezier curve */
  5240. y2: number;
  5241. /**
  5242. * Instantiates a bezier function
  5243. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5244. * @param x1 Defines the x component of the start tangent in the bezier curve
  5245. * @param y1 Defines the y component of the start tangent in the bezier curve
  5246. * @param x2 Defines the x component of the end tangent in the bezier curve
  5247. * @param y2 Defines the y component of the end tangent in the bezier curve
  5248. */
  5249. constructor(
  5250. /** Defines the x component of the start tangent in the bezier curve */
  5251. x1?: number,
  5252. /** Defines the y component of the start tangent in the bezier curve */
  5253. y1?: number,
  5254. /** Defines the x component of the end tangent in the bezier curve */
  5255. x2?: number,
  5256. /** Defines the y component of the end tangent in the bezier curve */
  5257. y2?: number);
  5258. /** @hidden */
  5259. easeInCore(gradient: number): number;
  5260. }
  5261. }
  5262. declare module BABYLON {
  5263. /**
  5264. * Class used to hold a RBG color
  5265. */
  5266. export class Color3 {
  5267. /**
  5268. * Defines the red component (between 0 and 1, default is 0)
  5269. */
  5270. r: number;
  5271. /**
  5272. * Defines the green component (between 0 and 1, default is 0)
  5273. */
  5274. g: number;
  5275. /**
  5276. * Defines the blue component (between 0 and 1, default is 0)
  5277. */
  5278. b: number;
  5279. /**
  5280. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5281. * @param r defines the red component (between 0 and 1, default is 0)
  5282. * @param g defines the green component (between 0 and 1, default is 0)
  5283. * @param b defines the blue component (between 0 and 1, default is 0)
  5284. */
  5285. constructor(
  5286. /**
  5287. * Defines the red component (between 0 and 1, default is 0)
  5288. */
  5289. r?: number,
  5290. /**
  5291. * Defines the green component (between 0 and 1, default is 0)
  5292. */
  5293. g?: number,
  5294. /**
  5295. * Defines the blue component (between 0 and 1, default is 0)
  5296. */
  5297. b?: number);
  5298. /**
  5299. * Creates a string with the Color3 current values
  5300. * @returns the string representation of the Color3 object
  5301. */
  5302. toString(): string;
  5303. /**
  5304. * Returns the string "Color3"
  5305. * @returns "Color3"
  5306. */
  5307. getClassName(): string;
  5308. /**
  5309. * Compute the Color3 hash code
  5310. * @returns an unique number that can be used to hash Color3 objects
  5311. */
  5312. getHashCode(): number;
  5313. /**
  5314. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5315. * @param array defines the array where to store the r,g,b components
  5316. * @param index defines an optional index in the target array to define where to start storing values
  5317. * @returns the current Color3 object
  5318. */
  5319. toArray(array: FloatArray, index?: number): Color3;
  5320. /**
  5321. * Returns a new Color4 object from the current Color3 and the given alpha
  5322. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5323. * @returns a new Color4 object
  5324. */
  5325. toColor4(alpha?: number): Color4;
  5326. /**
  5327. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5328. * @returns the new array
  5329. */
  5330. asArray(): number[];
  5331. /**
  5332. * Returns the luminance value
  5333. * @returns a float value
  5334. */
  5335. toLuminance(): number;
  5336. /**
  5337. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5338. * @param otherColor defines the second operand
  5339. * @returns the new Color3 object
  5340. */
  5341. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5342. /**
  5343. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5344. * @param otherColor defines the second operand
  5345. * @param result defines the Color3 object where to store the result
  5346. * @returns the current Color3
  5347. */
  5348. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5349. /**
  5350. * Determines equality between Color3 objects
  5351. * @param otherColor defines the second operand
  5352. * @returns true if the rgb values are equal to the given ones
  5353. */
  5354. equals(otherColor: DeepImmutable<Color3>): boolean;
  5355. /**
  5356. * Determines equality between the current Color3 object and a set of r,b,g values
  5357. * @param r defines the red component to check
  5358. * @param g defines the green component to check
  5359. * @param b defines the blue component to check
  5360. * @returns true if the rgb values are equal to the given ones
  5361. */
  5362. equalsFloats(r: number, g: number, b: number): boolean;
  5363. /**
  5364. * Multiplies in place each rgb value by scale
  5365. * @param scale defines the scaling factor
  5366. * @returns the updated Color3
  5367. */
  5368. scale(scale: number): Color3;
  5369. /**
  5370. * Multiplies the rgb values by scale and stores the result into "result"
  5371. * @param scale defines the scaling factor
  5372. * @param result defines the Color3 object where to store the result
  5373. * @returns the unmodified current Color3
  5374. */
  5375. scaleToRef(scale: number, result: Color3): Color3;
  5376. /**
  5377. * Scale the current Color3 values by a factor and add the result to a given Color3
  5378. * @param scale defines the scale factor
  5379. * @param result defines color to store the result into
  5380. * @returns the unmodified current Color3
  5381. */
  5382. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5383. /**
  5384. * Clamps the rgb values by the min and max values and stores the result into "result"
  5385. * @param min defines minimum clamping value (default is 0)
  5386. * @param max defines maximum clamping value (default is 1)
  5387. * @param result defines color to store the result into
  5388. * @returns the original Color3
  5389. */
  5390. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5391. /**
  5392. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5393. * @param otherColor defines the second operand
  5394. * @returns the new Color3
  5395. */
  5396. add(otherColor: DeepImmutable<Color3>): Color3;
  5397. /**
  5398. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5399. * @param otherColor defines the second operand
  5400. * @param result defines Color3 object to store the result into
  5401. * @returns the unmodified current Color3
  5402. */
  5403. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5404. /**
  5405. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5406. * @param otherColor defines the second operand
  5407. * @returns the new Color3
  5408. */
  5409. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5410. /**
  5411. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5412. * @param otherColor defines the second operand
  5413. * @param result defines Color3 object to store the result into
  5414. * @returns the unmodified current Color3
  5415. */
  5416. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5417. /**
  5418. * Copy the current object
  5419. * @returns a new Color3 copied the current one
  5420. */
  5421. clone(): Color3;
  5422. /**
  5423. * Copies the rgb values from the source in the current Color3
  5424. * @param source defines the source Color3 object
  5425. * @returns the updated Color3 object
  5426. */
  5427. copyFrom(source: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Updates the Color3 rgb values from the given floats
  5430. * @param r defines the red component to read from
  5431. * @param g defines the green component to read from
  5432. * @param b defines the blue component to read from
  5433. * @returns the current Color3 object
  5434. */
  5435. copyFromFloats(r: number, g: number, b: number): Color3;
  5436. /**
  5437. * Updates the Color3 rgb values from the given floats
  5438. * @param r defines the red component to read from
  5439. * @param g defines the green component to read from
  5440. * @param b defines the blue component to read from
  5441. * @returns the current Color3 object
  5442. */
  5443. set(r: number, g: number, b: number): Color3;
  5444. /**
  5445. * Compute the Color3 hexadecimal code as a string
  5446. * @returns a string containing the hexadecimal representation of the Color3 object
  5447. */
  5448. toHexString(): string;
  5449. /**
  5450. * Computes a new Color3 converted from the current one to linear space
  5451. * @returns a new Color3 object
  5452. */
  5453. toLinearSpace(): Color3;
  5454. /**
  5455. * Converts current color in rgb space to HSV values
  5456. * @returns a new color3 representing the HSV values
  5457. */
  5458. toHSV(): Color3;
  5459. /**
  5460. * Converts current color in rgb space to HSV values
  5461. * @param result defines the Color3 where to store the HSV values
  5462. */
  5463. toHSVToRef(result: Color3): void;
  5464. /**
  5465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5466. * @param convertedColor defines the Color3 object where to store the linear space version
  5467. * @returns the unmodified Color3
  5468. */
  5469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5470. /**
  5471. * Computes a new Color3 converted from the current one to gamma space
  5472. * @returns a new Color3 object
  5473. */
  5474. toGammaSpace(): Color3;
  5475. /**
  5476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5477. * @param convertedColor defines the Color3 object where to store the gamma space version
  5478. * @returns the unmodified Color3
  5479. */
  5480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5481. private static _BlackReadOnly;
  5482. /**
  5483. * Convert Hue, saturation and value to a Color3 (RGB)
  5484. * @param hue defines the hue
  5485. * @param saturation defines the saturation
  5486. * @param value defines the value
  5487. * @param result defines the Color3 where to store the RGB values
  5488. */
  5489. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5490. /**
  5491. * Creates a new Color3 from the string containing valid hexadecimal values
  5492. * @param hex defines a string containing valid hexadecimal values
  5493. * @returns a new Color3 object
  5494. */
  5495. static FromHexString(hex: string): Color3;
  5496. /**
  5497. * Creates a new Color3 from the starting index of the given array
  5498. * @param array defines the source array
  5499. * @param offset defines an offset in the source array
  5500. * @returns a new Color3 object
  5501. */
  5502. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5503. /**
  5504. * Creates a new Color3 from integer values (< 256)
  5505. * @param r defines the red component to read from (value between 0 and 255)
  5506. * @param g defines the green component to read from (value between 0 and 255)
  5507. * @param b defines the blue component to read from (value between 0 and 255)
  5508. * @returns a new Color3 object
  5509. */
  5510. static FromInts(r: number, g: number, b: number): Color3;
  5511. /**
  5512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5513. * @param start defines the start Color3 value
  5514. * @param end defines the end Color3 value
  5515. * @param amount defines the gradient value between start and end
  5516. * @returns a new Color3 object
  5517. */
  5518. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5519. /**
  5520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5521. * @param left defines the start value
  5522. * @param right defines the end value
  5523. * @param amount defines the gradient factor
  5524. * @param result defines the Color3 object where to store the result
  5525. */
  5526. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5527. /**
  5528. * Returns a Color3 value containing a red color
  5529. * @returns a new Color3 object
  5530. */
  5531. static Red(): Color3;
  5532. /**
  5533. * Returns a Color3 value containing a green color
  5534. * @returns a new Color3 object
  5535. */
  5536. static Green(): Color3;
  5537. /**
  5538. * Returns a Color3 value containing a blue color
  5539. * @returns a new Color3 object
  5540. */
  5541. static Blue(): Color3;
  5542. /**
  5543. * Returns a Color3 value containing a black color
  5544. * @returns a new Color3 object
  5545. */
  5546. static Black(): Color3;
  5547. /**
  5548. * Gets a Color3 value containing a black color that must not be updated
  5549. */
  5550. static get BlackReadOnly(): DeepImmutable<Color3>;
  5551. /**
  5552. * Returns a Color3 value containing a white color
  5553. * @returns a new Color3 object
  5554. */
  5555. static White(): Color3;
  5556. /**
  5557. * Returns a Color3 value containing a purple color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Purple(): Color3;
  5561. /**
  5562. * Returns a Color3 value containing a magenta color
  5563. * @returns a new Color3 object
  5564. */
  5565. static Magenta(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a yellow color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Yellow(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a gray color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Gray(): Color3;
  5576. /**
  5577. * Returns a Color3 value containing a teal color
  5578. * @returns a new Color3 object
  5579. */
  5580. static Teal(): Color3;
  5581. /**
  5582. * Returns a Color3 value containing a random color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Random(): Color3;
  5586. }
  5587. /**
  5588. * Class used to hold a RBGA color
  5589. */
  5590. export class Color4 {
  5591. /**
  5592. * Defines the red component (between 0 and 1, default is 0)
  5593. */
  5594. r: number;
  5595. /**
  5596. * Defines the green component (between 0 and 1, default is 0)
  5597. */
  5598. g: number;
  5599. /**
  5600. * Defines the blue component (between 0 and 1, default is 0)
  5601. */
  5602. b: number;
  5603. /**
  5604. * Defines the alpha component (between 0 and 1, default is 1)
  5605. */
  5606. a: number;
  5607. /**
  5608. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5609. * @param r defines the red component (between 0 and 1, default is 0)
  5610. * @param g defines the green component (between 0 and 1, default is 0)
  5611. * @param b defines the blue component (between 0 and 1, default is 0)
  5612. * @param a defines the alpha component (between 0 and 1, default is 1)
  5613. */
  5614. constructor(
  5615. /**
  5616. * Defines the red component (between 0 and 1, default is 0)
  5617. */
  5618. r?: number,
  5619. /**
  5620. * Defines the green component (between 0 and 1, default is 0)
  5621. */
  5622. g?: number,
  5623. /**
  5624. * Defines the blue component (between 0 and 1, default is 0)
  5625. */
  5626. b?: number,
  5627. /**
  5628. * Defines the alpha component (between 0 and 1, default is 1)
  5629. */
  5630. a?: number);
  5631. /**
  5632. * Adds in place the given Color4 values to the current Color4 object
  5633. * @param right defines the second operand
  5634. * @returns the current updated Color4 object
  5635. */
  5636. addInPlace(right: DeepImmutable<Color4>): Color4;
  5637. /**
  5638. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5639. * @returns the new array
  5640. */
  5641. asArray(): number[];
  5642. /**
  5643. * Stores from the starting index in the given array the Color4 successive values
  5644. * @param array defines the array where to store the r,g,b components
  5645. * @param index defines an optional index in the target array to define where to start storing values
  5646. * @returns the current Color4 object
  5647. */
  5648. toArray(array: number[], index?: number): Color4;
  5649. /**
  5650. * Determines equality between Color4 objects
  5651. * @param otherColor defines the second operand
  5652. * @returns true if the rgba values are equal to the given ones
  5653. */
  5654. equals(otherColor: DeepImmutable<Color4>): boolean;
  5655. /**
  5656. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5657. * @param right defines the second operand
  5658. * @returns a new Color4 object
  5659. */
  5660. add(right: DeepImmutable<Color4>): Color4;
  5661. /**
  5662. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5663. * @param right defines the second operand
  5664. * @returns a new Color4 object
  5665. */
  5666. subtract(right: DeepImmutable<Color4>): Color4;
  5667. /**
  5668. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5669. * @param right defines the second operand
  5670. * @param result defines the Color4 object where to store the result
  5671. * @returns the current Color4 object
  5672. */
  5673. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5674. /**
  5675. * Creates a new Color4 with the current Color4 values multiplied by scale
  5676. * @param scale defines the scaling factor to apply
  5677. * @returns a new Color4 object
  5678. */
  5679. scale(scale: number): Color4;
  5680. /**
  5681. * Multiplies the current Color4 values by scale and stores the result in "result"
  5682. * @param scale defines the scaling factor to apply
  5683. * @param result defines the Color4 object where to store the result
  5684. * @returns the current unmodified Color4
  5685. */
  5686. scaleToRef(scale: number, result: Color4): Color4;
  5687. /**
  5688. * Scale the current Color4 values by a factor and add the result to a given Color4
  5689. * @param scale defines the scale factor
  5690. * @param result defines the Color4 object where to store the result
  5691. * @returns the unmodified current Color4
  5692. */
  5693. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5694. /**
  5695. * Clamps the rgb values by the min and max values and stores the result into "result"
  5696. * @param min defines minimum clamping value (default is 0)
  5697. * @param max defines maximum clamping value (default is 1)
  5698. * @param result defines color to store the result into.
  5699. * @returns the cuurent Color4
  5700. */
  5701. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5702. /**
  5703. * Multipy an Color4 value by another and return a new Color4 object
  5704. * @param color defines the Color4 value to multiply by
  5705. * @returns a new Color4 object
  5706. */
  5707. multiply(color: Color4): Color4;
  5708. /**
  5709. * Multipy a Color4 value by another and push the result in a reference value
  5710. * @param color defines the Color4 value to multiply by
  5711. * @param result defines the Color4 to fill the result in
  5712. * @returns the result Color4
  5713. */
  5714. multiplyToRef(color: Color4, result: Color4): Color4;
  5715. /**
  5716. * Creates a string with the Color4 current values
  5717. * @returns the string representation of the Color4 object
  5718. */
  5719. toString(): string;
  5720. /**
  5721. * Returns the string "Color4"
  5722. * @returns "Color4"
  5723. */
  5724. getClassName(): string;
  5725. /**
  5726. * Compute the Color4 hash code
  5727. * @returns an unique number that can be used to hash Color4 objects
  5728. */
  5729. getHashCode(): number;
  5730. /**
  5731. * Creates a new Color4 copied from the current one
  5732. * @returns a new Color4 object
  5733. */
  5734. clone(): Color4;
  5735. /**
  5736. * Copies the given Color4 values into the current one
  5737. * @param source defines the source Color4 object
  5738. * @returns the current updated Color4 object
  5739. */
  5740. copyFrom(source: Color4): Color4;
  5741. /**
  5742. * Copies the given float values into the current one
  5743. * @param r defines the red component to read from
  5744. * @param g defines the green component to read from
  5745. * @param b defines the blue component to read from
  5746. * @param a defines the alpha component to read from
  5747. * @returns the current updated Color4 object
  5748. */
  5749. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5750. /**
  5751. * Copies the given float values into the current one
  5752. * @param r defines the red component to read from
  5753. * @param g defines the green component to read from
  5754. * @param b defines the blue component to read from
  5755. * @param a defines the alpha component to read from
  5756. * @returns the current updated Color4 object
  5757. */
  5758. set(r: number, g: number, b: number, a: number): Color4;
  5759. /**
  5760. * Compute the Color4 hexadecimal code as a string
  5761. * @returns a string containing the hexadecimal representation of the Color4 object
  5762. */
  5763. toHexString(): string;
  5764. /**
  5765. * Computes a new Color4 converted from the current one to linear space
  5766. * @returns a new Color4 object
  5767. */
  5768. toLinearSpace(): Color4;
  5769. /**
  5770. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5771. * @param convertedColor defines the Color4 object where to store the linear space version
  5772. * @returns the unmodified Color4
  5773. */
  5774. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5775. /**
  5776. * Computes a new Color4 converted from the current one to gamma space
  5777. * @returns a new Color4 object
  5778. */
  5779. toGammaSpace(): Color4;
  5780. /**
  5781. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5782. * @param convertedColor defines the Color4 object where to store the gamma space version
  5783. * @returns the unmodified Color4
  5784. */
  5785. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5786. /**
  5787. * Creates a new Color4 from the string containing valid hexadecimal values
  5788. * @param hex defines a string containing valid hexadecimal values
  5789. * @returns a new Color4 object
  5790. */
  5791. static FromHexString(hex: string): Color4;
  5792. /**
  5793. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5794. * @param left defines the start value
  5795. * @param right defines the end value
  5796. * @param amount defines the gradient factor
  5797. * @returns a new Color4 object
  5798. */
  5799. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5800. /**
  5801. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5802. * @param left defines the start value
  5803. * @param right defines the end value
  5804. * @param amount defines the gradient factor
  5805. * @param result defines the Color4 object where to store data
  5806. */
  5807. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5808. /**
  5809. * Creates a new Color4 from a Color3 and an alpha value
  5810. * @param color3 defines the source Color3 to read from
  5811. * @param alpha defines the alpha component (1.0 by default)
  5812. * @returns a new Color4 object
  5813. */
  5814. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5815. /**
  5816. * Creates a new Color4 from the starting index element of the given array
  5817. * @param array defines the source array to read from
  5818. * @param offset defines the offset in the source array
  5819. * @returns a new Color4 object
  5820. */
  5821. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5822. /**
  5823. * Creates a new Color3 from integer values (< 256)
  5824. * @param r defines the red component to read from (value between 0 and 255)
  5825. * @param g defines the green component to read from (value between 0 and 255)
  5826. * @param b defines the blue component to read from (value between 0 and 255)
  5827. * @param a defines the alpha component to read from (value between 0 and 255)
  5828. * @returns a new Color3 object
  5829. */
  5830. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5831. /**
  5832. * Check the content of a given array and convert it to an array containing RGBA data
  5833. * If the original array was already containing count * 4 values then it is returned directly
  5834. * @param colors defines the array to check
  5835. * @param count defines the number of RGBA data to expect
  5836. * @returns an array containing count * 4 values (RGBA)
  5837. */
  5838. static CheckColors4(colors: number[], count: number): number[];
  5839. }
  5840. /**
  5841. * @hidden
  5842. */
  5843. export class TmpColors {
  5844. static Color3: Color3[];
  5845. static Color4: Color4[];
  5846. }
  5847. }
  5848. declare module BABYLON {
  5849. /**
  5850. * Defines an interface which represents an animation key frame
  5851. */
  5852. export interface IAnimationKey {
  5853. /**
  5854. * Frame of the key frame
  5855. */
  5856. frame: number;
  5857. /**
  5858. * Value at the specifies key frame
  5859. */
  5860. value: any;
  5861. /**
  5862. * The input tangent for the cubic hermite spline
  5863. */
  5864. inTangent?: any;
  5865. /**
  5866. * The output tangent for the cubic hermite spline
  5867. */
  5868. outTangent?: any;
  5869. /**
  5870. * The animation interpolation type
  5871. */
  5872. interpolation?: AnimationKeyInterpolation;
  5873. }
  5874. /**
  5875. * Enum for the animation key frame interpolation type
  5876. */
  5877. export enum AnimationKeyInterpolation {
  5878. /**
  5879. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5880. */
  5881. STEP = 1
  5882. }
  5883. }
  5884. declare module BABYLON {
  5885. /**
  5886. * Represents the range of an animation
  5887. */
  5888. export class AnimationRange {
  5889. /**The name of the animation range**/
  5890. name: string;
  5891. /**The starting frame of the animation */
  5892. from: number;
  5893. /**The ending frame of the animation*/
  5894. to: number;
  5895. /**
  5896. * Initializes the range of an animation
  5897. * @param name The name of the animation range
  5898. * @param from The starting frame of the animation
  5899. * @param to The ending frame of the animation
  5900. */
  5901. constructor(
  5902. /**The name of the animation range**/
  5903. name: string,
  5904. /**The starting frame of the animation */
  5905. from: number,
  5906. /**The ending frame of the animation*/
  5907. to: number);
  5908. /**
  5909. * Makes a copy of the animation range
  5910. * @returns A copy of the animation range
  5911. */
  5912. clone(): AnimationRange;
  5913. }
  5914. }
  5915. declare module BABYLON {
  5916. /**
  5917. * Composed of a frame, and an action function
  5918. */
  5919. export class AnimationEvent {
  5920. /** The frame for which the event is triggered **/
  5921. frame: number;
  5922. /** The event to perform when triggered **/
  5923. action: (currentFrame: number) => void;
  5924. /** Specifies if the event should be triggered only once**/
  5925. onlyOnce?: boolean | undefined;
  5926. /**
  5927. * Specifies if the animation event is done
  5928. */
  5929. isDone: boolean;
  5930. /**
  5931. * Initializes the animation event
  5932. * @param frame The frame for which the event is triggered
  5933. * @param action The event to perform when triggered
  5934. * @param onlyOnce Specifies if the event should be triggered only once
  5935. */
  5936. constructor(
  5937. /** The frame for which the event is triggered **/
  5938. frame: number,
  5939. /** The event to perform when triggered **/
  5940. action: (currentFrame: number) => void,
  5941. /** Specifies if the event should be triggered only once**/
  5942. onlyOnce?: boolean | undefined);
  5943. /** @hidden */
  5944. _clone(): AnimationEvent;
  5945. }
  5946. }
  5947. declare module BABYLON {
  5948. /**
  5949. * Interface used to define a behavior
  5950. */
  5951. export interface Behavior<T> {
  5952. /** gets or sets behavior's name */
  5953. name: string;
  5954. /**
  5955. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5956. */
  5957. init(): void;
  5958. /**
  5959. * Called when the behavior is attached to a target
  5960. * @param target defines the target where the behavior is attached to
  5961. */
  5962. attach(target: T): void;
  5963. /**
  5964. * Called when the behavior is detached from its target
  5965. */
  5966. detach(): void;
  5967. }
  5968. /**
  5969. * Interface implemented by classes supporting behaviors
  5970. */
  5971. export interface IBehaviorAware<T> {
  5972. /**
  5973. * Attach a behavior
  5974. * @param behavior defines the behavior to attach
  5975. * @returns the current host
  5976. */
  5977. addBehavior(behavior: Behavior<T>): T;
  5978. /**
  5979. * Remove a behavior from the current object
  5980. * @param behavior defines the behavior to detach
  5981. * @returns the current host
  5982. */
  5983. removeBehavior(behavior: Behavior<T>): T;
  5984. /**
  5985. * Gets a behavior using its name to search
  5986. * @param name defines the name to search
  5987. * @returns the behavior or null if not found
  5988. */
  5989. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5990. }
  5991. }
  5992. declare module BABYLON {
  5993. /**
  5994. * Defines an array and its length.
  5995. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5996. */
  5997. export interface ISmartArrayLike<T> {
  5998. /**
  5999. * The data of the array.
  6000. */
  6001. data: Array<T>;
  6002. /**
  6003. * The active length of the array.
  6004. */
  6005. length: number;
  6006. }
  6007. /**
  6008. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6009. */
  6010. export class SmartArray<T> implements ISmartArrayLike<T> {
  6011. /**
  6012. * The full set of data from the array.
  6013. */
  6014. data: Array<T>;
  6015. /**
  6016. * The active length of the array.
  6017. */
  6018. length: number;
  6019. protected _id: number;
  6020. /**
  6021. * Instantiates a Smart Array.
  6022. * @param capacity defines the default capacity of the array.
  6023. */
  6024. constructor(capacity: number);
  6025. /**
  6026. * Pushes a value at the end of the active data.
  6027. * @param value defines the object to push in the array.
  6028. */
  6029. push(value: T): void;
  6030. /**
  6031. * Iterates over the active data and apply the lambda to them.
  6032. * @param func defines the action to apply on each value.
  6033. */
  6034. forEach(func: (content: T) => void): void;
  6035. /**
  6036. * Sorts the full sets of data.
  6037. * @param compareFn defines the comparison function to apply.
  6038. */
  6039. sort(compareFn: (a: T, b: T) => number): void;
  6040. /**
  6041. * Resets the active data to an empty array.
  6042. */
  6043. reset(): void;
  6044. /**
  6045. * Releases all the data from the array as well as the array.
  6046. */
  6047. dispose(): void;
  6048. /**
  6049. * Concats the active data with a given array.
  6050. * @param array defines the data to concatenate with.
  6051. */
  6052. concat(array: any): void;
  6053. /**
  6054. * Returns the position of a value in the active data.
  6055. * @param value defines the value to find the index for
  6056. * @returns the index if found in the active data otherwise -1
  6057. */
  6058. indexOf(value: T): number;
  6059. /**
  6060. * Returns whether an element is part of the active data.
  6061. * @param value defines the value to look for
  6062. * @returns true if found in the active data otherwise false
  6063. */
  6064. contains(value: T): boolean;
  6065. private static _GlobalId;
  6066. }
  6067. /**
  6068. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6069. * The data in this array can only be present once
  6070. */
  6071. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6072. private _duplicateId;
  6073. /**
  6074. * Pushes a value at the end of the active data.
  6075. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6076. * @param value defines the object to push in the array.
  6077. */
  6078. push(value: T): void;
  6079. /**
  6080. * Pushes a value at the end of the active data.
  6081. * If the data is already present, it won t be added again
  6082. * @param value defines the object to push in the array.
  6083. * @returns true if added false if it was already present
  6084. */
  6085. pushNoDuplicate(value: T): boolean;
  6086. /**
  6087. * Resets the active data to an empty array.
  6088. */
  6089. reset(): void;
  6090. /**
  6091. * Concats the active data with a given array.
  6092. * This ensures no dupplicate will be present in the result.
  6093. * @param array defines the data to concatenate with.
  6094. */
  6095. concatWithNoDuplicate(array: any): void;
  6096. }
  6097. }
  6098. declare module BABYLON {
  6099. /**
  6100. * @ignore
  6101. * This is a list of all the different input types that are available in the application.
  6102. * Fo instance: ArcRotateCameraGamepadInput...
  6103. */
  6104. export var CameraInputTypes: {};
  6105. /**
  6106. * This is the contract to implement in order to create a new input class.
  6107. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6108. */
  6109. export interface ICameraInput<TCamera extends Camera> {
  6110. /**
  6111. * Defines the camera the input is attached to.
  6112. */
  6113. camera: Nullable<TCamera>;
  6114. /**
  6115. * Gets the class name of the current intput.
  6116. * @returns the class name
  6117. */
  6118. getClassName(): string;
  6119. /**
  6120. * Get the friendly name associated with the input class.
  6121. * @returns the input friendly name
  6122. */
  6123. getSimpleName(): string;
  6124. /**
  6125. * Attach the input controls to a specific dom element to get the input from.
  6126. * @param element Defines the element the controls should be listened from
  6127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6128. */
  6129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6130. /**
  6131. * Detach the current controls from the specified dom element.
  6132. * @param element Defines the element to stop listening the inputs from
  6133. */
  6134. detachControl(element: Nullable<HTMLElement>): void;
  6135. /**
  6136. * Update the current camera state depending on the inputs that have been used this frame.
  6137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6138. */
  6139. checkInputs?: () => void;
  6140. }
  6141. /**
  6142. * Represents a map of input types to input instance or input index to input instance.
  6143. */
  6144. export interface CameraInputsMap<TCamera extends Camera> {
  6145. /**
  6146. * Accessor to the input by input type.
  6147. */
  6148. [name: string]: ICameraInput<TCamera>;
  6149. /**
  6150. * Accessor to the input by input index.
  6151. */
  6152. [idx: number]: ICameraInput<TCamera>;
  6153. }
  6154. /**
  6155. * This represents the input manager used within a camera.
  6156. * It helps dealing with all the different kind of input attached to a camera.
  6157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6158. */
  6159. export class CameraInputsManager<TCamera extends Camera> {
  6160. /**
  6161. * Defines the list of inputs attahed to the camera.
  6162. */
  6163. attached: CameraInputsMap<TCamera>;
  6164. /**
  6165. * Defines the dom element the camera is collecting inputs from.
  6166. * This is null if the controls have not been attached.
  6167. */
  6168. attachedElement: Nullable<HTMLElement>;
  6169. /**
  6170. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6171. */
  6172. noPreventDefault: boolean;
  6173. /**
  6174. * Defined the camera the input manager belongs to.
  6175. */
  6176. camera: TCamera;
  6177. /**
  6178. * Update the current camera state depending on the inputs that have been used this frame.
  6179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6180. */
  6181. checkInputs: () => void;
  6182. /**
  6183. * Instantiate a new Camera Input Manager.
  6184. * @param camera Defines the camera the input manager blongs to
  6185. */
  6186. constructor(camera: TCamera);
  6187. /**
  6188. * Add an input method to a camera
  6189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6190. * @param input camera input method
  6191. */
  6192. add(input: ICameraInput<TCamera>): void;
  6193. /**
  6194. * Remove a specific input method from a camera
  6195. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6196. * @param inputToRemove camera input method
  6197. */
  6198. remove(inputToRemove: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input type from a camera
  6201. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6202. * @param inputType the type of the input to remove
  6203. */
  6204. removeByType(inputType: string): void;
  6205. private _addCheckInputs;
  6206. /**
  6207. * Attach the input controls to the currently attached dom element to listen the events from.
  6208. * @param input Defines the input to attach
  6209. */
  6210. attachInput(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6213. * @param element Defines the dom element to collect the events from
  6214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6215. */
  6216. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6217. /**
  6218. * Detach the current manager inputs controls from a specific dom element.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6221. */
  6222. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6223. /**
  6224. * Rebuild the dynamic inputCheck function from the current list of
  6225. * defined inputs in the manager.
  6226. */
  6227. rebuildInputCheck(): void;
  6228. /**
  6229. * Remove all attached input methods from a camera
  6230. */
  6231. clear(): void;
  6232. /**
  6233. * Serialize the current input manager attached to a camera.
  6234. * This ensures than once parsed,
  6235. * the input associated to the camera will be identical to the current ones
  6236. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6237. */
  6238. serialize(serializedCamera: any): void;
  6239. /**
  6240. * Parses an input manager serialized JSON to restore the previous list of inputs
  6241. * and states associated to a camera.
  6242. * @param parsedCamera Defines the JSON to parse
  6243. */
  6244. parse(parsedCamera: any): void;
  6245. }
  6246. }
  6247. declare module BABYLON {
  6248. /**
  6249. * Class used to store data that will be store in GPU memory
  6250. */
  6251. export class Buffer {
  6252. private _engine;
  6253. private _buffer;
  6254. /** @hidden */
  6255. _data: Nullable<DataArray>;
  6256. private _updatable;
  6257. private _instanced;
  6258. private _divisor;
  6259. /**
  6260. * Gets the byte stride.
  6261. */
  6262. readonly byteStride: number;
  6263. /**
  6264. * Constructor
  6265. * @param engine the engine
  6266. * @param data the data to use for this buffer
  6267. * @param updatable whether the data is updatable
  6268. * @param stride the stride (optional)
  6269. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6270. * @param instanced whether the buffer is instanced (optional)
  6271. * @param useBytes set to true if the stride in in bytes (optional)
  6272. * @param divisor sets an optional divisor for instances (1 by default)
  6273. */
  6274. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6275. /**
  6276. * Create a new VertexBuffer based on the current buffer
  6277. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6278. * @param offset defines offset in the buffer (0 by default)
  6279. * @param size defines the size in floats of attributes (position is 3 for instance)
  6280. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6281. * @param instanced defines if the vertex buffer contains indexed data
  6282. * @param useBytes defines if the offset and stride are in bytes *
  6283. * @param divisor sets an optional divisor for instances (1 by default)
  6284. * @returns the new vertex buffer
  6285. */
  6286. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6287. /**
  6288. * Gets a boolean indicating if the Buffer is updatable?
  6289. * @returns true if the buffer is updatable
  6290. */
  6291. isUpdatable(): boolean;
  6292. /**
  6293. * Gets current buffer's data
  6294. * @returns a DataArray or null
  6295. */
  6296. getData(): Nullable<DataArray>;
  6297. /**
  6298. * Gets underlying native buffer
  6299. * @returns underlying native buffer
  6300. */
  6301. getBuffer(): Nullable<DataBuffer>;
  6302. /**
  6303. * Gets the stride in float32 units (i.e. byte stride / 4).
  6304. * May not be an integer if the byte stride is not divisible by 4.
  6305. * @returns the stride in float32 units
  6306. * @deprecated Please use byteStride instead.
  6307. */
  6308. getStrideSize(): number;
  6309. /**
  6310. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6311. * @param data defines the data to store
  6312. */
  6313. create(data?: Nullable<DataArray>): void;
  6314. /** @hidden */
  6315. _rebuild(): void;
  6316. /**
  6317. * Update current buffer data
  6318. * @param data defines the data to store
  6319. */
  6320. update(data: DataArray): void;
  6321. /**
  6322. * Updates the data directly.
  6323. * @param data the new data
  6324. * @param offset the new offset
  6325. * @param vertexCount the vertex count (optional)
  6326. * @param useBytes set to true if the offset is in bytes
  6327. */
  6328. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6329. /**
  6330. * Release all resources
  6331. */
  6332. dispose(): void;
  6333. }
  6334. /**
  6335. * Specialized buffer used to store vertex data
  6336. */
  6337. export class VertexBuffer {
  6338. /** @hidden */
  6339. _buffer: Buffer;
  6340. private _kind;
  6341. private _size;
  6342. private _ownsBuffer;
  6343. private _instanced;
  6344. private _instanceDivisor;
  6345. /**
  6346. * The byte type.
  6347. */
  6348. static readonly BYTE: number;
  6349. /**
  6350. * The unsigned byte type.
  6351. */
  6352. static readonly UNSIGNED_BYTE: number;
  6353. /**
  6354. * The short type.
  6355. */
  6356. static readonly SHORT: number;
  6357. /**
  6358. * The unsigned short type.
  6359. */
  6360. static readonly UNSIGNED_SHORT: number;
  6361. /**
  6362. * The integer type.
  6363. */
  6364. static readonly INT: number;
  6365. /**
  6366. * The unsigned integer type.
  6367. */
  6368. static readonly UNSIGNED_INT: number;
  6369. /**
  6370. * The float type.
  6371. */
  6372. static readonly FLOAT: number;
  6373. /**
  6374. * Gets or sets the instance divisor when in instanced mode
  6375. */
  6376. get instanceDivisor(): number;
  6377. set instanceDivisor(value: number);
  6378. /**
  6379. * Gets the byte stride.
  6380. */
  6381. readonly byteStride: number;
  6382. /**
  6383. * Gets the byte offset.
  6384. */
  6385. readonly byteOffset: number;
  6386. /**
  6387. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6388. */
  6389. readonly normalized: boolean;
  6390. /**
  6391. * Gets the data type of each component in the array.
  6392. */
  6393. readonly type: number;
  6394. /**
  6395. * Constructor
  6396. * @param engine the engine
  6397. * @param data the data to use for this vertex buffer
  6398. * @param kind the vertex buffer kind
  6399. * @param updatable whether the data is updatable
  6400. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6401. * @param stride the stride (optional)
  6402. * @param instanced whether the buffer is instanced (optional)
  6403. * @param offset the offset of the data (optional)
  6404. * @param size the number of components (optional)
  6405. * @param type the type of the component (optional)
  6406. * @param normalized whether the data contains normalized data (optional)
  6407. * @param useBytes set to true if stride and offset are in bytes (optional)
  6408. * @param divisor defines the instance divisor to use (1 by default)
  6409. */
  6410. 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);
  6411. /** @hidden */
  6412. _rebuild(): void;
  6413. /**
  6414. * Returns the kind of the VertexBuffer (string)
  6415. * @returns a string
  6416. */
  6417. getKind(): string;
  6418. /**
  6419. * Gets a boolean indicating if the VertexBuffer is updatable?
  6420. * @returns true if the buffer is updatable
  6421. */
  6422. isUpdatable(): boolean;
  6423. /**
  6424. * Gets current buffer's data
  6425. * @returns a DataArray or null
  6426. */
  6427. getData(): Nullable<DataArray>;
  6428. /**
  6429. * Gets underlying native buffer
  6430. * @returns underlying native buffer
  6431. */
  6432. getBuffer(): Nullable<DataBuffer>;
  6433. /**
  6434. * Gets the stride in float32 units (i.e. byte stride / 4).
  6435. * May not be an integer if the byte stride is not divisible by 4.
  6436. * @returns the stride in float32 units
  6437. * @deprecated Please use byteStride instead.
  6438. */
  6439. getStrideSize(): number;
  6440. /**
  6441. * Returns the offset as a multiple of the type byte length.
  6442. * @returns the offset in bytes
  6443. * @deprecated Please use byteOffset instead.
  6444. */
  6445. getOffset(): number;
  6446. /**
  6447. * Returns the number of components per vertex attribute (integer)
  6448. * @returns the size in float
  6449. */
  6450. getSize(): number;
  6451. /**
  6452. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6453. * @returns true if this buffer is instanced
  6454. */
  6455. getIsInstanced(): boolean;
  6456. /**
  6457. * Returns the instancing divisor, zero for non-instanced (integer).
  6458. * @returns a number
  6459. */
  6460. getInstanceDivisor(): number;
  6461. /**
  6462. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6463. * @param data defines the data to store
  6464. */
  6465. create(data?: DataArray): void;
  6466. /**
  6467. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6468. * This function will create a new buffer if the current one is not updatable
  6469. * @param data defines the data to store
  6470. */
  6471. update(data: DataArray): void;
  6472. /**
  6473. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6474. * Returns the directly updated WebGLBuffer.
  6475. * @param data the new data
  6476. * @param offset the new offset
  6477. * @param useBytes set to true if the offset is in bytes
  6478. */
  6479. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6480. /**
  6481. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6482. */
  6483. dispose(): void;
  6484. /**
  6485. * Enumerates each value of this vertex buffer as numbers.
  6486. * @param count the number of values to enumerate
  6487. * @param callback the callback function called for each value
  6488. */
  6489. forEach(count: number, callback: (value: number, index: number) => void): void;
  6490. /**
  6491. * Positions
  6492. */
  6493. static readonly PositionKind: string;
  6494. /**
  6495. * Normals
  6496. */
  6497. static readonly NormalKind: string;
  6498. /**
  6499. * Tangents
  6500. */
  6501. static readonly TangentKind: string;
  6502. /**
  6503. * Texture coordinates
  6504. */
  6505. static readonly UVKind: string;
  6506. /**
  6507. * Texture coordinates 2
  6508. */
  6509. static readonly UV2Kind: string;
  6510. /**
  6511. * Texture coordinates 3
  6512. */
  6513. static readonly UV3Kind: string;
  6514. /**
  6515. * Texture coordinates 4
  6516. */
  6517. static readonly UV4Kind: string;
  6518. /**
  6519. * Texture coordinates 5
  6520. */
  6521. static readonly UV5Kind: string;
  6522. /**
  6523. * Texture coordinates 6
  6524. */
  6525. static readonly UV6Kind: string;
  6526. /**
  6527. * Colors
  6528. */
  6529. static readonly ColorKind: string;
  6530. /**
  6531. * Matrix indices (for bones)
  6532. */
  6533. static readonly MatricesIndicesKind: string;
  6534. /**
  6535. * Matrix weights (for bones)
  6536. */
  6537. static readonly MatricesWeightsKind: string;
  6538. /**
  6539. * Additional matrix indices (for bones)
  6540. */
  6541. static readonly MatricesIndicesExtraKind: string;
  6542. /**
  6543. * Additional matrix weights (for bones)
  6544. */
  6545. static readonly MatricesWeightsExtraKind: string;
  6546. /**
  6547. * Deduces the stride given a kind.
  6548. * @param kind The kind string to deduce
  6549. * @returns The deduced stride
  6550. */
  6551. static DeduceStride(kind: string): number;
  6552. /**
  6553. * Gets the byte length of the given type.
  6554. * @param type the type
  6555. * @returns the number of bytes
  6556. */
  6557. static GetTypeByteLength(type: number): number;
  6558. /**
  6559. * Enumerates each value of the given parameters as numbers.
  6560. * @param data the data to enumerate
  6561. * @param byteOffset the byte offset of the data
  6562. * @param byteStride the byte stride of the data
  6563. * @param componentCount the number of components per element
  6564. * @param componentType the type of the component
  6565. * @param count the number of values to enumerate
  6566. * @param normalized whether the data is normalized
  6567. * @param callback the callback function called for each value
  6568. */
  6569. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6570. private static _GetFloatValue;
  6571. }
  6572. }
  6573. declare module BABYLON {
  6574. /**
  6575. * @hidden
  6576. */
  6577. export class IntersectionInfo {
  6578. bu: Nullable<number>;
  6579. bv: Nullable<number>;
  6580. distance: number;
  6581. faceId: number;
  6582. subMeshId: number;
  6583. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6584. }
  6585. }
  6586. declare module BABYLON {
  6587. /**
  6588. * Represens a plane by the equation ax + by + cz + d = 0
  6589. */
  6590. export class Plane {
  6591. private static _TmpMatrix;
  6592. /**
  6593. * Normal of the plane (a,b,c)
  6594. */
  6595. normal: Vector3;
  6596. /**
  6597. * d component of the plane
  6598. */
  6599. d: number;
  6600. /**
  6601. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6602. * @param a a component of the plane
  6603. * @param b b component of the plane
  6604. * @param c c component of the plane
  6605. * @param d d component of the plane
  6606. */
  6607. constructor(a: number, b: number, c: number, d: number);
  6608. /**
  6609. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6610. */
  6611. asArray(): number[];
  6612. /**
  6613. * @returns a new plane copied from the current Plane.
  6614. */
  6615. clone(): Plane;
  6616. /**
  6617. * @returns the string "Plane".
  6618. */
  6619. getClassName(): string;
  6620. /**
  6621. * @returns the Plane hash code.
  6622. */
  6623. getHashCode(): number;
  6624. /**
  6625. * Normalize the current Plane in place.
  6626. * @returns the updated Plane.
  6627. */
  6628. normalize(): Plane;
  6629. /**
  6630. * Applies a transformation the plane and returns the result
  6631. * @param transformation the transformation matrix to be applied to the plane
  6632. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6633. */
  6634. transform(transformation: DeepImmutable<Matrix>): Plane;
  6635. /**
  6636. * Calcualtte the dot product between the point and the plane normal
  6637. * @param point point to calculate the dot product with
  6638. * @returns the dot product (float) of the point coordinates and the plane normal.
  6639. */
  6640. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6641. /**
  6642. * Updates the current Plane from the plane defined by the three given points.
  6643. * @param point1 one of the points used to contruct the plane
  6644. * @param point2 one of the points used to contruct the plane
  6645. * @param point3 one of the points used to contruct the plane
  6646. * @returns the updated Plane.
  6647. */
  6648. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6649. /**
  6650. * Checks if the plane is facing a given direction
  6651. * @param direction the direction to check if the plane is facing
  6652. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6653. * @returns True is the vector "direction" is the same side than the plane normal.
  6654. */
  6655. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6656. /**
  6657. * Calculates the distance to a point
  6658. * @param point point to calculate distance to
  6659. * @returns the signed distance (float) from the given point to the Plane.
  6660. */
  6661. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6662. /**
  6663. * Creates a plane from an array
  6664. * @param array the array to create a plane from
  6665. * @returns a new Plane from the given array.
  6666. */
  6667. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6668. /**
  6669. * Creates a plane from three points
  6670. * @param point1 point used to create the plane
  6671. * @param point2 point used to create the plane
  6672. * @param point3 point used to create the plane
  6673. * @returns a new Plane defined by the three given points.
  6674. */
  6675. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6676. /**
  6677. * Creates a plane from an origin point and a normal
  6678. * @param origin origin of the plane to be constructed
  6679. * @param normal normal of the plane to be constructed
  6680. * @returns a new Plane the normal vector to this plane at the given origin point.
  6681. * Note : the vector "normal" is updated because normalized.
  6682. */
  6683. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6684. /**
  6685. * Calculates the distance from a plane and a point
  6686. * @param origin origin of the plane to be constructed
  6687. * @param normal normal of the plane to be constructed
  6688. * @param point point to calculate distance to
  6689. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6690. */
  6691. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6692. }
  6693. }
  6694. declare module BABYLON {
  6695. /**
  6696. * Class used to store bounding sphere information
  6697. */
  6698. export class BoundingSphere {
  6699. /**
  6700. * Gets the center of the bounding sphere in local space
  6701. */
  6702. readonly center: Vector3;
  6703. /**
  6704. * Radius of the bounding sphere in local space
  6705. */
  6706. radius: number;
  6707. /**
  6708. * Gets the center of the bounding sphere in world space
  6709. */
  6710. readonly centerWorld: Vector3;
  6711. /**
  6712. * Radius of the bounding sphere in world space
  6713. */
  6714. radiusWorld: number;
  6715. /**
  6716. * Gets the minimum vector in local space
  6717. */
  6718. readonly minimum: Vector3;
  6719. /**
  6720. * Gets the maximum vector in local space
  6721. */
  6722. readonly maximum: Vector3;
  6723. private _worldMatrix;
  6724. private static readonly TmpVector3;
  6725. /**
  6726. * Creates a new bounding sphere
  6727. * @param min defines the minimum vector (in local space)
  6728. * @param max defines the maximum vector (in local space)
  6729. * @param worldMatrix defines the new world matrix
  6730. */
  6731. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6732. /**
  6733. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6734. * @param min defines the new minimum vector (in local space)
  6735. * @param max defines the new maximum vector (in local space)
  6736. * @param worldMatrix defines the new world matrix
  6737. */
  6738. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6739. /**
  6740. * Scale the current bounding sphere by applying a scale factor
  6741. * @param factor defines the scale factor to apply
  6742. * @returns the current bounding box
  6743. */
  6744. scale(factor: number): BoundingSphere;
  6745. /**
  6746. * Gets the world matrix of the bounding box
  6747. * @returns a matrix
  6748. */
  6749. getWorldMatrix(): DeepImmutable<Matrix>;
  6750. /** @hidden */
  6751. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Tests if the bounding sphere is intersecting the frustum planes
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @returns true if there is an intersection
  6756. */
  6757. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if the bounding sphere center is in between the frustum planes.
  6760. * Used for optimistic fast inclusion.
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @returns true if the sphere center is in between the frustum planes
  6763. */
  6764. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. /**
  6766. * Tests if a point is inside the bounding sphere
  6767. * @param point defines the point to test
  6768. * @returns true if the point is inside the bounding sphere
  6769. */
  6770. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6771. /**
  6772. * Checks if two sphere intersct
  6773. * @param sphere0 sphere 0
  6774. * @param sphere1 sphere 1
  6775. * @returns true if the speres intersect
  6776. */
  6777. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6778. }
  6779. }
  6780. declare module BABYLON {
  6781. /**
  6782. * Class used to store bounding box information
  6783. */
  6784. export class BoundingBox implements ICullable {
  6785. /**
  6786. * Gets the 8 vectors representing the bounding box in local space
  6787. */
  6788. readonly vectors: Vector3[];
  6789. /**
  6790. * Gets the center of the bounding box in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Gets the center of the bounding box in world space
  6795. */
  6796. readonly centerWorld: Vector3;
  6797. /**
  6798. * Gets the extend size in local space
  6799. */
  6800. readonly extendSize: Vector3;
  6801. /**
  6802. * Gets the extend size in world space
  6803. */
  6804. readonly extendSizeWorld: Vector3;
  6805. /**
  6806. * Gets the OBB (object bounding box) directions
  6807. */
  6808. readonly directions: Vector3[];
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in world space
  6811. */
  6812. readonly vectorsWorld: Vector3[];
  6813. /**
  6814. * Gets the minimum vector in world space
  6815. */
  6816. readonly minimumWorld: Vector3;
  6817. /**
  6818. * Gets the maximum vector in world space
  6819. */
  6820. readonly maximumWorld: Vector3;
  6821. /**
  6822. * Gets the minimum vector in local space
  6823. */
  6824. readonly minimum: Vector3;
  6825. /**
  6826. * Gets the maximum vector in local space
  6827. */
  6828. readonly maximum: Vector3;
  6829. private _worldMatrix;
  6830. private static readonly TmpVector3;
  6831. /**
  6832. * @hidden
  6833. */
  6834. _tag: number;
  6835. /**
  6836. * Creates a new bounding box
  6837. * @param min defines the minimum vector (in local space)
  6838. * @param max defines the maximum vector (in local space)
  6839. * @param worldMatrix defines the new world matrix
  6840. */
  6841. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6842. /**
  6843. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6844. * @param min defines the new minimum vector (in local space)
  6845. * @param max defines the new maximum vector (in local space)
  6846. * @param worldMatrix defines the new world matrix
  6847. */
  6848. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6849. /**
  6850. * Scale the current bounding box by applying a scale factor
  6851. * @param factor defines the scale factor to apply
  6852. * @returns the current bounding box
  6853. */
  6854. scale(factor: number): BoundingBox;
  6855. /**
  6856. * Gets the world matrix of the bounding box
  6857. * @returns a matrix
  6858. */
  6859. getWorldMatrix(): DeepImmutable<Matrix>;
  6860. /** @hidden */
  6861. _update(world: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Tests if the bounding box is intersecting the frustum planes
  6864. * @param frustumPlanes defines the frustum planes to test
  6865. * @returns true if there is an intersection
  6866. */
  6867. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6868. /**
  6869. * Tests if the bounding box is entirely inside the frustum planes
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @returns true if there is an inclusion
  6872. */
  6873. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. /**
  6875. * Tests if a point is inside the bounding box
  6876. * @param point defines the point to test
  6877. * @returns true if the point is inside the bounding box
  6878. */
  6879. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6880. /**
  6881. * Tests if the bounding box intersects with a bounding sphere
  6882. * @param sphere defines the sphere to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6886. /**
  6887. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6888. * @param min defines the min vector to use
  6889. * @param max defines the max vector to use
  6890. * @returns true if there is an intersection
  6891. */
  6892. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Tests if two bounding boxes are intersections
  6895. * @param box0 defines the first box to test
  6896. * @param box1 defines the second box to test
  6897. * @returns true if there is an intersection
  6898. */
  6899. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6900. /**
  6901. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6902. * @param minPoint defines the minimum vector of the bounding box
  6903. * @param maxPoint defines the maximum vector of the bounding box
  6904. * @param sphereCenter defines the sphere center
  6905. * @param sphereRadius defines the sphere radius
  6906. * @returns true if there is an intersection
  6907. */
  6908. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6909. /**
  6910. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6911. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6912. * @param frustumPlanes defines the frustum planes to test
  6913. * @return true if there is an inclusion
  6914. */
  6915. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6916. /**
  6917. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6918. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6919. * @param frustumPlanes defines the frustum planes to test
  6920. * @return true if there is an intersection
  6921. */
  6922. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6923. }
  6924. }
  6925. declare module BABYLON {
  6926. /** @hidden */
  6927. export class Collider {
  6928. /** Define if a collision was found */
  6929. collisionFound: boolean;
  6930. /**
  6931. * Define last intersection point in local space
  6932. */
  6933. intersectionPoint: Vector3;
  6934. /**
  6935. * Define last collided mesh
  6936. */
  6937. collidedMesh: Nullable<AbstractMesh>;
  6938. private _collisionPoint;
  6939. private _planeIntersectionPoint;
  6940. private _tempVector;
  6941. private _tempVector2;
  6942. private _tempVector3;
  6943. private _tempVector4;
  6944. private _edge;
  6945. private _baseToVertex;
  6946. private _destinationPoint;
  6947. private _slidePlaneNormal;
  6948. private _displacementVector;
  6949. /** @hidden */
  6950. _radius: Vector3;
  6951. /** @hidden */
  6952. _retry: number;
  6953. private _velocity;
  6954. private _basePoint;
  6955. private _epsilon;
  6956. /** @hidden */
  6957. _velocityWorldLength: number;
  6958. /** @hidden */
  6959. _basePointWorld: Vector3;
  6960. private _velocityWorld;
  6961. private _normalizedVelocity;
  6962. /** @hidden */
  6963. _initialVelocity: Vector3;
  6964. /** @hidden */
  6965. _initialPosition: Vector3;
  6966. private _nearestDistance;
  6967. private _collisionMask;
  6968. get collisionMask(): number;
  6969. set collisionMask(mask: number);
  6970. /**
  6971. * Gets the plane normal used to compute the sliding response (in local space)
  6972. */
  6973. get slidePlaneNormal(): Vector3;
  6974. /** @hidden */
  6975. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6976. /** @hidden */
  6977. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6978. /** @hidden */
  6979. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6980. /** @hidden */
  6981. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6982. /** @hidden */
  6983. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6984. /** @hidden */
  6985. _getResponse(pos: Vector3, vel: Vector3): void;
  6986. }
  6987. }
  6988. declare module BABYLON {
  6989. /**
  6990. * Interface for cullable objects
  6991. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6992. */
  6993. export interface ICullable {
  6994. /**
  6995. * Checks if the object or part of the object is in the frustum
  6996. * @param frustumPlanes Camera near/planes
  6997. * @returns true if the object is in frustum otherwise false
  6998. */
  6999. isInFrustum(frustumPlanes: Plane[]): boolean;
  7000. /**
  7001. * Checks if a cullable object (mesh...) is in the camera frustum
  7002. * Unlike isInFrustum this cheks the full bounding box
  7003. * @param frustumPlanes Camera near/planes
  7004. * @returns true if the object is in frustum otherwise false
  7005. */
  7006. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7007. }
  7008. /**
  7009. * Info for a bounding data of a mesh
  7010. */
  7011. export class BoundingInfo implements ICullable {
  7012. /**
  7013. * Bounding box for the mesh
  7014. */
  7015. readonly boundingBox: BoundingBox;
  7016. /**
  7017. * Bounding sphere for the mesh
  7018. */
  7019. readonly boundingSphere: BoundingSphere;
  7020. private _isLocked;
  7021. private static readonly TmpVector3;
  7022. /**
  7023. * Constructs bounding info
  7024. * @param minimum min vector of the bounding box/sphere
  7025. * @param maximum max vector of the bounding box/sphere
  7026. * @param worldMatrix defines the new world matrix
  7027. */
  7028. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7029. /**
  7030. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7031. * @param min defines the new minimum vector (in local space)
  7032. * @param max defines the new maximum vector (in local space)
  7033. * @param worldMatrix defines the new world matrix
  7034. */
  7035. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7036. /**
  7037. * min vector of the bounding box/sphere
  7038. */
  7039. get minimum(): Vector3;
  7040. /**
  7041. * max vector of the bounding box/sphere
  7042. */
  7043. get maximum(): Vector3;
  7044. /**
  7045. * If the info is locked and won't be updated to avoid perf overhead
  7046. */
  7047. get isLocked(): boolean;
  7048. set isLocked(value: boolean);
  7049. /**
  7050. * Updates the bounding sphere and box
  7051. * @param world world matrix to be used to update
  7052. */
  7053. update(world: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7056. * @param center New center of the bounding info
  7057. * @param extend New extend of the bounding info
  7058. * @returns the current bounding info
  7059. */
  7060. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7061. /**
  7062. * Scale the current bounding info by applying a scale factor
  7063. * @param factor defines the scale factor to apply
  7064. * @returns the current bounding info
  7065. */
  7066. scale(factor: number): BoundingInfo;
  7067. /**
  7068. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7069. * @param frustumPlanes defines the frustum to test
  7070. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7071. * @returns true if the bounding info is in the frustum planes
  7072. */
  7073. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7074. /**
  7075. * Gets the world distance between the min and max points of the bounding box
  7076. */
  7077. get diagonalLength(): number;
  7078. /**
  7079. * Checks if a cullable object (mesh...) is in the camera frustum
  7080. * Unlike isInFrustum this cheks the full bounding box
  7081. * @param frustumPlanes Camera near/planes
  7082. * @returns true if the object is in frustum otherwise false
  7083. */
  7084. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7085. /** @hidden */
  7086. _checkCollision(collider: Collider): boolean;
  7087. /**
  7088. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7089. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7090. * @param point the point to check intersection with
  7091. * @returns if the point intersects
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7096. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7097. * @param boundingInfo the bounding info to check intersection with
  7098. * @param precise if the intersection should be done using OBB
  7099. * @returns if the bounding info intersects
  7100. */
  7101. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7102. }
  7103. }
  7104. declare module BABYLON {
  7105. /**
  7106. * Extracts minimum and maximum values from a list of indexed positions
  7107. * @param positions defines the positions to use
  7108. * @param indices defines the indices to the positions
  7109. * @param indexStart defines the start index
  7110. * @param indexCount defines the end index
  7111. * @param bias defines bias value to add to the result
  7112. * @return minimum and maximum values
  7113. */
  7114. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7115. minimum: Vector3;
  7116. maximum: Vector3;
  7117. };
  7118. /**
  7119. * Extracts minimum and maximum values from a list of positions
  7120. * @param positions defines the positions to use
  7121. * @param start defines the start index in the positions array
  7122. * @param count defines the number of positions to handle
  7123. * @param bias defines bias value to add to the result
  7124. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7125. * @return minimum and maximum values
  7126. */
  7127. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7128. minimum: Vector3;
  7129. maximum: Vector3;
  7130. };
  7131. }
  7132. declare module BABYLON {
  7133. /** @hidden */
  7134. export class WebGLDataBuffer extends DataBuffer {
  7135. private _buffer;
  7136. constructor(resource: WebGLBuffer);
  7137. get underlyingResource(): any;
  7138. }
  7139. }
  7140. declare module BABYLON {
  7141. /** @hidden */
  7142. export class WebGLPipelineContext implements IPipelineContext {
  7143. engine: ThinEngine;
  7144. program: Nullable<WebGLProgram>;
  7145. context?: WebGLRenderingContext;
  7146. vertexShader?: WebGLShader;
  7147. fragmentShader?: WebGLShader;
  7148. isParallelCompiled: boolean;
  7149. onCompiled?: () => void;
  7150. transformFeedback?: WebGLTransformFeedback | null;
  7151. vertexCompilationError: Nullable<string>;
  7152. fragmentCompilationError: Nullable<string>;
  7153. programLinkError: Nullable<string>;
  7154. programValidationError: Nullable<string>;
  7155. get isAsync(): boolean;
  7156. get isReady(): boolean;
  7157. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7158. }
  7159. }
  7160. declare module BABYLON {
  7161. interface ThinEngine {
  7162. /**
  7163. * Create an uniform buffer
  7164. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7165. * @param elements defines the content of the uniform buffer
  7166. * @returns the webGL uniform buffer
  7167. */
  7168. createUniformBuffer(elements: FloatArray): DataBuffer;
  7169. /**
  7170. * Create a dynamic uniform buffer
  7171. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7172. * @param elements defines the content of the uniform buffer
  7173. * @returns the webGL uniform buffer
  7174. */
  7175. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7176. /**
  7177. * Update an existing uniform buffer
  7178. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7179. * @param uniformBuffer defines the target uniform buffer
  7180. * @param elements defines the content to update
  7181. * @param offset defines the offset in the uniform buffer where update should start
  7182. * @param count defines the size of the data to update
  7183. */
  7184. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7185. /**
  7186. * Bind an uniform buffer to the current webGL context
  7187. * @param buffer defines the buffer to bind
  7188. */
  7189. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7190. /**
  7191. * Bind a buffer to the current webGL context at a given location
  7192. * @param buffer defines the buffer to bind
  7193. * @param location defines the index where to bind the buffer
  7194. */
  7195. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7196. /**
  7197. * Bind a specific block at a given index in a specific shader program
  7198. * @param pipelineContext defines the pipeline context to use
  7199. * @param blockName defines the block name
  7200. * @param index defines the index where to bind the block
  7201. */
  7202. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7203. }
  7204. }
  7205. declare module BABYLON {
  7206. /**
  7207. * Uniform buffer objects.
  7208. *
  7209. * Handles blocks of uniform on the GPU.
  7210. *
  7211. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7212. *
  7213. * For more information, please refer to :
  7214. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7215. */
  7216. export class UniformBuffer {
  7217. private _engine;
  7218. private _buffer;
  7219. private _data;
  7220. private _bufferData;
  7221. private _dynamic?;
  7222. private _uniformLocations;
  7223. private _uniformSizes;
  7224. private _uniformLocationPointer;
  7225. private _needSync;
  7226. private _noUBO;
  7227. private _currentEffect;
  7228. /** @hidden */
  7229. _alreadyBound: boolean;
  7230. private static _MAX_UNIFORM_SIZE;
  7231. private static _tempBuffer;
  7232. /**
  7233. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7234. * This is dynamic to allow compat with webgl 1 and 2.
  7235. * You will need to pass the name of the uniform as well as the value.
  7236. */
  7237. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7238. /**
  7239. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7240. * This is dynamic to allow compat with webgl 1 and 2.
  7241. * You will need to pass the name of the uniform as well as the value.
  7242. */
  7243. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7244. /**
  7245. * Lambda to Update a single float in a uniform buffer.
  7246. * This is dynamic to allow compat with webgl 1 and 2.
  7247. * You will need to pass the name of the uniform as well as the value.
  7248. */
  7249. updateFloat: (name: string, x: number) => void;
  7250. /**
  7251. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7256. /**
  7257. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7262. /**
  7263. * Lambda to Update a vec4 of 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7268. /**
  7269. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7274. /**
  7275. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7280. /**
  7281. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7286. /**
  7287. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7292. /**
  7293. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7298. /**
  7299. * Instantiates a new Uniform buffer objects.
  7300. *
  7301. * Handles blocks of uniform on the GPU.
  7302. *
  7303. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7304. *
  7305. * For more information, please refer to :
  7306. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7307. * @param engine Define the engine the buffer is associated with
  7308. * @param data Define the data contained in the buffer
  7309. * @param dynamic Define if the buffer is updatable
  7310. */
  7311. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7312. /**
  7313. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7314. * or just falling back on setUniformXXX calls.
  7315. */
  7316. get useUbo(): boolean;
  7317. /**
  7318. * Indicates if the WebGL underlying uniform buffer is in sync
  7319. * with the javascript cache data.
  7320. */
  7321. get isSync(): boolean;
  7322. /**
  7323. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7324. * Also, a dynamic UniformBuffer will disable cache verification and always
  7325. * update the underlying WebGL uniform buffer to the GPU.
  7326. * @returns if Dynamic, otherwise false
  7327. */
  7328. isDynamic(): boolean;
  7329. /**
  7330. * The data cache on JS side.
  7331. * @returns the underlying data as a float array
  7332. */
  7333. getData(): Float32Array;
  7334. /**
  7335. * The underlying WebGL Uniform buffer.
  7336. * @returns the webgl buffer
  7337. */
  7338. getBuffer(): Nullable<DataBuffer>;
  7339. /**
  7340. * std140 layout specifies how to align data within an UBO structure.
  7341. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7342. * for specs.
  7343. */
  7344. private _fillAlignment;
  7345. /**
  7346. * Adds an uniform in the buffer.
  7347. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7348. * for the layout to be correct !
  7349. * @param name Name of the uniform, as used in the uniform block in the shader.
  7350. * @param size Data size, or data directly.
  7351. */
  7352. addUniform(name: string, size: number | number[]): void;
  7353. /**
  7354. * Adds a Matrix 4x4 to the uniform buffer.
  7355. * @param name Name of the uniform, as used in the uniform block in the shader.
  7356. * @param mat A 4x4 matrix.
  7357. */
  7358. addMatrix(name: string, mat: Matrix): void;
  7359. /**
  7360. * Adds a vec2 to the uniform buffer.
  7361. * @param name Name of the uniform, as used in the uniform block in the shader.
  7362. * @param x Define the x component value of the vec2
  7363. * @param y Define the y component value of the vec2
  7364. */
  7365. addFloat2(name: string, x: number, y: number): void;
  7366. /**
  7367. * Adds a vec3 to the uniform buffer.
  7368. * @param name Name of the uniform, as used in the uniform block in the shader.
  7369. * @param x Define the x component value of the vec3
  7370. * @param y Define the y component value of the vec3
  7371. * @param z Define the z component value of the vec3
  7372. */
  7373. addFloat3(name: string, x: number, y: number, z: number): void;
  7374. /**
  7375. * Adds a vec3 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param color Define the vec3 from a Color
  7378. */
  7379. addColor3(name: string, color: Color3): void;
  7380. /**
  7381. * Adds a vec4 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param color Define the rgb components from a Color
  7384. * @param alpha Define the a component of the vec4
  7385. */
  7386. addColor4(name: string, color: Color3, alpha: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param vector Define the vec3 components from a Vector
  7391. */
  7392. addVector3(name: string, vector: Vector3): void;
  7393. /**
  7394. * Adds a Matrix 3x3 to the uniform buffer.
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. */
  7397. addMatrix3x3(name: string): void;
  7398. /**
  7399. * Adds a Matrix 2x2 to the uniform buffer.
  7400. * @param name Name of the uniform, as used in the uniform block in the shader.
  7401. */
  7402. addMatrix2x2(name: string): void;
  7403. /**
  7404. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7405. */
  7406. create(): void;
  7407. /** @hidden */
  7408. _rebuild(): void;
  7409. /**
  7410. * Updates the WebGL Uniform Buffer on the GPU.
  7411. * If the `dynamic` flag is set to true, no cache comparison is done.
  7412. * Otherwise, the buffer will be updated only if the cache differs.
  7413. */
  7414. update(): void;
  7415. /**
  7416. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7417. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7418. * @param data Define the flattened data
  7419. * @param size Define the size of the data.
  7420. */
  7421. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7422. private _valueCache;
  7423. private _cacheMatrix;
  7424. private _updateMatrix3x3ForUniform;
  7425. private _updateMatrix3x3ForEffect;
  7426. private _updateMatrix2x2ForEffect;
  7427. private _updateMatrix2x2ForUniform;
  7428. private _updateFloatForEffect;
  7429. private _updateFloatForUniform;
  7430. private _updateFloat2ForEffect;
  7431. private _updateFloat2ForUniform;
  7432. private _updateFloat3ForEffect;
  7433. private _updateFloat3ForUniform;
  7434. private _updateFloat4ForEffect;
  7435. private _updateFloat4ForUniform;
  7436. private _updateMatrixForEffect;
  7437. private _updateMatrixForUniform;
  7438. private _updateVector3ForEffect;
  7439. private _updateVector3ForUniform;
  7440. private _updateVector4ForEffect;
  7441. private _updateVector4ForUniform;
  7442. private _updateColor3ForEffect;
  7443. private _updateColor3ForUniform;
  7444. private _updateColor4ForEffect;
  7445. private _updateColor4ForUniform;
  7446. /**
  7447. * Sets a sampler uniform on the effect.
  7448. * @param name Define the name of the sampler.
  7449. * @param texture Define the texture to set in the sampler
  7450. */
  7451. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7452. /**
  7453. * Directly updates the value of the uniform in the cache AND on the GPU.
  7454. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7455. * @param data Define the flattened data
  7456. */
  7457. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7458. /**
  7459. * Binds this uniform buffer to an effect.
  7460. * @param effect Define the effect to bind the buffer to
  7461. * @param name Name of the uniform block in the shader.
  7462. */
  7463. bindToEffect(effect: Effect, name: string): void;
  7464. /**
  7465. * Disposes the uniform buffer.
  7466. */
  7467. dispose(): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Enum that determines the text-wrapping mode to use.
  7473. */
  7474. export enum InspectableType {
  7475. /**
  7476. * Checkbox for booleans
  7477. */
  7478. Checkbox = 0,
  7479. /**
  7480. * Sliders for numbers
  7481. */
  7482. Slider = 1,
  7483. /**
  7484. * Vector3
  7485. */
  7486. Vector3 = 2,
  7487. /**
  7488. * Quaternions
  7489. */
  7490. Quaternion = 3,
  7491. /**
  7492. * Color3
  7493. */
  7494. Color3 = 4,
  7495. /**
  7496. * String
  7497. */
  7498. String = 5
  7499. }
  7500. /**
  7501. * Interface used to define custom inspectable properties.
  7502. * This interface is used by the inspector to display custom property grids
  7503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7504. */
  7505. export interface IInspectable {
  7506. /**
  7507. * Gets the label to display
  7508. */
  7509. label: string;
  7510. /**
  7511. * Gets the name of the property to edit
  7512. */
  7513. propertyName: string;
  7514. /**
  7515. * Gets the type of the editor to use
  7516. */
  7517. type: InspectableType;
  7518. /**
  7519. * Gets the minimum value of the property when using in "slider" mode
  7520. */
  7521. min?: number;
  7522. /**
  7523. * Gets the maximum value of the property when using in "slider" mode
  7524. */
  7525. max?: number;
  7526. /**
  7527. * Gets the setp to use when using in "slider" mode
  7528. */
  7529. step?: number;
  7530. }
  7531. }
  7532. declare module BABYLON {
  7533. /**
  7534. * Class used to provide helper for timing
  7535. */
  7536. export class TimingTools {
  7537. /**
  7538. * Polyfill for setImmediate
  7539. * @param action defines the action to execute after the current execution block
  7540. */
  7541. static SetImmediate(action: () => void): void;
  7542. }
  7543. }
  7544. declare module BABYLON {
  7545. /**
  7546. * Class used to enable instatition of objects by class name
  7547. */
  7548. export class InstantiationTools {
  7549. /**
  7550. * Use this object to register external classes like custom textures or material
  7551. * to allow the laoders to instantiate them
  7552. */
  7553. static RegisteredExternalClasses: {
  7554. [key: string]: Object;
  7555. };
  7556. /**
  7557. * Tries to instantiate a new object from a given class name
  7558. * @param className defines the class name to instantiate
  7559. * @returns the new object or null if the system was not able to do the instantiation
  7560. */
  7561. static Instantiate(className: string): any;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Define options used to create a depth texture
  7567. */
  7568. export class DepthTextureCreationOptions {
  7569. /** Specifies whether or not a stencil should be allocated in the texture */
  7570. generateStencil?: boolean;
  7571. /** Specifies whether or not bilinear filtering is enable on the texture */
  7572. bilinearFiltering?: boolean;
  7573. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7574. comparisonFunction?: number;
  7575. /** Specifies if the created texture is a cube texture */
  7576. isCube?: boolean;
  7577. }
  7578. }
  7579. declare module BABYLON {
  7580. interface ThinEngine {
  7581. /**
  7582. * Creates a depth stencil cube texture.
  7583. * This is only available in WebGL 2.
  7584. * @param size The size of face edge in the cube texture.
  7585. * @param options The options defining the cube texture.
  7586. * @returns The cube texture
  7587. */
  7588. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7589. /**
  7590. * Creates a cube texture
  7591. * @param rootUrl defines the url where the files to load is located
  7592. * @param scene defines the current scene
  7593. * @param files defines the list of files to load (1 per face)
  7594. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7595. * @param onLoad defines an optional callback raised when the texture is loaded
  7596. * @param onError defines an optional callback raised if there is an issue to load the texture
  7597. * @param format defines the format of the data
  7598. * @param forcedExtension defines the extension to use to pick the right loader
  7599. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7600. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7601. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7602. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7603. * @returns the cube texture as an InternalTexture
  7604. */
  7605. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7606. /**
  7607. * Creates a cube texture
  7608. * @param rootUrl defines the url where the files to load is located
  7609. * @param scene defines the current scene
  7610. * @param files defines the list of files to load (1 per face)
  7611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7612. * @param onLoad defines an optional callback raised when the texture is loaded
  7613. * @param onError defines an optional callback raised if there is an issue to load the texture
  7614. * @param format defines the format of the data
  7615. * @param forcedExtension defines the extension to use to pick the right loader
  7616. * @returns the cube texture as an InternalTexture
  7617. */
  7618. 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;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7632. * @returns the cube texture as an InternalTexture
  7633. */
  7634. 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;
  7635. /** @hidden */
  7636. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7637. /** @hidden */
  7638. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7639. /** @hidden */
  7640. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7641. /** @hidden */
  7642. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7643. /**
  7644. * @hidden
  7645. */
  7646. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7647. }
  7648. }
  7649. declare module BABYLON {
  7650. /**
  7651. * Class for creating a cube texture
  7652. */
  7653. export class CubeTexture extends BaseTexture {
  7654. private _delayedOnLoad;
  7655. /**
  7656. * Observable triggered once the texture has been loaded.
  7657. */
  7658. onLoadObservable: Observable<CubeTexture>;
  7659. /**
  7660. * The url of the texture
  7661. */
  7662. url: string;
  7663. /**
  7664. * Gets or sets the center of the bounding box associated with the cube texture.
  7665. * It must define where the camera used to render the texture was set
  7666. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7667. */
  7668. boundingBoxPosition: Vector3;
  7669. private _boundingBoxSize;
  7670. /**
  7671. * Gets or sets the size of the bounding box associated with the cube texture
  7672. * When defined, the cubemap will switch to local mode
  7673. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7674. * @example https://www.babylonjs-playground.com/#RNASML
  7675. */
  7676. set boundingBoxSize(value: Vector3);
  7677. /**
  7678. * Returns the bounding box size
  7679. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7680. */
  7681. get boundingBoxSize(): Vector3;
  7682. protected _rotationY: number;
  7683. /**
  7684. * Sets texture matrix rotation angle around Y axis in radians.
  7685. */
  7686. set rotationY(value: number);
  7687. /**
  7688. * Gets texture matrix rotation angle around Y axis radians.
  7689. */
  7690. get rotationY(): number;
  7691. /**
  7692. * Are mip maps generated for this texture or not.
  7693. */
  7694. get noMipmap(): boolean;
  7695. private _noMipmap;
  7696. private _files;
  7697. protected _forcedExtension: Nullable<string>;
  7698. private _extensions;
  7699. private _textureMatrix;
  7700. private _format;
  7701. private _createPolynomials;
  7702. /** @hidden */
  7703. _prefiltered: boolean;
  7704. /**
  7705. * Creates a cube texture from an array of image urls
  7706. * @param files defines an array of image urls
  7707. * @param scene defines the hosting scene
  7708. * @param noMipmap specifies if mip maps are not used
  7709. * @returns a cube texture
  7710. */
  7711. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7712. /**
  7713. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7714. * @param url defines the url of the prefiltered texture
  7715. * @param scene defines the scene the texture is attached to
  7716. * @param forcedExtension defines the extension of the file if different from the url
  7717. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7718. * @return the prefiltered texture
  7719. */
  7720. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7721. /**
  7722. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7723. * as prefiltered data.
  7724. * @param rootUrl defines the url of the texture or the root name of the six images
  7725. * @param scene defines the scene the texture is attached to
  7726. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7727. * @param noMipmap defines if mipmaps should be created or not
  7728. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7729. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7730. * @param onError defines a callback triggered in case of error during load
  7731. * @param format defines the internal format to use for the texture once loaded
  7732. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7733. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7734. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7735. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7736. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7737. * @return the cube texture
  7738. */
  7739. 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);
  7740. /**
  7741. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7742. */
  7743. get isPrefiltered(): boolean;
  7744. /**
  7745. * Get the current class name of the texture useful for serialization or dynamic coding.
  7746. * @returns "CubeTexture"
  7747. */
  7748. getClassName(): string;
  7749. /**
  7750. * Update the url (and optional buffer) of this texture if url was null during construction.
  7751. * @param url the url of the texture
  7752. * @param forcedExtension defines the extension to use
  7753. * @param onLoad callback called when the texture is loaded (defaults to null)
  7754. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7755. */
  7756. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7757. /**
  7758. * Delays loading of the cube texture
  7759. * @param forcedExtension defines the extension to use
  7760. */
  7761. delayLoad(forcedExtension?: string): void;
  7762. /**
  7763. * Returns the reflection texture matrix
  7764. * @returns the reflection texture matrix
  7765. */
  7766. getReflectionTextureMatrix(): Matrix;
  7767. /**
  7768. * Sets the reflection texture matrix
  7769. * @param value Reflection texture matrix
  7770. */
  7771. setReflectionTextureMatrix(value: Matrix): void;
  7772. /**
  7773. * Parses text to create a cube texture
  7774. * @param parsedTexture define the serialized text to read from
  7775. * @param scene defines the hosting scene
  7776. * @param rootUrl defines the root url of the cube texture
  7777. * @returns a cube texture
  7778. */
  7779. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7780. /**
  7781. * Makes a clone, or deep copy, of the cube texture
  7782. * @returns a new cube texture
  7783. */
  7784. clone(): CubeTexture;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Manages the defines for the Material
  7790. */
  7791. export class MaterialDefines {
  7792. /** @hidden */
  7793. protected _keys: string[];
  7794. private _isDirty;
  7795. /** @hidden */
  7796. _renderId: number;
  7797. /** @hidden */
  7798. _areLightsDirty: boolean;
  7799. /** @hidden */
  7800. _areLightsDisposed: boolean;
  7801. /** @hidden */
  7802. _areAttributesDirty: boolean;
  7803. /** @hidden */
  7804. _areTexturesDirty: boolean;
  7805. /** @hidden */
  7806. _areFresnelDirty: boolean;
  7807. /** @hidden */
  7808. _areMiscDirty: boolean;
  7809. /** @hidden */
  7810. _areImageProcessingDirty: boolean;
  7811. /** @hidden */
  7812. _normals: boolean;
  7813. /** @hidden */
  7814. _uvs: boolean;
  7815. /** @hidden */
  7816. _needNormals: boolean;
  7817. /** @hidden */
  7818. _needUVs: boolean;
  7819. [id: string]: any;
  7820. /**
  7821. * Specifies if the material needs to be re-calculated
  7822. */
  7823. get isDirty(): boolean;
  7824. /**
  7825. * Marks the material to indicate that it has been re-calculated
  7826. */
  7827. markAsProcessed(): void;
  7828. /**
  7829. * Marks the material to indicate that it needs to be re-calculated
  7830. */
  7831. markAsUnprocessed(): void;
  7832. /**
  7833. * Marks the material to indicate all of its defines need to be re-calculated
  7834. */
  7835. markAllAsDirty(): void;
  7836. /**
  7837. * Marks the material to indicate that image processing needs to be re-calculated
  7838. */
  7839. markAsImageProcessingDirty(): void;
  7840. /**
  7841. * Marks the material to indicate the lights need to be re-calculated
  7842. * @param disposed Defines whether the light is dirty due to dispose or not
  7843. */
  7844. markAsLightDirty(disposed?: boolean): void;
  7845. /**
  7846. * Marks the attribute state as changed
  7847. */
  7848. markAsAttributesDirty(): void;
  7849. /**
  7850. * Marks the texture state as changed
  7851. */
  7852. markAsTexturesDirty(): void;
  7853. /**
  7854. * Marks the fresnel state as changed
  7855. */
  7856. markAsFresnelDirty(): void;
  7857. /**
  7858. * Marks the misc state as changed
  7859. */
  7860. markAsMiscDirty(): void;
  7861. /**
  7862. * Rebuilds the material defines
  7863. */
  7864. rebuild(): void;
  7865. /**
  7866. * Specifies if two material defines are equal
  7867. * @param other - A material define instance to compare to
  7868. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7869. */
  7870. isEqual(other: MaterialDefines): boolean;
  7871. /**
  7872. * Clones this instance's defines to another instance
  7873. * @param other - material defines to clone values to
  7874. */
  7875. cloneTo(other: MaterialDefines): void;
  7876. /**
  7877. * Resets the material define values
  7878. */
  7879. reset(): void;
  7880. /**
  7881. * Converts the material define values to a string
  7882. * @returns - String of material define information
  7883. */
  7884. toString(): string;
  7885. }
  7886. }
  7887. declare module BABYLON {
  7888. /**
  7889. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7890. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7891. * 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;
  7892. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7893. */
  7894. export class ColorCurves {
  7895. private _dirty;
  7896. private _tempColor;
  7897. private _globalCurve;
  7898. private _highlightsCurve;
  7899. private _midtonesCurve;
  7900. private _shadowsCurve;
  7901. private _positiveCurve;
  7902. private _negativeCurve;
  7903. private _globalHue;
  7904. private _globalDensity;
  7905. private _globalSaturation;
  7906. private _globalExposure;
  7907. /**
  7908. * Gets the global Hue value.
  7909. * 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).
  7910. */
  7911. get globalHue(): number;
  7912. /**
  7913. * Sets the global Hue value.
  7914. * 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).
  7915. */
  7916. set globalHue(value: number);
  7917. /**
  7918. * Gets the global Density value.
  7919. * 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.
  7920. * Values less than zero provide a filter of opposite hue.
  7921. */
  7922. get globalDensity(): number;
  7923. /**
  7924. * Sets the global Density value.
  7925. * 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.
  7926. * Values less than zero provide a filter of opposite hue.
  7927. */
  7928. set globalDensity(value: number);
  7929. /**
  7930. * Gets the global Saturation value.
  7931. * 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.
  7932. */
  7933. get globalSaturation(): number;
  7934. /**
  7935. * Sets the global Saturation value.
  7936. * 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.
  7937. */
  7938. set globalSaturation(value: number);
  7939. /**
  7940. * Gets the global Exposure value.
  7941. * 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.
  7942. */
  7943. get globalExposure(): number;
  7944. /**
  7945. * Sets the global Exposure value.
  7946. * 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.
  7947. */
  7948. set globalExposure(value: number);
  7949. private _highlightsHue;
  7950. private _highlightsDensity;
  7951. private _highlightsSaturation;
  7952. private _highlightsExposure;
  7953. /**
  7954. * Gets the highlights Hue value.
  7955. * 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).
  7956. */
  7957. get highlightsHue(): number;
  7958. /**
  7959. * Sets the highlights Hue value.
  7960. * 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).
  7961. */
  7962. set highlightsHue(value: number);
  7963. /**
  7964. * Gets the highlights Density value.
  7965. * 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.
  7966. * Values less than zero provide a filter of opposite hue.
  7967. */
  7968. get highlightsDensity(): number;
  7969. /**
  7970. * Sets the highlights Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. set highlightsDensity(value: number);
  7975. /**
  7976. * Gets the highlights Saturation value.
  7977. * 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.
  7978. */
  7979. get highlightsSaturation(): number;
  7980. /**
  7981. * Sets the highlights Saturation value.
  7982. * 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.
  7983. */
  7984. set highlightsSaturation(value: number);
  7985. /**
  7986. * Gets the highlights Exposure value.
  7987. * 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.
  7988. */
  7989. get highlightsExposure(): number;
  7990. /**
  7991. * Sets the highlights Exposure value.
  7992. * 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.
  7993. */
  7994. set highlightsExposure(value: number);
  7995. private _midtonesHue;
  7996. private _midtonesDensity;
  7997. private _midtonesSaturation;
  7998. private _midtonesExposure;
  7999. /**
  8000. * Gets the midtones Hue value.
  8001. * 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).
  8002. */
  8003. get midtonesHue(): number;
  8004. /**
  8005. * Sets the midtones Hue value.
  8006. * 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).
  8007. */
  8008. set midtonesHue(value: number);
  8009. /**
  8010. * Gets the midtones Density value.
  8011. * 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.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. get midtonesDensity(): number;
  8015. /**
  8016. * Sets the midtones Density value.
  8017. * 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.
  8018. * Values less than zero provide a filter of opposite hue.
  8019. */
  8020. set midtonesDensity(value: number);
  8021. /**
  8022. * Gets the midtones Saturation value.
  8023. * 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.
  8024. */
  8025. get midtonesSaturation(): number;
  8026. /**
  8027. * Sets the midtones Saturation value.
  8028. * 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.
  8029. */
  8030. set midtonesSaturation(value: number);
  8031. /**
  8032. * Gets the midtones Exposure value.
  8033. * 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.
  8034. */
  8035. get midtonesExposure(): number;
  8036. /**
  8037. * Sets the midtones Exposure value.
  8038. * 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.
  8039. */
  8040. set midtonesExposure(value: number);
  8041. private _shadowsHue;
  8042. private _shadowsDensity;
  8043. private _shadowsSaturation;
  8044. private _shadowsExposure;
  8045. /**
  8046. * Gets the shadows Hue value.
  8047. * 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).
  8048. */
  8049. get shadowsHue(): number;
  8050. /**
  8051. * Sets the shadows Hue value.
  8052. * 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).
  8053. */
  8054. set shadowsHue(value: number);
  8055. /**
  8056. * Gets the shadows Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. get shadowsDensity(): number;
  8061. /**
  8062. * Sets the shadows Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. set shadowsDensity(value: number);
  8067. /**
  8068. * Gets the shadows Saturation value.
  8069. * 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.
  8070. */
  8071. get shadowsSaturation(): number;
  8072. /**
  8073. * Sets the shadows Saturation value.
  8074. * 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.
  8075. */
  8076. set shadowsSaturation(value: number);
  8077. /**
  8078. * Gets the shadows Exposure value.
  8079. * 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.
  8080. */
  8081. get shadowsExposure(): number;
  8082. /**
  8083. * Sets the shadows Exposure value.
  8084. * 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.
  8085. */
  8086. set shadowsExposure(value: number);
  8087. /**
  8088. * Returns the class name
  8089. * @returns The class name
  8090. */
  8091. getClassName(): string;
  8092. /**
  8093. * Binds the color curves to the shader.
  8094. * @param colorCurves The color curve to bind
  8095. * @param effect The effect to bind to
  8096. * @param positiveUniform The positive uniform shader parameter
  8097. * @param neutralUniform The neutral uniform shader parameter
  8098. * @param negativeUniform The negative uniform shader parameter
  8099. */
  8100. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8101. /**
  8102. * Prepare the list of uniforms associated with the ColorCurves effects.
  8103. * @param uniformsList The list of uniforms used in the effect
  8104. */
  8105. static PrepareUniforms(uniformsList: string[]): void;
  8106. /**
  8107. * Returns color grading data based on a hue, density, saturation and exposure value.
  8108. * @param filterHue The hue of the color filter.
  8109. * @param filterDensity The density of the color filter.
  8110. * @param saturation The saturation.
  8111. * @param exposure The exposure.
  8112. * @param result The result data container.
  8113. */
  8114. private getColorGradingDataToRef;
  8115. /**
  8116. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8117. * @param value The input slider value in range [-100,100].
  8118. * @returns Adjusted value.
  8119. */
  8120. private static applyColorGradingSliderNonlinear;
  8121. /**
  8122. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8123. * @param hue The hue (H) input.
  8124. * @param saturation The saturation (S) input.
  8125. * @param brightness The brightness (B) input.
  8126. * @result An RGBA color represented as Vector4.
  8127. */
  8128. private static fromHSBToRef;
  8129. /**
  8130. * Returns a value clamped between min and max
  8131. * @param value The value to clamp
  8132. * @param min The minimum of value
  8133. * @param max The maximum of value
  8134. * @returns The clamped value.
  8135. */
  8136. private static clamp;
  8137. /**
  8138. * Clones the current color curve instance.
  8139. * @return The cloned curves
  8140. */
  8141. clone(): ColorCurves;
  8142. /**
  8143. * Serializes the current color curve instance to a json representation.
  8144. * @return a JSON representation
  8145. */
  8146. serialize(): any;
  8147. /**
  8148. * Parses the color curve from a json representation.
  8149. * @param source the JSON source to parse
  8150. * @return The parsed curves
  8151. */
  8152. static Parse(source: any): ColorCurves;
  8153. }
  8154. }
  8155. declare module BABYLON {
  8156. /**
  8157. * Interface to follow in your material defines to integrate easily the
  8158. * Image proccessing functions.
  8159. * @hidden
  8160. */
  8161. export interface IImageProcessingConfigurationDefines {
  8162. IMAGEPROCESSING: boolean;
  8163. VIGNETTE: boolean;
  8164. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8165. VIGNETTEBLENDMODEOPAQUE: boolean;
  8166. TONEMAPPING: boolean;
  8167. TONEMAPPING_ACES: boolean;
  8168. CONTRAST: boolean;
  8169. EXPOSURE: boolean;
  8170. COLORCURVES: boolean;
  8171. COLORGRADING: boolean;
  8172. COLORGRADING3D: boolean;
  8173. SAMPLER3DGREENDEPTH: boolean;
  8174. SAMPLER3DBGRMAP: boolean;
  8175. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8176. }
  8177. /**
  8178. * @hidden
  8179. */
  8180. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. COLORCURVES: boolean;
  8189. COLORGRADING: boolean;
  8190. COLORGRADING3D: boolean;
  8191. SAMPLER3DGREENDEPTH: boolean;
  8192. SAMPLER3DBGRMAP: boolean;
  8193. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8194. EXPOSURE: boolean;
  8195. constructor();
  8196. }
  8197. /**
  8198. * This groups together the common properties used for image processing either in direct forward pass
  8199. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8200. * or not.
  8201. */
  8202. export class ImageProcessingConfiguration {
  8203. /**
  8204. * Default tone mapping applied in BabylonJS.
  8205. */
  8206. static readonly TONEMAPPING_STANDARD: number;
  8207. /**
  8208. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8209. * to other engines rendering to increase portability.
  8210. */
  8211. static readonly TONEMAPPING_ACES: number;
  8212. /**
  8213. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8214. */
  8215. colorCurves: Nullable<ColorCurves>;
  8216. private _colorCurvesEnabled;
  8217. /**
  8218. * Gets wether the color curves effect is enabled.
  8219. */
  8220. get colorCurvesEnabled(): boolean;
  8221. /**
  8222. * Sets wether the color curves effect is enabled.
  8223. */
  8224. set colorCurvesEnabled(value: boolean);
  8225. private _colorGradingTexture;
  8226. /**
  8227. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8228. */
  8229. get colorGradingTexture(): Nullable<BaseTexture>;
  8230. /**
  8231. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8232. */
  8233. set colorGradingTexture(value: Nullable<BaseTexture>);
  8234. private _colorGradingEnabled;
  8235. /**
  8236. * Gets wether the color grading effect is enabled.
  8237. */
  8238. get colorGradingEnabled(): boolean;
  8239. /**
  8240. * Sets wether the color grading effect is enabled.
  8241. */
  8242. set colorGradingEnabled(value: boolean);
  8243. private _colorGradingWithGreenDepth;
  8244. /**
  8245. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8246. */
  8247. get colorGradingWithGreenDepth(): boolean;
  8248. /**
  8249. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8250. */
  8251. set colorGradingWithGreenDepth(value: boolean);
  8252. private _colorGradingBGR;
  8253. /**
  8254. * Gets wether the color grading texture contains BGR values.
  8255. */
  8256. get colorGradingBGR(): boolean;
  8257. /**
  8258. * Sets wether the color grading texture contains BGR values.
  8259. */
  8260. set colorGradingBGR(value: boolean);
  8261. /** @hidden */
  8262. _exposure: number;
  8263. /**
  8264. * Gets the Exposure used in the effect.
  8265. */
  8266. get exposure(): number;
  8267. /**
  8268. * Sets the Exposure used in the effect.
  8269. */
  8270. set exposure(value: number);
  8271. private _toneMappingEnabled;
  8272. /**
  8273. * Gets wether the tone mapping effect is enabled.
  8274. */
  8275. get toneMappingEnabled(): boolean;
  8276. /**
  8277. * Sets wether the tone mapping effect is enabled.
  8278. */
  8279. set toneMappingEnabled(value: boolean);
  8280. private _toneMappingType;
  8281. /**
  8282. * Gets the type of tone mapping effect.
  8283. */
  8284. get toneMappingType(): number;
  8285. /**
  8286. * Sets the type of tone mapping effect used in BabylonJS.
  8287. */
  8288. set toneMappingType(value: number);
  8289. protected _contrast: number;
  8290. /**
  8291. * Gets the contrast used in the effect.
  8292. */
  8293. get contrast(): number;
  8294. /**
  8295. * Sets the contrast used in the effect.
  8296. */
  8297. set contrast(value: number);
  8298. /**
  8299. * Vignette stretch size.
  8300. */
  8301. vignetteStretch: number;
  8302. /**
  8303. * Vignette centre X Offset.
  8304. */
  8305. vignetteCentreX: number;
  8306. /**
  8307. * Vignette centre Y Offset.
  8308. */
  8309. vignetteCentreY: number;
  8310. /**
  8311. * Vignette weight or intensity of the vignette effect.
  8312. */
  8313. vignetteWeight: number;
  8314. /**
  8315. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8316. * if vignetteEnabled is set to true.
  8317. */
  8318. vignetteColor: Color4;
  8319. /**
  8320. * Camera field of view used by the Vignette effect.
  8321. */
  8322. vignetteCameraFov: number;
  8323. private _vignetteBlendMode;
  8324. /**
  8325. * Gets the vignette blend mode allowing different kind of effect.
  8326. */
  8327. get vignetteBlendMode(): number;
  8328. /**
  8329. * Sets the vignette blend mode allowing different kind of effect.
  8330. */
  8331. set vignetteBlendMode(value: number);
  8332. private _vignetteEnabled;
  8333. /**
  8334. * Gets wether the vignette effect is enabled.
  8335. */
  8336. get vignetteEnabled(): boolean;
  8337. /**
  8338. * Sets wether the vignette effect is enabled.
  8339. */
  8340. set vignetteEnabled(value: boolean);
  8341. private _applyByPostProcess;
  8342. /**
  8343. * Gets wether the image processing is applied through a post process or not.
  8344. */
  8345. get applyByPostProcess(): boolean;
  8346. /**
  8347. * Sets wether the image processing is applied through a post process or not.
  8348. */
  8349. set applyByPostProcess(value: boolean);
  8350. private _isEnabled;
  8351. /**
  8352. * Gets wether the image processing is enabled or not.
  8353. */
  8354. get isEnabled(): boolean;
  8355. /**
  8356. * Sets wether the image processing is enabled or not.
  8357. */
  8358. set isEnabled(value: boolean);
  8359. /**
  8360. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8361. */
  8362. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8363. /**
  8364. * Method called each time the image processing information changes requires to recompile the effect.
  8365. */
  8366. protected _updateParameters(): void;
  8367. /**
  8368. * Gets the current class name.
  8369. * @return "ImageProcessingConfiguration"
  8370. */
  8371. getClassName(): string;
  8372. /**
  8373. * Prepare the list of uniforms associated with the Image Processing effects.
  8374. * @param uniforms The list of uniforms used in the effect
  8375. * @param defines the list of defines currently in use
  8376. */
  8377. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8378. /**
  8379. * Prepare the list of samplers associated with the Image Processing effects.
  8380. * @param samplersList The list of uniforms used in the effect
  8381. * @param defines the list of defines currently in use
  8382. */
  8383. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8384. /**
  8385. * Prepare the list of defines associated to the shader.
  8386. * @param defines the list of defines to complete
  8387. * @param forPostProcess Define if we are currently in post process mode or not
  8388. */
  8389. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8390. /**
  8391. * Returns true if all the image processing information are ready.
  8392. * @returns True if ready, otherwise, false
  8393. */
  8394. isReady(): boolean;
  8395. /**
  8396. * Binds the image processing to the shader.
  8397. * @param effect The effect to bind to
  8398. * @param overrideAspectRatio Override the aspect ratio of the effect
  8399. */
  8400. bind(effect: Effect, overrideAspectRatio?: number): void;
  8401. /**
  8402. * Clones the current image processing instance.
  8403. * @return The cloned image processing
  8404. */
  8405. clone(): ImageProcessingConfiguration;
  8406. /**
  8407. * Serializes the current image processing instance to a json representation.
  8408. * @return a JSON representation
  8409. */
  8410. serialize(): any;
  8411. /**
  8412. * Parses the image processing from a json representation.
  8413. * @param source the JSON source to parse
  8414. * @return The parsed image processing
  8415. */
  8416. static Parse(source: any): ImageProcessingConfiguration;
  8417. private static _VIGNETTEMODE_MULTIPLY;
  8418. private static _VIGNETTEMODE_OPAQUE;
  8419. /**
  8420. * Used to apply the vignette as a mix with the pixel color.
  8421. */
  8422. static get VIGNETTEMODE_MULTIPLY(): number;
  8423. /**
  8424. * Used to apply the vignette as a replacement of the pixel color.
  8425. */
  8426. static get VIGNETTEMODE_OPAQUE(): number;
  8427. }
  8428. }
  8429. declare module BABYLON {
  8430. /** @hidden */
  8431. export var postprocessVertexShader: {
  8432. name: string;
  8433. shader: string;
  8434. };
  8435. }
  8436. declare module BABYLON {
  8437. interface ThinEngine {
  8438. /**
  8439. * Creates a new render target texture
  8440. * @param size defines the size of the texture
  8441. * @param options defines the options used to create the texture
  8442. * @returns a new render target texture stored in an InternalTexture
  8443. */
  8444. createRenderTargetTexture(size: number | {
  8445. width: number;
  8446. height: number;
  8447. layers?: number;
  8448. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8449. /**
  8450. * Creates a depth stencil texture.
  8451. * This is only available in WebGL 2 or with the depth texture extension available.
  8452. * @param size The size of face edge in the texture.
  8453. * @param options The options defining the texture.
  8454. * @returns The texture
  8455. */
  8456. createDepthStencilTexture(size: number | {
  8457. width: number;
  8458. height: number;
  8459. layers?: number;
  8460. }, options: DepthTextureCreationOptions): InternalTexture;
  8461. /** @hidden */
  8462. _createDepthStencilTexture(size: number | {
  8463. width: number;
  8464. height: number;
  8465. layers?: number;
  8466. }, options: DepthTextureCreationOptions): InternalTexture;
  8467. }
  8468. }
  8469. declare module BABYLON {
  8470. /** Defines supported spaces */
  8471. export enum Space {
  8472. /** Local (object) space */
  8473. LOCAL = 0,
  8474. /** World space */
  8475. WORLD = 1,
  8476. /** Bone space */
  8477. BONE = 2
  8478. }
  8479. /** Defines the 3 main axes */
  8480. export class Axis {
  8481. /** X axis */
  8482. static X: Vector3;
  8483. /** Y axis */
  8484. static Y: Vector3;
  8485. /** Z axis */
  8486. static Z: Vector3;
  8487. }
  8488. }
  8489. declare module BABYLON {
  8490. /**
  8491. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8492. * This is the base of the follow, arc rotate cameras and Free camera
  8493. * @see http://doc.babylonjs.com/features/cameras
  8494. */
  8495. export class TargetCamera extends Camera {
  8496. private static _RigCamTransformMatrix;
  8497. private static _TargetTransformMatrix;
  8498. private static _TargetFocalPoint;
  8499. /**
  8500. * Define the current direction the camera is moving to
  8501. */
  8502. cameraDirection: Vector3;
  8503. /**
  8504. * Define the current rotation the camera is rotating to
  8505. */
  8506. cameraRotation: Vector2;
  8507. /**
  8508. * When set, the up vector of the camera will be updated by the rotation of the camera
  8509. */
  8510. updateUpVectorFromRotation: boolean;
  8511. private _tmpQuaternion;
  8512. /**
  8513. * Define the current rotation of the camera
  8514. */
  8515. rotation: Vector3;
  8516. /**
  8517. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8518. */
  8519. rotationQuaternion: Quaternion;
  8520. /**
  8521. * Define the current speed of the camera
  8522. */
  8523. speed: number;
  8524. /**
  8525. * Add constraint to the camera to prevent it to move freely in all directions and
  8526. * around all axis.
  8527. */
  8528. noRotationConstraint: boolean;
  8529. /**
  8530. * Define the current target of the camera as an object or a position.
  8531. */
  8532. lockedTarget: any;
  8533. /** @hidden */
  8534. _currentTarget: Vector3;
  8535. /** @hidden */
  8536. _initialFocalDistance: number;
  8537. /** @hidden */
  8538. _viewMatrix: Matrix;
  8539. /** @hidden */
  8540. _camMatrix: Matrix;
  8541. /** @hidden */
  8542. _cameraTransformMatrix: Matrix;
  8543. /** @hidden */
  8544. _cameraRotationMatrix: Matrix;
  8545. /** @hidden */
  8546. _referencePoint: Vector3;
  8547. /** @hidden */
  8548. _transformedReferencePoint: Vector3;
  8549. protected _globalCurrentTarget: Vector3;
  8550. protected _globalCurrentUpVector: Vector3;
  8551. /** @hidden */
  8552. _reset: () => void;
  8553. private _defaultUp;
  8554. /**
  8555. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8556. * This is the base of the follow, arc rotate cameras and Free camera
  8557. * @see http://doc.babylonjs.com/features/cameras
  8558. * @param name Defines the name of the camera in the scene
  8559. * @param position Defines the start position of the camera in the scene
  8560. * @param scene Defines the scene the camera belongs to
  8561. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8562. */
  8563. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8564. /**
  8565. * Gets the position in front of the camera at a given distance.
  8566. * @param distance The distance from the camera we want the position to be
  8567. * @returns the position
  8568. */
  8569. getFrontPosition(distance: number): Vector3;
  8570. /** @hidden */
  8571. _getLockedTargetPosition(): Nullable<Vector3>;
  8572. private _storedPosition;
  8573. private _storedRotation;
  8574. private _storedRotationQuaternion;
  8575. /**
  8576. * Store current camera state of the camera (fov, position, rotation, etc..)
  8577. * @returns the camera
  8578. */
  8579. storeState(): Camera;
  8580. /**
  8581. * Restored camera state. You must call storeState() first
  8582. * @returns whether it was successful or not
  8583. * @hidden
  8584. */
  8585. _restoreStateValues(): boolean;
  8586. /** @hidden */
  8587. _initCache(): void;
  8588. /** @hidden */
  8589. _updateCache(ignoreParentClass?: boolean): void;
  8590. /** @hidden */
  8591. _isSynchronizedViewMatrix(): boolean;
  8592. /** @hidden */
  8593. _computeLocalCameraSpeed(): number;
  8594. /**
  8595. * Defines the target the camera should look at.
  8596. * @param target Defines the new target as a Vector or a mesh
  8597. */
  8598. setTarget(target: Vector3): void;
  8599. /**
  8600. * Return the current target position of the camera. This value is expressed in local space.
  8601. * @returns the target position
  8602. */
  8603. getTarget(): Vector3;
  8604. /** @hidden */
  8605. _decideIfNeedsToMove(): boolean;
  8606. /** @hidden */
  8607. _updatePosition(): void;
  8608. /** @hidden */
  8609. _checkInputs(): void;
  8610. protected _updateCameraRotationMatrix(): void;
  8611. /**
  8612. * 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)
  8613. * @returns the current camera
  8614. */
  8615. private _rotateUpVectorWithCameraRotationMatrix;
  8616. private _cachedRotationZ;
  8617. private _cachedQuaternionRotationZ;
  8618. /** @hidden */
  8619. _getViewMatrix(): Matrix;
  8620. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8621. /**
  8622. * @hidden
  8623. */
  8624. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8625. /**
  8626. * @hidden
  8627. */
  8628. _updateRigCameras(): void;
  8629. private _getRigCamPositionAndTarget;
  8630. /**
  8631. * Gets the current object class name.
  8632. * @return the class name
  8633. */
  8634. getClassName(): string;
  8635. }
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * Gather the list of keyboard event types as constants.
  8640. */
  8641. export class KeyboardEventTypes {
  8642. /**
  8643. * The keydown event is fired when a key becomes active (pressed).
  8644. */
  8645. static readonly KEYDOWN: number;
  8646. /**
  8647. * The keyup event is fired when a key has been released.
  8648. */
  8649. static readonly KEYUP: number;
  8650. }
  8651. /**
  8652. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8653. */
  8654. export class KeyboardInfo {
  8655. /**
  8656. * Defines the type of event (KeyboardEventTypes)
  8657. */
  8658. type: number;
  8659. /**
  8660. * Defines the related dom event
  8661. */
  8662. event: KeyboardEvent;
  8663. /**
  8664. * Instantiates a new keyboard info.
  8665. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8666. * @param type Defines the type of event (KeyboardEventTypes)
  8667. * @param event Defines the related dom event
  8668. */
  8669. constructor(
  8670. /**
  8671. * Defines the type of event (KeyboardEventTypes)
  8672. */
  8673. type: number,
  8674. /**
  8675. * Defines the related dom event
  8676. */
  8677. event: KeyboardEvent);
  8678. }
  8679. /**
  8680. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8681. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8682. */
  8683. export class KeyboardInfoPre extends KeyboardInfo {
  8684. /**
  8685. * Defines the type of event (KeyboardEventTypes)
  8686. */
  8687. type: number;
  8688. /**
  8689. * Defines the related dom event
  8690. */
  8691. event: KeyboardEvent;
  8692. /**
  8693. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8694. */
  8695. skipOnPointerObservable: boolean;
  8696. /**
  8697. * Instantiates a new keyboard pre info.
  8698. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  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. }
  8713. declare module BABYLON {
  8714. /**
  8715. * Manage the keyboard inputs to control the movement of a free camera.
  8716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8717. */
  8718. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8719. /**
  8720. * Defines the camera the input is attached to.
  8721. */
  8722. camera: FreeCamera;
  8723. /**
  8724. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8725. */
  8726. keysUp: number[];
  8727. /**
  8728. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8729. */
  8730. keysDown: number[];
  8731. /**
  8732. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8733. */
  8734. keysLeft: number[];
  8735. /**
  8736. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8737. */
  8738. keysRight: number[];
  8739. private _keys;
  8740. private _onCanvasBlurObserver;
  8741. private _onKeyboardObserver;
  8742. private _engine;
  8743. private _scene;
  8744. /**
  8745. * Attach the input controls to a specific dom element to get the input from.
  8746. * @param element Defines the element the controls should be listened from
  8747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8748. */
  8749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8750. /**
  8751. * Detach the current controls from the specified dom element.
  8752. * @param element Defines the element to stop listening the inputs from
  8753. */
  8754. detachControl(element: Nullable<HTMLElement>): void;
  8755. /**
  8756. * Update the current camera state depending on the inputs that have been used this frame.
  8757. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8758. */
  8759. checkInputs(): void;
  8760. /**
  8761. * Gets the class name of the current intput.
  8762. * @returns the class name
  8763. */
  8764. getClassName(): string;
  8765. /** @hidden */
  8766. _onLostFocus(): void;
  8767. /**
  8768. * Get the friendly name associated with the input class.
  8769. * @returns the input friendly name
  8770. */
  8771. getSimpleName(): string;
  8772. }
  8773. }
  8774. declare module BABYLON {
  8775. /**
  8776. * Interface describing all the common properties and methods a shadow light needs to implement.
  8777. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8778. * as well as binding the different shadow properties to the effects.
  8779. */
  8780. export interface IShadowLight extends Light {
  8781. /**
  8782. * The light id in the scene (used in scene.findLighById for instance)
  8783. */
  8784. id: string;
  8785. /**
  8786. * The position the shdow will be casted from.
  8787. */
  8788. position: Vector3;
  8789. /**
  8790. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8791. */
  8792. direction: Vector3;
  8793. /**
  8794. * The transformed position. Position of the light in world space taking parenting in account.
  8795. */
  8796. transformedPosition: Vector3;
  8797. /**
  8798. * The transformed direction. Direction of the light in world space taking parenting in account.
  8799. */
  8800. transformedDirection: Vector3;
  8801. /**
  8802. * The friendly name of the light in the scene.
  8803. */
  8804. name: string;
  8805. /**
  8806. * Defines the shadow projection clipping minimum z value.
  8807. */
  8808. shadowMinZ: number;
  8809. /**
  8810. * Defines the shadow projection clipping maximum z value.
  8811. */
  8812. shadowMaxZ: number;
  8813. /**
  8814. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8815. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8816. */
  8817. computeTransformedInformation(): boolean;
  8818. /**
  8819. * Gets the scene the light belongs to.
  8820. * @returns The scene
  8821. */
  8822. getScene(): Scene;
  8823. /**
  8824. * Callback defining a custom Projection Matrix Builder.
  8825. * This can be used to override the default projection matrix computation.
  8826. */
  8827. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8828. /**
  8829. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8830. * @param matrix The materix to updated with the projection information
  8831. * @param viewMatrix The transform matrix of the light
  8832. * @param renderList The list of mesh to render in the map
  8833. * @returns The current light
  8834. */
  8835. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8836. /**
  8837. * Gets the current depth scale used in ESM.
  8838. * @returns The scale
  8839. */
  8840. getDepthScale(): number;
  8841. /**
  8842. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8843. * @returns true if a cube texture needs to be use
  8844. */
  8845. needCube(): boolean;
  8846. /**
  8847. * Detects if the projection matrix requires to be recomputed this frame.
  8848. * @returns true if it requires to be recomputed otherwise, false.
  8849. */
  8850. needProjectionMatrixCompute(): boolean;
  8851. /**
  8852. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8853. */
  8854. forceProjectionMatrixCompute(): void;
  8855. /**
  8856. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8857. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8858. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8859. */
  8860. getShadowDirection(faceIndex?: number): Vector3;
  8861. /**
  8862. * Gets the minZ used for shadow according to both the scene and the light.
  8863. * @param activeCamera The camera we are returning the min for
  8864. * @returns the depth min z
  8865. */
  8866. getDepthMinZ(activeCamera: Camera): number;
  8867. /**
  8868. * Gets the maxZ used for shadow according to both the scene and the light.
  8869. * @param activeCamera The camera we are returning the max for
  8870. * @returns the depth max z
  8871. */
  8872. getDepthMaxZ(activeCamera: Camera): number;
  8873. }
  8874. /**
  8875. * Base implementation IShadowLight
  8876. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8877. */
  8878. export abstract class ShadowLight extends Light implements IShadowLight {
  8879. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8880. protected _position: Vector3;
  8881. protected _setPosition(value: Vector3): void;
  8882. /**
  8883. * Sets the position the shadow will be casted from. Also use as the light position for both
  8884. * point and spot lights.
  8885. */
  8886. get position(): Vector3;
  8887. /**
  8888. * Sets the position the shadow will be casted from. Also use as the light position for both
  8889. * point and spot lights.
  8890. */
  8891. set position(value: Vector3);
  8892. protected _direction: Vector3;
  8893. protected _setDirection(value: Vector3): void;
  8894. /**
  8895. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8896. * Also use as the light direction on spot and directional lights.
  8897. */
  8898. get direction(): Vector3;
  8899. /**
  8900. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8901. * Also use as the light direction on spot and directional lights.
  8902. */
  8903. set direction(value: Vector3);
  8904. protected _shadowMinZ: number;
  8905. /**
  8906. * Gets the shadow projection clipping minimum z value.
  8907. */
  8908. get shadowMinZ(): number;
  8909. /**
  8910. * Sets the shadow projection clipping minimum z value.
  8911. */
  8912. set shadowMinZ(value: number);
  8913. protected _shadowMaxZ: number;
  8914. /**
  8915. * Sets the shadow projection clipping maximum z value.
  8916. */
  8917. get shadowMaxZ(): number;
  8918. /**
  8919. * Gets the shadow projection clipping maximum z value.
  8920. */
  8921. set shadowMaxZ(value: number);
  8922. /**
  8923. * Callback defining a custom Projection Matrix Builder.
  8924. * This can be used to override the default projection matrix computation.
  8925. */
  8926. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8927. /**
  8928. * The transformed position. Position of the light in world space taking parenting in account.
  8929. */
  8930. transformedPosition: Vector3;
  8931. /**
  8932. * The transformed direction. Direction of the light in world space taking parenting in account.
  8933. */
  8934. transformedDirection: Vector3;
  8935. private _needProjectionMatrixCompute;
  8936. /**
  8937. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8938. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8939. */
  8940. computeTransformedInformation(): boolean;
  8941. /**
  8942. * Return the depth scale used for the shadow map.
  8943. * @returns the depth scale.
  8944. */
  8945. getDepthScale(): number;
  8946. /**
  8947. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8948. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8949. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8950. */
  8951. getShadowDirection(faceIndex?: number): Vector3;
  8952. /**
  8953. * Returns the ShadowLight absolute position in the World.
  8954. * @returns the position vector in world space
  8955. */
  8956. getAbsolutePosition(): Vector3;
  8957. /**
  8958. * Sets the ShadowLight direction toward the passed target.
  8959. * @param target The point to target in local space
  8960. * @returns the updated ShadowLight direction
  8961. */
  8962. setDirectionToTarget(target: Vector3): Vector3;
  8963. /**
  8964. * Returns the light rotation in euler definition.
  8965. * @returns the x y z rotation in local space.
  8966. */
  8967. getRotation(): Vector3;
  8968. /**
  8969. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8970. * @returns true if a cube texture needs to be use
  8971. */
  8972. needCube(): boolean;
  8973. /**
  8974. * Detects if the projection matrix requires to be recomputed this frame.
  8975. * @returns true if it requires to be recomputed otherwise, false.
  8976. */
  8977. needProjectionMatrixCompute(): boolean;
  8978. /**
  8979. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8980. */
  8981. forceProjectionMatrixCompute(): void;
  8982. /** @hidden */
  8983. _initCache(): void;
  8984. /** @hidden */
  8985. _isSynchronized(): boolean;
  8986. /**
  8987. * Computes the world matrix of the node
  8988. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8989. * @returns the world matrix
  8990. */
  8991. computeWorldMatrix(force?: boolean): Matrix;
  8992. /**
  8993. * Gets the minZ used for shadow according to both the scene and the light.
  8994. * @param activeCamera The camera we are returning the min for
  8995. * @returns the depth min z
  8996. */
  8997. getDepthMinZ(activeCamera: Camera): number;
  8998. /**
  8999. * Gets the maxZ used for shadow according to both the scene and the light.
  9000. * @param activeCamera The camera we are returning the max for
  9001. * @returns the depth max z
  9002. */
  9003. getDepthMaxZ(activeCamera: Camera): number;
  9004. /**
  9005. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9006. * @param matrix The materix to updated with the projection information
  9007. * @param viewMatrix The transform matrix of the light
  9008. * @param renderList The list of mesh to render in the map
  9009. * @returns The current light
  9010. */
  9011. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9012. }
  9013. }
  9014. declare module BABYLON {
  9015. /**
  9016. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9017. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9018. */
  9019. export class EffectFallbacks implements IEffectFallbacks {
  9020. private _defines;
  9021. private _currentRank;
  9022. private _maxRank;
  9023. private _mesh;
  9024. /**
  9025. * Removes the fallback from the bound mesh.
  9026. */
  9027. unBindMesh(): void;
  9028. /**
  9029. * Adds a fallback on the specified property.
  9030. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9031. * @param define The name of the define in the shader
  9032. */
  9033. addFallback(rank: number, define: string): void;
  9034. /**
  9035. * Sets the mesh to use CPU skinning when needing to fallback.
  9036. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9037. * @param mesh The mesh to use the fallbacks.
  9038. */
  9039. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9040. /**
  9041. * Checks to see if more fallbacks are still availible.
  9042. */
  9043. get hasMoreFallbacks(): boolean;
  9044. /**
  9045. * Removes the defines that should be removed when falling back.
  9046. * @param currentDefines defines the current define statements for the shader.
  9047. * @param effect defines the current effect we try to compile
  9048. * @returns The resulting defines with defines of the current rank removed.
  9049. */
  9050. reduce(currentDefines: string, effect: Effect): string;
  9051. }
  9052. }
  9053. declare module BABYLON {
  9054. /**
  9055. * "Static Class" containing the most commonly used helper while dealing with material for
  9056. * rendering purpose.
  9057. *
  9058. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9059. *
  9060. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9061. */
  9062. export class MaterialHelper {
  9063. /**
  9064. * Bind the current view position to an effect.
  9065. * @param effect The effect to be bound
  9066. * @param scene The scene the eyes position is used from
  9067. */
  9068. static BindEyePosition(effect: Effect, scene: Scene): void;
  9069. /**
  9070. * Helps preparing the defines values about the UVs in used in the effect.
  9071. * UVs are shared as much as we can accross channels in the shaders.
  9072. * @param texture The texture we are preparing the UVs for
  9073. * @param defines The defines to update
  9074. * @param key The channel key "diffuse", "specular"... used in the shader
  9075. */
  9076. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9077. /**
  9078. * Binds a texture matrix value to its corrsponding uniform
  9079. * @param texture The texture to bind the matrix for
  9080. * @param uniformBuffer The uniform buffer receivin the data
  9081. * @param key The channel key "diffuse", "specular"... used in the shader
  9082. */
  9083. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9084. /**
  9085. * Gets the current status of the fog (should it be enabled?)
  9086. * @param mesh defines the mesh to evaluate for fog support
  9087. * @param scene defines the hosting scene
  9088. * @returns true if fog must be enabled
  9089. */
  9090. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9091. /**
  9092. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9093. * @param mesh defines the current mesh
  9094. * @param scene defines the current scene
  9095. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9096. * @param pointsCloud defines if point cloud rendering has to be turned on
  9097. * @param fogEnabled defines if fog has to be turned on
  9098. * @param alphaTest defines if alpha testing has to be turned on
  9099. * @param defines defines the current list of defines
  9100. */
  9101. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9102. /**
  9103. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9104. * @param scene defines the current scene
  9105. * @param engine defines the current engine
  9106. * @param defines specifies the list of active defines
  9107. * @param useInstances defines if instances have to be turned on
  9108. * @param useClipPlane defines if clip plane have to be turned on
  9109. */
  9110. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9111. /**
  9112. * Prepares the defines for bones
  9113. * @param mesh The mesh containing the geometry data we will draw
  9114. * @param defines The defines to update
  9115. */
  9116. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9117. /**
  9118. * Prepares the defines for morph targets
  9119. * @param mesh The mesh containing the geometry data we will draw
  9120. * @param defines The defines to update
  9121. */
  9122. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9123. /**
  9124. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9125. * @param mesh The mesh containing the geometry data we will draw
  9126. * @param defines The defines to update
  9127. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9128. * @param useBones Precise whether bones should be used or not (override mesh info)
  9129. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9130. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9131. * @returns false if defines are considered not dirty and have not been checked
  9132. */
  9133. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9134. /**
  9135. * Prepares the defines related to multiview
  9136. * @param scene The scene we are intending to draw
  9137. * @param defines The defines to update
  9138. */
  9139. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9140. /**
  9141. * Prepares the defines related to the light information passed in parameter
  9142. * @param scene The scene we are intending to draw
  9143. * @param mesh The mesh the effect is compiling for
  9144. * @param light The light the effect is compiling for
  9145. * @param lightIndex The index of the light
  9146. * @param defines The defines to update
  9147. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9148. * @param state Defines the current state regarding what is needed (normals, etc...)
  9149. */
  9150. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9151. needNormals: boolean;
  9152. needRebuild: boolean;
  9153. shadowEnabled: boolean;
  9154. specularEnabled: boolean;
  9155. lightmapMode: boolean;
  9156. }): void;
  9157. /**
  9158. * Prepares the defines related to the light information passed in parameter
  9159. * @param scene The scene we are intending to draw
  9160. * @param mesh The mesh the effect is compiling for
  9161. * @param defines The defines to update
  9162. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9163. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9164. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9165. * @returns true if normals will be required for the rest of the effect
  9166. */
  9167. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9168. /**
  9169. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9170. * @param lightIndex defines the light index
  9171. * @param uniformsList The uniform list
  9172. * @param samplersList The sampler list
  9173. * @param projectedLightTexture defines if projected texture must be used
  9174. * @param uniformBuffersList defines an optional list of uniform buffers
  9175. */
  9176. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9177. /**
  9178. * Prepares the uniforms and samplers list to be used in the effect
  9179. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9180. * @param samplersList The sampler list
  9181. * @param defines The defines helping in the list generation
  9182. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9183. */
  9184. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9185. /**
  9186. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9187. * @param defines The defines to update while falling back
  9188. * @param fallbacks The authorized effect fallbacks
  9189. * @param maxSimultaneousLights The maximum number of lights allowed
  9190. * @param rank the current rank of the Effect
  9191. * @returns The newly affected rank
  9192. */
  9193. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9194. private static _TmpMorphInfluencers;
  9195. /**
  9196. * Prepares the list of attributes required for morph targets according to the effect defines.
  9197. * @param attribs The current list of supported attribs
  9198. * @param mesh The mesh to prepare the morph targets attributes for
  9199. * @param influencers The number of influencers
  9200. */
  9201. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9202. /**
  9203. * Prepares the list of attributes required for morph targets according to the effect defines.
  9204. * @param attribs The current list of supported attribs
  9205. * @param mesh The mesh to prepare the morph targets attributes for
  9206. * @param defines The current Defines of the effect
  9207. */
  9208. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9209. /**
  9210. * Prepares the list of attributes required for bones according to the effect defines.
  9211. * @param attribs The current list of supported attribs
  9212. * @param mesh The mesh to prepare the bones attributes for
  9213. * @param defines The current Defines of the effect
  9214. * @param fallbacks The current efffect fallback strategy
  9215. */
  9216. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9217. /**
  9218. * Check and prepare the list of attributes required for instances according to the effect defines.
  9219. * @param attribs The current list of supported attribs
  9220. * @param defines The current MaterialDefines of the effect
  9221. */
  9222. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9223. /**
  9224. * Add the list of attributes required for instances to the attribs array.
  9225. * @param attribs The current list of supported attribs
  9226. */
  9227. static PushAttributesForInstances(attribs: string[]): void;
  9228. /**
  9229. * Binds the light information to the effect.
  9230. * @param light The light containing the generator
  9231. * @param effect The effect we are binding the data to
  9232. * @param lightIndex The light index in the effect used to render
  9233. */
  9234. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9235. /**
  9236. * Binds the lights information from the scene to the effect for the given mesh.
  9237. * @param light Light to bind
  9238. * @param lightIndex Light index
  9239. * @param scene The scene where the light belongs to
  9240. * @param effect The effect we are binding the data to
  9241. * @param useSpecular Defines if specular is supported
  9242. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9243. */
  9244. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9245. /**
  9246. * Binds the lights information from the scene to the effect for the given mesh.
  9247. * @param scene The scene the lights belongs to
  9248. * @param mesh The mesh we are binding the information to render
  9249. * @param effect The effect we are binding the data to
  9250. * @param defines The generated defines for the effect
  9251. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9252. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9253. */
  9254. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9255. private static _tempFogColor;
  9256. /**
  9257. * Binds the fog information from the scene to the effect for the given mesh.
  9258. * @param scene The scene the lights belongs to
  9259. * @param mesh The mesh we are binding the information to render
  9260. * @param effect The effect we are binding the data to
  9261. * @param linearSpace Defines if the fog effect is applied in linear space
  9262. */
  9263. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9264. /**
  9265. * Binds the bones information from the mesh to the effect.
  9266. * @param mesh The mesh we are binding the information to render
  9267. * @param effect The effect we are binding the data to
  9268. */
  9269. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9270. /**
  9271. * Binds the morph targets information from the mesh to the effect.
  9272. * @param abstractMesh The mesh we are binding the information to render
  9273. * @param effect The effect we are binding the data to
  9274. */
  9275. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9276. /**
  9277. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9278. * @param defines The generated defines used in the effect
  9279. * @param effect The effect we are binding the data to
  9280. * @param scene The scene we are willing to render with logarithmic scale for
  9281. */
  9282. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9283. /**
  9284. * Binds the clip plane information from the scene to the effect.
  9285. * @param scene The scene the clip plane information are extracted from
  9286. * @param effect The effect we are binding the data to
  9287. */
  9288. static BindClipPlane(effect: Effect, scene: Scene): void;
  9289. }
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var packingFunctions: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var clipPlaneFragmentDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var clipPlaneFragment: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var shadowMapPixelShader: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var bonesDeclaration: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var morphTargetsVertexGlobalDeclaration: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var morphTargetsVertexDeclaration: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var instancesDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var helperFunctions: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var clipPlaneVertexDeclaration: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var morphTargetsVertex: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var instancesVertex: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var bonesVertex: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var clipPlaneVertex: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var shadowMapVertexShader: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var depthBoxBlurPixelShader: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /**
  9405. * Class representing a ray with position and direction
  9406. */
  9407. export class Ray {
  9408. /** origin point */
  9409. origin: Vector3;
  9410. /** direction */
  9411. direction: Vector3;
  9412. /** length of the ray */
  9413. length: number;
  9414. private static readonly TmpVector3;
  9415. private _tmpRay;
  9416. /**
  9417. * Creates a new ray
  9418. * @param origin origin point
  9419. * @param direction direction
  9420. * @param length length of the ray
  9421. */
  9422. constructor(
  9423. /** origin point */
  9424. origin: Vector3,
  9425. /** direction */
  9426. direction: Vector3,
  9427. /** length of the ray */
  9428. length?: number);
  9429. /**
  9430. * Checks if the ray intersects a box
  9431. * @param minimum bound of the box
  9432. * @param maximum bound of the box
  9433. * @param intersectionTreshold extra extend to be added to the box in all direction
  9434. * @returns if the box was hit
  9435. */
  9436. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9437. /**
  9438. * Checks if the ray intersects a box
  9439. * @param box the bounding box to check
  9440. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9441. * @returns if the box was hit
  9442. */
  9443. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9444. /**
  9445. * If the ray hits a sphere
  9446. * @param sphere the bounding sphere to check
  9447. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9448. * @returns true if it hits the sphere
  9449. */
  9450. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9451. /**
  9452. * If the ray hits a triange
  9453. * @param vertex0 triangle vertex
  9454. * @param vertex1 triangle vertex
  9455. * @param vertex2 triangle vertex
  9456. * @returns intersection information if hit
  9457. */
  9458. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9459. /**
  9460. * Checks if ray intersects a plane
  9461. * @param plane the plane to check
  9462. * @returns the distance away it was hit
  9463. */
  9464. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9465. /**
  9466. * Calculate the intercept of a ray on a given axis
  9467. * @param axis to check 'x' | 'y' | 'z'
  9468. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9469. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9470. */
  9471. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9472. /**
  9473. * Checks if ray intersects a mesh
  9474. * @param mesh the mesh to check
  9475. * @param fastCheck if only the bounding box should checked
  9476. * @returns picking info of the intersecton
  9477. */
  9478. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9479. /**
  9480. * Checks if ray intersects a mesh
  9481. * @param meshes the meshes to check
  9482. * @param fastCheck if only the bounding box should checked
  9483. * @param results array to store result in
  9484. * @returns Array of picking infos
  9485. */
  9486. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9487. private _comparePickingInfo;
  9488. private static smallnum;
  9489. private static rayl;
  9490. /**
  9491. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9492. * @param sega the first point of the segment to test the intersection against
  9493. * @param segb the second point of the segment to test the intersection against
  9494. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9495. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9496. */
  9497. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9498. /**
  9499. * Update the ray from viewport position
  9500. * @param x position
  9501. * @param y y position
  9502. * @param viewportWidth viewport width
  9503. * @param viewportHeight viewport height
  9504. * @param world world matrix
  9505. * @param view view matrix
  9506. * @param projection projection matrix
  9507. * @returns this ray updated
  9508. */
  9509. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9510. /**
  9511. * Creates a ray with origin and direction of 0,0,0
  9512. * @returns the new ray
  9513. */
  9514. static Zero(): Ray;
  9515. /**
  9516. * Creates a new ray from screen space and viewport
  9517. * @param x position
  9518. * @param y y position
  9519. * @param viewportWidth viewport width
  9520. * @param viewportHeight viewport height
  9521. * @param world world matrix
  9522. * @param view view matrix
  9523. * @param projection projection matrix
  9524. * @returns new ray
  9525. */
  9526. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9527. /**
  9528. * 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
  9529. * transformed to the given world matrix.
  9530. * @param origin The origin point
  9531. * @param end The end point
  9532. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9533. * @returns the new ray
  9534. */
  9535. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9536. /**
  9537. * Transforms a ray by a matrix
  9538. * @param ray ray to transform
  9539. * @param matrix matrix to apply
  9540. * @returns the resulting new ray
  9541. */
  9542. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9543. /**
  9544. * Transforms a ray by a matrix
  9545. * @param ray ray to transform
  9546. * @param matrix matrix to apply
  9547. * @param result ray to store result in
  9548. */
  9549. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9550. /**
  9551. * Unproject a ray from screen space to object space
  9552. * @param sourceX defines the screen space x coordinate to use
  9553. * @param sourceY defines the screen space y coordinate to use
  9554. * @param viewportWidth defines the current width of the viewport
  9555. * @param viewportHeight defines the current height of the viewport
  9556. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9557. * @param view defines the view matrix to use
  9558. * @param projection defines the projection matrix to use
  9559. */
  9560. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9561. }
  9562. /**
  9563. * Type used to define predicate used to select faces when a mesh intersection is detected
  9564. */
  9565. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9566. interface Scene {
  9567. /** @hidden */
  9568. _tempPickingRay: Nullable<Ray>;
  9569. /** @hidden */
  9570. _cachedRayForTransform: Ray;
  9571. /** @hidden */
  9572. _pickWithRayInverseMatrix: Matrix;
  9573. /** @hidden */
  9574. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9575. /** @hidden */
  9576. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9577. }
  9578. }
  9579. declare module BABYLON {
  9580. /**
  9581. * Groups all the scene component constants in one place to ease maintenance.
  9582. * @hidden
  9583. */
  9584. export class SceneComponentConstants {
  9585. static readonly NAME_EFFECTLAYER: string;
  9586. static readonly NAME_LAYER: string;
  9587. static readonly NAME_LENSFLARESYSTEM: string;
  9588. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9589. static readonly NAME_PARTICLESYSTEM: string;
  9590. static readonly NAME_GAMEPAD: string;
  9591. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9592. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9593. static readonly NAME_DEPTHRENDERER: string;
  9594. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9595. static readonly NAME_SPRITE: string;
  9596. static readonly NAME_OUTLINERENDERER: string;
  9597. static readonly NAME_PROCEDURALTEXTURE: string;
  9598. static readonly NAME_SHADOWGENERATOR: string;
  9599. static readonly NAME_OCTREE: string;
  9600. static readonly NAME_PHYSICSENGINE: string;
  9601. static readonly NAME_AUDIO: string;
  9602. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9603. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9604. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9605. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9606. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9607. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9608. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9609. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9610. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9611. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9612. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9613. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9614. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9615. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9616. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9617. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9618. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9619. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9620. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9621. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9622. static readonly STEP_AFTERRENDER_AUDIO: number;
  9623. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9624. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9625. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9626. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9627. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9628. static readonly STEP_POINTERMOVE_SPRITE: number;
  9629. static readonly STEP_POINTERDOWN_SPRITE: number;
  9630. static readonly STEP_POINTERUP_SPRITE: number;
  9631. }
  9632. /**
  9633. * This represents a scene component.
  9634. *
  9635. * This is used to decouple the dependency the scene is having on the different workloads like
  9636. * layers, post processes...
  9637. */
  9638. export interface ISceneComponent {
  9639. /**
  9640. * The name of the component. Each component must have a unique name.
  9641. */
  9642. name: string;
  9643. /**
  9644. * The scene the component belongs to.
  9645. */
  9646. scene: Scene;
  9647. /**
  9648. * Register the component to one instance of a scene.
  9649. */
  9650. register(): void;
  9651. /**
  9652. * Rebuilds the elements related to this component in case of
  9653. * context lost for instance.
  9654. */
  9655. rebuild(): void;
  9656. /**
  9657. * Disposes the component and the associated ressources.
  9658. */
  9659. dispose(): void;
  9660. }
  9661. /**
  9662. * This represents a SERIALIZABLE scene component.
  9663. *
  9664. * This extends Scene Component to add Serialization methods on top.
  9665. */
  9666. export interface ISceneSerializableComponent extends ISceneComponent {
  9667. /**
  9668. * Adds all the elements from the container to the scene
  9669. * @param container the container holding the elements
  9670. */
  9671. addFromContainer(container: AbstractScene): void;
  9672. /**
  9673. * Removes all the elements in the container from the scene
  9674. * @param container contains the elements to remove
  9675. * @param dispose if the removed element should be disposed (default: false)
  9676. */
  9677. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9678. /**
  9679. * Serializes the component data to the specified json object
  9680. * @param serializationObject The object to serialize to
  9681. */
  9682. serialize(serializationObject: any): void;
  9683. }
  9684. /**
  9685. * Strong typing of a Mesh related stage step action
  9686. */
  9687. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9688. /**
  9689. * Strong typing of a Evaluate Sub Mesh related stage step action
  9690. */
  9691. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9692. /**
  9693. * Strong typing of a Active Mesh related stage step action
  9694. */
  9695. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9696. /**
  9697. * Strong typing of a Camera related stage step action
  9698. */
  9699. export type CameraStageAction = (camera: Camera) => void;
  9700. /**
  9701. * Strong typing of a Camera Frame buffer related stage step action
  9702. */
  9703. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9704. /**
  9705. * Strong typing of a Render Target related stage step action
  9706. */
  9707. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9708. /**
  9709. * Strong typing of a RenderingGroup related stage step action
  9710. */
  9711. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9712. /**
  9713. * Strong typing of a Mesh Render related stage step action
  9714. */
  9715. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9716. /**
  9717. * Strong typing of a simple stage step action
  9718. */
  9719. export type SimpleStageAction = () => void;
  9720. /**
  9721. * Strong typing of a render target action.
  9722. */
  9723. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9724. /**
  9725. * Strong typing of a pointer move action.
  9726. */
  9727. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9728. /**
  9729. * Strong typing of a pointer up/down action.
  9730. */
  9731. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9732. /**
  9733. * Representation of a stage in the scene (Basically a list of ordered steps)
  9734. * @hidden
  9735. */
  9736. export class Stage<T extends Function> extends Array<{
  9737. index: number;
  9738. component: ISceneComponent;
  9739. action: T;
  9740. }> {
  9741. /**
  9742. * Hide ctor from the rest of the world.
  9743. * @param items The items to add.
  9744. */
  9745. private constructor();
  9746. /**
  9747. * Creates a new Stage.
  9748. * @returns A new instance of a Stage
  9749. */
  9750. static Create<T extends Function>(): Stage<T>;
  9751. /**
  9752. * Registers a step in an ordered way in the targeted stage.
  9753. * @param index Defines the position to register the step in
  9754. * @param component Defines the component attached to the step
  9755. * @param action Defines the action to launch during the step
  9756. */
  9757. registerStep(index: number, component: ISceneComponent, action: T): void;
  9758. /**
  9759. * Clears all the steps from the stage.
  9760. */
  9761. clear(): void;
  9762. }
  9763. }
  9764. declare module BABYLON {
  9765. interface Scene {
  9766. /** @hidden */
  9767. _pointerOverSprite: Nullable<Sprite>;
  9768. /** @hidden */
  9769. _pickedDownSprite: Nullable<Sprite>;
  9770. /** @hidden */
  9771. _tempSpritePickingRay: Nullable<Ray>;
  9772. /**
  9773. * All of the sprite managers added to this scene
  9774. * @see http://doc.babylonjs.com/babylon101/sprites
  9775. */
  9776. spriteManagers: Array<ISpriteManager>;
  9777. /**
  9778. * An event triggered when sprites rendering is about to start
  9779. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9780. */
  9781. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9782. /**
  9783. * An event triggered when sprites rendering is done
  9784. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9785. */
  9786. onAfterSpritesRenderingObservable: Observable<Scene>;
  9787. /** @hidden */
  9788. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9789. /** Launch a ray to try to pick a sprite in the scene
  9790. * @param x position on screen
  9791. * @param y position on screen
  9792. * @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
  9793. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9794. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9795. * @returns a PickingInfo
  9796. */
  9797. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9798. /** Use the given ray to pick a sprite in the scene
  9799. * @param ray The ray (in world space) to use to pick meshes
  9800. * @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
  9801. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9802. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9803. * @returns a PickingInfo
  9804. */
  9805. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9806. /** @hidden */
  9807. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9808. /** Launch a ray to try to pick sprites 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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9813. * @returns a PickingInfo array
  9814. */
  9815. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9816. /** Use the given ray to pick sprites in the scene
  9817. * @param ray The ray (in world space) to use to pick meshes
  9818. * @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
  9819. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9820. * @returns a PickingInfo array
  9821. */
  9822. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9823. /**
  9824. * Force the sprite under the pointer
  9825. * @param sprite defines the sprite to use
  9826. */
  9827. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9828. /**
  9829. * Gets the sprite under the pointer
  9830. * @returns a Sprite or null if no sprite is under the pointer
  9831. */
  9832. getPointerOverSprite(): Nullable<Sprite>;
  9833. }
  9834. /**
  9835. * Defines the sprite scene component responsible to manage sprites
  9836. * in a given scene.
  9837. */
  9838. export class SpriteSceneComponent implements ISceneComponent {
  9839. /**
  9840. * The component name helpfull to identify the component in the list of scene components.
  9841. */
  9842. readonly name: string;
  9843. /**
  9844. * The scene the component belongs to.
  9845. */
  9846. scene: Scene;
  9847. /** @hidden */
  9848. private _spritePredicate;
  9849. /**
  9850. * Creates a new instance of the component for the given scene
  9851. * @param scene Defines the scene to register the component in
  9852. */
  9853. constructor(scene: Scene);
  9854. /**
  9855. * Registers the component in a given scene
  9856. */
  9857. register(): void;
  9858. /**
  9859. * Rebuilds the elements related to this component in case of
  9860. * context lost for instance.
  9861. */
  9862. rebuild(): void;
  9863. /**
  9864. * Disposes the component and the associated ressources.
  9865. */
  9866. dispose(): void;
  9867. private _pickSpriteButKeepRay;
  9868. private _pointerMove;
  9869. private _pointerDown;
  9870. private _pointerUp;
  9871. }
  9872. }
  9873. declare module BABYLON {
  9874. /** @hidden */
  9875. export var fogFragmentDeclaration: {
  9876. name: string;
  9877. shader: string;
  9878. };
  9879. }
  9880. declare module BABYLON {
  9881. /** @hidden */
  9882. export var fogFragment: {
  9883. name: string;
  9884. shader: string;
  9885. };
  9886. }
  9887. declare module BABYLON {
  9888. /** @hidden */
  9889. export var spritesPixelShader: {
  9890. name: string;
  9891. shader: string;
  9892. };
  9893. }
  9894. declare module BABYLON {
  9895. /** @hidden */
  9896. export var fogVertexDeclaration: {
  9897. name: string;
  9898. shader: string;
  9899. };
  9900. }
  9901. declare module BABYLON {
  9902. /** @hidden */
  9903. export var spritesVertexShader: {
  9904. name: string;
  9905. shader: string;
  9906. };
  9907. }
  9908. declare module BABYLON {
  9909. /**
  9910. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9911. */
  9912. export interface ISpriteManager extends IDisposable {
  9913. /**
  9914. * Restricts the camera to viewing objects with the same layerMask.
  9915. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9916. */
  9917. layerMask: number;
  9918. /**
  9919. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9920. */
  9921. isPickable: boolean;
  9922. /**
  9923. * Specifies the rendering group id for this mesh (0 by default)
  9924. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9925. */
  9926. renderingGroupId: number;
  9927. /**
  9928. * Defines the list of sprites managed by the manager.
  9929. */
  9930. sprites: Array<Sprite>;
  9931. /**
  9932. * Tests the intersection of a sprite with a specific ray.
  9933. * @param ray The ray we are sending to test the collision
  9934. * @param camera The camera space we are sending rays in
  9935. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9936. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9937. * @returns picking info or null.
  9938. */
  9939. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9940. /**
  9941. * Intersects the sprites with a ray
  9942. * @param ray defines the ray to intersect with
  9943. * @param camera defines the current active camera
  9944. * @param predicate defines a predicate used to select candidate sprites
  9945. * @returns null if no hit or a PickingInfo array
  9946. */
  9947. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9948. /**
  9949. * Renders the list of sprites on screen.
  9950. */
  9951. render(): void;
  9952. }
  9953. /**
  9954. * Class used to manage multiple sprites on the same spritesheet
  9955. * @see http://doc.babylonjs.com/babylon101/sprites
  9956. */
  9957. export class SpriteManager implements ISpriteManager {
  9958. /** defines the manager's name */
  9959. name: string;
  9960. /** Gets the list of sprites */
  9961. sprites: Sprite[];
  9962. /** Gets or sets the rendering group id (0 by default) */
  9963. renderingGroupId: number;
  9964. /** Gets or sets camera layer mask */
  9965. layerMask: number;
  9966. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9967. fogEnabled: boolean;
  9968. /** Gets or sets a boolean indicating if the sprites are pickable */
  9969. isPickable: boolean;
  9970. /** Defines the default width of a cell in the spritesheet */
  9971. cellWidth: number;
  9972. /** Defines the default height of a cell in the spritesheet */
  9973. cellHeight: number;
  9974. /** Associative array from JSON sprite data file */
  9975. private _cellData;
  9976. /** Array of sprite names from JSON sprite data file */
  9977. private _spriteMap;
  9978. /** True when packed cell data from JSON file is ready*/
  9979. private _packedAndReady;
  9980. /**
  9981. * An event triggered when the manager is disposed.
  9982. */
  9983. onDisposeObservable: Observable<SpriteManager>;
  9984. private _onDisposeObserver;
  9985. /**
  9986. * Callback called when the manager is disposed
  9987. */
  9988. set onDispose(callback: () => void);
  9989. private _capacity;
  9990. private _fromPacked;
  9991. private _spriteTexture;
  9992. private _epsilon;
  9993. private _scene;
  9994. private _vertexData;
  9995. private _buffer;
  9996. private _vertexBuffers;
  9997. private _indexBuffer;
  9998. private _effectBase;
  9999. private _effectFog;
  10000. /**
  10001. * Gets or sets the spritesheet texture
  10002. */
  10003. get texture(): Texture;
  10004. set texture(value: Texture);
  10005. private _blendMode;
  10006. /**
  10007. * Blend mode use to render the particle, it can be any of
  10008. * the static Constants.ALPHA_x properties provided in this class.
  10009. * Default value is Constants.ALPHA_COMBINE
  10010. */
  10011. get blendMode(): number;
  10012. set blendMode(blendMode: number);
  10013. /** Disables writing to the depth buffer when rendering the sprites.
  10014. * It can be handy to disable depth writing when using textures without alpha channel
  10015. * and setting some specific blend modes.
  10016. */
  10017. disableDepthWrite: boolean;
  10018. /**
  10019. * Creates a new sprite manager
  10020. * @param name defines the manager's name
  10021. * @param imgUrl defines the sprite sheet url
  10022. * @param capacity defines the maximum allowed number of sprites
  10023. * @param cellSize defines the size of a sprite cell
  10024. * @param scene defines the hosting scene
  10025. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10026. * @param samplingMode defines the smapling mode to use with spritesheet
  10027. * @param fromPacked set to false; do not alter
  10028. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10029. */
  10030. constructor(
  10031. /** defines the manager's name */
  10032. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10033. private _makePacked;
  10034. private _appendSpriteVertex;
  10035. /**
  10036. * Intersects the sprites with a ray
  10037. * @param ray defines the ray to intersect with
  10038. * @param camera defines the current active camera
  10039. * @param predicate defines a predicate used to select candidate sprites
  10040. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10041. * @returns null if no hit or a PickingInfo
  10042. */
  10043. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10044. /**
  10045. * Intersects the sprites with a ray
  10046. * @param ray defines the ray to intersect with
  10047. * @param camera defines the current active camera
  10048. * @param predicate defines a predicate used to select candidate sprites
  10049. * @returns null if no hit or a PickingInfo array
  10050. */
  10051. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10052. /**
  10053. * Render all child sprites
  10054. */
  10055. render(): void;
  10056. /**
  10057. * Release associated resources
  10058. */
  10059. dispose(): void;
  10060. }
  10061. }
  10062. declare module BABYLON {
  10063. /** Interface used by value gradients (color, factor, ...) */
  10064. export interface IValueGradient {
  10065. /**
  10066. * Gets or sets the gradient value (between 0 and 1)
  10067. */
  10068. gradient: number;
  10069. }
  10070. /** Class used to store color4 gradient */
  10071. export class ColorGradient implements IValueGradient {
  10072. /**
  10073. * Gets or sets the gradient value (between 0 and 1)
  10074. */
  10075. gradient: number;
  10076. /**
  10077. * Gets or sets first associated color
  10078. */
  10079. color1: Color4;
  10080. /**
  10081. * Gets or sets second associated color
  10082. */
  10083. color2?: Color4;
  10084. /**
  10085. * Will get a color picked randomly between color1 and color2.
  10086. * If color2 is undefined then color1 will be used
  10087. * @param result defines the target Color4 to store the result in
  10088. */
  10089. getColorToRef(result: Color4): void;
  10090. }
  10091. /** Class used to store color 3 gradient */
  10092. export class Color3Gradient implements IValueGradient {
  10093. /**
  10094. * Gets or sets the gradient value (between 0 and 1)
  10095. */
  10096. gradient: number;
  10097. /**
  10098. * Gets or sets the associated color
  10099. */
  10100. color: Color3;
  10101. }
  10102. /** Class used to store factor gradient */
  10103. export class FactorGradient implements IValueGradient {
  10104. /**
  10105. * Gets or sets the gradient value (between 0 and 1)
  10106. */
  10107. gradient: number;
  10108. /**
  10109. * Gets or sets first associated factor
  10110. */
  10111. factor1: number;
  10112. /**
  10113. * Gets or sets second associated factor
  10114. */
  10115. factor2?: number;
  10116. /**
  10117. * Will get a number picked randomly between factor1 and factor2.
  10118. * If factor2 is undefined then factor1 will be used
  10119. * @returns the picked number
  10120. */
  10121. getFactor(): number;
  10122. }
  10123. /**
  10124. * Helper used to simplify some generic gradient tasks
  10125. */
  10126. export class GradientHelper {
  10127. /**
  10128. * Gets the current gradient from an array of IValueGradient
  10129. * @param ratio defines the current ratio to get
  10130. * @param gradients defines the array of IValueGradient
  10131. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10132. */
  10133. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10134. }
  10135. }
  10136. declare module BABYLON {
  10137. /**
  10138. * Interface for the size containing width and height
  10139. */
  10140. export interface ISize {
  10141. /**
  10142. * Width
  10143. */
  10144. width: number;
  10145. /**
  10146. * Heighht
  10147. */
  10148. height: number;
  10149. }
  10150. /**
  10151. * Size containing widht and height
  10152. */
  10153. export class Size implements ISize {
  10154. /**
  10155. * Width
  10156. */
  10157. width: number;
  10158. /**
  10159. * Height
  10160. */
  10161. height: number;
  10162. /**
  10163. * Creates a Size object from the given width and height (floats).
  10164. * @param width width of the new size
  10165. * @param height height of the new size
  10166. */
  10167. constructor(width: number, height: number);
  10168. /**
  10169. * Returns a string with the Size width and height
  10170. * @returns a string with the Size width and height
  10171. */
  10172. toString(): string;
  10173. /**
  10174. * "Size"
  10175. * @returns the string "Size"
  10176. */
  10177. getClassName(): string;
  10178. /**
  10179. * Returns the Size hash code.
  10180. * @returns a hash code for a unique width and height
  10181. */
  10182. getHashCode(): number;
  10183. /**
  10184. * Updates the current size from the given one.
  10185. * @param src the given size
  10186. */
  10187. copyFrom(src: Size): void;
  10188. /**
  10189. * Updates in place the current Size from the given floats.
  10190. * @param width width of the new size
  10191. * @param height height of the new size
  10192. * @returns the updated Size.
  10193. */
  10194. copyFromFloats(width: number, height: number): Size;
  10195. /**
  10196. * Updates in place the current Size from the given floats.
  10197. * @param width width to set
  10198. * @param height height to set
  10199. * @returns the updated Size.
  10200. */
  10201. set(width: number, height: number): Size;
  10202. /**
  10203. * Multiplies the width and height by numbers
  10204. * @param w factor to multiple the width by
  10205. * @param h factor to multiple the height by
  10206. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10207. */
  10208. multiplyByFloats(w: number, h: number): Size;
  10209. /**
  10210. * Clones the size
  10211. * @returns a new Size copied from the given one.
  10212. */
  10213. clone(): Size;
  10214. /**
  10215. * True if the current Size and the given one width and height are strictly equal.
  10216. * @param other the other size to compare against
  10217. * @returns True if the current Size and the given one width and height are strictly equal.
  10218. */
  10219. equals(other: Size): boolean;
  10220. /**
  10221. * The surface of the Size : width * height (float).
  10222. */
  10223. get surface(): number;
  10224. /**
  10225. * Create a new size of zero
  10226. * @returns a new Size set to (0.0, 0.0)
  10227. */
  10228. static Zero(): Size;
  10229. /**
  10230. * Sums the width and height of two sizes
  10231. * @param otherSize size to add to this size
  10232. * @returns a new Size set as the addition result of the current Size and the given one.
  10233. */
  10234. add(otherSize: Size): Size;
  10235. /**
  10236. * Subtracts the width and height of two
  10237. * @param otherSize size to subtract to this size
  10238. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10239. */
  10240. subtract(otherSize: Size): Size;
  10241. /**
  10242. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10243. * @param start starting size to lerp between
  10244. * @param end end size to lerp between
  10245. * @param amount amount to lerp between the start and end values
  10246. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10247. */
  10248. static Lerp(start: Size, end: Size, amount: number): Size;
  10249. }
  10250. }
  10251. declare module BABYLON {
  10252. interface ThinEngine {
  10253. /**
  10254. * Creates a dynamic texture
  10255. * @param width defines the width of the texture
  10256. * @param height defines the height of the texture
  10257. * @param generateMipMaps defines if the engine should generate the mip levels
  10258. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10259. * @returns the dynamic texture inside an InternalTexture
  10260. */
  10261. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10262. /**
  10263. * Update the content of a dynamic texture
  10264. * @param texture defines the texture to update
  10265. * @param canvas defines the canvas containing the source
  10266. * @param invertY defines if data must be stored with Y axis inverted
  10267. * @param premulAlpha defines if alpha is stored as premultiplied
  10268. * @param format defines the format of the data
  10269. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10270. */
  10271. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10272. }
  10273. }
  10274. declare module BABYLON {
  10275. /**
  10276. * Helper class used to generate a canvas to manipulate images
  10277. */
  10278. export class CanvasGenerator {
  10279. /**
  10280. * Create a new canvas (or offscreen canvas depending on the context)
  10281. * @param width defines the expected width
  10282. * @param height defines the expected height
  10283. * @return a new canvas or offscreen canvas
  10284. */
  10285. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10286. }
  10287. }
  10288. declare module BABYLON {
  10289. /**
  10290. * A class extending Texture allowing drawing on a texture
  10291. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10292. */
  10293. export class DynamicTexture extends Texture {
  10294. private _generateMipMaps;
  10295. private _canvas;
  10296. private _context;
  10297. private _engine;
  10298. /**
  10299. * Creates a DynamicTexture
  10300. * @param name defines the name of the texture
  10301. * @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
  10302. * @param scene defines the scene where you want the texture
  10303. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10304. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10305. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10306. */
  10307. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10308. /**
  10309. * Get the current class name of the texture useful for serialization or dynamic coding.
  10310. * @returns "DynamicTexture"
  10311. */
  10312. getClassName(): string;
  10313. /**
  10314. * Gets the current state of canRescale
  10315. */
  10316. get canRescale(): boolean;
  10317. private _recreate;
  10318. /**
  10319. * Scales the texture
  10320. * @param ratio the scale factor to apply to both width and height
  10321. */
  10322. scale(ratio: number): void;
  10323. /**
  10324. * Resizes the texture
  10325. * @param width the new width
  10326. * @param height the new height
  10327. */
  10328. scaleTo(width: number, height: number): void;
  10329. /**
  10330. * Gets the context of the canvas used by the texture
  10331. * @returns the canvas context of the dynamic texture
  10332. */
  10333. getContext(): CanvasRenderingContext2D;
  10334. /**
  10335. * Clears the texture
  10336. */
  10337. clear(): void;
  10338. /**
  10339. * Updates the texture
  10340. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10341. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10342. */
  10343. update(invertY?: boolean, premulAlpha?: boolean): void;
  10344. /**
  10345. * Draws text onto the texture
  10346. * @param text defines the text to be drawn
  10347. * @param x defines the placement of the text from the left
  10348. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10349. * @param font defines the font to be used with font-style, font-size, font-name
  10350. * @param color defines the color used for the text
  10351. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10352. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10353. * @param update defines whether texture is immediately update (default is true)
  10354. */
  10355. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10356. /**
  10357. * Clones the texture
  10358. * @returns the clone of the texture.
  10359. */
  10360. clone(): DynamicTexture;
  10361. /**
  10362. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10363. * @returns a serialized dynamic texture object
  10364. */
  10365. serialize(): any;
  10366. /** @hidden */
  10367. _rebuild(): void;
  10368. }
  10369. }
  10370. declare module BABYLON {
  10371. interface Engine {
  10372. /**
  10373. * Creates a raw texture
  10374. * @param data defines the data to store in the texture
  10375. * @param width defines the width of the texture
  10376. * @param height defines the height of the texture
  10377. * @param format defines the format of the data
  10378. * @param generateMipMaps defines if the engine should generate the mip levels
  10379. * @param invertY defines if data must be stored with Y axis inverted
  10380. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10381. * @param compression defines the compression used (null by default)
  10382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10383. * @returns the raw texture inside an InternalTexture
  10384. */
  10385. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10386. /**
  10387. * Update a raw texture
  10388. * @param texture defines the texture to update
  10389. * @param data defines the data to store in the texture
  10390. * @param format defines the format of the data
  10391. * @param invertY defines if data must be stored with Y axis inverted
  10392. */
  10393. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10394. /**
  10395. * Update a raw texture
  10396. * @param texture defines the texture to update
  10397. * @param data defines the data to store in the texture
  10398. * @param format defines the format of the data
  10399. * @param invertY defines if data must be stored with Y axis inverted
  10400. * @param compression defines the compression used (null by default)
  10401. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10402. */
  10403. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10404. /**
  10405. * Creates a new raw cube texture
  10406. * @param data defines the array of data to use to create each face
  10407. * @param size defines the size of the textures
  10408. * @param format defines the format of the data
  10409. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10410. * @param generateMipMaps defines if the engine should generate the mip levels
  10411. * @param invertY defines if data must be stored with Y axis inverted
  10412. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10413. * @param compression defines the compression used (null by default)
  10414. * @returns the cube texture as an InternalTexture
  10415. */
  10416. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10417. /**
  10418. * Update a raw cube texture
  10419. * @param texture defines the texture to udpdate
  10420. * @param data defines the data to store
  10421. * @param format defines the data format
  10422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10423. * @param invertY defines if data must be stored with Y axis inverted
  10424. */
  10425. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10426. /**
  10427. * Update a raw cube texture
  10428. * @param texture defines the texture to udpdate
  10429. * @param data defines the data to store
  10430. * @param format defines the data format
  10431. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10432. * @param invertY defines if data must be stored with Y axis inverted
  10433. * @param compression defines the compression used (null by default)
  10434. */
  10435. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10436. /**
  10437. * Update a raw cube texture
  10438. * @param texture defines the texture to udpdate
  10439. * @param data defines the data to store
  10440. * @param format defines the data format
  10441. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10442. * @param invertY defines if data must be stored with Y axis inverted
  10443. * @param compression defines the compression used (null by default)
  10444. * @param level defines which level of the texture to update
  10445. */
  10446. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10447. /**
  10448. * Creates a new raw cube texture from a specified url
  10449. * @param url defines the url where the data is located
  10450. * @param scene defines the current scene
  10451. * @param size defines the size of the textures
  10452. * @param format defines the format of the data
  10453. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10454. * @param noMipmap defines if the engine should avoid generating the mip levels
  10455. * @param callback defines a callback used to extract texture data from loaded data
  10456. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10457. * @param onLoad defines a callback called when texture is loaded
  10458. * @param onError defines a callback called if there is an error
  10459. * @returns the cube texture as an InternalTexture
  10460. */
  10461. 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;
  10462. /**
  10463. * Creates a new raw cube texture from a specified url
  10464. * @param url defines the url where the data is located
  10465. * @param scene defines the current scene
  10466. * @param size defines the size of the textures
  10467. * @param format defines the format of the data
  10468. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10469. * @param noMipmap defines if the engine should avoid generating the mip levels
  10470. * @param callback defines a callback used to extract texture data from loaded data
  10471. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10472. * @param onLoad defines a callback called when texture is loaded
  10473. * @param onError defines a callback called if there is an error
  10474. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10475. * @param invertY defines if data must be stored with Y axis inverted
  10476. * @returns the cube texture as an InternalTexture
  10477. */
  10478. 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;
  10479. /**
  10480. * Creates a new raw 3D texture
  10481. * @param data defines the data used to create the texture
  10482. * @param width defines the width of the texture
  10483. * @param height defines the height of the texture
  10484. * @param depth defines the depth of the texture
  10485. * @param format defines the format of the texture
  10486. * @param generateMipMaps defines if the engine must generate mip levels
  10487. * @param invertY defines if data must be stored with Y axis inverted
  10488. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10489. * @param compression defines the compressed used (can be null)
  10490. * @param textureType defines the compressed used (can be null)
  10491. * @returns a new raw 3D texture (stored in an InternalTexture)
  10492. */
  10493. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10494. /**
  10495. * Update a raw 3D texture
  10496. * @param texture defines the texture to update
  10497. * @param data defines the data to store
  10498. * @param format defines the data format
  10499. * @param invertY defines if data must be stored with Y axis inverted
  10500. */
  10501. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10502. /**
  10503. * Update a raw 3D texture
  10504. * @param texture defines the texture to update
  10505. * @param data defines the data to store
  10506. * @param format defines the data format
  10507. * @param invertY defines if data must be stored with Y axis inverted
  10508. * @param compression defines the used compression (can be null)
  10509. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10510. */
  10511. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10512. /**
  10513. * Creates a new raw 2D array texture
  10514. * @param data defines the data used to create the texture
  10515. * @param width defines the width of the texture
  10516. * @param height defines the height of the texture
  10517. * @param depth defines the number of layers of the texture
  10518. * @param format defines the format of the texture
  10519. * @param generateMipMaps defines if the engine must generate mip levels
  10520. * @param invertY defines if data must be stored with Y axis inverted
  10521. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10522. * @param compression defines the compressed used (can be null)
  10523. * @param textureType defines the compressed used (can be null)
  10524. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10525. */
  10526. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10527. /**
  10528. * Update a raw 2D array texture
  10529. * @param texture defines the texture to update
  10530. * @param data defines the data to store
  10531. * @param format defines the data format
  10532. * @param invertY defines if data must be stored with Y axis inverted
  10533. */
  10534. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10535. /**
  10536. * Update a raw 2D array texture
  10537. * @param texture defines the texture to update
  10538. * @param data defines the data to store
  10539. * @param format defines the data format
  10540. * @param invertY defines if data must be stored with Y axis inverted
  10541. * @param compression defines the used compression (can be null)
  10542. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10543. */
  10544. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10545. }
  10546. }
  10547. declare module BABYLON {
  10548. /**
  10549. * Raw texture can help creating a texture directly from an array of data.
  10550. * This can be super useful if you either get the data from an uncompressed source or
  10551. * if you wish to create your texture pixel by pixel.
  10552. */
  10553. export class RawTexture extends Texture {
  10554. /**
  10555. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10556. */
  10557. format: number;
  10558. private _engine;
  10559. /**
  10560. * Instantiates a new RawTexture.
  10561. * Raw texture can help creating a texture directly from an array of data.
  10562. * This can be super useful if you either get the data from an uncompressed source or
  10563. * if you wish to create your texture pixel by pixel.
  10564. * @param data define the array of data to use to create the texture
  10565. * @param width define the width of the texture
  10566. * @param height define the height of the texture
  10567. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10568. * @param scene define the scene the texture belongs to
  10569. * @param generateMipMaps define whether mip maps should be generated or not
  10570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10573. */
  10574. constructor(data: ArrayBufferView, width: number, height: number,
  10575. /**
  10576. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10577. */
  10578. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10579. /**
  10580. * Updates the texture underlying data.
  10581. * @param data Define the new data of the texture
  10582. */
  10583. update(data: ArrayBufferView): void;
  10584. /**
  10585. * Creates a luminance texture from some data.
  10586. * @param data Define the texture data
  10587. * @param width Define the width of the texture
  10588. * @param height Define the height of the texture
  10589. * @param scene Define the scene the texture belongs to
  10590. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10591. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10592. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10593. * @returns the luminance texture
  10594. */
  10595. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10596. /**
  10597. * Creates a luminance alpha texture from some data.
  10598. * @param data Define the texture data
  10599. * @param width Define the width of the texture
  10600. * @param height Define the height of the texture
  10601. * @param scene Define the scene the texture belongs to
  10602. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10603. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10604. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10605. * @returns the luminance alpha texture
  10606. */
  10607. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10608. /**
  10609. * Creates an alpha texture from some data.
  10610. * @param data Define the texture data
  10611. * @param width Define the width of the texture
  10612. * @param height Define the height of the texture
  10613. * @param scene Define the scene the texture belongs to
  10614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10617. * @returns the alpha texture
  10618. */
  10619. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10620. /**
  10621. * Creates a RGB texture from some data.
  10622. * @param data Define the texture data
  10623. * @param width Define the width of the texture
  10624. * @param height Define the height of the texture
  10625. * @param scene Define the scene the texture belongs to
  10626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10629. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10630. * @returns the RGB alpha texture
  10631. */
  10632. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10633. /**
  10634. * Creates a RGBA texture from some data.
  10635. * @param data Define the texture data
  10636. * @param width Define the width of the texture
  10637. * @param height Define the height of the texture
  10638. * @param scene Define the scene the texture belongs to
  10639. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10642. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10643. * @returns the RGBA texture
  10644. */
  10645. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10646. /**
  10647. * Creates a R texture from some data.
  10648. * @param data Define the texture data
  10649. * @param width Define the width of the texture
  10650. * @param height Define the height of the texture
  10651. * @param scene Define the scene the texture belongs to
  10652. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10656. * @returns the R texture
  10657. */
  10658. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10659. }
  10660. }
  10661. declare module BABYLON {
  10662. interface AbstractScene {
  10663. /**
  10664. * The list of procedural textures added to the scene
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10666. */
  10667. proceduralTextures: Array<ProceduralTexture>;
  10668. }
  10669. /**
  10670. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10671. * in a given scene.
  10672. */
  10673. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10674. /**
  10675. * The component name helpfull to identify the component in the list of scene components.
  10676. */
  10677. readonly name: string;
  10678. /**
  10679. * The scene the component belongs to.
  10680. */
  10681. scene: Scene;
  10682. /**
  10683. * Creates a new instance of the component for the given scene
  10684. * @param scene Defines the scene to register the component in
  10685. */
  10686. constructor(scene: Scene);
  10687. /**
  10688. * Registers the component in a given scene
  10689. */
  10690. register(): void;
  10691. /**
  10692. * Rebuilds the elements related to this component in case of
  10693. * context lost for instance.
  10694. */
  10695. rebuild(): void;
  10696. /**
  10697. * Disposes the component and the associated ressources.
  10698. */
  10699. dispose(): void;
  10700. private _beforeClear;
  10701. }
  10702. }
  10703. declare module BABYLON {
  10704. interface ThinEngine {
  10705. /**
  10706. * Creates a new render target cube texture
  10707. * @param size defines the size of the texture
  10708. * @param options defines the options used to create the texture
  10709. * @returns a new render target cube texture stored in an InternalTexture
  10710. */
  10711. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10712. }
  10713. }
  10714. declare module BABYLON {
  10715. /** @hidden */
  10716. export var proceduralVertexShader: {
  10717. name: string;
  10718. shader: string;
  10719. };
  10720. }
  10721. declare module BABYLON {
  10722. /**
  10723. * 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.
  10724. * This is the base class of any Procedural texture and contains most of the shareable code.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10726. */
  10727. export class ProceduralTexture extends Texture {
  10728. isCube: boolean;
  10729. /**
  10730. * Define if the texture is enabled or not (disabled texture will not render)
  10731. */
  10732. isEnabled: boolean;
  10733. /**
  10734. * Define if the texture must be cleared before rendering (default is true)
  10735. */
  10736. autoClear: boolean;
  10737. /**
  10738. * Callback called when the texture is generated
  10739. */
  10740. onGenerated: () => void;
  10741. /**
  10742. * Event raised when the texture is generated
  10743. */
  10744. onGeneratedObservable: Observable<ProceduralTexture>;
  10745. /** @hidden */
  10746. _generateMipMaps: boolean;
  10747. /** @hidden **/
  10748. _effect: Effect;
  10749. /** @hidden */
  10750. _textures: {
  10751. [key: string]: Texture;
  10752. };
  10753. private _size;
  10754. private _currentRefreshId;
  10755. private _frameId;
  10756. private _refreshRate;
  10757. private _vertexBuffers;
  10758. private _indexBuffer;
  10759. private _uniforms;
  10760. private _samplers;
  10761. private _fragment;
  10762. private _floats;
  10763. private _ints;
  10764. private _floatsArrays;
  10765. private _colors3;
  10766. private _colors4;
  10767. private _vectors2;
  10768. private _vectors3;
  10769. private _matrices;
  10770. private _fallbackTexture;
  10771. private _fallbackTextureUsed;
  10772. private _engine;
  10773. private _cachedDefines;
  10774. private _contentUpdateId;
  10775. private _contentData;
  10776. /**
  10777. * Instantiates a new procedural texture.
  10778. * 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.
  10779. * This is the base class of any Procedural texture and contains most of the shareable code.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10781. * @param name Define the name of the texture
  10782. * @param size Define the size of the texture to create
  10783. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10784. * @param scene Define the scene the texture belongs to
  10785. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10786. * @param generateMipMaps Define if the texture should creates mip maps or not
  10787. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10788. */
  10789. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10790. /**
  10791. * The effect that is created when initializing the post process.
  10792. * @returns The created effect corresponding the the postprocess.
  10793. */
  10794. getEffect(): Effect;
  10795. /**
  10796. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10797. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10798. */
  10799. getContent(): Nullable<ArrayBufferView>;
  10800. private _createIndexBuffer;
  10801. /** @hidden */
  10802. _rebuild(): void;
  10803. /**
  10804. * Resets the texture in order to recreate its associated resources.
  10805. * This can be called in case of context loss
  10806. */
  10807. reset(): void;
  10808. protected _getDefines(): string;
  10809. /**
  10810. * Is the texture ready to be used ? (rendered at least once)
  10811. * @returns true if ready, otherwise, false.
  10812. */
  10813. isReady(): boolean;
  10814. /**
  10815. * Resets the refresh counter of the texture and start bak from scratch.
  10816. * Could be useful to regenerate the texture if it is setup to render only once.
  10817. */
  10818. resetRefreshCounter(): void;
  10819. /**
  10820. * Set the fragment shader to use in order to render the texture.
  10821. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10822. */
  10823. setFragment(fragment: any): void;
  10824. /**
  10825. * Define the refresh rate of the texture or the rendering frequency.
  10826. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10827. */
  10828. get refreshRate(): number;
  10829. set refreshRate(value: number);
  10830. /** @hidden */
  10831. _shouldRender(): boolean;
  10832. /**
  10833. * Get the size the texture is rendering at.
  10834. * @returns the size (texture is always squared)
  10835. */
  10836. getRenderSize(): number;
  10837. /**
  10838. * Resize the texture to new value.
  10839. * @param size Define the new size the texture should have
  10840. * @param generateMipMaps Define whether the new texture should create mip maps
  10841. */
  10842. resize(size: number, generateMipMaps: boolean): void;
  10843. private _checkUniform;
  10844. /**
  10845. * Set a texture in the shader program used to render.
  10846. * @param name Define the name of the uniform samplers as defined in the shader
  10847. * @param texture Define the texture to bind to this sampler
  10848. * @return the texture itself allowing "fluent" like uniform updates
  10849. */
  10850. setTexture(name: string, texture: Texture): ProceduralTexture;
  10851. /**
  10852. * Set a float in the shader.
  10853. * @param name Define the name of the uniform as defined in the shader
  10854. * @param value Define the value to give to the uniform
  10855. * @return the texture itself allowing "fluent" like uniform updates
  10856. */
  10857. setFloat(name: string, value: number): ProceduralTexture;
  10858. /**
  10859. * Set a int in the shader.
  10860. * @param name Define the name of the uniform as defined in the shader
  10861. * @param value Define the value to give to the uniform
  10862. * @return the texture itself allowing "fluent" like uniform updates
  10863. */
  10864. setInt(name: string, value: number): ProceduralTexture;
  10865. /**
  10866. * Set an array of floats in the shader.
  10867. * @param name Define the name of the uniform as defined in the shader
  10868. * @param value Define the value to give to the uniform
  10869. * @return the texture itself allowing "fluent" like uniform updates
  10870. */
  10871. setFloats(name: string, value: number[]): ProceduralTexture;
  10872. /**
  10873. * Set a vec3 in the shader from a Color3.
  10874. * @param name Define the name of the uniform as defined in the shader
  10875. * @param value Define the value to give to the uniform
  10876. * @return the texture itself allowing "fluent" like uniform updates
  10877. */
  10878. setColor3(name: string, value: Color3): ProceduralTexture;
  10879. /**
  10880. * Set a vec4 in the shader from a Color4.
  10881. * @param name Define the name of the uniform as defined in the shader
  10882. * @param value Define the value to give to the uniform
  10883. * @return the texture itself allowing "fluent" like uniform updates
  10884. */
  10885. setColor4(name: string, value: Color4): ProceduralTexture;
  10886. /**
  10887. * Set a vec2 in the shader from a Vector2.
  10888. * @param name Define the name of the uniform as defined in the shader
  10889. * @param value Define the value to give to the uniform
  10890. * @return the texture itself allowing "fluent" like uniform updates
  10891. */
  10892. setVector2(name: string, value: Vector2): ProceduralTexture;
  10893. /**
  10894. * Set a vec3 in the shader from a Vector3.
  10895. * @param name Define the name of the uniform as defined in the shader
  10896. * @param value Define the value to give to the uniform
  10897. * @return the texture itself allowing "fluent" like uniform updates
  10898. */
  10899. setVector3(name: string, value: Vector3): ProceduralTexture;
  10900. /**
  10901. * Set a mat4 in the shader from a MAtrix.
  10902. * @param name Define the name of the uniform as defined in the shader
  10903. * @param value Define the value to give to the uniform
  10904. * @return the texture itself allowing "fluent" like uniform updates
  10905. */
  10906. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10907. /**
  10908. * Render the texture to its associated render target.
  10909. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10910. */
  10911. render(useCameraPostProcess?: boolean): void;
  10912. /**
  10913. * Clone the texture.
  10914. * @returns the cloned texture
  10915. */
  10916. clone(): ProceduralTexture;
  10917. /**
  10918. * Dispose the texture and release its asoociated resources.
  10919. */
  10920. dispose(): void;
  10921. }
  10922. }
  10923. declare module BABYLON {
  10924. /**
  10925. * This represents the base class for particle system in Babylon.
  10926. * 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.
  10927. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10928. * @example https://doc.babylonjs.com/babylon101/particles
  10929. */
  10930. export class BaseParticleSystem {
  10931. /**
  10932. * Source color is added to the destination color without alpha affecting the result
  10933. */
  10934. static BLENDMODE_ONEONE: number;
  10935. /**
  10936. * Blend current color and particle color using particle’s alpha
  10937. */
  10938. static BLENDMODE_STANDARD: number;
  10939. /**
  10940. * Add current color and particle color multiplied by particle’s alpha
  10941. */
  10942. static BLENDMODE_ADD: number;
  10943. /**
  10944. * Multiply current color with particle color
  10945. */
  10946. static BLENDMODE_MULTIPLY: number;
  10947. /**
  10948. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10949. */
  10950. static BLENDMODE_MULTIPLYADD: number;
  10951. /**
  10952. * List of animations used by the particle system.
  10953. */
  10954. animations: Animation[];
  10955. /**
  10956. * The id of the Particle system.
  10957. */
  10958. id: string;
  10959. /**
  10960. * The friendly name of the Particle system.
  10961. */
  10962. name: string;
  10963. /**
  10964. * The rendering group used by the Particle system to chose when to render.
  10965. */
  10966. renderingGroupId: number;
  10967. /**
  10968. * The emitter represents the Mesh or position we are attaching the particle system to.
  10969. */
  10970. emitter: Nullable<AbstractMesh | Vector3>;
  10971. /**
  10972. * The maximum number of particles to emit per frame
  10973. */
  10974. emitRate: number;
  10975. /**
  10976. * If you want to launch only a few particles at once, that can be done, as well.
  10977. */
  10978. manualEmitCount: number;
  10979. /**
  10980. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  10981. */
  10982. updateSpeed: number;
  10983. /**
  10984. * The amount of time the particle system is running (depends of the overall update speed).
  10985. */
  10986. targetStopDuration: number;
  10987. /**
  10988. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  10989. */
  10990. disposeOnStop: boolean;
  10991. /**
  10992. * Minimum power of emitting particles.
  10993. */
  10994. minEmitPower: number;
  10995. /**
  10996. * Maximum power of emitting particles.
  10997. */
  10998. maxEmitPower: number;
  10999. /**
  11000. * Minimum life time of emitting particles.
  11001. */
  11002. minLifeTime: number;
  11003. /**
  11004. * Maximum life time of emitting particles.
  11005. */
  11006. maxLifeTime: number;
  11007. /**
  11008. * Minimum Size of emitting particles.
  11009. */
  11010. minSize: number;
  11011. /**
  11012. * Maximum Size of emitting particles.
  11013. */
  11014. maxSize: number;
  11015. /**
  11016. * Minimum scale of emitting particles on X axis.
  11017. */
  11018. minScaleX: number;
  11019. /**
  11020. * Maximum scale of emitting particles on X axis.
  11021. */
  11022. maxScaleX: number;
  11023. /**
  11024. * Minimum scale of emitting particles on Y axis.
  11025. */
  11026. minScaleY: number;
  11027. /**
  11028. * Maximum scale of emitting particles on Y axis.
  11029. */
  11030. maxScaleY: number;
  11031. /**
  11032. * Gets or sets the minimal initial rotation in radians.
  11033. */
  11034. minInitialRotation: number;
  11035. /**
  11036. * Gets or sets the maximal initial rotation in radians.
  11037. */
  11038. maxInitialRotation: number;
  11039. /**
  11040. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11041. */
  11042. minAngularSpeed: number;
  11043. /**
  11044. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11045. */
  11046. maxAngularSpeed: number;
  11047. /**
  11048. * The texture used to render each particle. (this can be a spritesheet)
  11049. */
  11050. particleTexture: Nullable<Texture>;
  11051. /**
  11052. * The layer mask we are rendering the particles through.
  11053. */
  11054. layerMask: number;
  11055. /**
  11056. * This can help using your own shader to render the particle system.
  11057. * The according effect will be created
  11058. */
  11059. customShader: any;
  11060. /**
  11061. * By default particle system starts as soon as they are created. This prevents the
  11062. * automatic start to happen and let you decide when to start emitting particles.
  11063. */
  11064. preventAutoStart: boolean;
  11065. private _noiseTexture;
  11066. /**
  11067. * Gets or sets a texture used to add random noise to particle positions
  11068. */
  11069. get noiseTexture(): Nullable<ProceduralTexture>;
  11070. set noiseTexture(value: Nullable<ProceduralTexture>);
  11071. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11072. noiseStrength: Vector3;
  11073. /**
  11074. * Callback triggered when the particle animation is ending.
  11075. */
  11076. onAnimationEnd: Nullable<() => void>;
  11077. /**
  11078. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11079. */
  11080. blendMode: number;
  11081. /**
  11082. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11083. * to override the particles.
  11084. */
  11085. forceDepthWrite: boolean;
  11086. /** 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 */
  11087. preWarmCycles: number;
  11088. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11089. preWarmStepOffset: number;
  11090. /**
  11091. * 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)
  11092. */
  11093. spriteCellChangeSpeed: number;
  11094. /**
  11095. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11096. */
  11097. startSpriteCellID: number;
  11098. /**
  11099. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11100. */
  11101. endSpriteCellID: number;
  11102. /**
  11103. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11104. */
  11105. spriteCellWidth: number;
  11106. /**
  11107. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11108. */
  11109. spriteCellHeight: number;
  11110. /**
  11111. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11112. */
  11113. spriteRandomStartCell: boolean;
  11114. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11115. translationPivot: Vector2;
  11116. /** @hidden */
  11117. protected _isAnimationSheetEnabled: boolean;
  11118. /**
  11119. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11120. */
  11121. beginAnimationOnStart: boolean;
  11122. /**
  11123. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11124. */
  11125. beginAnimationFrom: number;
  11126. /**
  11127. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11128. */
  11129. beginAnimationTo: number;
  11130. /**
  11131. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11132. */
  11133. beginAnimationLoop: boolean;
  11134. /**
  11135. * Gets or sets a world offset applied to all particles
  11136. */
  11137. worldOffset: Vector3;
  11138. /**
  11139. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11140. */
  11141. get isAnimationSheetEnabled(): boolean;
  11142. set isAnimationSheetEnabled(value: boolean);
  11143. /**
  11144. * Get hosting scene
  11145. * @returns the scene
  11146. */
  11147. getScene(): Scene;
  11148. /**
  11149. * You can use gravity if you want to give an orientation to your particles.
  11150. */
  11151. gravity: Vector3;
  11152. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11153. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11154. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11155. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11156. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11157. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11158. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11159. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11160. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11161. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11162. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11163. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11164. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11165. /**
  11166. * Defines the delay in milliseconds before starting the system (0 by default)
  11167. */
  11168. startDelay: number;
  11169. /**
  11170. * Gets the current list of drag gradients.
  11171. * You must use addDragGradient and removeDragGradient to udpate this list
  11172. * @returns the list of drag gradients
  11173. */
  11174. getDragGradients(): Nullable<Array<FactorGradient>>;
  11175. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11176. limitVelocityDamping: number;
  11177. /**
  11178. * Gets the current list of limit velocity gradients.
  11179. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11180. * @returns the list of limit velocity gradients
  11181. */
  11182. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11183. /**
  11184. * Gets the current list of color gradients.
  11185. * You must use addColorGradient and removeColorGradient to udpate this list
  11186. * @returns the list of color gradients
  11187. */
  11188. getColorGradients(): Nullable<Array<ColorGradient>>;
  11189. /**
  11190. * Gets the current list of size gradients.
  11191. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11192. * @returns the list of size gradients
  11193. */
  11194. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11195. /**
  11196. * Gets the current list of color remap gradients.
  11197. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11198. * @returns the list of color remap gradients
  11199. */
  11200. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11201. /**
  11202. * Gets the current list of alpha remap gradients.
  11203. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11204. * @returns the list of alpha remap gradients
  11205. */
  11206. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11207. /**
  11208. * Gets the current list of life time gradients.
  11209. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11210. * @returns the list of life time gradients
  11211. */
  11212. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11213. /**
  11214. * Gets the current list of angular speed gradients.
  11215. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11216. * @returns the list of angular speed gradients
  11217. */
  11218. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11219. /**
  11220. * Gets the current list of velocity gradients.
  11221. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11222. * @returns the list of velocity gradients
  11223. */
  11224. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11225. /**
  11226. * Gets the current list of start size gradients.
  11227. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11228. * @returns the list of start size gradients
  11229. */
  11230. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11231. /**
  11232. * Gets the current list of emit rate gradients.
  11233. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11234. * @returns the list of emit rate gradients
  11235. */
  11236. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11237. /**
  11238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11239. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11240. */
  11241. get direction1(): Vector3;
  11242. set direction1(value: Vector3);
  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 direction2(): Vector3;
  11248. set direction2(value: Vector3);
  11249. /**
  11250. * 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.
  11251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11252. */
  11253. get minEmitBox(): Vector3;
  11254. set minEmitBox(value: Vector3);
  11255. /**
  11256. * 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.
  11257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11258. */
  11259. get maxEmitBox(): Vector3;
  11260. set maxEmitBox(value: Vector3);
  11261. /**
  11262. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11263. */
  11264. color1: Color4;
  11265. /**
  11266. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11267. */
  11268. color2: Color4;
  11269. /**
  11270. * Color the particle will have at the end of its lifetime
  11271. */
  11272. colorDead: Color4;
  11273. /**
  11274. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11275. */
  11276. textureMask: Color4;
  11277. /**
  11278. * The particle emitter type defines the emitter used by the particle system.
  11279. * It can be for example box, sphere, or cone...
  11280. */
  11281. particleEmitterType: IParticleEmitterType;
  11282. /** @hidden */
  11283. _isSubEmitter: boolean;
  11284. /**
  11285. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11286. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11287. */
  11288. billboardMode: number;
  11289. protected _isBillboardBased: boolean;
  11290. /**
  11291. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11292. */
  11293. get isBillboardBased(): boolean;
  11294. set isBillboardBased(value: boolean);
  11295. /**
  11296. * The scene the particle system belongs to.
  11297. */
  11298. protected _scene: Scene;
  11299. /**
  11300. * Local cache of defines for image processing.
  11301. */
  11302. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11303. /**
  11304. * Default configuration related to image processing available in the standard Material.
  11305. */
  11306. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11307. /**
  11308. * Gets the image processing configuration used either in this material.
  11309. */
  11310. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11311. /**
  11312. * Sets the Default image processing configuration used either in the this material.
  11313. *
  11314. * If sets to null, the scene one is in use.
  11315. */
  11316. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11317. /**
  11318. * Attaches a new image processing configuration to the Standard Material.
  11319. * @param configuration
  11320. */
  11321. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11322. /** @hidden */
  11323. protected _reset(): void;
  11324. /** @hidden */
  11325. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11326. /**
  11327. * Instantiates a particle system.
  11328. * 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.
  11329. * @param name The name of the particle system
  11330. */
  11331. constructor(name: string);
  11332. /**
  11333. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11334. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11335. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11336. * @returns the emitter
  11337. */
  11338. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11339. /**
  11340. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11341. * @param radius The radius of the hemisphere to emit from
  11342. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11343. * @returns the emitter
  11344. */
  11345. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11346. /**
  11347. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11348. * @param radius The radius of the sphere to emit from
  11349. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11350. * @returns the emitter
  11351. */
  11352. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11353. /**
  11354. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11355. * @param radius The radius of the sphere to emit from
  11356. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11357. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11358. * @returns the emitter
  11359. */
  11360. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11361. /**
  11362. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11363. * @param radius The radius of the emission cylinder
  11364. * @param height The height of the emission cylinder
  11365. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11366. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11367. * @returns the emitter
  11368. */
  11369. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11370. /**
  11371. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11372. * @param radius The radius of the cylinder to emit from
  11373. * @param height The height of the emission cylinder
  11374. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11375. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11376. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11377. * @returns the emitter
  11378. */
  11379. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11380. /**
  11381. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11382. * @param radius The radius of the cone to emit from
  11383. * @param angle The base angle of the cone
  11384. * @returns the emitter
  11385. */
  11386. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11387. /**
  11388. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11391. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11392. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11393. * @returns the emitter
  11394. */
  11395. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11396. }
  11397. }
  11398. declare module BABYLON {
  11399. /**
  11400. * Type of sub emitter
  11401. */
  11402. export enum SubEmitterType {
  11403. /**
  11404. * Attached to the particle over it's lifetime
  11405. */
  11406. ATTACHED = 0,
  11407. /**
  11408. * Created when the particle dies
  11409. */
  11410. END = 1
  11411. }
  11412. /**
  11413. * Sub emitter class used to emit particles from an existing particle
  11414. */
  11415. export class SubEmitter {
  11416. /**
  11417. * the particle system to be used by the sub emitter
  11418. */
  11419. particleSystem: ParticleSystem;
  11420. /**
  11421. * Type of the submitter (Default: END)
  11422. */
  11423. type: SubEmitterType;
  11424. /**
  11425. * 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)
  11426. * Note: This only is supported when using an emitter of type Mesh
  11427. */
  11428. inheritDirection: boolean;
  11429. /**
  11430. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11431. */
  11432. inheritedVelocityAmount: number;
  11433. /**
  11434. * Creates a sub emitter
  11435. * @param particleSystem the particle system to be used by the sub emitter
  11436. */
  11437. constructor(
  11438. /**
  11439. * the particle system to be used by the sub emitter
  11440. */
  11441. particleSystem: ParticleSystem);
  11442. /**
  11443. * Clones the sub emitter
  11444. * @returns the cloned sub emitter
  11445. */
  11446. clone(): SubEmitter;
  11447. /**
  11448. * Serialize current object to a JSON object
  11449. * @returns the serialized object
  11450. */
  11451. serialize(): any;
  11452. /** @hidden */
  11453. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11454. /**
  11455. * Creates a new SubEmitter from a serialized JSON version
  11456. * @param serializationObject defines the JSON object to read from
  11457. * @param scene defines the hosting scene
  11458. * @param rootUrl defines the rootUrl for data loading
  11459. * @returns a new SubEmitter
  11460. */
  11461. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11462. /** Release associated resources */
  11463. dispose(): void;
  11464. }
  11465. }
  11466. declare module BABYLON {
  11467. /** @hidden */
  11468. export var imageProcessingDeclaration: {
  11469. name: string;
  11470. shader: string;
  11471. };
  11472. }
  11473. declare module BABYLON {
  11474. /** @hidden */
  11475. export var imageProcessingFunctions: {
  11476. name: string;
  11477. shader: string;
  11478. };
  11479. }
  11480. declare module BABYLON {
  11481. /** @hidden */
  11482. export var particlesPixelShader: {
  11483. name: string;
  11484. shader: string;
  11485. };
  11486. }
  11487. declare module BABYLON {
  11488. /** @hidden */
  11489. export var particlesVertexShader: {
  11490. name: string;
  11491. shader: string;
  11492. };
  11493. }
  11494. declare module BABYLON {
  11495. /**
  11496. * This represents a particle system in Babylon.
  11497. * 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.
  11498. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11499. * @example https://doc.babylonjs.com/babylon101/particles
  11500. */
  11501. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11502. /**
  11503. * Billboard mode will only apply to Y axis
  11504. */
  11505. static readonly BILLBOARDMODE_Y: number;
  11506. /**
  11507. * Billboard mode will apply to all axes
  11508. */
  11509. static readonly BILLBOARDMODE_ALL: number;
  11510. /**
  11511. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11512. */
  11513. static readonly BILLBOARDMODE_STRETCHED: number;
  11514. /**
  11515. * This function can be defined to provide custom update for active particles.
  11516. * This function will be called instead of regular update (age, position, color, etc.).
  11517. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11518. */
  11519. updateFunction: (particles: Particle[]) => void;
  11520. private _emitterWorldMatrix;
  11521. /**
  11522. * This function can be defined to specify initial direction for every new particle.
  11523. * It by default use the emitterType defined function
  11524. */
  11525. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11526. /**
  11527. * This function can be defined to specify initial position for every new particle.
  11528. * It by default use the emitterType defined function
  11529. */
  11530. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11531. /**
  11532. * @hidden
  11533. */
  11534. _inheritedVelocityOffset: Vector3;
  11535. /**
  11536. * An event triggered when the system is disposed
  11537. */
  11538. onDisposeObservable: Observable<ParticleSystem>;
  11539. private _onDisposeObserver;
  11540. /**
  11541. * Sets a callback that will be triggered when the system is disposed
  11542. */
  11543. set onDispose(callback: () => void);
  11544. private _particles;
  11545. private _epsilon;
  11546. private _capacity;
  11547. private _stockParticles;
  11548. private _newPartsExcess;
  11549. private _vertexData;
  11550. private _vertexBuffer;
  11551. private _vertexBuffers;
  11552. private _spriteBuffer;
  11553. private _indexBuffer;
  11554. private _effect;
  11555. private _customEffect;
  11556. private _cachedDefines;
  11557. private _scaledColorStep;
  11558. private _colorDiff;
  11559. private _scaledDirection;
  11560. private _scaledGravity;
  11561. private _currentRenderId;
  11562. private _alive;
  11563. private _useInstancing;
  11564. private _started;
  11565. private _stopped;
  11566. private _actualFrame;
  11567. private _scaledUpdateSpeed;
  11568. private _vertexBufferSize;
  11569. /** @hidden */
  11570. _currentEmitRateGradient: Nullable<FactorGradient>;
  11571. /** @hidden */
  11572. _currentEmitRate1: number;
  11573. /** @hidden */
  11574. _currentEmitRate2: number;
  11575. /** @hidden */
  11576. _currentStartSizeGradient: Nullable<FactorGradient>;
  11577. /** @hidden */
  11578. _currentStartSize1: number;
  11579. /** @hidden */
  11580. _currentStartSize2: number;
  11581. private readonly _rawTextureWidth;
  11582. private _rampGradientsTexture;
  11583. private _useRampGradients;
  11584. /** Gets or sets a boolean indicating that ramp gradients must be used
  11585. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11586. */
  11587. get useRampGradients(): boolean;
  11588. set useRampGradients(value: boolean);
  11589. /**
  11590. * 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.
  11591. * 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: [])
  11592. */
  11593. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11594. private _subEmitters;
  11595. /**
  11596. * @hidden
  11597. * If the particle systems emitter should be disposed when the particle system is disposed
  11598. */
  11599. _disposeEmitterOnDispose: boolean;
  11600. /**
  11601. * The current active Sub-systems, this property is used by the root particle system only.
  11602. */
  11603. activeSubSystems: Array<ParticleSystem>;
  11604. /**
  11605. * Specifies if the particles are updated in emitter local space or world space
  11606. */
  11607. isLocal: boolean;
  11608. private _rootParticleSystem;
  11609. /**
  11610. * Gets the current list of active particles
  11611. */
  11612. get particles(): Particle[];
  11613. /**
  11614. * Returns the string "ParticleSystem"
  11615. * @returns a string containing the class name
  11616. */
  11617. getClassName(): string;
  11618. /**
  11619. * Instantiates a particle system.
  11620. * 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.
  11621. * @param name The name of the particle system
  11622. * @param capacity The max number of particles alive at the same time
  11623. * @param scene The scene the particle system belongs to
  11624. * @param customEffect a custom effect used to change the way particles are rendered by default
  11625. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11626. * @param epsilon Offset used to render the particles
  11627. */
  11628. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11629. private _addFactorGradient;
  11630. private _removeFactorGradient;
  11631. /**
  11632. * Adds a new life time gradient
  11633. * @param gradient defines the gradient to use (between 0 and 1)
  11634. * @param factor defines the life time factor to affect to the specified gradient
  11635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11636. * @returns the current particle system
  11637. */
  11638. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11639. /**
  11640. * Remove a specific life time gradient
  11641. * @param gradient defines the gradient to remove
  11642. * @returns the current particle system
  11643. */
  11644. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11645. /**
  11646. * Adds a new size gradient
  11647. * @param gradient defines the gradient to use (between 0 and 1)
  11648. * @param factor defines the size factor to affect to the specified gradient
  11649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11650. * @returns the current particle system
  11651. */
  11652. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11653. /**
  11654. * Remove a specific size gradient
  11655. * @param gradient defines the gradient to remove
  11656. * @returns the current particle system
  11657. */
  11658. removeSizeGradient(gradient: number): IParticleSystem;
  11659. /**
  11660. * Adds a new color remap gradient
  11661. * @param gradient defines the gradient to use (between 0 and 1)
  11662. * @param min defines the color remap minimal range
  11663. * @param max defines the color remap maximal range
  11664. * @returns the current particle system
  11665. */
  11666. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11667. /**
  11668. * Remove a specific color remap gradient
  11669. * @param gradient defines the gradient to remove
  11670. * @returns the current particle system
  11671. */
  11672. removeColorRemapGradient(gradient: number): IParticleSystem;
  11673. /**
  11674. * Adds a new alpha remap gradient
  11675. * @param gradient defines the gradient to use (between 0 and 1)
  11676. * @param min defines the alpha remap minimal range
  11677. * @param max defines the alpha remap maximal range
  11678. * @returns the current particle system
  11679. */
  11680. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11681. /**
  11682. * Remove a specific alpha remap gradient
  11683. * @param gradient defines the gradient to remove
  11684. * @returns the current particle system
  11685. */
  11686. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11687. /**
  11688. * Adds a new angular speed gradient
  11689. * @param gradient defines the gradient to use (between 0 and 1)
  11690. * @param factor defines the angular speed to affect to the specified gradient
  11691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11692. * @returns the current particle system
  11693. */
  11694. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11695. /**
  11696. * Remove a specific angular speed gradient
  11697. * @param gradient defines the gradient to remove
  11698. * @returns the current particle system
  11699. */
  11700. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11701. /**
  11702. * Adds a new velocity gradient
  11703. * @param gradient defines the gradient to use (between 0 and 1)
  11704. * @param factor defines the velocity to affect to the specified gradient
  11705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11706. * @returns the current particle system
  11707. */
  11708. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11709. /**
  11710. * Remove a specific velocity gradient
  11711. * @param gradient defines the gradient to remove
  11712. * @returns the current particle system
  11713. */
  11714. removeVelocityGradient(gradient: number): IParticleSystem;
  11715. /**
  11716. * Adds a new limit velocity gradient
  11717. * @param gradient defines the gradient to use (between 0 and 1)
  11718. * @param factor defines the limit velocity value to affect to the specified gradient
  11719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11720. * @returns the current particle system
  11721. */
  11722. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11723. /**
  11724. * Remove a specific limit velocity gradient
  11725. * @param gradient defines the gradient to remove
  11726. * @returns the current particle system
  11727. */
  11728. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11729. /**
  11730. * Adds a new drag gradient
  11731. * @param gradient defines the gradient to use (between 0 and 1)
  11732. * @param factor defines the drag value to affect to the specified gradient
  11733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11734. * @returns the current particle system
  11735. */
  11736. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11737. /**
  11738. * Remove a specific drag gradient
  11739. * @param gradient defines the gradient to remove
  11740. * @returns the current particle system
  11741. */
  11742. removeDragGradient(gradient: number): IParticleSystem;
  11743. /**
  11744. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11745. * @param gradient defines the gradient to use (between 0 and 1)
  11746. * @param factor defines the emit rate value to affect to the specified gradient
  11747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11748. * @returns the current particle system
  11749. */
  11750. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11751. /**
  11752. * Remove a specific emit rate gradient
  11753. * @param gradient defines the gradient to remove
  11754. * @returns the current particle system
  11755. */
  11756. removeEmitRateGradient(gradient: number): IParticleSystem;
  11757. /**
  11758. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11759. * @param gradient defines the gradient to use (between 0 and 1)
  11760. * @param factor defines the start size value to affect to the specified gradient
  11761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11762. * @returns the current particle system
  11763. */
  11764. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11765. /**
  11766. * Remove a specific start size gradient
  11767. * @param gradient defines the gradient to remove
  11768. * @returns the current particle system
  11769. */
  11770. removeStartSizeGradient(gradient: number): IParticleSystem;
  11771. private _createRampGradientTexture;
  11772. /**
  11773. * Gets the current list of ramp gradients.
  11774. * You must use addRampGradient and removeRampGradient to udpate this list
  11775. * @returns the list of ramp gradients
  11776. */
  11777. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11778. /**
  11779. * Adds a new ramp gradient used to remap particle colors
  11780. * @param gradient defines the gradient to use (between 0 and 1)
  11781. * @param color defines the color to affect to the specified gradient
  11782. * @returns the current particle system
  11783. */
  11784. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11785. /**
  11786. * Remove a specific ramp gradient
  11787. * @param gradient defines the gradient to remove
  11788. * @returns the current particle system
  11789. */
  11790. removeRampGradient(gradient: number): ParticleSystem;
  11791. /**
  11792. * Adds a new color gradient
  11793. * @param gradient defines the gradient to use (between 0 and 1)
  11794. * @param color1 defines the color to affect to the specified gradient
  11795. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11796. * @returns this particle system
  11797. */
  11798. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11799. /**
  11800. * Remove a specific color gradient
  11801. * @param gradient defines the gradient to remove
  11802. * @returns this particle system
  11803. */
  11804. removeColorGradient(gradient: number): IParticleSystem;
  11805. private _fetchR;
  11806. protected _reset(): void;
  11807. private _resetEffect;
  11808. private _createVertexBuffers;
  11809. private _createIndexBuffer;
  11810. /**
  11811. * Gets the maximum number of particles active at the same time.
  11812. * @returns The max number of active particles.
  11813. */
  11814. getCapacity(): number;
  11815. /**
  11816. * Gets whether there are still active particles in the system.
  11817. * @returns True if it is alive, otherwise false.
  11818. */
  11819. isAlive(): boolean;
  11820. /**
  11821. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11822. * @returns True if it has been started, otherwise false.
  11823. */
  11824. isStarted(): boolean;
  11825. private _prepareSubEmitterInternalArray;
  11826. /**
  11827. * Starts the particle system and begins to emit
  11828. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11829. */
  11830. start(delay?: number): void;
  11831. /**
  11832. * Stops the particle system.
  11833. * @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.
  11834. */
  11835. stop(stopSubEmitters?: boolean): void;
  11836. /**
  11837. * Remove all active particles
  11838. */
  11839. reset(): void;
  11840. /**
  11841. * @hidden (for internal use only)
  11842. */
  11843. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11844. /**
  11845. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11846. * Its lifetime will start back at 0.
  11847. */
  11848. recycleParticle: (particle: Particle) => void;
  11849. private _stopSubEmitters;
  11850. private _createParticle;
  11851. private _removeFromRoot;
  11852. private _emitFromParticle;
  11853. private _update;
  11854. /** @hidden */
  11855. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11856. /** @hidden */
  11857. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11858. /** @hidden */
  11859. private _getEffect;
  11860. /**
  11861. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11862. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11863. */
  11864. animate(preWarmOnly?: boolean): void;
  11865. private _appendParticleVertices;
  11866. /**
  11867. * Rebuilds the particle system.
  11868. */
  11869. rebuild(): void;
  11870. /**
  11871. * Is this system ready to be used/rendered
  11872. * @return true if the system is ready
  11873. */
  11874. isReady(): boolean;
  11875. private _render;
  11876. /**
  11877. * Renders the particle system in its current state.
  11878. * @returns the current number of particles
  11879. */
  11880. render(): number;
  11881. /**
  11882. * Disposes the particle system and free the associated resources
  11883. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11884. */
  11885. dispose(disposeTexture?: boolean): void;
  11886. /**
  11887. * Clones the particle system.
  11888. * @param name The name of the cloned object
  11889. * @param newEmitter The new emitter to use
  11890. * @returns the cloned particle system
  11891. */
  11892. clone(name: string, newEmitter: any): ParticleSystem;
  11893. /**
  11894. * Serializes the particle system to a JSON object.
  11895. * @returns the JSON object
  11896. */
  11897. serialize(): any;
  11898. /** @hidden */
  11899. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11900. /** @hidden */
  11901. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11902. /**
  11903. * Parses a JSON object to create a particle system.
  11904. * @param parsedParticleSystem The JSON object to parse
  11905. * @param scene The scene to create the particle system in
  11906. * @param rootUrl The root url to use to load external dependencies like texture
  11907. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11908. * @returns the Parsed particle system
  11909. */
  11910. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11911. }
  11912. }
  11913. declare module BABYLON {
  11914. /**
  11915. * A particle represents one of the element emitted by a particle system.
  11916. * This is mainly define by its coordinates, direction, velocity and age.
  11917. */
  11918. export class Particle {
  11919. /**
  11920. * The particle system the particle belongs to.
  11921. */
  11922. particleSystem: ParticleSystem;
  11923. private static _Count;
  11924. /**
  11925. * Unique ID of the particle
  11926. */
  11927. id: number;
  11928. /**
  11929. * The world position of the particle in the scene.
  11930. */
  11931. position: Vector3;
  11932. /**
  11933. * The world direction of the particle in the scene.
  11934. */
  11935. direction: Vector3;
  11936. /**
  11937. * The color of the particle.
  11938. */
  11939. color: Color4;
  11940. /**
  11941. * The color change of the particle per step.
  11942. */
  11943. colorStep: Color4;
  11944. /**
  11945. * Defines how long will the life of the particle be.
  11946. */
  11947. lifeTime: number;
  11948. /**
  11949. * The current age of the particle.
  11950. */
  11951. age: number;
  11952. /**
  11953. * The current size of the particle.
  11954. */
  11955. size: number;
  11956. /**
  11957. * The current scale of the particle.
  11958. */
  11959. scale: Vector2;
  11960. /**
  11961. * The current angle of the particle.
  11962. */
  11963. angle: number;
  11964. /**
  11965. * Defines how fast is the angle changing.
  11966. */
  11967. angularSpeed: number;
  11968. /**
  11969. * Defines the cell index used by the particle to be rendered from a sprite.
  11970. */
  11971. cellIndex: number;
  11972. /**
  11973. * The information required to support color remapping
  11974. */
  11975. remapData: Vector4;
  11976. /** @hidden */
  11977. _randomCellOffset?: number;
  11978. /** @hidden */
  11979. _initialDirection: Nullable<Vector3>;
  11980. /** @hidden */
  11981. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  11982. /** @hidden */
  11983. _initialStartSpriteCellID: number;
  11984. /** @hidden */
  11985. _initialEndSpriteCellID: number;
  11986. /** @hidden */
  11987. _currentColorGradient: Nullable<ColorGradient>;
  11988. /** @hidden */
  11989. _currentColor1: Color4;
  11990. /** @hidden */
  11991. _currentColor2: Color4;
  11992. /** @hidden */
  11993. _currentSizeGradient: Nullable<FactorGradient>;
  11994. /** @hidden */
  11995. _currentSize1: number;
  11996. /** @hidden */
  11997. _currentSize2: number;
  11998. /** @hidden */
  11999. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12000. /** @hidden */
  12001. _currentAngularSpeed1: number;
  12002. /** @hidden */
  12003. _currentAngularSpeed2: number;
  12004. /** @hidden */
  12005. _currentVelocityGradient: Nullable<FactorGradient>;
  12006. /** @hidden */
  12007. _currentVelocity1: number;
  12008. /** @hidden */
  12009. _currentVelocity2: number;
  12010. /** @hidden */
  12011. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12012. /** @hidden */
  12013. _currentLimitVelocity1: number;
  12014. /** @hidden */
  12015. _currentLimitVelocity2: number;
  12016. /** @hidden */
  12017. _currentDragGradient: Nullable<FactorGradient>;
  12018. /** @hidden */
  12019. _currentDrag1: number;
  12020. /** @hidden */
  12021. _currentDrag2: number;
  12022. /** @hidden */
  12023. _randomNoiseCoordinates1: Vector3;
  12024. /** @hidden */
  12025. _randomNoiseCoordinates2: Vector3;
  12026. /** @hidden */
  12027. _localPosition?: 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. * @param isLocal defines if the direction should be set in local space
  12067. */
  12068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12069. /**
  12070. * Called by the particle System when the position is computed for the created particle.
  12071. * @param worldMatrix is the world matrix of the particle system
  12072. * @param positionToUpdate is the position vector to update with the result
  12073. * @param particle is the particle we are computed the position for
  12074. * @param isLocal defines if the position should be set in local space
  12075. */
  12076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12077. /**
  12078. * Clones the current emitter and returns a copy of it
  12079. * @returns the new emitter
  12080. */
  12081. clone(): IParticleEmitterType;
  12082. /**
  12083. * Called by the GPUParticleSystem to setup the update shader
  12084. * @param effect defines the update shader
  12085. */
  12086. applyToShader(effect: Effect): void;
  12087. /**
  12088. * Returns a string to use to update the GPU particles update shader
  12089. * @returns the effect defines string
  12090. */
  12091. getEffectDefines(): string;
  12092. /**
  12093. * Returns a string representing the class name
  12094. * @returns a string containing the class name
  12095. */
  12096. getClassName(): string;
  12097. /**
  12098. * Serializes the particle system to a JSON object.
  12099. * @returns the JSON object
  12100. */
  12101. serialize(): any;
  12102. /**
  12103. * Parse properties from a JSON object
  12104. * @param serializationObject defines the JSON object
  12105. * @param scene defines the hosting scene
  12106. */
  12107. parse(serializationObject: any, scene: Scene): void;
  12108. }
  12109. }
  12110. declare module BABYLON {
  12111. /**
  12112. * Particle emitter emitting particles from the inside of a box.
  12113. * It emits the particles randomly between 2 given directions.
  12114. */
  12115. export class BoxParticleEmitter implements IParticleEmitterType {
  12116. /**
  12117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12118. */
  12119. direction1: Vector3;
  12120. /**
  12121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12122. */
  12123. direction2: Vector3;
  12124. /**
  12125. * 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.
  12126. */
  12127. minEmitBox: Vector3;
  12128. /**
  12129. * 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.
  12130. */
  12131. maxEmitBox: Vector3;
  12132. /**
  12133. * Creates a new instance BoxParticleEmitter
  12134. */
  12135. constructor();
  12136. /**
  12137. * Called by the particle System when the direction is computed for the created particle.
  12138. * @param worldMatrix is the world matrix of the particle system
  12139. * @param directionToUpdate is the direction vector to update with the result
  12140. * @param particle is the particle we are computed the direction for
  12141. * @param isLocal defines if the direction should be set in local space
  12142. */
  12143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12144. /**
  12145. * Called by the particle System when the position is computed for the created particle.
  12146. * @param worldMatrix is the world matrix of the particle system
  12147. * @param positionToUpdate is the position vector to update with the result
  12148. * @param particle is the particle we are computed the position for
  12149. * @param isLocal defines if the position should be set in local space
  12150. */
  12151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12152. /**
  12153. * Clones the current emitter and returns a copy of it
  12154. * @returns the new emitter
  12155. */
  12156. clone(): BoxParticleEmitter;
  12157. /**
  12158. * Called by the GPUParticleSystem to setup the update shader
  12159. * @param effect defines the update shader
  12160. */
  12161. applyToShader(effect: Effect): void;
  12162. /**
  12163. * Returns a string to use to update the GPU particles update shader
  12164. * @returns a string containng the defines string
  12165. */
  12166. getEffectDefines(): string;
  12167. /**
  12168. * Returns the string "BoxParticleEmitter"
  12169. * @returns a string containing the class name
  12170. */
  12171. getClassName(): string;
  12172. /**
  12173. * Serializes the particle system to a JSON object.
  12174. * @returns the JSON object
  12175. */
  12176. serialize(): any;
  12177. /**
  12178. * Parse properties from a JSON object
  12179. * @param serializationObject defines the JSON object
  12180. */
  12181. parse(serializationObject: any): void;
  12182. }
  12183. }
  12184. declare module BABYLON {
  12185. /**
  12186. * Particle emitter emitting particles from the inside of a cone.
  12187. * It emits the particles alongside the cone volume from the base to the particle.
  12188. * The emission direction might be randomized.
  12189. */
  12190. export class ConeParticleEmitter implements IParticleEmitterType {
  12191. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12192. directionRandomizer: number;
  12193. private _radius;
  12194. private _angle;
  12195. private _height;
  12196. /**
  12197. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12198. */
  12199. radiusRange: number;
  12200. /**
  12201. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12202. */
  12203. heightRange: number;
  12204. /**
  12205. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12206. */
  12207. emitFromSpawnPointOnly: boolean;
  12208. /**
  12209. * Gets or sets the radius of the emission cone
  12210. */
  12211. get radius(): number;
  12212. set radius(value: number);
  12213. /**
  12214. * Gets or sets the angle of the emission cone
  12215. */
  12216. get angle(): number;
  12217. set angle(value: number);
  12218. private _buildHeight;
  12219. /**
  12220. * Creates a new instance ConeParticleEmitter
  12221. * @param radius the radius of the emission cone (1 by default)
  12222. * @param angle the cone base angle (PI by default)
  12223. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12224. */
  12225. constructor(radius?: number, angle?: number,
  12226. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12227. directionRandomizer?: number);
  12228. /**
  12229. * Called by the particle System when the direction is computed for the created particle.
  12230. * @param worldMatrix is the world matrix of the particle system
  12231. * @param directionToUpdate is the direction vector to update with the result
  12232. * @param particle is the particle we are computed the direction for
  12233. * @param isLocal defines if the direction should be set in local space
  12234. */
  12235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12236. /**
  12237. * Called by the particle System when the position is computed for the created particle.
  12238. * @param worldMatrix is the world matrix of the particle system
  12239. * @param positionToUpdate is the position vector to update with the result
  12240. * @param particle is the particle we are computed the position for
  12241. * @param isLocal defines if the position should be set in local space
  12242. */
  12243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12244. /**
  12245. * Clones the current emitter and returns a copy of it
  12246. * @returns the new emitter
  12247. */
  12248. clone(): ConeParticleEmitter;
  12249. /**
  12250. * Called by the GPUParticleSystem to setup the update shader
  12251. * @param effect defines the update shader
  12252. */
  12253. applyToShader(effect: Effect): void;
  12254. /**
  12255. * Returns a string to use to update the GPU particles update shader
  12256. * @returns a string containng the defines string
  12257. */
  12258. getEffectDefines(): string;
  12259. /**
  12260. * Returns the string "ConeParticleEmitter"
  12261. * @returns a string containing the class name
  12262. */
  12263. getClassName(): string;
  12264. /**
  12265. * Serializes the particle system to a JSON object.
  12266. * @returns the JSON object
  12267. */
  12268. serialize(): any;
  12269. /**
  12270. * Parse properties from a JSON object
  12271. * @param serializationObject defines the JSON object
  12272. */
  12273. parse(serializationObject: any): void;
  12274. }
  12275. }
  12276. declare module BABYLON {
  12277. /**
  12278. * Particle emitter emitting particles from the inside of a cylinder.
  12279. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12280. */
  12281. export class CylinderParticleEmitter implements IParticleEmitterType {
  12282. /**
  12283. * The radius of the emission cylinder.
  12284. */
  12285. radius: number;
  12286. /**
  12287. * The height of the emission cylinder.
  12288. */
  12289. height: number;
  12290. /**
  12291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12292. */
  12293. radiusRange: number;
  12294. /**
  12295. * How much to randomize the particle direction [0-1].
  12296. */
  12297. directionRandomizer: number;
  12298. /**
  12299. * Creates a new instance CylinderParticleEmitter
  12300. * @param radius the radius of the emission cylinder (1 by default)
  12301. * @param height the height of the emission cylinder (1 by default)
  12302. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12304. */
  12305. constructor(
  12306. /**
  12307. * The radius of the emission cylinder.
  12308. */
  12309. radius?: number,
  12310. /**
  12311. * The height of the emission cylinder.
  12312. */
  12313. height?: number,
  12314. /**
  12315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12316. */
  12317. radiusRange?: number,
  12318. /**
  12319. * How much to randomize the particle direction [0-1].
  12320. */
  12321. directionRandomizer?: number);
  12322. /**
  12323. * Called by the particle System when the direction is computed for the created particle.
  12324. * @param worldMatrix is the world matrix of the particle system
  12325. * @param directionToUpdate is the direction vector to update with the result
  12326. * @param particle is the particle we are computed the direction for
  12327. * @param isLocal defines if the direction should be set in local space
  12328. */
  12329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12330. /**
  12331. * Called by the particle System when the position is computed for the created particle.
  12332. * @param worldMatrix is the world matrix of the particle system
  12333. * @param positionToUpdate is the position vector to update with the result
  12334. * @param particle is the particle we are computed the position for
  12335. * @param isLocal defines if the position should be set in local space
  12336. */
  12337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12338. /**
  12339. * Clones the current emitter and returns a copy of it
  12340. * @returns the new emitter
  12341. */
  12342. clone(): CylinderParticleEmitter;
  12343. /**
  12344. * Called by the GPUParticleSystem to setup the update shader
  12345. * @param effect defines the update shader
  12346. */
  12347. applyToShader(effect: Effect): void;
  12348. /**
  12349. * Returns a string to use to update the GPU particles update shader
  12350. * @returns a string containng the defines string
  12351. */
  12352. getEffectDefines(): string;
  12353. /**
  12354. * Returns the string "CylinderParticleEmitter"
  12355. * @returns a string containing the class name
  12356. */
  12357. getClassName(): string;
  12358. /**
  12359. * Serializes the particle system to a JSON object.
  12360. * @returns the JSON object
  12361. */
  12362. serialize(): any;
  12363. /**
  12364. * Parse properties from a JSON object
  12365. * @param serializationObject defines the JSON object
  12366. */
  12367. parse(serializationObject: any): void;
  12368. }
  12369. /**
  12370. * Particle emitter emitting particles from the inside of a cylinder.
  12371. * It emits the particles randomly between two vectors.
  12372. */
  12373. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12374. /**
  12375. * The min limit of the emission direction.
  12376. */
  12377. direction1: Vector3;
  12378. /**
  12379. * The max limit of the emission direction.
  12380. */
  12381. direction2: Vector3;
  12382. /**
  12383. * Creates a new instance CylinderDirectedParticleEmitter
  12384. * @param radius the radius of the emission cylinder (1 by default)
  12385. * @param height the height of the emission cylinder (1 by default)
  12386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12387. * @param direction1 the min limit of the emission direction (up vector by default)
  12388. * @param direction2 the max limit of the emission direction (up vector by default)
  12389. */
  12390. constructor(radius?: number, height?: number, radiusRange?: number,
  12391. /**
  12392. * The min limit of the emission direction.
  12393. */
  12394. direction1?: Vector3,
  12395. /**
  12396. * The max limit of the emission direction.
  12397. */
  12398. direction2?: Vector3);
  12399. /**
  12400. * Called by the particle System when the direction is computed for the created particle.
  12401. * @param worldMatrix is the world matrix of the particle system
  12402. * @param directionToUpdate is the direction vector to update with the result
  12403. * @param particle is the particle we are computed the direction for
  12404. */
  12405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12406. /**
  12407. * Clones the current emitter and returns a copy of it
  12408. * @returns the new emitter
  12409. */
  12410. clone(): CylinderDirectedParticleEmitter;
  12411. /**
  12412. * Called by the GPUParticleSystem to setup the update shader
  12413. * @param effect defines the update shader
  12414. */
  12415. applyToShader(effect: Effect): void;
  12416. /**
  12417. * Returns a string to use to update the GPU particles update shader
  12418. * @returns a string containng the defines string
  12419. */
  12420. getEffectDefines(): string;
  12421. /**
  12422. * Returns the string "CylinderDirectedParticleEmitter"
  12423. * @returns a string containing the class name
  12424. */
  12425. getClassName(): string;
  12426. /**
  12427. * Serializes the particle system to a JSON object.
  12428. * @returns the JSON object
  12429. */
  12430. serialize(): any;
  12431. /**
  12432. * Parse properties from a JSON object
  12433. * @param serializationObject defines the JSON object
  12434. */
  12435. parse(serializationObject: any): void;
  12436. }
  12437. }
  12438. declare module BABYLON {
  12439. /**
  12440. * Particle emitter emitting particles from the inside of a hemisphere.
  12441. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12442. */
  12443. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12444. /**
  12445. * The radius of the emission hemisphere.
  12446. */
  12447. radius: number;
  12448. /**
  12449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12450. */
  12451. radiusRange: number;
  12452. /**
  12453. * How much to randomize the particle direction [0-1].
  12454. */
  12455. directionRandomizer: number;
  12456. /**
  12457. * Creates a new instance HemisphericParticleEmitter
  12458. * @param radius the radius of the emission hemisphere (1 by default)
  12459. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12461. */
  12462. constructor(
  12463. /**
  12464. * The radius of the emission hemisphere.
  12465. */
  12466. radius?: number,
  12467. /**
  12468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12469. */
  12470. radiusRange?: number,
  12471. /**
  12472. * How much to randomize the particle direction [0-1].
  12473. */
  12474. directionRandomizer?: number);
  12475. /**
  12476. * Called by the particle System when the direction is computed for the created particle.
  12477. * @param worldMatrix is the world matrix of the particle system
  12478. * @param directionToUpdate is the direction vector to update with the result
  12479. * @param particle is the particle we are computed the direction for
  12480. * @param isLocal defines if the direction should be set in local space
  12481. */
  12482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12483. /**
  12484. * Called by the particle System when the position is computed for the created particle.
  12485. * @param worldMatrix is the world matrix of the particle system
  12486. * @param positionToUpdate is the position vector to update with the result
  12487. * @param particle is the particle we are computed the position for
  12488. * @param isLocal defines if the position should be set in local space
  12489. */
  12490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12491. /**
  12492. * Clones the current emitter and returns a copy of it
  12493. * @returns the new emitter
  12494. */
  12495. clone(): HemisphericParticleEmitter;
  12496. /**
  12497. * Called by the GPUParticleSystem to setup the update shader
  12498. * @param effect defines the update shader
  12499. */
  12500. applyToShader(effect: Effect): void;
  12501. /**
  12502. * Returns a string to use to update the GPU particles update shader
  12503. * @returns a string containng the defines string
  12504. */
  12505. getEffectDefines(): string;
  12506. /**
  12507. * Returns the string "HemisphericParticleEmitter"
  12508. * @returns a string containing the class name
  12509. */
  12510. getClassName(): string;
  12511. /**
  12512. * Serializes the particle system to a JSON object.
  12513. * @returns the JSON object
  12514. */
  12515. serialize(): any;
  12516. /**
  12517. * Parse properties from a JSON object
  12518. * @param serializationObject defines the JSON object
  12519. */
  12520. parse(serializationObject: any): void;
  12521. }
  12522. }
  12523. declare module BABYLON {
  12524. /**
  12525. * Particle emitter emitting particles from a point.
  12526. * It emits the particles randomly between 2 given directions.
  12527. */
  12528. export class PointParticleEmitter implements IParticleEmitterType {
  12529. /**
  12530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12531. */
  12532. direction1: Vector3;
  12533. /**
  12534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12535. */
  12536. direction2: Vector3;
  12537. /**
  12538. * Creates a new instance PointParticleEmitter
  12539. */
  12540. constructor();
  12541. /**
  12542. * Called by the particle System when the direction is computed for the created particle.
  12543. * @param worldMatrix is the world matrix of the particle system
  12544. * @param directionToUpdate is the direction vector to update with the result
  12545. * @param particle is the particle we are computed the direction for
  12546. * @param isLocal defines if the direction should be set in local space
  12547. */
  12548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12549. /**
  12550. * Called by the particle System when the position is computed for the created particle.
  12551. * @param worldMatrix is the world matrix of the particle system
  12552. * @param positionToUpdate is the position vector to update with the result
  12553. * @param particle is the particle we are computed the position for
  12554. * @param isLocal defines if the position should be set in local space
  12555. */
  12556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12557. /**
  12558. * Clones the current emitter and returns a copy of it
  12559. * @returns the new emitter
  12560. */
  12561. clone(): PointParticleEmitter;
  12562. /**
  12563. * Called by the GPUParticleSystem to setup the update shader
  12564. * @param effect defines the update shader
  12565. */
  12566. applyToShader(effect: Effect): void;
  12567. /**
  12568. * Returns a string to use to update the GPU particles update shader
  12569. * @returns a string containng the defines string
  12570. */
  12571. getEffectDefines(): string;
  12572. /**
  12573. * Returns the string "PointParticleEmitter"
  12574. * @returns a string containing the class name
  12575. */
  12576. getClassName(): string;
  12577. /**
  12578. * Serializes the particle system to a JSON object.
  12579. * @returns the JSON object
  12580. */
  12581. serialize(): any;
  12582. /**
  12583. * Parse properties from a JSON object
  12584. * @param serializationObject defines the JSON object
  12585. */
  12586. parse(serializationObject: any): void;
  12587. }
  12588. }
  12589. declare module BABYLON {
  12590. /**
  12591. * Particle emitter emitting particles from the inside of a sphere.
  12592. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12593. */
  12594. export class SphereParticleEmitter implements IParticleEmitterType {
  12595. /**
  12596. * The radius of the emission sphere.
  12597. */
  12598. radius: number;
  12599. /**
  12600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12601. */
  12602. radiusRange: number;
  12603. /**
  12604. * How much to randomize the particle direction [0-1].
  12605. */
  12606. directionRandomizer: number;
  12607. /**
  12608. * Creates a new instance SphereParticleEmitter
  12609. * @param radius the radius of the emission sphere (1 by default)
  12610. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12612. */
  12613. constructor(
  12614. /**
  12615. * The radius of the emission sphere.
  12616. */
  12617. radius?: number,
  12618. /**
  12619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12620. */
  12621. radiusRange?: number,
  12622. /**
  12623. * How much to randomize the particle direction [0-1].
  12624. */
  12625. directionRandomizer?: number);
  12626. /**
  12627. * Called by the particle System when the direction is computed for the created particle.
  12628. * @param worldMatrix is the world matrix of the particle system
  12629. * @param directionToUpdate is the direction vector to update with the result
  12630. * @param particle is the particle we are computed the direction for
  12631. * @param isLocal defines if the direction should be set in local space
  12632. */
  12633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12634. /**
  12635. * Called by the particle System when the position is computed for the created particle.
  12636. * @param worldMatrix is the world matrix of the particle system
  12637. * @param positionToUpdate is the position vector to update with the result
  12638. * @param particle is the particle we are computed the position for
  12639. * @param isLocal defines if the position should be set in local space
  12640. */
  12641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12642. /**
  12643. * Clones the current emitter and returns a copy of it
  12644. * @returns the new emitter
  12645. */
  12646. clone(): SphereParticleEmitter;
  12647. /**
  12648. * Called by the GPUParticleSystem to setup the update shader
  12649. * @param effect defines the update shader
  12650. */
  12651. applyToShader(effect: Effect): void;
  12652. /**
  12653. * Returns a string to use to update the GPU particles update shader
  12654. * @returns a string containng the defines string
  12655. */
  12656. getEffectDefines(): string;
  12657. /**
  12658. * Returns the string "SphereParticleEmitter"
  12659. * @returns a string containing the class name
  12660. */
  12661. getClassName(): string;
  12662. /**
  12663. * Serializes the particle system to a JSON object.
  12664. * @returns the JSON object
  12665. */
  12666. serialize(): any;
  12667. /**
  12668. * Parse properties from a JSON object
  12669. * @param serializationObject defines the JSON object
  12670. */
  12671. parse(serializationObject: any): void;
  12672. }
  12673. /**
  12674. * Particle emitter emitting particles from the inside of a sphere.
  12675. * It emits the particles randomly between two vectors.
  12676. */
  12677. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12678. /**
  12679. * The min limit of the emission direction.
  12680. */
  12681. direction1: Vector3;
  12682. /**
  12683. * The max limit of the emission direction.
  12684. */
  12685. direction2: Vector3;
  12686. /**
  12687. * Creates a new instance SphereDirectedParticleEmitter
  12688. * @param radius the radius of the emission sphere (1 by default)
  12689. * @param direction1 the min limit of the emission direction (up vector by default)
  12690. * @param direction2 the max limit of the emission direction (up vector by default)
  12691. */
  12692. constructor(radius?: number,
  12693. /**
  12694. * The min limit of the emission direction.
  12695. */
  12696. direction1?: Vector3,
  12697. /**
  12698. * The max limit of the emission direction.
  12699. */
  12700. direction2?: Vector3);
  12701. /**
  12702. * Called by the particle System when the direction is computed for the created particle.
  12703. * @param worldMatrix is the world matrix of the particle system
  12704. * @param directionToUpdate is the direction vector to update with the result
  12705. * @param particle is the particle we are computed the direction for
  12706. */
  12707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12708. /**
  12709. * Clones the current emitter and returns a copy of it
  12710. * @returns the new emitter
  12711. */
  12712. clone(): SphereDirectedParticleEmitter;
  12713. /**
  12714. * Called by the GPUParticleSystem to setup the update shader
  12715. * @param effect defines the update shader
  12716. */
  12717. applyToShader(effect: Effect): void;
  12718. /**
  12719. * Returns a string to use to update the GPU particles update shader
  12720. * @returns a string containng the defines string
  12721. */
  12722. getEffectDefines(): string;
  12723. /**
  12724. * Returns the string "SphereDirectedParticleEmitter"
  12725. * @returns a string containing the class name
  12726. */
  12727. getClassName(): string;
  12728. /**
  12729. * Serializes the particle system to a JSON object.
  12730. * @returns the JSON object
  12731. */
  12732. serialize(): any;
  12733. /**
  12734. * Parse properties from a JSON object
  12735. * @param serializationObject defines the JSON object
  12736. */
  12737. parse(serializationObject: any): void;
  12738. }
  12739. }
  12740. declare module BABYLON {
  12741. /**
  12742. * Particle emitter emitting particles from a custom list of positions.
  12743. */
  12744. export class CustomParticleEmitter implements IParticleEmitterType {
  12745. /**
  12746. * Gets or sets the position generator that will create the inital position of each particle.
  12747. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12748. */
  12749. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12750. /**
  12751. * Gets or sets the destination generator that will create the final destination of each particle.
  12752. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12753. */
  12754. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12755. /**
  12756. * Creates a new instance CustomParticleEmitter
  12757. */
  12758. constructor();
  12759. /**
  12760. * Called by the particle System when the direction is computed for the created particle.
  12761. * @param worldMatrix is the world matrix of the particle system
  12762. * @param directionToUpdate is the direction vector to update with the result
  12763. * @param particle is the particle we are computed the direction for
  12764. * @param isLocal defines if the direction should be set in local space
  12765. */
  12766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12767. /**
  12768. * Called by the particle System when the position is computed for the created particle.
  12769. * @param worldMatrix is the world matrix of the particle system
  12770. * @param positionToUpdate is the position vector to update with the result
  12771. * @param particle is the particle we are computed the position for
  12772. * @param isLocal defines if the position should be set in local space
  12773. */
  12774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12775. /**
  12776. * Clones the current emitter and returns a copy of it
  12777. * @returns the new emitter
  12778. */
  12779. clone(): CustomParticleEmitter;
  12780. /**
  12781. * Called by the GPUParticleSystem to setup the update shader
  12782. * @param effect defines the update shader
  12783. */
  12784. applyToShader(effect: Effect): void;
  12785. /**
  12786. * Returns a string to use to update the GPU particles update shader
  12787. * @returns a string containng the defines string
  12788. */
  12789. getEffectDefines(): string;
  12790. /**
  12791. * Returns the string "PointParticleEmitter"
  12792. * @returns a string containing the class name
  12793. */
  12794. getClassName(): string;
  12795. /**
  12796. * Serializes the particle system to a JSON object.
  12797. * @returns the JSON object
  12798. */
  12799. serialize(): any;
  12800. /**
  12801. * Parse properties from a JSON object
  12802. * @param serializationObject defines the JSON object
  12803. */
  12804. parse(serializationObject: any): void;
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /**
  12809. * Particle emitter emitting particles from the inside of a box.
  12810. * It emits the particles randomly between 2 given directions.
  12811. */
  12812. export class MeshParticleEmitter implements IParticleEmitterType {
  12813. /** Defines the mesh to use as source */
  12814. mesh?: AbstractMesh | undefined;
  12815. private _indices;
  12816. private _positions;
  12817. private _normals;
  12818. private _storedNormal;
  12819. /**
  12820. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12821. */
  12822. direction1: Vector3;
  12823. /**
  12824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12825. */
  12826. direction2: Vector3;
  12827. /**
  12828. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12829. */
  12830. useMeshNormalsForDirection: boolean;
  12831. /**
  12832. * Creates a new instance MeshParticleEmitter
  12833. * @param mesh defines the mesh to use as source
  12834. */
  12835. constructor(
  12836. /** Defines the mesh to use as source */
  12837. mesh?: AbstractMesh | undefined);
  12838. /**
  12839. * Called by the particle System when the direction is computed for the created particle.
  12840. * @param worldMatrix is the world matrix of the particle system
  12841. * @param directionToUpdate is the direction vector to update with the result
  12842. * @param particle is the particle we are computed the direction for
  12843. * @param isLocal defines if the direction should be set in local space
  12844. */
  12845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12846. /**
  12847. * Called by the particle System when the position is computed for the created particle.
  12848. * @param worldMatrix is the world matrix of the particle system
  12849. * @param positionToUpdate is the position vector to update with the result
  12850. * @param particle is the particle we are computed the position for
  12851. * @param isLocal defines if the position should be set in local space
  12852. */
  12853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12854. /**
  12855. * Clones the current emitter and returns a copy of it
  12856. * @returns the new emitter
  12857. */
  12858. clone(): MeshParticleEmitter;
  12859. /**
  12860. * Called by the GPUParticleSystem to setup the update shader
  12861. * @param effect defines the update shader
  12862. */
  12863. applyToShader(effect: Effect): void;
  12864. /**
  12865. * Returns a string to use to update the GPU particles update shader
  12866. * @returns a string containng the defines string
  12867. */
  12868. getEffectDefines(): string;
  12869. /**
  12870. * Returns the string "BoxParticleEmitter"
  12871. * @returns a string containing the class name
  12872. */
  12873. getClassName(): string;
  12874. /**
  12875. * Serializes the particle system to a JSON object.
  12876. * @returns the JSON object
  12877. */
  12878. serialize(): any;
  12879. /**
  12880. * Parse properties from a JSON object
  12881. * @param serializationObject defines the JSON object
  12882. * @param scene defines the hosting scene
  12883. */
  12884. parse(serializationObject: any, scene: Scene): void;
  12885. }
  12886. }
  12887. declare module BABYLON {
  12888. /**
  12889. * Interface representing a particle system in Babylon.js.
  12890. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12891. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12892. */
  12893. export interface IParticleSystem {
  12894. /**
  12895. * List of animations used by the particle system.
  12896. */
  12897. animations: Animation[];
  12898. /**
  12899. * The id of the Particle system.
  12900. */
  12901. id: string;
  12902. /**
  12903. * The name of the Particle system.
  12904. */
  12905. name: string;
  12906. /**
  12907. * The emitter represents the Mesh or position we are attaching the particle system to.
  12908. */
  12909. emitter: Nullable<AbstractMesh | Vector3>;
  12910. /**
  12911. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12912. */
  12913. isBillboardBased: boolean;
  12914. /**
  12915. * The rendering group used by the Particle system to chose when to render.
  12916. */
  12917. renderingGroupId: number;
  12918. /**
  12919. * The layer mask we are rendering the particles through.
  12920. */
  12921. layerMask: number;
  12922. /**
  12923. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12924. */
  12925. updateSpeed: number;
  12926. /**
  12927. * The amount of time the particle system is running (depends of the overall update speed).
  12928. */
  12929. targetStopDuration: number;
  12930. /**
  12931. * The texture used to render each particle. (this can be a spritesheet)
  12932. */
  12933. particleTexture: Nullable<Texture>;
  12934. /**
  12935. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12936. */
  12937. blendMode: number;
  12938. /**
  12939. * Minimum life time of emitting particles.
  12940. */
  12941. minLifeTime: number;
  12942. /**
  12943. * Maximum life time of emitting particles.
  12944. */
  12945. maxLifeTime: number;
  12946. /**
  12947. * Minimum Size of emitting particles.
  12948. */
  12949. minSize: number;
  12950. /**
  12951. * Maximum Size of emitting particles.
  12952. */
  12953. maxSize: number;
  12954. /**
  12955. * Minimum scale of emitting particles on X axis.
  12956. */
  12957. minScaleX: number;
  12958. /**
  12959. * Maximum scale of emitting particles on X axis.
  12960. */
  12961. maxScaleX: number;
  12962. /**
  12963. * Minimum scale of emitting particles on Y axis.
  12964. */
  12965. minScaleY: number;
  12966. /**
  12967. * Maximum scale of emitting particles on Y axis.
  12968. */
  12969. maxScaleY: number;
  12970. /**
  12971. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12972. */
  12973. color1: Color4;
  12974. /**
  12975. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12976. */
  12977. color2: Color4;
  12978. /**
  12979. * Color the particle will have at the end of its lifetime.
  12980. */
  12981. colorDead: Color4;
  12982. /**
  12983. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  12984. */
  12985. emitRate: number;
  12986. /**
  12987. * You can use gravity if you want to give an orientation to your particles.
  12988. */
  12989. gravity: Vector3;
  12990. /**
  12991. * Minimum power of emitting particles.
  12992. */
  12993. minEmitPower: number;
  12994. /**
  12995. * Maximum power of emitting particles.
  12996. */
  12997. maxEmitPower: number;
  12998. /**
  12999. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13000. */
  13001. minAngularSpeed: number;
  13002. /**
  13003. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13004. */
  13005. maxAngularSpeed: number;
  13006. /**
  13007. * Gets or sets the minimal initial rotation in radians.
  13008. */
  13009. minInitialRotation: number;
  13010. /**
  13011. * Gets or sets the maximal initial rotation in radians.
  13012. */
  13013. maxInitialRotation: number;
  13014. /**
  13015. * The particle emitter type defines the emitter used by the particle system.
  13016. * It can be for example box, sphere, or cone...
  13017. */
  13018. particleEmitterType: Nullable<IParticleEmitterType>;
  13019. /**
  13020. * Defines the delay in milliseconds before starting the system (0 by default)
  13021. */
  13022. startDelay: number;
  13023. /**
  13024. * 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
  13025. */
  13026. preWarmCycles: number;
  13027. /**
  13028. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13029. */
  13030. preWarmStepOffset: number;
  13031. /**
  13032. * 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)
  13033. */
  13034. spriteCellChangeSpeed: number;
  13035. /**
  13036. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13037. */
  13038. startSpriteCellID: number;
  13039. /**
  13040. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13041. */
  13042. endSpriteCellID: number;
  13043. /**
  13044. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13045. */
  13046. spriteCellWidth: number;
  13047. /**
  13048. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13049. */
  13050. spriteCellHeight: number;
  13051. /**
  13052. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13053. */
  13054. spriteRandomStartCell: boolean;
  13055. /**
  13056. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13057. */
  13058. isAnimationSheetEnabled: boolean;
  13059. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13060. translationPivot: Vector2;
  13061. /**
  13062. * Gets or sets a texture used to add random noise to particle positions
  13063. */
  13064. noiseTexture: Nullable<BaseTexture>;
  13065. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13066. noiseStrength: Vector3;
  13067. /**
  13068. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13069. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13070. */
  13071. billboardMode: number;
  13072. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13073. limitVelocityDamping: number;
  13074. /**
  13075. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13076. */
  13077. beginAnimationOnStart: boolean;
  13078. /**
  13079. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13080. */
  13081. beginAnimationFrom: number;
  13082. /**
  13083. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13084. */
  13085. beginAnimationTo: number;
  13086. /**
  13087. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13088. */
  13089. beginAnimationLoop: boolean;
  13090. /**
  13091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13092. */
  13093. disposeOnStop: boolean;
  13094. /**
  13095. * Specifies if the particles are updated in emitter local space or world space
  13096. */
  13097. isLocal: boolean;
  13098. /**
  13099. * Gets the maximum number of particles active at the same time.
  13100. * @returns The max number of active particles.
  13101. */
  13102. getCapacity(): number;
  13103. /**
  13104. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13105. * @returns True if it has been started, otherwise false.
  13106. */
  13107. isStarted(): boolean;
  13108. /**
  13109. * Animates the particle system for this frame.
  13110. */
  13111. animate(): void;
  13112. /**
  13113. * Renders the particle system in its current state.
  13114. * @returns the current number of particles
  13115. */
  13116. render(): number;
  13117. /**
  13118. * Dispose the particle system and frees its associated resources.
  13119. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13120. */
  13121. dispose(disposeTexture?: boolean): void;
  13122. /**
  13123. * Clones the particle system.
  13124. * @param name The name of the cloned object
  13125. * @param newEmitter The new emitter to use
  13126. * @returns the cloned particle system
  13127. */
  13128. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13129. /**
  13130. * Serializes the particle system to a JSON object.
  13131. * @returns the JSON object
  13132. */
  13133. serialize(): any;
  13134. /**
  13135. * Rebuild the particle system
  13136. */
  13137. rebuild(): void;
  13138. /**
  13139. * Starts the particle system and begins to emit
  13140. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13141. */
  13142. start(delay?: number): void;
  13143. /**
  13144. * Stops the particle system.
  13145. */
  13146. stop(): void;
  13147. /**
  13148. * Remove all active particles
  13149. */
  13150. reset(): void;
  13151. /**
  13152. * Is this system ready to be used/rendered
  13153. * @return true if the system is ready
  13154. */
  13155. isReady(): boolean;
  13156. /**
  13157. * Adds a new color gradient
  13158. * @param gradient defines the gradient to use (between 0 and 1)
  13159. * @param color1 defines the color to affect to the specified gradient
  13160. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13161. * @returns the current particle system
  13162. */
  13163. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13164. /**
  13165. * Remove a specific color gradient
  13166. * @param gradient defines the gradient to remove
  13167. * @returns the current particle system
  13168. */
  13169. removeColorGradient(gradient: number): IParticleSystem;
  13170. /**
  13171. * Adds a new size gradient
  13172. * @param gradient defines the gradient to use (between 0 and 1)
  13173. * @param factor defines the size factor to affect to the specified gradient
  13174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13175. * @returns the current particle system
  13176. */
  13177. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13178. /**
  13179. * Remove a specific size gradient
  13180. * @param gradient defines the gradient to remove
  13181. * @returns the current particle system
  13182. */
  13183. removeSizeGradient(gradient: number): IParticleSystem;
  13184. /**
  13185. * Gets the current list of color gradients.
  13186. * You must use addColorGradient and removeColorGradient to udpate this list
  13187. * @returns the list of color gradients
  13188. */
  13189. getColorGradients(): Nullable<Array<ColorGradient>>;
  13190. /**
  13191. * Gets the current list of size gradients.
  13192. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13193. * @returns the list of size gradients
  13194. */
  13195. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13196. /**
  13197. * Gets the current list of angular speed gradients.
  13198. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13199. * @returns the list of angular speed gradients
  13200. */
  13201. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13202. /**
  13203. * Adds a new angular speed gradient
  13204. * @param gradient defines the gradient to use (between 0 and 1)
  13205. * @param factor defines the angular speed to affect to the specified gradient
  13206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13207. * @returns the current particle system
  13208. */
  13209. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13210. /**
  13211. * Remove a specific angular speed gradient
  13212. * @param gradient defines the gradient to remove
  13213. * @returns the current particle system
  13214. */
  13215. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13216. /**
  13217. * Gets the current list of velocity gradients.
  13218. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13219. * @returns the list of velocity gradients
  13220. */
  13221. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13222. /**
  13223. * Adds a new velocity gradient
  13224. * @param gradient defines the gradient to use (between 0 and 1)
  13225. * @param factor defines the velocity to affect to the specified gradient
  13226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13227. * @returns the current particle system
  13228. */
  13229. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13230. /**
  13231. * Remove a specific velocity gradient
  13232. * @param gradient defines the gradient to remove
  13233. * @returns the current particle system
  13234. */
  13235. removeVelocityGradient(gradient: number): IParticleSystem;
  13236. /**
  13237. * Gets the current list of limit velocity gradients.
  13238. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13239. * @returns the list of limit velocity gradients
  13240. */
  13241. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13242. /**
  13243. * Adds a new limit velocity gradient
  13244. * @param gradient defines the gradient to use (between 0 and 1)
  13245. * @param factor defines the limit velocity to affect to the specified gradient
  13246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13247. * @returns the current particle system
  13248. */
  13249. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13250. /**
  13251. * Remove a specific limit velocity gradient
  13252. * @param gradient defines the gradient to remove
  13253. * @returns the current particle system
  13254. */
  13255. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13256. /**
  13257. * Adds a new drag gradient
  13258. * @param gradient defines the gradient to use (between 0 and 1)
  13259. * @param factor defines the drag to affect to the specified gradient
  13260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13261. * @returns the current particle system
  13262. */
  13263. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13264. /**
  13265. * Remove a specific drag gradient
  13266. * @param gradient defines the gradient to remove
  13267. * @returns the current particle system
  13268. */
  13269. removeDragGradient(gradient: number): IParticleSystem;
  13270. /**
  13271. * Gets the current list of drag gradients.
  13272. * You must use addDragGradient and removeDragGradient to udpate this list
  13273. * @returns the list of drag gradients
  13274. */
  13275. getDragGradients(): Nullable<Array<FactorGradient>>;
  13276. /**
  13277. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13278. * @param gradient defines the gradient to use (between 0 and 1)
  13279. * @param factor defines the emit rate to affect to the specified gradient
  13280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13281. * @returns the current particle system
  13282. */
  13283. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13284. /**
  13285. * Remove a specific emit rate gradient
  13286. * @param gradient defines the gradient to remove
  13287. * @returns the current particle system
  13288. */
  13289. removeEmitRateGradient(gradient: number): IParticleSystem;
  13290. /**
  13291. * Gets the current list of emit rate gradients.
  13292. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13293. * @returns the list of emit rate gradients
  13294. */
  13295. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13296. /**
  13297. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13298. * @param gradient defines the gradient to use (between 0 and 1)
  13299. * @param factor defines the start size to affect to the specified gradient
  13300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13301. * @returns the current particle system
  13302. */
  13303. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13304. /**
  13305. * Remove a specific start size gradient
  13306. * @param gradient defines the gradient to remove
  13307. * @returns the current particle system
  13308. */
  13309. removeStartSizeGradient(gradient: number): IParticleSystem;
  13310. /**
  13311. * Gets the current list of start size gradients.
  13312. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13313. * @returns the list of start size gradients
  13314. */
  13315. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13316. /**
  13317. * Adds a new life time gradient
  13318. * @param gradient defines the gradient to use (between 0 and 1)
  13319. * @param factor defines the life time factor to affect to the specified gradient
  13320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13321. * @returns the current particle system
  13322. */
  13323. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13324. /**
  13325. * Remove a specific life time gradient
  13326. * @param gradient defines the gradient to remove
  13327. * @returns the current particle system
  13328. */
  13329. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13330. /**
  13331. * Gets the current list of life time gradients.
  13332. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13333. * @returns the list of life time gradients
  13334. */
  13335. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13336. /**
  13337. * Gets the current list of color gradients.
  13338. * You must use addColorGradient and removeColorGradient to udpate this list
  13339. * @returns the list of color gradients
  13340. */
  13341. getColorGradients(): Nullable<Array<ColorGradient>>;
  13342. /**
  13343. * Adds a new ramp gradient used to remap particle colors
  13344. * @param gradient defines the gradient to use (between 0 and 1)
  13345. * @param color defines the color to affect to the specified gradient
  13346. * @returns the current particle system
  13347. */
  13348. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13349. /**
  13350. * Gets the current list of ramp gradients.
  13351. * You must use addRampGradient and removeRampGradient to udpate this list
  13352. * @returns the list of ramp gradients
  13353. */
  13354. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13355. /** Gets or sets a boolean indicating that ramp gradients must be used
  13356. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13357. */
  13358. useRampGradients: boolean;
  13359. /**
  13360. * Adds a new color remap gradient
  13361. * @param gradient defines the gradient to use (between 0 and 1)
  13362. * @param min defines the color remap minimal range
  13363. * @param max defines the color remap maximal range
  13364. * @returns the current particle system
  13365. */
  13366. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13367. /**
  13368. * Gets the current list of color remap gradients.
  13369. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13370. * @returns the list of color remap gradients
  13371. */
  13372. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13373. /**
  13374. * Adds a new alpha remap gradient
  13375. * @param gradient defines the gradient to use (between 0 and 1)
  13376. * @param min defines the alpha remap minimal range
  13377. * @param max defines the alpha remap maximal range
  13378. * @returns the current particle system
  13379. */
  13380. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13381. /**
  13382. * Gets the current list of alpha remap gradients.
  13383. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13384. * @returns the list of alpha remap gradients
  13385. */
  13386. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13387. /**
  13388. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13391. * @returns the emitter
  13392. */
  13393. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13394. /**
  13395. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13396. * @param radius The radius of the hemisphere to emit from
  13397. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13398. * @returns the emitter
  13399. */
  13400. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13401. /**
  13402. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13403. * @param radius The radius of the sphere to emit from
  13404. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13405. * @returns the emitter
  13406. */
  13407. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13408. /**
  13409. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13410. * @param radius The radius of the sphere to emit from
  13411. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13412. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13413. * @returns the emitter
  13414. */
  13415. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13416. /**
  13417. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13418. * @param radius The radius of the emission cylinder
  13419. * @param height The height of the emission cylinder
  13420. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13421. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13422. * @returns the emitter
  13423. */
  13424. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13425. /**
  13426. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13427. * @param radius The radius of the cylinder to emit from
  13428. * @param height The height of the emission cylinder
  13429. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13432. * @returns the emitter
  13433. */
  13434. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13435. /**
  13436. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13437. * @param radius The radius of the cone to emit from
  13438. * @param angle The base angle of the cone
  13439. * @returns the emitter
  13440. */
  13441. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13442. /**
  13443. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13446. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13447. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13448. * @returns the emitter
  13449. */
  13450. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13451. /**
  13452. * Get hosting scene
  13453. * @returns the scene
  13454. */
  13455. getScene(): Scene;
  13456. }
  13457. }
  13458. declare module BABYLON {
  13459. /**
  13460. * 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.
  13461. * @see https://doc.babylonjs.com/how_to/transformnode
  13462. */
  13463. export class TransformNode extends Node {
  13464. /**
  13465. * Object will not rotate to face the camera
  13466. */
  13467. static BILLBOARDMODE_NONE: number;
  13468. /**
  13469. * Object will rotate to face the camera but only on the x axis
  13470. */
  13471. static BILLBOARDMODE_X: number;
  13472. /**
  13473. * Object will rotate to face the camera but only on the y axis
  13474. */
  13475. static BILLBOARDMODE_Y: number;
  13476. /**
  13477. * Object will rotate to face the camera but only on the z axis
  13478. */
  13479. static BILLBOARDMODE_Z: number;
  13480. /**
  13481. * Object will rotate to face the camera
  13482. */
  13483. static BILLBOARDMODE_ALL: number;
  13484. /**
  13485. * Object will rotate to face the camera's position instead of orientation
  13486. */
  13487. static BILLBOARDMODE_USE_POSITION: number;
  13488. private _forward;
  13489. private _forwardInverted;
  13490. private _up;
  13491. private _right;
  13492. private _rightInverted;
  13493. private _position;
  13494. private _rotation;
  13495. private _rotationQuaternion;
  13496. protected _scaling: Vector3;
  13497. protected _isDirty: boolean;
  13498. private _transformToBoneReferal;
  13499. private _isAbsoluteSynced;
  13500. private _billboardMode;
  13501. /**
  13502. * Gets or sets the billboard mode. Default is 0.
  13503. *
  13504. * | Value | Type | Description |
  13505. * | --- | --- | --- |
  13506. * | 0 | BILLBOARDMODE_NONE | |
  13507. * | 1 | BILLBOARDMODE_X | |
  13508. * | 2 | BILLBOARDMODE_Y | |
  13509. * | 4 | BILLBOARDMODE_Z | |
  13510. * | 7 | BILLBOARDMODE_ALL | |
  13511. *
  13512. */
  13513. get billboardMode(): number;
  13514. set billboardMode(value: number);
  13515. private _preserveParentRotationForBillboard;
  13516. /**
  13517. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13518. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13519. */
  13520. get preserveParentRotationForBillboard(): boolean;
  13521. set preserveParentRotationForBillboard(value: boolean);
  13522. /**
  13523. * 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
  13524. */
  13525. scalingDeterminant: number;
  13526. private _infiniteDistance;
  13527. /**
  13528. * Gets or sets the distance of the object to max, often used by skybox
  13529. */
  13530. get infiniteDistance(): boolean;
  13531. set infiniteDistance(value: boolean);
  13532. /**
  13533. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13534. * By default the system will update normals to compensate
  13535. */
  13536. ignoreNonUniformScaling: boolean;
  13537. /**
  13538. * 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
  13539. */
  13540. reIntegrateRotationIntoRotationQuaternion: boolean;
  13541. /** @hidden */
  13542. _poseMatrix: Nullable<Matrix>;
  13543. /** @hidden */
  13544. _localMatrix: Matrix;
  13545. private _usePivotMatrix;
  13546. private _absolutePosition;
  13547. private _absoluteScaling;
  13548. private _absoluteRotationQuaternion;
  13549. private _pivotMatrix;
  13550. private _pivotMatrixInverse;
  13551. protected _postMultiplyPivotMatrix: boolean;
  13552. protected _isWorldMatrixFrozen: boolean;
  13553. /** @hidden */
  13554. _indexInSceneTransformNodesArray: number;
  13555. /**
  13556. * An event triggered after the world matrix is updated
  13557. */
  13558. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13559. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13560. /**
  13561. * Gets a string identifying the name of the class
  13562. * @returns "TransformNode" string
  13563. */
  13564. getClassName(): string;
  13565. /**
  13566. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13567. */
  13568. get position(): Vector3;
  13569. set position(newPosition: Vector3);
  13570. /**
  13571. * 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)).
  13572. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13573. */
  13574. get rotation(): Vector3;
  13575. set rotation(newRotation: Vector3);
  13576. /**
  13577. * 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)).
  13578. */
  13579. get scaling(): Vector3;
  13580. set scaling(newScaling: Vector3);
  13581. /**
  13582. * 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).
  13583. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13584. */
  13585. get rotationQuaternion(): Nullable<Quaternion>;
  13586. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13587. /**
  13588. * The forward direction of that transform in world space.
  13589. */
  13590. get forward(): Vector3;
  13591. /**
  13592. * The up direction of that transform in world space.
  13593. */
  13594. get up(): Vector3;
  13595. /**
  13596. * The right direction of that transform in world space.
  13597. */
  13598. get right(): Vector3;
  13599. /**
  13600. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13601. * @param matrix the matrix to copy the pose from
  13602. * @returns this TransformNode.
  13603. */
  13604. updatePoseMatrix(matrix: Matrix): TransformNode;
  13605. /**
  13606. * Returns the mesh Pose matrix.
  13607. * @returns the pose matrix
  13608. */
  13609. getPoseMatrix(): Matrix;
  13610. /** @hidden */
  13611. _isSynchronized(): boolean;
  13612. /** @hidden */
  13613. _initCache(): void;
  13614. /**
  13615. * Flag the transform node as dirty (Forcing it to update everything)
  13616. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13617. * @returns this transform node
  13618. */
  13619. markAsDirty(property: string): TransformNode;
  13620. /**
  13621. * Returns the current mesh absolute position.
  13622. * Returns a Vector3.
  13623. */
  13624. get absolutePosition(): Vector3;
  13625. /**
  13626. * Returns the current mesh absolute scaling.
  13627. * Returns a Vector3.
  13628. */
  13629. get absoluteScaling(): Vector3;
  13630. /**
  13631. * Returns the current mesh absolute rotation.
  13632. * Returns a Quaternion.
  13633. */
  13634. get absoluteRotationQuaternion(): Quaternion;
  13635. /**
  13636. * Sets a new matrix to apply before all other transformation
  13637. * @param matrix defines the transform matrix
  13638. * @returns the current TransformNode
  13639. */
  13640. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13641. /**
  13642. * Sets a new pivot matrix to the current node
  13643. * @param matrix defines the new pivot matrix to use
  13644. * @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
  13645. * @returns the current TransformNode
  13646. */
  13647. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13648. /**
  13649. * Returns the mesh pivot matrix.
  13650. * Default : Identity.
  13651. * @returns the matrix
  13652. */
  13653. getPivotMatrix(): Matrix;
  13654. /**
  13655. * Instantiate (when possible) or clone that node with its hierarchy
  13656. * @param newParent defines the new parent to use for the instance (or clone)
  13657. * @param options defines options to configure how copy is done
  13658. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13659. * @returns an instance (or a clone) of the current node with its hiearchy
  13660. */
  13661. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13662. doNotInstantiate: boolean;
  13663. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13664. /**
  13665. * Prevents the World matrix to be computed any longer
  13666. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13667. * @returns the TransformNode.
  13668. */
  13669. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13670. /**
  13671. * Allows back the World matrix computation.
  13672. * @returns the TransformNode.
  13673. */
  13674. unfreezeWorldMatrix(): this;
  13675. /**
  13676. * True if the World matrix has been frozen.
  13677. */
  13678. get isWorldMatrixFrozen(): boolean;
  13679. /**
  13680. * Retuns the mesh absolute position in the World.
  13681. * @returns a Vector3.
  13682. */
  13683. getAbsolutePosition(): Vector3;
  13684. /**
  13685. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13686. * @param absolutePosition the absolute position to set
  13687. * @returns the TransformNode.
  13688. */
  13689. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13690. /**
  13691. * Sets the mesh position in its local space.
  13692. * @param vector3 the position to set in localspace
  13693. * @returns the TransformNode.
  13694. */
  13695. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13696. /**
  13697. * Returns the mesh position in the local space from the current World matrix values.
  13698. * @returns a new Vector3.
  13699. */
  13700. getPositionExpressedInLocalSpace(): Vector3;
  13701. /**
  13702. * Translates the mesh along the passed Vector3 in its local space.
  13703. * @param vector3 the distance to translate in localspace
  13704. * @returns the TransformNode.
  13705. */
  13706. locallyTranslate(vector3: Vector3): TransformNode;
  13707. private static _lookAtVectorCache;
  13708. /**
  13709. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13710. * @param targetPoint the position (must be in same space as current mesh) to look at
  13711. * @param yawCor optional yaw (y-axis) correction in radians
  13712. * @param pitchCor optional pitch (x-axis) correction in radians
  13713. * @param rollCor optional roll (z-axis) correction in radians
  13714. * @param space the choosen space of the target
  13715. * @returns the TransformNode.
  13716. */
  13717. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13718. /**
  13719. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13720. * This Vector3 is expressed in the World space.
  13721. * @param localAxis axis to rotate
  13722. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13723. */
  13724. getDirection(localAxis: Vector3): Vector3;
  13725. /**
  13726. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13727. * localAxis is expressed in the mesh local space.
  13728. * result is computed in the Wordl space from the mesh World matrix.
  13729. * @param localAxis axis to rotate
  13730. * @param result the resulting transformnode
  13731. * @returns this TransformNode.
  13732. */
  13733. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13734. /**
  13735. * Sets this transform node rotation to the given local axis.
  13736. * @param localAxis the axis in local space
  13737. * @param yawCor optional yaw (y-axis) correction in radians
  13738. * @param pitchCor optional pitch (x-axis) correction in radians
  13739. * @param rollCor optional roll (z-axis) correction in radians
  13740. * @returns this TransformNode
  13741. */
  13742. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13743. /**
  13744. * Sets a new pivot point to the current node
  13745. * @param point defines the new pivot point to use
  13746. * @param space defines if the point is in world or local space (local by default)
  13747. * @returns the current TransformNode
  13748. */
  13749. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13750. /**
  13751. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13752. * @returns the pivot point
  13753. */
  13754. getPivotPoint(): Vector3;
  13755. /**
  13756. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13757. * @param result the vector3 to store the result
  13758. * @returns this TransformNode.
  13759. */
  13760. getPivotPointToRef(result: Vector3): TransformNode;
  13761. /**
  13762. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13763. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13764. */
  13765. getAbsolutePivotPoint(): Vector3;
  13766. /**
  13767. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13768. * @param result vector3 to store the result
  13769. * @returns this TransformNode.
  13770. */
  13771. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13772. /**
  13773. * Defines the passed node as the parent of the current node.
  13774. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13775. * @see https://doc.babylonjs.com/how_to/parenting
  13776. * @param node the node ot set as the parent
  13777. * @returns this TransformNode.
  13778. */
  13779. setParent(node: Nullable<Node>): TransformNode;
  13780. private _nonUniformScaling;
  13781. /**
  13782. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13783. */
  13784. get nonUniformScaling(): boolean;
  13785. /** @hidden */
  13786. _updateNonUniformScalingState(value: boolean): boolean;
  13787. /**
  13788. * Attach the current TransformNode to another TransformNode associated with a bone
  13789. * @param bone Bone affecting the TransformNode
  13790. * @param affectedTransformNode TransformNode associated with the bone
  13791. * @returns this object
  13792. */
  13793. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13794. /**
  13795. * Detach the transform node if its associated with a bone
  13796. * @returns this object
  13797. */
  13798. detachFromBone(): TransformNode;
  13799. private static _rotationAxisCache;
  13800. /**
  13801. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13802. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13803. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13804. * The passed axis is also normalized.
  13805. * @param axis the axis to rotate around
  13806. * @param amount the amount to rotate in radians
  13807. * @param space Space to rotate in (Default: local)
  13808. * @returns the TransformNode.
  13809. */
  13810. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13811. /**
  13812. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13813. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13814. * The passed axis is also normalized. .
  13815. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13816. * @param point the point to rotate around
  13817. * @param axis the axis to rotate around
  13818. * @param amount the amount to rotate in radians
  13819. * @returns the TransformNode
  13820. */
  13821. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13822. /**
  13823. * Translates the mesh along the axis vector for the passed distance in the given space.
  13824. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13825. * @param axis the axis to translate in
  13826. * @param distance the distance to translate
  13827. * @param space Space to rotate in (Default: local)
  13828. * @returns the TransformNode.
  13829. */
  13830. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13831. /**
  13832. * Adds a rotation step to the mesh current rotation.
  13833. * x, y, z are Euler angles expressed in radians.
  13834. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13835. * This means this rotation is made in the mesh local space only.
  13836. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13837. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13838. * ```javascript
  13839. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13840. * ```
  13841. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13842. * 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.
  13843. * @param x Rotation to add
  13844. * @param y Rotation to add
  13845. * @param z Rotation to add
  13846. * @returns the TransformNode.
  13847. */
  13848. addRotation(x: number, y: number, z: number): TransformNode;
  13849. /**
  13850. * @hidden
  13851. */
  13852. protected _getEffectiveParent(): Nullable<Node>;
  13853. /**
  13854. * Computes the world matrix of the node
  13855. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13856. * @returns the world matrix
  13857. */
  13858. computeWorldMatrix(force?: boolean): Matrix;
  13859. /**
  13860. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13861. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13862. */
  13863. resetLocalMatrix(independentOfChildren?: boolean): void;
  13864. protected _afterComputeWorldMatrix(): void;
  13865. /**
  13866. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13867. * @param func callback function to add
  13868. *
  13869. * @returns the TransformNode.
  13870. */
  13871. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13872. /**
  13873. * Removes a registered callback function.
  13874. * @param func callback function to remove
  13875. * @returns the TransformNode.
  13876. */
  13877. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13878. /**
  13879. * Gets the position of the current mesh in camera space
  13880. * @param camera defines the camera to use
  13881. * @returns a position
  13882. */
  13883. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13884. /**
  13885. * Returns the distance from the mesh to the active camera
  13886. * @param camera defines the camera to use
  13887. * @returns the distance
  13888. */
  13889. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13890. /**
  13891. * Clone the current transform node
  13892. * @param name Name of the new clone
  13893. * @param newParent New parent for the clone
  13894. * @param doNotCloneChildren Do not clone children hierarchy
  13895. * @returns the new transform node
  13896. */
  13897. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13898. /**
  13899. * Serializes the objects information.
  13900. * @param currentSerializationObject defines the object to serialize in
  13901. * @returns the serialized object
  13902. */
  13903. serialize(currentSerializationObject?: any): any;
  13904. /**
  13905. * Returns a new TransformNode object parsed from the source provided.
  13906. * @param parsedTransformNode is the source.
  13907. * @param scene the scne the object belongs to
  13908. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13909. * @returns a new TransformNode object parsed from the source provided.
  13910. */
  13911. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13912. /**
  13913. * Get all child-transformNodes of this node
  13914. * @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
  13915. * @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
  13916. * @returns an array of TransformNode
  13917. */
  13918. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13919. /**
  13920. * Releases resources associated with this transform node.
  13921. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13922. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13923. */
  13924. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13925. /**
  13926. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13927. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13928. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13929. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13930. * @returns the current mesh
  13931. */
  13932. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13933. private _syncAbsoluteScalingAndRotation;
  13934. }
  13935. }
  13936. declare module BABYLON {
  13937. /**
  13938. * Class used to override all child animations of a given target
  13939. */
  13940. export class AnimationPropertiesOverride {
  13941. /**
  13942. * Gets or sets a value indicating if animation blending must be used
  13943. */
  13944. enableBlending: boolean;
  13945. /**
  13946. * Gets or sets the blending speed to use when enableBlending is true
  13947. */
  13948. blendingSpeed: number;
  13949. /**
  13950. * Gets or sets the default loop mode to use
  13951. */
  13952. loopMode: number;
  13953. }
  13954. }
  13955. declare module BABYLON {
  13956. /**
  13957. * Class used to store bone information
  13958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13959. */
  13960. export class Bone extends Node {
  13961. /**
  13962. * defines the bone name
  13963. */
  13964. name: string;
  13965. private static _tmpVecs;
  13966. private static _tmpQuat;
  13967. private static _tmpMats;
  13968. /**
  13969. * Gets the list of child bones
  13970. */
  13971. children: Bone[];
  13972. /** Gets the animations associated with this bone */
  13973. animations: Animation[];
  13974. /**
  13975. * Gets or sets bone length
  13976. */
  13977. length: number;
  13978. /**
  13979. * @hidden Internal only
  13980. * Set this value to map this bone to a different index in the transform matrices
  13981. * Set this value to -1 to exclude the bone from the transform matrices
  13982. */
  13983. _index: Nullable<number>;
  13984. private _skeleton;
  13985. private _localMatrix;
  13986. private _restPose;
  13987. private _baseMatrix;
  13988. private _absoluteTransform;
  13989. private _invertedAbsoluteTransform;
  13990. private _parent;
  13991. private _scalingDeterminant;
  13992. private _worldTransform;
  13993. private _localScaling;
  13994. private _localRotation;
  13995. private _localPosition;
  13996. private _needToDecompose;
  13997. private _needToCompose;
  13998. /** @hidden */
  13999. _linkedTransformNode: Nullable<TransformNode>;
  14000. /** @hidden */
  14001. _waitingTransformNodeId: Nullable<string>;
  14002. /** @hidden */
  14003. get _matrix(): Matrix;
  14004. /** @hidden */
  14005. set _matrix(value: Matrix);
  14006. /**
  14007. * Create a new bone
  14008. * @param name defines the bone name
  14009. * @param skeleton defines the parent skeleton
  14010. * @param parentBone defines the parent (can be null if the bone is the root)
  14011. * @param localMatrix defines the local matrix
  14012. * @param restPose defines the rest pose matrix
  14013. * @param baseMatrix defines the base matrix
  14014. * @param index defines index of the bone in the hiearchy
  14015. */
  14016. constructor(
  14017. /**
  14018. * defines the bone name
  14019. */
  14020. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14021. /**
  14022. * Gets the current object class name.
  14023. * @return the class name
  14024. */
  14025. getClassName(): string;
  14026. /**
  14027. * Gets the parent skeleton
  14028. * @returns a skeleton
  14029. */
  14030. getSkeleton(): Skeleton;
  14031. /**
  14032. * Gets parent bone
  14033. * @returns a bone or null if the bone is the root of the bone hierarchy
  14034. */
  14035. getParent(): Nullable<Bone>;
  14036. /**
  14037. * Returns an array containing the root bones
  14038. * @returns an array containing the root bones
  14039. */
  14040. getChildren(): Array<Bone>;
  14041. /**
  14042. * Gets the node index in matrix array generated for rendering
  14043. * @returns the node index
  14044. */
  14045. getIndex(): number;
  14046. /**
  14047. * Sets the parent bone
  14048. * @param parent defines the parent (can be null if the bone is the root)
  14049. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14050. */
  14051. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14052. /**
  14053. * Gets the local matrix
  14054. * @returns a matrix
  14055. */
  14056. getLocalMatrix(): Matrix;
  14057. /**
  14058. * Gets the base matrix (initial matrix which remains unchanged)
  14059. * @returns a matrix
  14060. */
  14061. getBaseMatrix(): Matrix;
  14062. /**
  14063. * Gets the rest pose matrix
  14064. * @returns a matrix
  14065. */
  14066. getRestPose(): Matrix;
  14067. /**
  14068. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14069. */
  14070. getWorldMatrix(): Matrix;
  14071. /**
  14072. * Sets the local matrix to rest pose matrix
  14073. */
  14074. returnToRest(): void;
  14075. /**
  14076. * Gets the inverse of the absolute transform matrix.
  14077. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14078. * @returns a matrix
  14079. */
  14080. getInvertedAbsoluteTransform(): Matrix;
  14081. /**
  14082. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14083. * @returns a matrix
  14084. */
  14085. getAbsoluteTransform(): Matrix;
  14086. /**
  14087. * Links with the given transform node.
  14088. * The local matrix of this bone is copied from the transform node every frame.
  14089. * @param transformNode defines the transform node to link to
  14090. */
  14091. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14092. /**
  14093. * Gets the node used to drive the bone's transformation
  14094. * @returns a transform node or null
  14095. */
  14096. getTransformNode(): Nullable<TransformNode>;
  14097. /** Gets or sets current position (in local space) */
  14098. get position(): Vector3;
  14099. set position(newPosition: Vector3);
  14100. /** Gets or sets current rotation (in local space) */
  14101. get rotation(): Vector3;
  14102. set rotation(newRotation: Vector3);
  14103. /** Gets or sets current rotation quaternion (in local space) */
  14104. get rotationQuaternion(): Quaternion;
  14105. set rotationQuaternion(newRotation: Quaternion);
  14106. /** Gets or sets current scaling (in local space) */
  14107. get scaling(): Vector3;
  14108. set scaling(newScaling: Vector3);
  14109. /**
  14110. * Gets the animation properties override
  14111. */
  14112. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14113. private _decompose;
  14114. private _compose;
  14115. /**
  14116. * Update the base and local matrices
  14117. * @param matrix defines the new base or local matrix
  14118. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14119. * @param updateLocalMatrix defines if the local matrix should be updated
  14120. */
  14121. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14122. /** @hidden */
  14123. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14124. /**
  14125. * Flag the bone as dirty (Forcing it to update everything)
  14126. */
  14127. markAsDirty(): void;
  14128. /** @hidden */
  14129. _markAsDirtyAndCompose(): void;
  14130. private _markAsDirtyAndDecompose;
  14131. /**
  14132. * Translate the bone in local or world space
  14133. * @param vec The amount to translate the bone
  14134. * @param space The space that the translation is in
  14135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14136. */
  14137. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14138. /**
  14139. * Set the postion of the bone in local or world space
  14140. * @param position The position to set the bone
  14141. * @param space The space that the position is in
  14142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14143. */
  14144. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14145. /**
  14146. * Set the absolute position of the bone (world space)
  14147. * @param position The position to set the bone
  14148. * @param mesh The mesh that this bone is attached to
  14149. */
  14150. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14151. /**
  14152. * Scale the bone on the x, y and z axes (in local space)
  14153. * @param x The amount to scale the bone on the x axis
  14154. * @param y The amount to scale the bone on the y axis
  14155. * @param z The amount to scale the bone on the z axis
  14156. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14157. */
  14158. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14159. /**
  14160. * Set the bone scaling in local space
  14161. * @param scale defines the scaling vector
  14162. */
  14163. setScale(scale: Vector3): void;
  14164. /**
  14165. * Gets the current scaling in local space
  14166. * @returns the current scaling vector
  14167. */
  14168. getScale(): Vector3;
  14169. /**
  14170. * Gets the current scaling in local space and stores it in a target vector
  14171. * @param result defines the target vector
  14172. */
  14173. getScaleToRef(result: Vector3): void;
  14174. /**
  14175. * Set the yaw, pitch, and roll of the bone in local or world space
  14176. * @param yaw The rotation of the bone on the y axis
  14177. * @param pitch The rotation of the bone on the x axis
  14178. * @param roll The rotation of the bone on the z axis
  14179. * @param space The space that the axes of rotation are in
  14180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14181. */
  14182. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14183. /**
  14184. * Add a rotation to the bone on an axis in local or world space
  14185. * @param axis The axis to rotate the bone on
  14186. * @param amount The amount to rotate the bone
  14187. * @param space The space that the axis is in
  14188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14189. */
  14190. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14191. /**
  14192. * Set the rotation of the bone to a particular axis angle in local or world space
  14193. * @param axis The axis to rotate the bone on
  14194. * @param angle The angle that the bone should be rotated to
  14195. * @param space The space that the axis is in
  14196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14197. */
  14198. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14199. /**
  14200. * Set the euler rotation of the bone in local of world space
  14201. * @param rotation The euler rotation that the bone should be set to
  14202. * @param space The space that the rotation is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. */
  14205. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14206. /**
  14207. * Set the quaternion rotation of the bone in local of world space
  14208. * @param quat The quaternion rotation that the bone should be set to
  14209. * @param space The space that the rotation is in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. */
  14212. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14213. /**
  14214. * Set the rotation matrix of the bone in local of world space
  14215. * @param rotMat The rotation matrix that the bone should be set to
  14216. * @param space The space that the rotation is in
  14217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14218. */
  14219. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14220. private _rotateWithMatrix;
  14221. private _getNegativeRotationToRef;
  14222. /**
  14223. * Get the position of the bone in local or world space
  14224. * @param space The space that the returned position is in
  14225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14226. * @returns The position of the bone
  14227. */
  14228. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14229. /**
  14230. * Copy the position of the bone to a vector3 in local or world space
  14231. * @param space The space that the returned position is in
  14232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14233. * @param result The vector3 to copy the position to
  14234. */
  14235. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14236. /**
  14237. * Get the absolute position of the bone (world space)
  14238. * @param mesh The mesh that this bone is attached to
  14239. * @returns The absolute position of the bone
  14240. */
  14241. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14242. /**
  14243. * Copy the absolute position of the bone (world space) to the result param
  14244. * @param mesh The mesh that this bone is attached to
  14245. * @param result The vector3 to copy the absolute position to
  14246. */
  14247. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14248. /**
  14249. * Compute the absolute transforms of this bone and its children
  14250. */
  14251. computeAbsoluteTransforms(): void;
  14252. /**
  14253. * Get the world direction from an axis that is in the local space of the bone
  14254. * @param localAxis The local direction that is used to compute the world direction
  14255. * @param mesh The mesh that this bone is attached to
  14256. * @returns The world direction
  14257. */
  14258. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14259. /**
  14260. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14261. * @param localAxis The local direction that is used to compute the world direction
  14262. * @param mesh The mesh that this bone is attached to
  14263. * @param result The vector3 that the world direction will be copied to
  14264. */
  14265. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14266. /**
  14267. * Get the euler rotation of the bone in local or world space
  14268. * @param space The space that the rotation should be in
  14269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14270. * @returns The euler rotation
  14271. */
  14272. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14273. /**
  14274. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14275. * @param space The space that the rotation should be in
  14276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14277. * @param result The vector3 that the rotation should be copied to
  14278. */
  14279. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14280. /**
  14281. * Get the quaternion rotation of the bone in either local or world space
  14282. * @param space The space that the rotation should be in
  14283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14284. * @returns The quaternion rotation
  14285. */
  14286. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14287. /**
  14288. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14289. * @param space The space that the rotation should be in
  14290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14291. * @param result The quaternion that the rotation should be copied to
  14292. */
  14293. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14294. /**
  14295. * Get the rotation matrix of the bone in local or world space
  14296. * @param space The space that the rotation should be in
  14297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14298. * @returns The rotation matrix
  14299. */
  14300. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14301. /**
  14302. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14303. * @param space The space that the rotation should be in
  14304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14305. * @param result The quaternion that the rotation should be copied to
  14306. */
  14307. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14308. /**
  14309. * Get the world position of a point that is in the local space of the bone
  14310. * @param position The local position
  14311. * @param mesh The mesh that this bone is attached to
  14312. * @returns The world position
  14313. */
  14314. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14315. /**
  14316. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14317. * @param position The local position
  14318. * @param mesh The mesh that this bone is attached to
  14319. * @param result The vector3 that the world position should be copied to
  14320. */
  14321. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14322. /**
  14323. * Get the local position of a point that is in world space
  14324. * @param position The world position
  14325. * @param mesh The mesh that this bone is attached to
  14326. * @returns The local position
  14327. */
  14328. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14329. /**
  14330. * Get the local position of a point that is in world space and copy it to the result param
  14331. * @param position The world position
  14332. * @param mesh The mesh that this bone is attached to
  14333. * @param result The vector3 that the local position should be copied to
  14334. */
  14335. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14336. }
  14337. }
  14338. declare module BABYLON {
  14339. /**
  14340. * Defines a runtime animation
  14341. */
  14342. export class RuntimeAnimation {
  14343. private _events;
  14344. /**
  14345. * The current frame of the runtime animation
  14346. */
  14347. private _currentFrame;
  14348. /**
  14349. * The animation used by the runtime animation
  14350. */
  14351. private _animation;
  14352. /**
  14353. * The target of the runtime animation
  14354. */
  14355. private _target;
  14356. /**
  14357. * The initiating animatable
  14358. */
  14359. private _host;
  14360. /**
  14361. * The original value of the runtime animation
  14362. */
  14363. private _originalValue;
  14364. /**
  14365. * The original blend value of the runtime animation
  14366. */
  14367. private _originalBlendValue;
  14368. /**
  14369. * The offsets cache of the runtime animation
  14370. */
  14371. private _offsetsCache;
  14372. /**
  14373. * The high limits cache of the runtime animation
  14374. */
  14375. private _highLimitsCache;
  14376. /**
  14377. * Specifies if the runtime animation has been stopped
  14378. */
  14379. private _stopped;
  14380. /**
  14381. * The blending factor of the runtime animation
  14382. */
  14383. private _blendingFactor;
  14384. /**
  14385. * The BabylonJS scene
  14386. */
  14387. private _scene;
  14388. /**
  14389. * The current value of the runtime animation
  14390. */
  14391. private _currentValue;
  14392. /** @hidden */
  14393. _animationState: _IAnimationState;
  14394. /**
  14395. * The active target of the runtime animation
  14396. */
  14397. private _activeTargets;
  14398. private _currentActiveTarget;
  14399. private _directTarget;
  14400. /**
  14401. * The target path of the runtime animation
  14402. */
  14403. private _targetPath;
  14404. /**
  14405. * The weight of the runtime animation
  14406. */
  14407. private _weight;
  14408. /**
  14409. * The ratio offset of the runtime animation
  14410. */
  14411. private _ratioOffset;
  14412. /**
  14413. * The previous delay of the runtime animation
  14414. */
  14415. private _previousDelay;
  14416. /**
  14417. * The previous ratio of the runtime animation
  14418. */
  14419. private _previousRatio;
  14420. private _enableBlending;
  14421. private _keys;
  14422. private _minFrame;
  14423. private _maxFrame;
  14424. private _minValue;
  14425. private _maxValue;
  14426. private _targetIsArray;
  14427. /**
  14428. * Gets the current frame of the runtime animation
  14429. */
  14430. get currentFrame(): number;
  14431. /**
  14432. * Gets the weight of the runtime animation
  14433. */
  14434. get weight(): number;
  14435. /**
  14436. * Gets the current value of the runtime animation
  14437. */
  14438. get currentValue(): any;
  14439. /**
  14440. * Gets the target path of the runtime animation
  14441. */
  14442. get targetPath(): string;
  14443. /**
  14444. * Gets the actual target of the runtime animation
  14445. */
  14446. get target(): any;
  14447. /** @hidden */
  14448. _onLoop: () => void;
  14449. /**
  14450. * Create a new RuntimeAnimation object
  14451. * @param target defines the target of the animation
  14452. * @param animation defines the source animation object
  14453. * @param scene defines the hosting scene
  14454. * @param host defines the initiating Animatable
  14455. */
  14456. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14457. private _preparePath;
  14458. /**
  14459. * Gets the animation from the runtime animation
  14460. */
  14461. get animation(): Animation;
  14462. /**
  14463. * Resets the runtime animation to the beginning
  14464. * @param restoreOriginal defines whether to restore the target property to the original value
  14465. */
  14466. reset(restoreOriginal?: boolean): void;
  14467. /**
  14468. * Specifies if the runtime animation is stopped
  14469. * @returns Boolean specifying if the runtime animation is stopped
  14470. */
  14471. isStopped(): boolean;
  14472. /**
  14473. * Disposes of the runtime animation
  14474. */
  14475. dispose(): void;
  14476. /**
  14477. * Apply the interpolated value to the target
  14478. * @param currentValue defines the value computed by the animation
  14479. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14480. */
  14481. setValue(currentValue: any, weight: number): void;
  14482. private _getOriginalValues;
  14483. private _setValue;
  14484. /**
  14485. * Gets the loop pmode of the runtime animation
  14486. * @returns Loop Mode
  14487. */
  14488. private _getCorrectLoopMode;
  14489. /**
  14490. * Move the current animation to a given frame
  14491. * @param frame defines the frame to move to
  14492. */
  14493. goToFrame(frame: number): void;
  14494. /**
  14495. * @hidden Internal use only
  14496. */
  14497. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14498. /**
  14499. * Execute the current animation
  14500. * @param delay defines the delay to add to the current frame
  14501. * @param from defines the lower bound of the animation range
  14502. * @param to defines the upper bound of the animation range
  14503. * @param loop defines if the current animation must loop
  14504. * @param speedRatio defines the current speed ratio
  14505. * @param weight defines the weight of the animation (default is -1 so no weight)
  14506. * @param onLoop optional callback called when animation loops
  14507. * @returns a boolean indicating if the animation is running
  14508. */
  14509. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14510. }
  14511. }
  14512. declare module BABYLON {
  14513. /**
  14514. * Class used to store an actual running animation
  14515. */
  14516. export class Animatable {
  14517. /** defines the target object */
  14518. target: any;
  14519. /** defines the starting frame number (default is 0) */
  14520. fromFrame: number;
  14521. /** defines the ending frame number (default is 100) */
  14522. toFrame: number;
  14523. /** defines if the animation must loop (default is false) */
  14524. loopAnimation: boolean;
  14525. /** defines a callback to call when animation ends if it is not looping */
  14526. onAnimationEnd?: (() => void) | null | undefined;
  14527. /** defines a callback to call when animation loops */
  14528. onAnimationLoop?: (() => void) | null | undefined;
  14529. private _localDelayOffset;
  14530. private _pausedDelay;
  14531. private _runtimeAnimations;
  14532. private _paused;
  14533. private _scene;
  14534. private _speedRatio;
  14535. private _weight;
  14536. private _syncRoot;
  14537. /**
  14538. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14539. * This will only apply for non looping animation (default is true)
  14540. */
  14541. disposeOnEnd: boolean;
  14542. /**
  14543. * Gets a boolean indicating if the animation has started
  14544. */
  14545. animationStarted: boolean;
  14546. /**
  14547. * Observer raised when the animation ends
  14548. */
  14549. onAnimationEndObservable: Observable<Animatable>;
  14550. /**
  14551. * Observer raised when the animation loops
  14552. */
  14553. onAnimationLoopObservable: Observable<Animatable>;
  14554. /**
  14555. * Gets the root Animatable used to synchronize and normalize animations
  14556. */
  14557. get syncRoot(): Nullable<Animatable>;
  14558. /**
  14559. * Gets the current frame of the first RuntimeAnimation
  14560. * Used to synchronize Animatables
  14561. */
  14562. get masterFrame(): number;
  14563. /**
  14564. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14565. */
  14566. get weight(): number;
  14567. set weight(value: number);
  14568. /**
  14569. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14570. */
  14571. get speedRatio(): number;
  14572. set speedRatio(value: number);
  14573. /**
  14574. * Creates a new Animatable
  14575. * @param scene defines the hosting scene
  14576. * @param target defines the target object
  14577. * @param fromFrame defines the starting frame number (default is 0)
  14578. * @param toFrame defines the ending frame number (default is 100)
  14579. * @param loopAnimation defines if the animation must loop (default is false)
  14580. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14581. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14582. * @param animations defines a group of animation to add to the new Animatable
  14583. * @param onAnimationLoop defines a callback to call when animation loops
  14584. */
  14585. constructor(scene: Scene,
  14586. /** defines the target object */
  14587. target: any,
  14588. /** defines the starting frame number (default is 0) */
  14589. fromFrame?: number,
  14590. /** defines the ending frame number (default is 100) */
  14591. toFrame?: number,
  14592. /** defines if the animation must loop (default is false) */
  14593. loopAnimation?: boolean, speedRatio?: number,
  14594. /** defines a callback to call when animation ends if it is not looping */
  14595. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14596. /** defines a callback to call when animation loops */
  14597. onAnimationLoop?: (() => void) | null | undefined);
  14598. /**
  14599. * Synchronize and normalize current Animatable with a source Animatable
  14600. * This is useful when using animation weights and when animations are not of the same length
  14601. * @param root defines the root Animatable to synchronize with
  14602. * @returns the current Animatable
  14603. */
  14604. syncWith(root: Animatable): Animatable;
  14605. /**
  14606. * Gets the list of runtime animations
  14607. * @returns an array of RuntimeAnimation
  14608. */
  14609. getAnimations(): RuntimeAnimation[];
  14610. /**
  14611. * Adds more animations to the current animatable
  14612. * @param target defines the target of the animations
  14613. * @param animations defines the new animations to add
  14614. */
  14615. appendAnimations(target: any, animations: Animation[]): void;
  14616. /**
  14617. * Gets the source animation for a specific property
  14618. * @param property defines the propertyu to look for
  14619. * @returns null or the source animation for the given property
  14620. */
  14621. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14622. /**
  14623. * Gets the runtime animation for a specific property
  14624. * @param property defines the propertyu to look for
  14625. * @returns null or the runtime animation for the given property
  14626. */
  14627. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14628. /**
  14629. * Resets the animatable to its original state
  14630. */
  14631. reset(): void;
  14632. /**
  14633. * Allows the animatable to blend with current running animations
  14634. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14635. * @param blendingSpeed defines the blending speed to use
  14636. */
  14637. enableBlending(blendingSpeed: number): void;
  14638. /**
  14639. * Disable animation blending
  14640. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14641. */
  14642. disableBlending(): void;
  14643. /**
  14644. * Jump directly to a given frame
  14645. * @param frame defines the frame to jump to
  14646. */
  14647. goToFrame(frame: number): void;
  14648. /**
  14649. * Pause the animation
  14650. */
  14651. pause(): void;
  14652. /**
  14653. * Restart the animation
  14654. */
  14655. restart(): void;
  14656. private _raiseOnAnimationEnd;
  14657. /**
  14658. * Stop and delete the current animation
  14659. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14660. * @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)
  14661. */
  14662. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14663. /**
  14664. * Wait asynchronously for the animation to end
  14665. * @returns a promise which will be fullfilled when the animation ends
  14666. */
  14667. waitAsync(): Promise<Animatable>;
  14668. /** @hidden */
  14669. _animate(delay: number): boolean;
  14670. }
  14671. interface Scene {
  14672. /** @hidden */
  14673. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14674. /** @hidden */
  14675. _processLateAnimationBindingsForMatrices(holder: {
  14676. totalWeight: number;
  14677. animations: RuntimeAnimation[];
  14678. originalValue: Matrix;
  14679. }): any;
  14680. /** @hidden */
  14681. _processLateAnimationBindingsForQuaternions(holder: {
  14682. totalWeight: number;
  14683. animations: RuntimeAnimation[];
  14684. originalValue: Quaternion;
  14685. }, refQuaternion: Quaternion): Quaternion;
  14686. /** @hidden */
  14687. _processLateAnimationBindings(): void;
  14688. /**
  14689. * Will start the animation sequence of a given target
  14690. * @param target defines the target
  14691. * @param from defines from which frame should animation start
  14692. * @param to defines until which frame should animation run.
  14693. * @param weight defines the weight to apply to the animation (1.0 by default)
  14694. * @param loop defines if the animation loops
  14695. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14696. * @param onAnimationEnd defines the function to be executed when the animation ends
  14697. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14698. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14699. * @param onAnimationLoop defines the callback to call when an animation loops
  14700. * @returns the animatable object created for this animation
  14701. */
  14702. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14703. /**
  14704. * Will start the animation sequence of a given target
  14705. * @param target defines the target
  14706. * @param from defines from which frame should animation start
  14707. * @param to defines until which frame should animation run.
  14708. * @param loop defines if the animation loops
  14709. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14710. * @param onAnimationEnd defines the function to be executed when the animation ends
  14711. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14712. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14713. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14714. * @param onAnimationLoop defines the callback to call when an animation loops
  14715. * @returns the animatable object created for this animation
  14716. */
  14717. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14718. /**
  14719. * Will start the animation sequence of a given target and its hierarchy
  14720. * @param target defines the target
  14721. * @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.
  14722. * @param from defines from which frame should animation start
  14723. * @param to defines until which frame should animation run.
  14724. * @param loop defines if the animation loops
  14725. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14726. * @param onAnimationEnd defines the function to be executed when the animation ends
  14727. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14728. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14729. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14730. * @param onAnimationLoop defines the callback to call when an animation loops
  14731. * @returns the list of created animatables
  14732. */
  14733. 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[];
  14734. /**
  14735. * Begin a new animation on a given node
  14736. * @param target defines the target where the animation will take place
  14737. * @param animations defines the list of animations to start
  14738. * @param from defines the initial value
  14739. * @param to defines the final value
  14740. * @param loop defines if you want animation to loop (off by default)
  14741. * @param speedRatio defines the speed ratio to apply to all animations
  14742. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14743. * @param onAnimationLoop defines the callback to call when an animation loops
  14744. * @returns the list of created animatables
  14745. */
  14746. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14747. /**
  14748. * Begin a new animation on a given node and its hierarchy
  14749. * @param target defines the root node where the animation will take place
  14750. * @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.
  14751. * @param animations defines the list of animations to start
  14752. * @param from defines the initial value
  14753. * @param to defines the final value
  14754. * @param loop defines if you want animation to loop (off by default)
  14755. * @param speedRatio defines the speed ratio to apply to all animations
  14756. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14757. * @param onAnimationLoop defines the callback to call when an animation loops
  14758. * @returns the list of animatables created for all nodes
  14759. */
  14760. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14761. /**
  14762. * Gets the animatable associated with a specific target
  14763. * @param target defines the target of the animatable
  14764. * @returns the required animatable if found
  14765. */
  14766. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14767. /**
  14768. * Gets all animatables associated with a given target
  14769. * @param target defines the target to look animatables for
  14770. * @returns an array of Animatables
  14771. */
  14772. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14773. /**
  14774. * Stops and removes all animations that have been applied to the scene
  14775. */
  14776. stopAllAnimations(): void;
  14777. /**
  14778. * Gets the current delta time used by animation engine
  14779. */
  14780. deltaTime: number;
  14781. }
  14782. interface Bone {
  14783. /**
  14784. * Copy an animation range from another bone
  14785. * @param source defines the source bone
  14786. * @param rangeName defines the range name to copy
  14787. * @param frameOffset defines the frame offset
  14788. * @param rescaleAsRequired defines if rescaling must be applied if required
  14789. * @param skelDimensionsRatio defines the scaling ratio
  14790. * @returns true if operation was successful
  14791. */
  14792. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14793. }
  14794. }
  14795. declare module BABYLON {
  14796. /**
  14797. * Class used to handle skinning animations
  14798. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14799. */
  14800. export class Skeleton implements IAnimatable {
  14801. /** defines the skeleton name */
  14802. name: string;
  14803. /** defines the skeleton Id */
  14804. id: string;
  14805. /**
  14806. * Defines the list of child bones
  14807. */
  14808. bones: Bone[];
  14809. /**
  14810. * Defines an estimate of the dimension of the skeleton at rest
  14811. */
  14812. dimensionsAtRest: Vector3;
  14813. /**
  14814. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14815. */
  14816. needInitialSkinMatrix: boolean;
  14817. /**
  14818. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14819. */
  14820. overrideMesh: Nullable<AbstractMesh>;
  14821. /**
  14822. * Gets the list of animations attached to this skeleton
  14823. */
  14824. animations: Array<Animation>;
  14825. private _scene;
  14826. private _isDirty;
  14827. private _transformMatrices;
  14828. private _transformMatrixTexture;
  14829. private _meshesWithPoseMatrix;
  14830. private _animatables;
  14831. private _identity;
  14832. private _synchronizedWithMesh;
  14833. private _ranges;
  14834. private _lastAbsoluteTransformsUpdateId;
  14835. private _canUseTextureForBones;
  14836. private _uniqueId;
  14837. /** @hidden */
  14838. _numBonesWithLinkedTransformNode: number;
  14839. /** @hidden */
  14840. _hasWaitingData: Nullable<boolean>;
  14841. /**
  14842. * Specifies if the skeleton should be serialized
  14843. */
  14844. doNotSerialize: boolean;
  14845. private _useTextureToStoreBoneMatrices;
  14846. /**
  14847. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14848. * Please note that this option is not available if the hardware does not support it
  14849. */
  14850. get useTextureToStoreBoneMatrices(): boolean;
  14851. set useTextureToStoreBoneMatrices(value: boolean);
  14852. private _animationPropertiesOverride;
  14853. /**
  14854. * Gets or sets the animation properties override
  14855. */
  14856. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14857. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14858. /**
  14859. * List of inspectable custom properties (used by the Inspector)
  14860. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14861. */
  14862. inspectableCustomProperties: IInspectable[];
  14863. /**
  14864. * An observable triggered before computing the skeleton's matrices
  14865. */
  14866. onBeforeComputeObservable: Observable<Skeleton>;
  14867. /**
  14868. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14869. */
  14870. get isUsingTextureForMatrices(): boolean;
  14871. /**
  14872. * Gets the unique ID of this skeleton
  14873. */
  14874. get uniqueId(): number;
  14875. /**
  14876. * Creates a new skeleton
  14877. * @param name defines the skeleton name
  14878. * @param id defines the skeleton Id
  14879. * @param scene defines the hosting scene
  14880. */
  14881. constructor(
  14882. /** defines the skeleton name */
  14883. name: string,
  14884. /** defines the skeleton Id */
  14885. id: string, scene: Scene);
  14886. /**
  14887. * Gets the current object class name.
  14888. * @return the class name
  14889. */
  14890. getClassName(): string;
  14891. /**
  14892. * Returns an array containing the root bones
  14893. * @returns an array containing the root bones
  14894. */
  14895. getChildren(): Array<Bone>;
  14896. /**
  14897. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14898. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14899. * @returns a Float32Array containing matrices data
  14900. */
  14901. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14902. /**
  14903. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14904. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14905. * @returns a raw texture containing the data
  14906. */
  14907. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14908. /**
  14909. * Gets the current hosting scene
  14910. * @returns a scene object
  14911. */
  14912. getScene(): Scene;
  14913. /**
  14914. * Gets a string representing the current skeleton data
  14915. * @param fullDetails defines a boolean indicating if we want a verbose version
  14916. * @returns a string representing the current skeleton data
  14917. */
  14918. toString(fullDetails?: boolean): string;
  14919. /**
  14920. * Get bone's index searching by name
  14921. * @param name defines bone's name to search for
  14922. * @return the indice of the bone. Returns -1 if not found
  14923. */
  14924. getBoneIndexByName(name: string): number;
  14925. /**
  14926. * Creater a new animation range
  14927. * @param name defines the name of the range
  14928. * @param from defines the start key
  14929. * @param to defines the end key
  14930. */
  14931. createAnimationRange(name: string, from: number, to: number): void;
  14932. /**
  14933. * Delete a specific animation range
  14934. * @param name defines the name of the range
  14935. * @param deleteFrames defines if frames must be removed as well
  14936. */
  14937. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14938. /**
  14939. * Gets a specific animation range
  14940. * @param name defines the name of the range to look for
  14941. * @returns the requested animation range or null if not found
  14942. */
  14943. getAnimationRange(name: string): Nullable<AnimationRange>;
  14944. /**
  14945. * Gets the list of all animation ranges defined on this skeleton
  14946. * @returns an array
  14947. */
  14948. getAnimationRanges(): Nullable<AnimationRange>[];
  14949. /**
  14950. * Copy animation range from a source skeleton.
  14951. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14952. * @param source defines the source skeleton
  14953. * @param name defines the name of the range to copy
  14954. * @param rescaleAsRequired defines if rescaling must be applied if required
  14955. * @returns true if operation was successful
  14956. */
  14957. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14958. /**
  14959. * Forces the skeleton to go to rest pose
  14960. */
  14961. returnToRest(): void;
  14962. private _getHighestAnimationFrame;
  14963. /**
  14964. * Begin a specific animation range
  14965. * @param name defines the name of the range to start
  14966. * @param loop defines if looping must be turned on (false by default)
  14967. * @param speedRatio defines the speed ratio to apply (1 by default)
  14968. * @param onAnimationEnd defines a callback which will be called when animation will end
  14969. * @returns a new animatable
  14970. */
  14971. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  14972. /** @hidden */
  14973. _markAsDirty(): void;
  14974. /** @hidden */
  14975. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14976. /** @hidden */
  14977. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14978. private _computeTransformMatrices;
  14979. /**
  14980. * Build all resources required to render a skeleton
  14981. */
  14982. prepare(): void;
  14983. /**
  14984. * Gets the list of animatables currently running for this skeleton
  14985. * @returns an array of animatables
  14986. */
  14987. getAnimatables(): IAnimatable[];
  14988. /**
  14989. * Clone the current skeleton
  14990. * @param name defines the name of the new skeleton
  14991. * @param id defines the id of the new skeleton
  14992. * @returns the new skeleton
  14993. */
  14994. clone(name: string, id?: string): Skeleton;
  14995. /**
  14996. * Enable animation blending for this skeleton
  14997. * @param blendingSpeed defines the blending speed to apply
  14998. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14999. */
  15000. enableBlending(blendingSpeed?: number): void;
  15001. /**
  15002. * Releases all resources associated with the current skeleton
  15003. */
  15004. dispose(): void;
  15005. /**
  15006. * Serialize the skeleton in a JSON object
  15007. * @returns a JSON object
  15008. */
  15009. serialize(): any;
  15010. /**
  15011. * Creates a new skeleton from serialized data
  15012. * @param parsedSkeleton defines the serialized data
  15013. * @param scene defines the hosting scene
  15014. * @returns a new skeleton
  15015. */
  15016. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15017. /**
  15018. * Compute all node absolute transforms
  15019. * @param forceUpdate defines if computation must be done even if cache is up to date
  15020. */
  15021. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15022. /**
  15023. * Gets the root pose matrix
  15024. * @returns a matrix
  15025. */
  15026. getPoseMatrix(): Nullable<Matrix>;
  15027. /**
  15028. * Sorts bones per internal index
  15029. */
  15030. sortBones(): void;
  15031. private _sortBones;
  15032. }
  15033. }
  15034. declare module BABYLON {
  15035. /**
  15036. * Creates an instance based on a source mesh.
  15037. */
  15038. export class InstancedMesh extends AbstractMesh {
  15039. private _sourceMesh;
  15040. private _currentLOD;
  15041. /** @hidden */
  15042. _indexInSourceMeshInstanceArray: number;
  15043. constructor(name: string, source: Mesh);
  15044. /**
  15045. * Returns the string "InstancedMesh".
  15046. */
  15047. getClassName(): string;
  15048. /** Gets the list of lights affecting that mesh */
  15049. get lightSources(): Light[];
  15050. _resyncLightSources(): void;
  15051. _resyncLightSource(light: Light): void;
  15052. _removeLightSource(light: Light, dispose: boolean): void;
  15053. /**
  15054. * If the source mesh receives shadows
  15055. */
  15056. get receiveShadows(): boolean;
  15057. /**
  15058. * The material of the source mesh
  15059. */
  15060. get material(): Nullable<Material>;
  15061. /**
  15062. * Visibility of the source mesh
  15063. */
  15064. get visibility(): number;
  15065. /**
  15066. * Skeleton of the source mesh
  15067. */
  15068. get skeleton(): Nullable<Skeleton>;
  15069. /**
  15070. * Rendering ground id of the source mesh
  15071. */
  15072. get renderingGroupId(): number;
  15073. set renderingGroupId(value: number);
  15074. /**
  15075. * Returns the total number of vertices (integer).
  15076. */
  15077. getTotalVertices(): number;
  15078. /**
  15079. * Returns a positive integer : the total number of indices in this mesh geometry.
  15080. * @returns the numner of indices or zero if the mesh has no geometry.
  15081. */
  15082. getTotalIndices(): number;
  15083. /**
  15084. * The source mesh of the instance
  15085. */
  15086. get sourceMesh(): Mesh;
  15087. /**
  15088. * Is this node ready to be used/rendered
  15089. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15090. * @return {boolean} is it ready
  15091. */
  15092. isReady(completeCheck?: boolean): boolean;
  15093. /**
  15094. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15095. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15096. * @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.
  15097. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15098. */
  15099. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15100. /**
  15101. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15102. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15103. * The `data` are either a numeric array either a Float32Array.
  15104. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15105. * 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).
  15106. * Note that a new underlying VertexBuffer object is created each call.
  15107. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15108. *
  15109. * Possible `kind` values :
  15110. * - VertexBuffer.PositionKind
  15111. * - VertexBuffer.UVKind
  15112. * - VertexBuffer.UV2Kind
  15113. * - VertexBuffer.UV3Kind
  15114. * - VertexBuffer.UV4Kind
  15115. * - VertexBuffer.UV5Kind
  15116. * - VertexBuffer.UV6Kind
  15117. * - VertexBuffer.ColorKind
  15118. * - VertexBuffer.MatricesIndicesKind
  15119. * - VertexBuffer.MatricesIndicesExtraKind
  15120. * - VertexBuffer.MatricesWeightsKind
  15121. * - VertexBuffer.MatricesWeightsExtraKind
  15122. *
  15123. * Returns the Mesh.
  15124. */
  15125. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15126. /**
  15127. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15128. * If the mesh has no geometry, it is simply returned as it is.
  15129. * The `data` are either a numeric array either a Float32Array.
  15130. * No new underlying VertexBuffer object is created.
  15131. * 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.
  15132. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15133. *
  15134. * Possible `kind` values :
  15135. * - VertexBuffer.PositionKind
  15136. * - VertexBuffer.UVKind
  15137. * - VertexBuffer.UV2Kind
  15138. * - VertexBuffer.UV3Kind
  15139. * - VertexBuffer.UV4Kind
  15140. * - VertexBuffer.UV5Kind
  15141. * - VertexBuffer.UV6Kind
  15142. * - VertexBuffer.ColorKind
  15143. * - VertexBuffer.MatricesIndicesKind
  15144. * - VertexBuffer.MatricesIndicesExtraKind
  15145. * - VertexBuffer.MatricesWeightsKind
  15146. * - VertexBuffer.MatricesWeightsExtraKind
  15147. *
  15148. * Returns the Mesh.
  15149. */
  15150. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15151. /**
  15152. * Sets the mesh indices.
  15153. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15154. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15155. * This method creates a new index buffer each call.
  15156. * Returns the Mesh.
  15157. */
  15158. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15159. /**
  15160. * Boolean : True if the mesh owns the requested kind of data.
  15161. */
  15162. isVerticesDataPresent(kind: string): boolean;
  15163. /**
  15164. * Returns an array of indices (IndicesArray).
  15165. */
  15166. getIndices(): Nullable<IndicesArray>;
  15167. get _positions(): Nullable<Vector3[]>;
  15168. /**
  15169. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15170. * This means the mesh underlying bounding box and sphere are recomputed.
  15171. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15172. * @returns the current mesh
  15173. */
  15174. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15175. /** @hidden */
  15176. _preActivate(): InstancedMesh;
  15177. /** @hidden */
  15178. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15179. /** @hidden */
  15180. _postActivate(): void;
  15181. getWorldMatrix(): Matrix;
  15182. get isAnInstance(): boolean;
  15183. /**
  15184. * Returns the current associated LOD AbstractMesh.
  15185. */
  15186. getLOD(camera: Camera): AbstractMesh;
  15187. /** @hidden */
  15188. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15189. /** @hidden */
  15190. _syncSubMeshes(): InstancedMesh;
  15191. /** @hidden */
  15192. _generatePointsArray(): boolean;
  15193. /**
  15194. * Creates a new InstancedMesh from the current mesh.
  15195. * - name (string) : the cloned mesh name
  15196. * - newParent (optional Node) : the optional Node to parent the clone to.
  15197. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15198. *
  15199. * Returns the clone.
  15200. */
  15201. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15202. /**
  15203. * Disposes the InstancedMesh.
  15204. * Returns nothing.
  15205. */
  15206. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15207. }
  15208. interface Mesh {
  15209. /**
  15210. * Register a custom buffer that will be instanced
  15211. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15212. * @param kind defines the buffer kind
  15213. * @param stride defines the stride in floats
  15214. */
  15215. registerInstancedBuffer(kind: string, stride: number): void;
  15216. /** @hidden */
  15217. _userInstancedBuffersStorage: {
  15218. data: {
  15219. [key: string]: Float32Array;
  15220. };
  15221. sizes: {
  15222. [key: string]: number;
  15223. };
  15224. vertexBuffers: {
  15225. [key: string]: Nullable<VertexBuffer>;
  15226. };
  15227. strides: {
  15228. [key: string]: number;
  15229. };
  15230. };
  15231. }
  15232. interface AbstractMesh {
  15233. /**
  15234. * Object used to store instanced buffers defined by user
  15235. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15236. */
  15237. instancedBuffers: {
  15238. [key: string]: any;
  15239. };
  15240. }
  15241. }
  15242. declare module BABYLON {
  15243. /**
  15244. * Defines the options associated with the creation of a shader material.
  15245. */
  15246. export interface IShaderMaterialOptions {
  15247. /**
  15248. * Does the material work in alpha blend mode
  15249. */
  15250. needAlphaBlending: boolean;
  15251. /**
  15252. * Does the material work in alpha test mode
  15253. */
  15254. needAlphaTesting: boolean;
  15255. /**
  15256. * The list of attribute names used in the shader
  15257. */
  15258. attributes: string[];
  15259. /**
  15260. * The list of unifrom names used in the shader
  15261. */
  15262. uniforms: string[];
  15263. /**
  15264. * The list of UBO names used in the shader
  15265. */
  15266. uniformBuffers: string[];
  15267. /**
  15268. * The list of sampler names used in the shader
  15269. */
  15270. samplers: string[];
  15271. /**
  15272. * The list of defines used in the shader
  15273. */
  15274. defines: string[];
  15275. }
  15276. /**
  15277. * 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.
  15278. *
  15279. * This returned material effects how the mesh will look based on the code in the shaders.
  15280. *
  15281. * @see http://doc.babylonjs.com/how_to/shader_material
  15282. */
  15283. export class ShaderMaterial extends Material {
  15284. private _shaderPath;
  15285. private _options;
  15286. private _textures;
  15287. private _textureArrays;
  15288. private _floats;
  15289. private _ints;
  15290. private _floatsArrays;
  15291. private _colors3;
  15292. private _colors3Arrays;
  15293. private _colors4;
  15294. private _colors4Arrays;
  15295. private _vectors2;
  15296. private _vectors3;
  15297. private _vectors4;
  15298. private _matrices;
  15299. private _matrixArrays;
  15300. private _matrices3x3;
  15301. private _matrices2x2;
  15302. private _vectors2Arrays;
  15303. private _vectors3Arrays;
  15304. private _vectors4Arrays;
  15305. private _cachedWorldViewMatrix;
  15306. private _cachedWorldViewProjectionMatrix;
  15307. private _renderId;
  15308. private _multiview;
  15309. /**
  15310. * Instantiate a new shader material.
  15311. * 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.
  15312. * This returned material effects how the mesh will look based on the code in the shaders.
  15313. * @see http://doc.babylonjs.com/how_to/shader_material
  15314. * @param name Define the name of the material in the scene
  15315. * @param scene Define the scene the material belongs to
  15316. * @param shaderPath Defines the route to the shader code in one of three ways:
  15317. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15318. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15319. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15320. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15321. * @param options Define the options used to create the shader
  15322. */
  15323. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15324. /**
  15325. * Gets the shader path used to define the shader code
  15326. * It can be modified to trigger a new compilation
  15327. */
  15328. get shaderPath(): any;
  15329. /**
  15330. * Sets the shader path used to define the shader code
  15331. * It can be modified to trigger a new compilation
  15332. */
  15333. set shaderPath(shaderPath: any);
  15334. /**
  15335. * Gets the options used to compile the shader.
  15336. * They can be modified to trigger a new compilation
  15337. */
  15338. get options(): IShaderMaterialOptions;
  15339. /**
  15340. * Gets the current class name of the material e.g. "ShaderMaterial"
  15341. * Mainly use in serialization.
  15342. * @returns the class name
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Specifies if the material will require alpha blending
  15347. * @returns a boolean specifying if alpha blending is needed
  15348. */
  15349. needAlphaBlending(): boolean;
  15350. /**
  15351. * Specifies if this material should be rendered in alpha test mode
  15352. * @returns a boolean specifying if an alpha test is needed.
  15353. */
  15354. needAlphaTesting(): boolean;
  15355. private _checkUniform;
  15356. /**
  15357. * Set a texture in the shader.
  15358. * @param name Define the name of the uniform samplers as defined in the shader
  15359. * @param texture Define the texture to bind to this sampler
  15360. * @return the material itself allowing "fluent" like uniform updates
  15361. */
  15362. setTexture(name: string, texture: Texture): ShaderMaterial;
  15363. /**
  15364. * Set a texture array in the shader.
  15365. * @param name Define the name of the uniform sampler array as defined in the shader
  15366. * @param textures Define the list of textures to bind to this sampler
  15367. * @return the material itself allowing "fluent" like uniform updates
  15368. */
  15369. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15370. /**
  15371. * Set a float in the shader.
  15372. * @param name Define the name of the uniform as defined in the shader
  15373. * @param value Define the value to give to the uniform
  15374. * @return the material itself allowing "fluent" like uniform updates
  15375. */
  15376. setFloat(name: string, value: number): ShaderMaterial;
  15377. /**
  15378. * Set a int in the shader.
  15379. * @param name Define the name of the uniform as defined in the shader
  15380. * @param value Define the value to give to the uniform
  15381. * @return the material itself allowing "fluent" like uniform updates
  15382. */
  15383. setInt(name: string, value: number): ShaderMaterial;
  15384. /**
  15385. * Set an array of floats in the shader.
  15386. * @param name Define the name of the uniform as defined in the shader
  15387. * @param value Define the value to give to the uniform
  15388. * @return the material itself allowing "fluent" like uniform updates
  15389. */
  15390. setFloats(name: string, value: number[]): ShaderMaterial;
  15391. /**
  15392. * Set a vec3 in the shader from a Color3.
  15393. * @param name Define the name of the uniform as defined in the shader
  15394. * @param value Define the value to give to the uniform
  15395. * @return the material itself allowing "fluent" like uniform updates
  15396. */
  15397. setColor3(name: string, value: Color3): ShaderMaterial;
  15398. /**
  15399. * Set a vec3 array in the shader from a Color3 array.
  15400. * @param name Define the name of the uniform as defined in the shader
  15401. * @param value Define the value to give to the uniform
  15402. * @return the material itself allowing "fluent" like uniform updates
  15403. */
  15404. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15405. /**
  15406. * Set a vec4 in the shader from a Color4.
  15407. * @param name Define the name of the uniform as defined in the shader
  15408. * @param value Define the value to give to the uniform
  15409. * @return the material itself allowing "fluent" like uniform updates
  15410. */
  15411. setColor4(name: string, value: Color4): ShaderMaterial;
  15412. /**
  15413. * Set a vec4 array in the shader from a Color4 array.
  15414. * @param name Define the name of the uniform as defined in the shader
  15415. * @param value Define the value to give to the uniform
  15416. * @return the material itself allowing "fluent" like uniform updates
  15417. */
  15418. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15419. /**
  15420. * Set a vec2 in the shader from a Vector2.
  15421. * @param name Define the name of the uniform as defined in the shader
  15422. * @param value Define the value to give to the uniform
  15423. * @return the material itself allowing "fluent" like uniform updates
  15424. */
  15425. setVector2(name: string, value: Vector2): ShaderMaterial;
  15426. /**
  15427. * Set a vec3 in the shader from a Vector3.
  15428. * @param name Define the name of the uniform as defined in the shader
  15429. * @param value Define the value to give to the uniform
  15430. * @return the material itself allowing "fluent" like uniform updates
  15431. */
  15432. setVector3(name: string, value: Vector3): ShaderMaterial;
  15433. /**
  15434. * Set a vec4 in the shader from a Vector4.
  15435. * @param name Define the name of the uniform as defined in the shader
  15436. * @param value Define the value to give to the uniform
  15437. * @return the material itself allowing "fluent" like uniform updates
  15438. */
  15439. setVector4(name: string, value: Vector4): ShaderMaterial;
  15440. /**
  15441. * Set a mat4 in the shader from a Matrix.
  15442. * @param name Define the name of the uniform as defined in the shader
  15443. * @param value Define the value to give to the uniform
  15444. * @return the material itself allowing "fluent" like uniform updates
  15445. */
  15446. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15447. /**
  15448. * Set a float32Array in the shader from a matrix array.
  15449. * @param name Define the name of the uniform as defined in the shader
  15450. * @param value Define the value to give to the uniform
  15451. * @return the material itself allowing "fluent" like uniform updates
  15452. */
  15453. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15454. /**
  15455. * Set a mat3 in the shader from a Float32Array.
  15456. * @param name Define the name of the uniform as defined in the shader
  15457. * @param value Define the value to give to the uniform
  15458. * @return the material itself allowing "fluent" like uniform updates
  15459. */
  15460. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15461. /**
  15462. * Set a mat2 in the shader from a Float32Array.
  15463. * @param name Define the name of the uniform as defined in the shader
  15464. * @param value Define the value to give to the uniform
  15465. * @return the material itself allowing "fluent" like uniform updates
  15466. */
  15467. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15468. /**
  15469. * Set a vec2 array in the shader from a number array.
  15470. * @param name Define the name of the uniform as defined in the shader
  15471. * @param value Define the value to give to the uniform
  15472. * @return the material itself allowing "fluent" like uniform updates
  15473. */
  15474. setArray2(name: string, value: number[]): ShaderMaterial;
  15475. /**
  15476. * Set a vec3 array in the shader from a number array.
  15477. * @param name Define the name of the uniform as defined in the shader
  15478. * @param value Define the value to give to the uniform
  15479. * @return the material itself allowing "fluent" like uniform updates
  15480. */
  15481. setArray3(name: string, value: number[]): ShaderMaterial;
  15482. /**
  15483. * Set a vec4 array in the shader from a number array.
  15484. * @param name Define the name of the uniform as defined in the shader
  15485. * @param value Define the value to give to the uniform
  15486. * @return the material itself allowing "fluent" like uniform updates
  15487. */
  15488. setArray4(name: string, value: number[]): ShaderMaterial;
  15489. private _checkCache;
  15490. /**
  15491. * Specifies that the submesh is ready to be used
  15492. * @param mesh defines the mesh to check
  15493. * @param subMesh defines which submesh to check
  15494. * @param useInstances specifies that instances should be used
  15495. * @returns a boolean indicating that the submesh is ready or not
  15496. */
  15497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15498. /**
  15499. * Checks if the material is ready to render the requested mesh
  15500. * @param mesh Define the mesh to render
  15501. * @param useInstances Define whether or not the material is used with instances
  15502. * @returns true if ready, otherwise false
  15503. */
  15504. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15505. /**
  15506. * Binds the world matrix to the material
  15507. * @param world defines the world transformation matrix
  15508. */
  15509. bindOnlyWorldMatrix(world: Matrix): void;
  15510. /**
  15511. * Binds the material to the mesh
  15512. * @param world defines the world transformation matrix
  15513. * @param mesh defines the mesh to bind the material to
  15514. */
  15515. bind(world: Matrix, mesh?: Mesh): void;
  15516. /**
  15517. * Gets the active textures from the material
  15518. * @returns an array of textures
  15519. */
  15520. getActiveTextures(): BaseTexture[];
  15521. /**
  15522. * Specifies if the material uses a texture
  15523. * @param texture defines the texture to check against the material
  15524. * @returns a boolean specifying if the material uses the texture
  15525. */
  15526. hasTexture(texture: BaseTexture): boolean;
  15527. /**
  15528. * Makes a duplicate of the material, and gives it a new name
  15529. * @param name defines the new name for the duplicated material
  15530. * @returns the cloned material
  15531. */
  15532. clone(name: string): ShaderMaterial;
  15533. /**
  15534. * Disposes the material
  15535. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15536. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15537. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15538. */
  15539. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15540. /**
  15541. * Serializes this material in a JSON representation
  15542. * @returns the serialized material object
  15543. */
  15544. serialize(): any;
  15545. /**
  15546. * Creates a shader material from parsed shader material data
  15547. * @param source defines the JSON represnetation of the material
  15548. * @param scene defines the hosting scene
  15549. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15550. * @returns a new material
  15551. */
  15552. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15553. }
  15554. }
  15555. declare module BABYLON {
  15556. /** @hidden */
  15557. export var colorPixelShader: {
  15558. name: string;
  15559. shader: string;
  15560. };
  15561. }
  15562. declare module BABYLON {
  15563. /** @hidden */
  15564. export var colorVertexShader: {
  15565. name: string;
  15566. shader: string;
  15567. };
  15568. }
  15569. declare module BABYLON {
  15570. /**
  15571. * Line mesh
  15572. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15573. */
  15574. export class LinesMesh extends Mesh {
  15575. /**
  15576. * If vertex color should be applied to the mesh
  15577. */
  15578. readonly useVertexColor?: boolean | undefined;
  15579. /**
  15580. * If vertex alpha should be applied to the mesh
  15581. */
  15582. readonly useVertexAlpha?: boolean | undefined;
  15583. /**
  15584. * Color of the line (Default: White)
  15585. */
  15586. color: Color3;
  15587. /**
  15588. * Alpha of the line (Default: 1)
  15589. */
  15590. alpha: number;
  15591. /**
  15592. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15593. * This margin is expressed in world space coordinates, so its value may vary.
  15594. * Default value is 0.1
  15595. */
  15596. intersectionThreshold: number;
  15597. private _colorShader;
  15598. private color4;
  15599. /**
  15600. * Creates a new LinesMesh
  15601. * @param name defines the name
  15602. * @param scene defines the hosting scene
  15603. * @param parent defines the parent mesh if any
  15604. * @param source defines the optional source LinesMesh used to clone data from
  15605. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15606. * When false, achieved by calling a clone(), also passing False.
  15607. * This will make creation of children, recursive.
  15608. * @param useVertexColor defines if this LinesMesh supports vertex color
  15609. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15610. */
  15611. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15612. /**
  15613. * If vertex color should be applied to the mesh
  15614. */
  15615. useVertexColor?: boolean | undefined,
  15616. /**
  15617. * If vertex alpha should be applied to the mesh
  15618. */
  15619. useVertexAlpha?: boolean | undefined);
  15620. private _addClipPlaneDefine;
  15621. private _removeClipPlaneDefine;
  15622. isReady(): boolean;
  15623. /**
  15624. * Returns the string "LineMesh"
  15625. */
  15626. getClassName(): string;
  15627. /**
  15628. * @hidden
  15629. */
  15630. get material(): Material;
  15631. /**
  15632. * @hidden
  15633. */
  15634. set material(value: Material);
  15635. /**
  15636. * @hidden
  15637. */
  15638. get checkCollisions(): boolean;
  15639. /** @hidden */
  15640. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15641. /** @hidden */
  15642. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15643. /**
  15644. * Disposes of the line mesh
  15645. * @param doNotRecurse If children should be disposed
  15646. */
  15647. dispose(doNotRecurse?: boolean): void;
  15648. /**
  15649. * Returns a new LineMesh object cloned from the current one.
  15650. */
  15651. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15652. /**
  15653. * Creates a new InstancedLinesMesh object from the mesh model.
  15654. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15655. * @param name defines the name of the new instance
  15656. * @returns a new InstancedLinesMesh
  15657. */
  15658. createInstance(name: string): InstancedLinesMesh;
  15659. }
  15660. /**
  15661. * Creates an instance based on a source LinesMesh
  15662. */
  15663. export class InstancedLinesMesh extends InstancedMesh {
  15664. /**
  15665. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15666. * This margin is expressed in world space coordinates, so its value may vary.
  15667. * Initilized with the intersectionThreshold value of the source LinesMesh
  15668. */
  15669. intersectionThreshold: number;
  15670. constructor(name: string, source: LinesMesh);
  15671. /**
  15672. * Returns the string "InstancedLinesMesh".
  15673. */
  15674. getClassName(): string;
  15675. }
  15676. }
  15677. declare module BABYLON {
  15678. /** @hidden */
  15679. export var linePixelShader: {
  15680. name: string;
  15681. shader: string;
  15682. };
  15683. }
  15684. declare module BABYLON {
  15685. /** @hidden */
  15686. export var lineVertexShader: {
  15687. name: string;
  15688. shader: string;
  15689. };
  15690. }
  15691. declare module BABYLON {
  15692. interface AbstractMesh {
  15693. /**
  15694. * Gets the edgesRenderer associated with the mesh
  15695. */
  15696. edgesRenderer: Nullable<EdgesRenderer>;
  15697. }
  15698. interface LinesMesh {
  15699. /**
  15700. * Enables the edge rendering mode on the mesh.
  15701. * This mode makes the mesh edges visible
  15702. * @param epsilon defines the maximal distance between two angles to detect a face
  15703. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15704. * @returns the currentAbstractMesh
  15705. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15706. */
  15707. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15708. }
  15709. interface InstancedLinesMesh {
  15710. /**
  15711. * Enables the edge rendering mode on the mesh.
  15712. * This mode makes the mesh edges visible
  15713. * @param epsilon defines the maximal distance between two angles to detect a face
  15714. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15715. * @returns the current InstancedLinesMesh
  15716. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15717. */
  15718. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15719. }
  15720. /**
  15721. * Defines the minimum contract an Edges renderer should follow.
  15722. */
  15723. export interface IEdgesRenderer extends IDisposable {
  15724. /**
  15725. * Gets or sets a boolean indicating if the edgesRenderer is active
  15726. */
  15727. isEnabled: boolean;
  15728. /**
  15729. * Renders the edges of the attached mesh,
  15730. */
  15731. render(): void;
  15732. /**
  15733. * Checks wether or not the edges renderer is ready to render.
  15734. * @return true if ready, otherwise false.
  15735. */
  15736. isReady(): boolean;
  15737. }
  15738. /**
  15739. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15740. */
  15741. export class EdgesRenderer implements IEdgesRenderer {
  15742. /**
  15743. * Define the size of the edges with an orthographic camera
  15744. */
  15745. edgesWidthScalerForOrthographic: number;
  15746. /**
  15747. * Define the size of the edges with a perspective camera
  15748. */
  15749. edgesWidthScalerForPerspective: number;
  15750. protected _source: AbstractMesh;
  15751. protected _linesPositions: number[];
  15752. protected _linesNormals: number[];
  15753. protected _linesIndices: number[];
  15754. protected _epsilon: number;
  15755. protected _indicesCount: number;
  15756. protected _lineShader: ShaderMaterial;
  15757. protected _ib: DataBuffer;
  15758. protected _buffers: {
  15759. [key: string]: Nullable<VertexBuffer>;
  15760. };
  15761. protected _checkVerticesInsteadOfIndices: boolean;
  15762. private _meshRebuildObserver;
  15763. private _meshDisposeObserver;
  15764. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15765. isEnabled: boolean;
  15766. /**
  15767. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15768. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15769. * @param source Mesh used to create edges
  15770. * @param epsilon sum of angles in adjacency to check for edge
  15771. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15772. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15773. */
  15774. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15775. protected _prepareRessources(): void;
  15776. /** @hidden */
  15777. _rebuild(): void;
  15778. /**
  15779. * Releases the required resources for the edges renderer
  15780. */
  15781. dispose(): void;
  15782. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15783. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15784. /**
  15785. * Checks if the pair of p0 and p1 is en edge
  15786. * @param faceIndex
  15787. * @param edge
  15788. * @param faceNormals
  15789. * @param p0
  15790. * @param p1
  15791. * @private
  15792. */
  15793. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15794. /**
  15795. * push line into the position, normal and index buffer
  15796. * @protected
  15797. */
  15798. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15799. /**
  15800. * Generates lines edges from adjacencjes
  15801. * @private
  15802. */
  15803. _generateEdgesLines(): void;
  15804. /**
  15805. * Checks wether or not the edges renderer is ready to render.
  15806. * @return true if ready, otherwise false.
  15807. */
  15808. isReady(): boolean;
  15809. /**
  15810. * Renders the edges of the attached mesh,
  15811. */
  15812. render(): void;
  15813. }
  15814. /**
  15815. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15816. */
  15817. export class LineEdgesRenderer extends EdgesRenderer {
  15818. /**
  15819. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15820. * @param source LineMesh used to generate edges
  15821. * @param epsilon not important (specified angle for edge detection)
  15822. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15823. */
  15824. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15825. /**
  15826. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15827. */
  15828. _generateEdgesLines(): void;
  15829. }
  15830. }
  15831. declare module BABYLON {
  15832. /**
  15833. * This represents the object necessary to create a rendering group.
  15834. * This is exclusively used and created by the rendering manager.
  15835. * To modify the behavior, you use the available helpers in your scene or meshes.
  15836. * @hidden
  15837. */
  15838. export class RenderingGroup {
  15839. index: number;
  15840. private static _zeroVector;
  15841. private _scene;
  15842. private _opaqueSubMeshes;
  15843. private _transparentSubMeshes;
  15844. private _alphaTestSubMeshes;
  15845. private _depthOnlySubMeshes;
  15846. private _particleSystems;
  15847. private _spriteManagers;
  15848. private _opaqueSortCompareFn;
  15849. private _alphaTestSortCompareFn;
  15850. private _transparentSortCompareFn;
  15851. private _renderOpaque;
  15852. private _renderAlphaTest;
  15853. private _renderTransparent;
  15854. /** @hidden */
  15855. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15856. onBeforeTransparentRendering: () => void;
  15857. /**
  15858. * Set the opaque sort comparison function.
  15859. * If null the sub meshes will be render in the order they were created
  15860. */
  15861. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15862. /**
  15863. * Set the alpha test sort comparison function.
  15864. * If null the sub meshes will be render in the order they were created
  15865. */
  15866. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15867. /**
  15868. * Set the transparent sort comparison function.
  15869. * If null the sub meshes will be render in the order they were created
  15870. */
  15871. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15872. /**
  15873. * Creates a new rendering group.
  15874. * @param index The rendering group index
  15875. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15876. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15877. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15878. */
  15879. 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>);
  15880. /**
  15881. * Render all the sub meshes contained in the group.
  15882. * @param customRenderFunction Used to override the default render behaviour of the group.
  15883. * @returns true if rendered some submeshes.
  15884. */
  15885. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15886. /**
  15887. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15888. * @param subMeshes The submeshes to render
  15889. */
  15890. private renderOpaqueSorted;
  15891. /**
  15892. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15893. * @param subMeshes The submeshes to render
  15894. */
  15895. private renderAlphaTestSorted;
  15896. /**
  15897. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15898. * @param subMeshes The submeshes to render
  15899. */
  15900. private renderTransparentSorted;
  15901. /**
  15902. * Renders the submeshes in a specified order.
  15903. * @param subMeshes The submeshes to sort before render
  15904. * @param sortCompareFn The comparison function use to sort
  15905. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15906. * @param transparent Specifies to activate blending if true
  15907. */
  15908. private static renderSorted;
  15909. /**
  15910. * Renders the submeshes in the order they were dispatched (no sort applied).
  15911. * @param subMeshes The submeshes to render
  15912. */
  15913. private static renderUnsorted;
  15914. /**
  15915. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15916. * are rendered back to front if in the same alpha index.
  15917. *
  15918. * @param a The first submesh
  15919. * @param b The second submesh
  15920. * @returns The result of the comparison
  15921. */
  15922. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15923. /**
  15924. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15925. * are rendered back to front.
  15926. *
  15927. * @param a The first submesh
  15928. * @param b The second submesh
  15929. * @returns The result of the comparison
  15930. */
  15931. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15932. /**
  15933. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15934. * are rendered front to back (prevent overdraw).
  15935. *
  15936. * @param a The first submesh
  15937. * @param b The second submesh
  15938. * @returns The result of the comparison
  15939. */
  15940. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15941. /**
  15942. * Resets the different lists of submeshes to prepare a new frame.
  15943. */
  15944. prepare(): void;
  15945. dispose(): void;
  15946. /**
  15947. * Inserts the submesh in its correct queue depending on its material.
  15948. * @param subMesh The submesh to dispatch
  15949. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15950. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15951. */
  15952. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15953. dispatchSprites(spriteManager: ISpriteManager): void;
  15954. dispatchParticles(particleSystem: IParticleSystem): void;
  15955. private _renderParticles;
  15956. private _renderSprites;
  15957. }
  15958. }
  15959. declare module BABYLON {
  15960. /**
  15961. * Interface describing the different options available in the rendering manager
  15962. * regarding Auto Clear between groups.
  15963. */
  15964. export interface IRenderingManagerAutoClearSetup {
  15965. /**
  15966. * Defines whether or not autoclear is enable.
  15967. */
  15968. autoClear: boolean;
  15969. /**
  15970. * Defines whether or not to autoclear the depth buffer.
  15971. */
  15972. depth: boolean;
  15973. /**
  15974. * Defines whether or not to autoclear the stencil buffer.
  15975. */
  15976. stencil: boolean;
  15977. }
  15978. /**
  15979. * This class is used by the onRenderingGroupObservable
  15980. */
  15981. export class RenderingGroupInfo {
  15982. /**
  15983. * The Scene that being rendered
  15984. */
  15985. scene: Scene;
  15986. /**
  15987. * The camera currently used for the rendering pass
  15988. */
  15989. camera: Nullable<Camera>;
  15990. /**
  15991. * The ID of the renderingGroup being processed
  15992. */
  15993. renderingGroupId: number;
  15994. }
  15995. /**
  15996. * This is the manager responsible of all the rendering for meshes sprites and particles.
  15997. * It is enable to manage the different groups as well as the different necessary sort functions.
  15998. * This should not be used directly aside of the few static configurations
  15999. */
  16000. export class RenderingManager {
  16001. /**
  16002. * The max id used for rendering groups (not included)
  16003. */
  16004. static MAX_RENDERINGGROUPS: number;
  16005. /**
  16006. * The min id used for rendering groups (included)
  16007. */
  16008. static MIN_RENDERINGGROUPS: number;
  16009. /**
  16010. * Used to globally prevent autoclearing scenes.
  16011. */
  16012. static AUTOCLEAR: boolean;
  16013. /**
  16014. * @hidden
  16015. */
  16016. _useSceneAutoClearSetup: boolean;
  16017. private _scene;
  16018. private _renderingGroups;
  16019. private _depthStencilBufferAlreadyCleaned;
  16020. private _autoClearDepthStencil;
  16021. private _customOpaqueSortCompareFn;
  16022. private _customAlphaTestSortCompareFn;
  16023. private _customTransparentSortCompareFn;
  16024. private _renderingGroupInfo;
  16025. /**
  16026. * Instantiates a new rendering group for a particular scene
  16027. * @param scene Defines the scene the groups belongs to
  16028. */
  16029. constructor(scene: Scene);
  16030. private _clearDepthStencilBuffer;
  16031. /**
  16032. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16033. * @hidden
  16034. */
  16035. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16036. /**
  16037. * Resets the different information of the group to prepare a new frame
  16038. * @hidden
  16039. */
  16040. reset(): void;
  16041. /**
  16042. * Dispose and release the group and its associated resources.
  16043. * @hidden
  16044. */
  16045. dispose(): void;
  16046. /**
  16047. * Clear the info related to rendering groups preventing retention points during dispose.
  16048. */
  16049. freeRenderingGroups(): void;
  16050. private _prepareRenderingGroup;
  16051. /**
  16052. * Add a sprite manager to the rendering manager in order to render it this frame.
  16053. * @param spriteManager Define the sprite manager to render
  16054. */
  16055. dispatchSprites(spriteManager: ISpriteManager): void;
  16056. /**
  16057. * Add a particle system to the rendering manager in order to render it this frame.
  16058. * @param particleSystem Define the particle system to render
  16059. */
  16060. dispatchParticles(particleSystem: IParticleSystem): void;
  16061. /**
  16062. * Add a submesh to the manager in order to render it this frame
  16063. * @param subMesh The submesh to dispatch
  16064. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16065. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16066. */
  16067. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16068. /**
  16069. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16070. * This allowed control for front to back rendering or reversly depending of the special needs.
  16071. *
  16072. * @param renderingGroupId The rendering group id corresponding to its index
  16073. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16074. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16075. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16076. */
  16077. 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;
  16078. /**
  16079. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16080. *
  16081. * @param renderingGroupId The rendering group id corresponding to its index
  16082. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16083. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16084. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16085. */
  16086. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16087. /**
  16088. * Gets the current auto clear configuration for one rendering group of the rendering
  16089. * manager.
  16090. * @param index the rendering group index to get the information for
  16091. * @returns The auto clear setup for the requested rendering group
  16092. */
  16093. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16094. }
  16095. }
  16096. declare module BABYLON {
  16097. /**
  16098. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16099. */
  16100. export interface ICustomShaderOptions {
  16101. /**
  16102. * Gets or sets the custom shader name to use
  16103. */
  16104. shaderName: string;
  16105. /**
  16106. * The list of attribute names used in the shader
  16107. */
  16108. attributes?: string[];
  16109. /**
  16110. * The list of unifrom names used in the shader
  16111. */
  16112. uniforms?: string[];
  16113. /**
  16114. * The list of sampler names used in the shader
  16115. */
  16116. samplers?: string[];
  16117. /**
  16118. * The list of defines used in the shader
  16119. */
  16120. defines?: string[];
  16121. }
  16122. /**
  16123. * Interface to implement to create a shadow generator compatible with BJS.
  16124. */
  16125. export interface IShadowGenerator {
  16126. /**
  16127. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16128. * @returns The render target texture if present otherwise, null
  16129. */
  16130. getShadowMap(): Nullable<RenderTargetTexture>;
  16131. /**
  16132. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16133. * @param subMesh The submesh we want to render in the shadow map
  16134. * @param useInstances Defines wether will draw in the map using instances
  16135. * @returns true if ready otherwise, false
  16136. */
  16137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16138. /**
  16139. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16140. * @param defines Defines of the material we want to update
  16141. * @param lightIndex Index of the light in the enabled light list of the material
  16142. */
  16143. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16144. /**
  16145. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16146. * defined in the generator but impacting the effect).
  16147. * It implies the unifroms available on the materials are the standard BJS ones.
  16148. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16149. * @param effect The effect we are binfing the information for
  16150. */
  16151. bindShadowLight(lightIndex: string, effect: Effect): void;
  16152. /**
  16153. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16154. * (eq to shadow prjection matrix * light transform matrix)
  16155. * @returns The transform matrix used to create the shadow map
  16156. */
  16157. getTransformMatrix(): Matrix;
  16158. /**
  16159. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16160. * Cube and 2D textures for instance.
  16161. */
  16162. recreateShadowMap(): void;
  16163. /**
  16164. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16165. * @param onCompiled Callback triggered at the and of the effects compilation
  16166. * @param options Sets of optional options forcing the compilation with different modes
  16167. */
  16168. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16169. useInstances: boolean;
  16170. }>): void;
  16171. /**
  16172. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16173. * @param options Sets of optional options forcing the compilation with different modes
  16174. * @returns A promise that resolves when the compilation completes
  16175. */
  16176. forceCompilationAsync(options?: Partial<{
  16177. useInstances: boolean;
  16178. }>): Promise<void>;
  16179. /**
  16180. * Serializes the shadow generator setup to a json object.
  16181. * @returns The serialized JSON object
  16182. */
  16183. serialize(): any;
  16184. /**
  16185. * Disposes the Shadow map and related Textures and effects.
  16186. */
  16187. dispose(): void;
  16188. }
  16189. /**
  16190. * Default implementation IShadowGenerator.
  16191. * This is the main object responsible of generating shadows in the framework.
  16192. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16193. */
  16194. export class ShadowGenerator implements IShadowGenerator {
  16195. /**
  16196. * Name of the shadow generator class
  16197. */
  16198. static CLASSNAME: string;
  16199. /**
  16200. * Shadow generator mode None: no filtering applied.
  16201. */
  16202. static readonly FILTER_NONE: number;
  16203. /**
  16204. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16205. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16206. */
  16207. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16208. /**
  16209. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16210. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16211. */
  16212. static readonly FILTER_POISSONSAMPLING: number;
  16213. /**
  16214. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16215. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16216. */
  16217. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16218. /**
  16219. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16220. * edge artifacts on steep falloff.
  16221. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16222. */
  16223. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16224. /**
  16225. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16226. * edge artifacts on steep falloff.
  16227. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16228. */
  16229. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16230. /**
  16231. * Shadow generator mode PCF: Percentage Closer Filtering
  16232. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16233. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16234. */
  16235. static readonly FILTER_PCF: number;
  16236. /**
  16237. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16238. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16239. * Contact Hardening
  16240. */
  16241. static readonly FILTER_PCSS: number;
  16242. /**
  16243. * Reserved for PCF and PCSS
  16244. * Highest Quality.
  16245. *
  16246. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16247. *
  16248. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16249. */
  16250. static readonly QUALITY_HIGH: number;
  16251. /**
  16252. * Reserved for PCF and PCSS
  16253. * Good tradeoff for quality/perf cross devices
  16254. *
  16255. * Execute PCF on a 3*3 kernel.
  16256. *
  16257. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16258. */
  16259. static readonly QUALITY_MEDIUM: number;
  16260. /**
  16261. * Reserved for PCF and PCSS
  16262. * The lowest quality but the fastest.
  16263. *
  16264. * Execute PCF on a 1*1 kernel.
  16265. *
  16266. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16267. */
  16268. static readonly QUALITY_LOW: number;
  16269. /** Gets or sets the custom shader name to use */
  16270. customShaderOptions: ICustomShaderOptions;
  16271. /**
  16272. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16273. */
  16274. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16275. /**
  16276. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16277. */
  16278. onAfterShadowMapRenderObservable: Observable<Effect>;
  16279. /**
  16280. * Observable triggered before a mesh is rendered in the shadow map.
  16281. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16282. */
  16283. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16284. /**
  16285. * Observable triggered after a mesh is rendered in the shadow map.
  16286. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16287. */
  16288. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16289. protected _bias: number;
  16290. /**
  16291. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16292. */
  16293. get bias(): number;
  16294. /**
  16295. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16296. */
  16297. set bias(bias: number);
  16298. protected _normalBias: number;
  16299. /**
  16300. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16301. */
  16302. get normalBias(): number;
  16303. /**
  16304. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16305. */
  16306. set normalBias(normalBias: number);
  16307. protected _blurBoxOffset: number;
  16308. /**
  16309. * Gets the blur box offset: offset applied during the blur pass.
  16310. * Only useful if useKernelBlur = false
  16311. */
  16312. get blurBoxOffset(): number;
  16313. /**
  16314. * Sets the blur box offset: offset applied during the blur pass.
  16315. * Only useful if useKernelBlur = false
  16316. */
  16317. set blurBoxOffset(value: number);
  16318. protected _blurScale: number;
  16319. /**
  16320. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16321. * 2 means half of the size.
  16322. */
  16323. get blurScale(): number;
  16324. /**
  16325. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16326. * 2 means half of the size.
  16327. */
  16328. set blurScale(value: number);
  16329. protected _blurKernel: number;
  16330. /**
  16331. * Gets the blur kernel: kernel size of the blur pass.
  16332. * Only useful if useKernelBlur = true
  16333. */
  16334. get blurKernel(): number;
  16335. /**
  16336. * Sets the blur kernel: kernel size of the blur pass.
  16337. * Only useful if useKernelBlur = true
  16338. */
  16339. set blurKernel(value: number);
  16340. protected _useKernelBlur: boolean;
  16341. /**
  16342. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16343. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16344. */
  16345. get useKernelBlur(): boolean;
  16346. /**
  16347. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16348. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16349. */
  16350. set useKernelBlur(value: boolean);
  16351. protected _depthScale: number;
  16352. /**
  16353. * Gets the depth scale used in ESM mode.
  16354. */
  16355. get depthScale(): number;
  16356. /**
  16357. * Sets the depth scale used in ESM mode.
  16358. * This can override the scale stored on the light.
  16359. */
  16360. set depthScale(value: number);
  16361. protected _validateFilter(filter: number): number;
  16362. protected _filter: number;
  16363. /**
  16364. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16365. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16366. */
  16367. get filter(): number;
  16368. /**
  16369. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16370. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16371. */
  16372. set filter(value: number);
  16373. /**
  16374. * Gets if the current filter is set to Poisson Sampling.
  16375. */
  16376. get usePoissonSampling(): boolean;
  16377. /**
  16378. * Sets the current filter to Poisson Sampling.
  16379. */
  16380. set usePoissonSampling(value: boolean);
  16381. /**
  16382. * Gets if the current filter is set to ESM.
  16383. */
  16384. get useExponentialShadowMap(): boolean;
  16385. /**
  16386. * Sets the current filter is to ESM.
  16387. */
  16388. set useExponentialShadowMap(value: boolean);
  16389. /**
  16390. * Gets if the current filter is set to filtered ESM.
  16391. */
  16392. get useBlurExponentialShadowMap(): boolean;
  16393. /**
  16394. * Gets if the current filter is set to filtered ESM.
  16395. */
  16396. set useBlurExponentialShadowMap(value: boolean);
  16397. /**
  16398. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16399. * exponential to prevent steep falloff artifacts).
  16400. */
  16401. get useCloseExponentialShadowMap(): boolean;
  16402. /**
  16403. * Sets the current filter to "close ESM" (using the inverse of the
  16404. * exponential to prevent steep falloff artifacts).
  16405. */
  16406. set useCloseExponentialShadowMap(value: boolean);
  16407. /**
  16408. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16409. * exponential to prevent steep falloff artifacts).
  16410. */
  16411. get useBlurCloseExponentialShadowMap(): boolean;
  16412. /**
  16413. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16414. * exponential to prevent steep falloff artifacts).
  16415. */
  16416. set useBlurCloseExponentialShadowMap(value: boolean);
  16417. /**
  16418. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16419. */
  16420. get usePercentageCloserFiltering(): boolean;
  16421. /**
  16422. * Sets the current filter to "PCF" (percentage closer filtering).
  16423. */
  16424. set usePercentageCloserFiltering(value: boolean);
  16425. protected _filteringQuality: number;
  16426. /**
  16427. * Gets the PCF or PCSS Quality.
  16428. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16429. */
  16430. get filteringQuality(): number;
  16431. /**
  16432. * Sets the PCF or PCSS Quality.
  16433. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16434. */
  16435. set filteringQuality(filteringQuality: number);
  16436. /**
  16437. * Gets if the current filter is set to "PCSS" (contact hardening).
  16438. */
  16439. get useContactHardeningShadow(): boolean;
  16440. /**
  16441. * Sets the current filter to "PCSS" (contact hardening).
  16442. */
  16443. set useContactHardeningShadow(value: boolean);
  16444. protected _contactHardeningLightSizeUVRatio: number;
  16445. /**
  16446. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16447. * Using a ratio helps keeping shape stability independently of the map size.
  16448. *
  16449. * It does not account for the light projection as it was having too much
  16450. * instability during the light setup or during light position changes.
  16451. *
  16452. * Only valid if useContactHardeningShadow is true.
  16453. */
  16454. get contactHardeningLightSizeUVRatio(): number;
  16455. /**
  16456. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16457. * Using a ratio helps keeping shape stability independently of the map size.
  16458. *
  16459. * It does not account for the light projection as it was having too much
  16460. * instability during the light setup or during light position changes.
  16461. *
  16462. * Only valid if useContactHardeningShadow is true.
  16463. */
  16464. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16465. protected _darkness: number;
  16466. /** Gets or sets the actual darkness of a shadow */
  16467. get darkness(): number;
  16468. set darkness(value: number);
  16469. /**
  16470. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16471. * 0 means strongest and 1 would means no shadow.
  16472. * @returns the darkness.
  16473. */
  16474. getDarkness(): number;
  16475. /**
  16476. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16477. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16478. * @returns the shadow generator allowing fluent coding.
  16479. */
  16480. setDarkness(darkness: number): ShadowGenerator;
  16481. protected _transparencyShadow: boolean;
  16482. /** Gets or sets the ability to have transparent shadow */
  16483. get transparencyShadow(): boolean;
  16484. set transparencyShadow(value: boolean);
  16485. /**
  16486. * Sets the ability to have transparent shadow (boolean).
  16487. * @param transparent True if transparent else False
  16488. * @returns the shadow generator allowing fluent coding
  16489. */
  16490. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16491. protected _shadowMap: Nullable<RenderTargetTexture>;
  16492. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16493. /**
  16494. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16495. * @returns The render target texture if present otherwise, null
  16496. */
  16497. getShadowMap(): Nullable<RenderTargetTexture>;
  16498. /**
  16499. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16500. * @returns The render target texture if the shadow map is present otherwise, null
  16501. */
  16502. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16503. /**
  16504. * Gets the class name of that object
  16505. * @returns "ShadowGenerator"
  16506. */
  16507. getClassName(): string;
  16508. /**
  16509. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16510. * @param mesh Mesh to add
  16511. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16512. * @returns the Shadow Generator itself
  16513. */
  16514. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16515. /**
  16516. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16517. * @param mesh Mesh to remove
  16518. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16519. * @returns the Shadow Generator itself
  16520. */
  16521. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16522. /**
  16523. * Controls the extent to which the shadows fade out at the edge of the frustum
  16524. */
  16525. frustumEdgeFalloff: number;
  16526. protected _light: IShadowLight;
  16527. /**
  16528. * Returns the associated light object.
  16529. * @returns the light generating the shadow
  16530. */
  16531. getLight(): IShadowLight;
  16532. /**
  16533. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16534. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16535. * It might on the other hand introduce peter panning.
  16536. */
  16537. forceBackFacesOnly: boolean;
  16538. protected _scene: Scene;
  16539. protected _lightDirection: Vector3;
  16540. protected _effect: Effect;
  16541. protected _viewMatrix: Matrix;
  16542. protected _projectionMatrix: Matrix;
  16543. protected _transformMatrix: Matrix;
  16544. protected _cachedPosition: Vector3;
  16545. protected _cachedDirection: Vector3;
  16546. protected _cachedDefines: string;
  16547. protected _currentRenderID: number;
  16548. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16549. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16550. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16551. protected _blurPostProcesses: PostProcess[];
  16552. protected _mapSize: number;
  16553. protected _currentFaceIndex: number;
  16554. protected _currentFaceIndexCache: number;
  16555. protected _textureType: number;
  16556. protected _defaultTextureMatrix: Matrix;
  16557. protected _storedUniqueId: Nullable<number>;
  16558. /** @hidden */
  16559. static _SceneComponentInitialization: (scene: Scene) => void;
  16560. /**
  16561. * Creates a ShadowGenerator object.
  16562. * A ShadowGenerator is the required tool to use the shadows.
  16563. * Each light casting shadows needs to use its own ShadowGenerator.
  16564. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16565. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16566. * @param light The light object generating the shadows.
  16567. * @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.
  16568. */
  16569. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16570. protected _initializeGenerator(): void;
  16571. protected _createTargetRenderTexture(): void;
  16572. protected _initializeShadowMap(): void;
  16573. protected _initializeBlurRTTAndPostProcesses(): void;
  16574. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16575. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16576. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16577. protected _applyFilterValues(): void;
  16578. /**
  16579. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16580. * @param onCompiled Callback triggered at the and of the effects compilation
  16581. * @param options Sets of optional options forcing the compilation with different modes
  16582. */
  16583. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16584. useInstances: boolean;
  16585. }>): void;
  16586. /**
  16587. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16588. * @param options Sets of optional options forcing the compilation with different modes
  16589. * @returns A promise that resolves when the compilation completes
  16590. */
  16591. forceCompilationAsync(options?: Partial<{
  16592. useInstances: boolean;
  16593. }>): Promise<void>;
  16594. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16595. /**
  16596. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16597. * @param subMesh The submesh we want to render in the shadow map
  16598. * @param useInstances Defines wether will draw in the map using instances
  16599. * @returns true if ready otherwise, false
  16600. */
  16601. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16602. /**
  16603. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16604. * @param defines Defines of the material we want to update
  16605. * @param lightIndex Index of the light in the enabled light list of the material
  16606. */
  16607. prepareDefines(defines: any, lightIndex: number): void;
  16608. /**
  16609. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16610. * defined in the generator but impacting the effect).
  16611. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16612. * @param effect The effect we are binfing the information for
  16613. */
  16614. bindShadowLight(lightIndex: string, effect: Effect): void;
  16615. /**
  16616. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16617. * (eq to shadow prjection matrix * light transform matrix)
  16618. * @returns The transform matrix used to create the shadow map
  16619. */
  16620. getTransformMatrix(): Matrix;
  16621. /**
  16622. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16623. * Cube and 2D textures for instance.
  16624. */
  16625. recreateShadowMap(): void;
  16626. protected _disposeBlurPostProcesses(): void;
  16627. protected _disposeRTTandPostProcesses(): void;
  16628. /**
  16629. * Disposes the ShadowGenerator.
  16630. * Returns nothing.
  16631. */
  16632. dispose(): void;
  16633. /**
  16634. * Serializes the shadow generator setup to a json object.
  16635. * @returns The serialized JSON object
  16636. */
  16637. serialize(): any;
  16638. /**
  16639. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16640. * @param parsedShadowGenerator The JSON object to parse
  16641. * @param scene The scene to create the shadow map for
  16642. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16643. * @returns The parsed shadow generator
  16644. */
  16645. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16646. }
  16647. }
  16648. declare module BABYLON {
  16649. /**
  16650. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16651. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16652. * 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.
  16653. */
  16654. export abstract class Light extends Node {
  16655. /**
  16656. * Falloff Default: light is falling off following the material specification:
  16657. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16658. */
  16659. static readonly FALLOFF_DEFAULT: number;
  16660. /**
  16661. * Falloff Physical: light is falling off following the inverse squared distance law.
  16662. */
  16663. static readonly FALLOFF_PHYSICAL: number;
  16664. /**
  16665. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16666. * to enhance interoperability with other engines.
  16667. */
  16668. static readonly FALLOFF_GLTF: number;
  16669. /**
  16670. * Falloff Standard: light is falling off like in the standard material
  16671. * to enhance interoperability with other materials.
  16672. */
  16673. static readonly FALLOFF_STANDARD: number;
  16674. /**
  16675. * If every light affecting the material is in this lightmapMode,
  16676. * material.lightmapTexture adds or multiplies
  16677. * (depends on material.useLightmapAsShadowmap)
  16678. * after every other light calculations.
  16679. */
  16680. static readonly LIGHTMAP_DEFAULT: number;
  16681. /**
  16682. * material.lightmapTexture as only diffuse lighting from this light
  16683. * adds only specular lighting from this light
  16684. * adds dynamic shadows
  16685. */
  16686. static readonly LIGHTMAP_SPECULAR: number;
  16687. /**
  16688. * material.lightmapTexture as only lighting
  16689. * no light calculation from this light
  16690. * only adds dynamic shadows from this light
  16691. */
  16692. static readonly LIGHTMAP_SHADOWSONLY: number;
  16693. /**
  16694. * Each light type uses the default quantity according to its type:
  16695. * point/spot lights use luminous intensity
  16696. * directional lights use illuminance
  16697. */
  16698. static readonly INTENSITYMODE_AUTOMATIC: number;
  16699. /**
  16700. * lumen (lm)
  16701. */
  16702. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16703. /**
  16704. * candela (lm/sr)
  16705. */
  16706. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16707. /**
  16708. * lux (lm/m^2)
  16709. */
  16710. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16711. /**
  16712. * nit (cd/m^2)
  16713. */
  16714. static readonly INTENSITYMODE_LUMINANCE: number;
  16715. /**
  16716. * Light type const id of the point light.
  16717. */
  16718. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16719. /**
  16720. * Light type const id of the directional light.
  16721. */
  16722. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16723. /**
  16724. * Light type const id of the spot light.
  16725. */
  16726. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16727. /**
  16728. * Light type const id of the hemispheric light.
  16729. */
  16730. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16731. /**
  16732. * Diffuse gives the basic color to an object.
  16733. */
  16734. diffuse: Color3;
  16735. /**
  16736. * Specular produces a highlight color on an object.
  16737. * Note: This is note affecting PBR materials.
  16738. */
  16739. specular: Color3;
  16740. /**
  16741. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16742. * falling off base on range or angle.
  16743. * This can be set to any values in Light.FALLOFF_x.
  16744. *
  16745. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16746. * other types of materials.
  16747. */
  16748. falloffType: number;
  16749. /**
  16750. * Strength of the light.
  16751. * Note: By default it is define in the framework own unit.
  16752. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16753. */
  16754. intensity: number;
  16755. private _range;
  16756. protected _inverseSquaredRange: number;
  16757. /**
  16758. * Defines how far from the source the light is impacting in scene units.
  16759. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16760. */
  16761. get range(): number;
  16762. /**
  16763. * Defines how far from the source the light is impacting in scene units.
  16764. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16765. */
  16766. set range(value: number);
  16767. /**
  16768. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16769. * of light.
  16770. */
  16771. private _photometricScale;
  16772. private _intensityMode;
  16773. /**
  16774. * Gets the photometric scale used to interpret the intensity.
  16775. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16776. */
  16777. get intensityMode(): number;
  16778. /**
  16779. * Sets the photometric scale used to interpret the intensity.
  16780. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16781. */
  16782. set intensityMode(value: number);
  16783. private _radius;
  16784. /**
  16785. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16786. */
  16787. get radius(): number;
  16788. /**
  16789. * sets the light radius used by PBR Materials to simulate soft area lights.
  16790. */
  16791. set radius(value: number);
  16792. private _renderPriority;
  16793. /**
  16794. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16795. * exceeding the number allowed of the materials.
  16796. */
  16797. renderPriority: number;
  16798. private _shadowEnabled;
  16799. /**
  16800. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16801. * the current shadow generator.
  16802. */
  16803. get shadowEnabled(): boolean;
  16804. /**
  16805. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16806. * the current shadow generator.
  16807. */
  16808. set shadowEnabled(value: boolean);
  16809. private _includedOnlyMeshes;
  16810. /**
  16811. * Gets the only meshes impacted by this light.
  16812. */
  16813. get includedOnlyMeshes(): AbstractMesh[];
  16814. /**
  16815. * Sets the only meshes impacted by this light.
  16816. */
  16817. set includedOnlyMeshes(value: AbstractMesh[]);
  16818. private _excludedMeshes;
  16819. /**
  16820. * Gets the meshes not impacted by this light.
  16821. */
  16822. get excludedMeshes(): AbstractMesh[];
  16823. /**
  16824. * Sets the meshes not impacted by this light.
  16825. */
  16826. set excludedMeshes(value: AbstractMesh[]);
  16827. private _excludeWithLayerMask;
  16828. /**
  16829. * Gets the layer id use to find what meshes are not impacted by the light.
  16830. * Inactive if 0
  16831. */
  16832. get excludeWithLayerMask(): number;
  16833. /**
  16834. * Sets the layer id use to find what meshes are not impacted by the light.
  16835. * Inactive if 0
  16836. */
  16837. set excludeWithLayerMask(value: number);
  16838. private _includeOnlyWithLayerMask;
  16839. /**
  16840. * Gets the layer id use to find what meshes are impacted by the light.
  16841. * Inactive if 0
  16842. */
  16843. get includeOnlyWithLayerMask(): number;
  16844. /**
  16845. * Sets the layer id use to find what meshes are impacted by the light.
  16846. * Inactive if 0
  16847. */
  16848. set includeOnlyWithLayerMask(value: number);
  16849. private _lightmapMode;
  16850. /**
  16851. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16852. */
  16853. get lightmapMode(): number;
  16854. /**
  16855. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16856. */
  16857. set lightmapMode(value: number);
  16858. /**
  16859. * Shadow generator associted to the light.
  16860. * @hidden Internal use only.
  16861. */
  16862. _shadowGenerator: Nullable<IShadowGenerator>;
  16863. /**
  16864. * @hidden Internal use only.
  16865. */
  16866. _excludedMeshesIds: string[];
  16867. /**
  16868. * @hidden Internal use only.
  16869. */
  16870. _includedOnlyMeshesIds: string[];
  16871. /**
  16872. * The current light unifom buffer.
  16873. * @hidden Internal use only.
  16874. */
  16875. _uniformBuffer: UniformBuffer;
  16876. /** @hidden */
  16877. _renderId: number;
  16878. /**
  16879. * Creates a Light object in the scene.
  16880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16881. * @param name The firendly name of the light
  16882. * @param scene The scene the light belongs too
  16883. */
  16884. constructor(name: string, scene: Scene);
  16885. protected abstract _buildUniformLayout(): void;
  16886. /**
  16887. * Sets the passed Effect "effect" with the Light information.
  16888. * @param effect The effect to update
  16889. * @param lightIndex The index of the light in the effect to update
  16890. * @returns The light
  16891. */
  16892. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16893. /**
  16894. * Sets the passed Effect "effect" with the Light textures.
  16895. * @param effect The effect to update
  16896. * @param lightIndex The index of the light in the effect to update
  16897. * @returns The light
  16898. */
  16899. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16900. /**
  16901. * Binds the lights information from the scene to the effect for the given mesh.
  16902. * @param lightIndex Light index
  16903. * @param scene The scene where the light belongs to
  16904. * @param effect The effect we are binding the data to
  16905. * @param useSpecular Defines if specular is supported
  16906. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16907. */
  16908. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16909. /**
  16910. * Sets the passed Effect "effect" with the Light information.
  16911. * @param effect The effect to update
  16912. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16913. * @returns The light
  16914. */
  16915. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16916. /**
  16917. * Returns the string "Light".
  16918. * @returns the class name
  16919. */
  16920. getClassName(): string;
  16921. /** @hidden */
  16922. readonly _isLight: boolean;
  16923. /**
  16924. * Converts the light information to a readable string for debug purpose.
  16925. * @param fullDetails Supports for multiple levels of logging within scene loading
  16926. * @returns the human readable light info
  16927. */
  16928. toString(fullDetails?: boolean): string;
  16929. /** @hidden */
  16930. protected _syncParentEnabledState(): void;
  16931. /**
  16932. * Set the enabled state of this node.
  16933. * @param value - the new enabled state
  16934. */
  16935. setEnabled(value: boolean): void;
  16936. /**
  16937. * Returns the Light associated shadow generator if any.
  16938. * @return the associated shadow generator.
  16939. */
  16940. getShadowGenerator(): Nullable<IShadowGenerator>;
  16941. /**
  16942. * Returns a Vector3, the absolute light position in the World.
  16943. * @returns the world space position of the light
  16944. */
  16945. getAbsolutePosition(): Vector3;
  16946. /**
  16947. * Specifies if the light will affect the passed mesh.
  16948. * @param mesh The mesh to test against the light
  16949. * @return true the mesh is affected otherwise, false.
  16950. */
  16951. canAffectMesh(mesh: AbstractMesh): boolean;
  16952. /**
  16953. * Sort function to order lights for rendering.
  16954. * @param a First Light object to compare to second.
  16955. * @param b Second Light object to compare first.
  16956. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16957. */
  16958. static CompareLightsPriority(a: Light, b: Light): number;
  16959. /**
  16960. * Releases resources associated with this node.
  16961. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16962. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16963. */
  16964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16965. /**
  16966. * Returns the light type ID (integer).
  16967. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16968. */
  16969. getTypeID(): number;
  16970. /**
  16971. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16972. * @returns the scaled intensity in intensity mode unit
  16973. */
  16974. getScaledIntensity(): number;
  16975. /**
  16976. * Returns a new Light object, named "name", from the current one.
  16977. * @param name The name of the cloned light
  16978. * @returns the new created light
  16979. */
  16980. clone(name: string): Nullable<Light>;
  16981. /**
  16982. * Serializes the current light into a Serialization object.
  16983. * @returns the serialized object.
  16984. */
  16985. serialize(): any;
  16986. /**
  16987. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16988. * This new light is named "name" and added to the passed scene.
  16989. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16990. * @param name The friendly name of the light
  16991. * @param scene The scene the new light will belong to
  16992. * @returns the constructor function
  16993. */
  16994. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16995. /**
  16996. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16997. * @param parsedLight The JSON representation of the light
  16998. * @param scene The scene to create the parsed light in
  16999. * @returns the created light after parsing
  17000. */
  17001. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17002. private _hookArrayForExcluded;
  17003. private _hookArrayForIncludedOnly;
  17004. private _resyncMeshes;
  17005. /**
  17006. * Forces the meshes to update their light related information in their rendering used effects
  17007. * @hidden Internal Use Only
  17008. */
  17009. _markMeshesAsLightDirty(): void;
  17010. /**
  17011. * Recomputes the cached photometric scale if needed.
  17012. */
  17013. private _computePhotometricScale;
  17014. /**
  17015. * Returns the Photometric Scale according to the light type and intensity mode.
  17016. */
  17017. private _getPhotometricScale;
  17018. /**
  17019. * Reorder the light in the scene according to their defined priority.
  17020. * @hidden Internal Use Only
  17021. */
  17022. _reorderLightsInScene(): void;
  17023. /**
  17024. * Prepares the list of defines specific to the light type.
  17025. * @param defines the list of defines
  17026. * @param lightIndex defines the index of the light for the effect
  17027. */
  17028. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17029. }
  17030. }
  17031. declare module BABYLON {
  17032. /**
  17033. * Interface used to define Action
  17034. */
  17035. export interface IAction {
  17036. /**
  17037. * Trigger for the action
  17038. */
  17039. trigger: number;
  17040. /** Options of the trigger */
  17041. triggerOptions: any;
  17042. /**
  17043. * Gets the trigger parameters
  17044. * @returns the trigger parameters
  17045. */
  17046. getTriggerParameter(): any;
  17047. /**
  17048. * Internal only - executes current action event
  17049. * @hidden
  17050. */
  17051. _executeCurrent(evt?: ActionEvent): void;
  17052. /**
  17053. * Serialize placeholder for child classes
  17054. * @param parent of child
  17055. * @returns the serialized object
  17056. */
  17057. serialize(parent: any): any;
  17058. /**
  17059. * Internal only
  17060. * @hidden
  17061. */
  17062. _prepare(): void;
  17063. /**
  17064. * Internal only - manager for action
  17065. * @hidden
  17066. */
  17067. _actionManager: AbstractActionManager;
  17068. /**
  17069. * Adds action to chain of actions, may be a DoNothingAction
  17070. * @param action defines the next action to execute
  17071. * @returns The action passed in
  17072. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17073. */
  17074. then(action: IAction): IAction;
  17075. }
  17076. /**
  17077. * The action to be carried out following a trigger
  17078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17079. */
  17080. export class Action implements IAction {
  17081. /** the trigger, with or without parameters, for the action */
  17082. triggerOptions: any;
  17083. /**
  17084. * Trigger for the action
  17085. */
  17086. trigger: number;
  17087. /**
  17088. * Internal only - manager for action
  17089. * @hidden
  17090. */
  17091. _actionManager: ActionManager;
  17092. private _nextActiveAction;
  17093. private _child;
  17094. private _condition?;
  17095. private _triggerParameter;
  17096. /**
  17097. * An event triggered prior to action being executed.
  17098. */
  17099. onBeforeExecuteObservable: Observable<Action>;
  17100. /**
  17101. * Creates a new Action
  17102. * @param triggerOptions the trigger, with or without parameters, for the action
  17103. * @param condition an optional determinant of action
  17104. */
  17105. constructor(
  17106. /** the trigger, with or without parameters, for the action */
  17107. triggerOptions: any, condition?: Condition);
  17108. /**
  17109. * Internal only
  17110. * @hidden
  17111. */
  17112. _prepare(): void;
  17113. /**
  17114. * Gets the trigger parameters
  17115. * @returns the trigger parameters
  17116. */
  17117. getTriggerParameter(): any;
  17118. /**
  17119. * Internal only - executes current action event
  17120. * @hidden
  17121. */
  17122. _executeCurrent(evt?: ActionEvent): void;
  17123. /**
  17124. * Execute placeholder for child classes
  17125. * @param evt optional action event
  17126. */
  17127. execute(evt?: ActionEvent): void;
  17128. /**
  17129. * Skips to next active action
  17130. */
  17131. skipToNextActiveAction(): void;
  17132. /**
  17133. * Adds action to chain of actions, may be a DoNothingAction
  17134. * @param action defines the next action to execute
  17135. * @returns The action passed in
  17136. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17137. */
  17138. then(action: Action): Action;
  17139. /**
  17140. * Internal only
  17141. * @hidden
  17142. */
  17143. _getProperty(propertyPath: string): string;
  17144. /**
  17145. * Internal only
  17146. * @hidden
  17147. */
  17148. _getEffectiveTarget(target: any, propertyPath: string): any;
  17149. /**
  17150. * Serialize placeholder for child classes
  17151. * @param parent of child
  17152. * @returns the serialized object
  17153. */
  17154. serialize(parent: any): any;
  17155. /**
  17156. * Internal only called by serialize
  17157. * @hidden
  17158. */
  17159. protected _serialize(serializedAction: any, parent?: any): any;
  17160. /**
  17161. * Internal only
  17162. * @hidden
  17163. */
  17164. static _SerializeValueAsString: (value: any) => string;
  17165. /**
  17166. * Internal only
  17167. * @hidden
  17168. */
  17169. static _GetTargetProperty: (target: Node | Scene) => {
  17170. name: string;
  17171. targetType: string;
  17172. value: string;
  17173. };
  17174. }
  17175. }
  17176. declare module BABYLON {
  17177. /**
  17178. * A Condition applied to an Action
  17179. */
  17180. export class Condition {
  17181. /**
  17182. * Internal only - manager for action
  17183. * @hidden
  17184. */
  17185. _actionManager: ActionManager;
  17186. /**
  17187. * Internal only
  17188. * @hidden
  17189. */
  17190. _evaluationId: number;
  17191. /**
  17192. * Internal only
  17193. * @hidden
  17194. */
  17195. _currentResult: boolean;
  17196. /**
  17197. * Creates a new Condition
  17198. * @param actionManager the manager of the action the condition is applied to
  17199. */
  17200. constructor(actionManager: ActionManager);
  17201. /**
  17202. * Check if the current condition is valid
  17203. * @returns a boolean
  17204. */
  17205. isValid(): boolean;
  17206. /**
  17207. * Internal only
  17208. * @hidden
  17209. */
  17210. _getProperty(propertyPath: string): string;
  17211. /**
  17212. * Internal only
  17213. * @hidden
  17214. */
  17215. _getEffectiveTarget(target: any, propertyPath: string): any;
  17216. /**
  17217. * Serialize placeholder for child classes
  17218. * @returns the serialized object
  17219. */
  17220. serialize(): any;
  17221. /**
  17222. * Internal only
  17223. * @hidden
  17224. */
  17225. protected _serialize(serializedCondition: any): any;
  17226. }
  17227. /**
  17228. * Defines specific conditional operators as extensions of Condition
  17229. */
  17230. export class ValueCondition extends Condition {
  17231. /** path to specify the property of the target the conditional operator uses */
  17232. propertyPath: string;
  17233. /** the value compared by the conditional operator against the current value of the property */
  17234. value: any;
  17235. /** the conditional operator, default ValueCondition.IsEqual */
  17236. operator: number;
  17237. /**
  17238. * Internal only
  17239. * @hidden
  17240. */
  17241. private static _IsEqual;
  17242. /**
  17243. * Internal only
  17244. * @hidden
  17245. */
  17246. private static _IsDifferent;
  17247. /**
  17248. * Internal only
  17249. * @hidden
  17250. */
  17251. private static _IsGreater;
  17252. /**
  17253. * Internal only
  17254. * @hidden
  17255. */
  17256. private static _IsLesser;
  17257. /**
  17258. * returns the number for IsEqual
  17259. */
  17260. static get IsEqual(): number;
  17261. /**
  17262. * Returns the number for IsDifferent
  17263. */
  17264. static get IsDifferent(): number;
  17265. /**
  17266. * Returns the number for IsGreater
  17267. */
  17268. static get IsGreater(): number;
  17269. /**
  17270. * Returns the number for IsLesser
  17271. */
  17272. static get IsLesser(): number;
  17273. /**
  17274. * Internal only The action manager for the condition
  17275. * @hidden
  17276. */
  17277. _actionManager: ActionManager;
  17278. /**
  17279. * Internal only
  17280. * @hidden
  17281. */
  17282. private _target;
  17283. /**
  17284. * Internal only
  17285. * @hidden
  17286. */
  17287. private _effectiveTarget;
  17288. /**
  17289. * Internal only
  17290. * @hidden
  17291. */
  17292. private _property;
  17293. /**
  17294. * Creates a new ValueCondition
  17295. * @param actionManager manager for the action the condition applies to
  17296. * @param target for the action
  17297. * @param propertyPath path to specify the property of the target the conditional operator uses
  17298. * @param value the value compared by the conditional operator against the current value of the property
  17299. * @param operator the conditional operator, default ValueCondition.IsEqual
  17300. */
  17301. constructor(actionManager: ActionManager, target: any,
  17302. /** path to specify the property of the target the conditional operator uses */
  17303. propertyPath: string,
  17304. /** the value compared by the conditional operator against the current value of the property */
  17305. value: any,
  17306. /** the conditional operator, default ValueCondition.IsEqual */
  17307. operator?: number);
  17308. /**
  17309. * Compares the given value with the property value for the specified conditional operator
  17310. * @returns the result of the comparison
  17311. */
  17312. isValid(): boolean;
  17313. /**
  17314. * Serialize the ValueCondition into a JSON compatible object
  17315. * @returns serialization object
  17316. */
  17317. serialize(): any;
  17318. /**
  17319. * Gets the name of the conditional operator for the ValueCondition
  17320. * @param operator the conditional operator
  17321. * @returns the name
  17322. */
  17323. static GetOperatorName(operator: number): string;
  17324. }
  17325. /**
  17326. * Defines a predicate condition as an extension of Condition
  17327. */
  17328. export class PredicateCondition extends Condition {
  17329. /** defines the predicate function used to validate the condition */
  17330. predicate: () => boolean;
  17331. /**
  17332. * Internal only - manager for action
  17333. * @hidden
  17334. */
  17335. _actionManager: ActionManager;
  17336. /**
  17337. * Creates a new PredicateCondition
  17338. * @param actionManager manager for the action the condition applies to
  17339. * @param predicate defines the predicate function used to validate the condition
  17340. */
  17341. constructor(actionManager: ActionManager,
  17342. /** defines the predicate function used to validate the condition */
  17343. predicate: () => boolean);
  17344. /**
  17345. * @returns the validity of the predicate condition
  17346. */
  17347. isValid(): boolean;
  17348. }
  17349. /**
  17350. * Defines a state condition as an extension of Condition
  17351. */
  17352. export class StateCondition extends Condition {
  17353. /** Value to compare with target state */
  17354. value: string;
  17355. /**
  17356. * Internal only - manager for action
  17357. * @hidden
  17358. */
  17359. _actionManager: ActionManager;
  17360. /**
  17361. * Internal only
  17362. * @hidden
  17363. */
  17364. private _target;
  17365. /**
  17366. * Creates a new StateCondition
  17367. * @param actionManager manager for the action the condition applies to
  17368. * @param target of the condition
  17369. * @param value to compare with target state
  17370. */
  17371. constructor(actionManager: ActionManager, target: any,
  17372. /** Value to compare with target state */
  17373. value: string);
  17374. /**
  17375. * Gets a boolean indicating if the current condition is met
  17376. * @returns the validity of the state
  17377. */
  17378. isValid(): boolean;
  17379. /**
  17380. * Serialize the StateCondition into a JSON compatible object
  17381. * @returns serialization object
  17382. */
  17383. serialize(): any;
  17384. }
  17385. }
  17386. declare module BABYLON {
  17387. /**
  17388. * This defines an action responsible to toggle a boolean once triggered.
  17389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17390. */
  17391. export class SwitchBooleanAction extends Action {
  17392. /**
  17393. * The path to the boolean property in the target object
  17394. */
  17395. propertyPath: string;
  17396. private _target;
  17397. private _effectiveTarget;
  17398. private _property;
  17399. /**
  17400. * Instantiate the action
  17401. * @param triggerOptions defines the trigger options
  17402. * @param target defines the object containing the boolean
  17403. * @param propertyPath defines the path to the boolean property in the target object
  17404. * @param condition defines the trigger related conditions
  17405. */
  17406. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17407. /** @hidden */
  17408. _prepare(): void;
  17409. /**
  17410. * Execute the action toggle the boolean value.
  17411. */
  17412. execute(): void;
  17413. /**
  17414. * Serializes the actions and its related information.
  17415. * @param parent defines the object to serialize in
  17416. * @returns the serialized object
  17417. */
  17418. serialize(parent: any): any;
  17419. }
  17420. /**
  17421. * This defines an action responsible to set a the state field of the target
  17422. * to a desired value once triggered.
  17423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17424. */
  17425. export class SetStateAction extends Action {
  17426. /**
  17427. * The value to store in the state field.
  17428. */
  17429. value: string;
  17430. private _target;
  17431. /**
  17432. * Instantiate the action
  17433. * @param triggerOptions defines the trigger options
  17434. * @param target defines the object containing the state property
  17435. * @param value defines the value to store in the state field
  17436. * @param condition defines the trigger related conditions
  17437. */
  17438. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17439. /**
  17440. * Execute the action and store the value on the target state property.
  17441. */
  17442. execute(): void;
  17443. /**
  17444. * Serializes the actions and its related information.
  17445. * @param parent defines the object to serialize in
  17446. * @returns the serialized object
  17447. */
  17448. serialize(parent: any): any;
  17449. }
  17450. /**
  17451. * This defines an action responsible to set a property of the target
  17452. * to a desired value once triggered.
  17453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17454. */
  17455. export class SetValueAction extends Action {
  17456. /**
  17457. * The path of the property to set in the target.
  17458. */
  17459. propertyPath: string;
  17460. /**
  17461. * The value to set in the property
  17462. */
  17463. value: any;
  17464. private _target;
  17465. private _effectiveTarget;
  17466. private _property;
  17467. /**
  17468. * Instantiate the action
  17469. * @param triggerOptions defines the trigger options
  17470. * @param target defines the object containing the property
  17471. * @param propertyPath defines the path of the property to set in the target
  17472. * @param value defines the value to set in the property
  17473. * @param condition defines the trigger related conditions
  17474. */
  17475. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17476. /** @hidden */
  17477. _prepare(): void;
  17478. /**
  17479. * Execute the action and set the targetted property to the desired value.
  17480. */
  17481. execute(): void;
  17482. /**
  17483. * Serializes the actions and its related information.
  17484. * @param parent defines the object to serialize in
  17485. * @returns the serialized object
  17486. */
  17487. serialize(parent: any): any;
  17488. }
  17489. /**
  17490. * This defines an action responsible to increment the target value
  17491. * to a desired value once triggered.
  17492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17493. */
  17494. export class IncrementValueAction extends Action {
  17495. /**
  17496. * The path of the property to increment in the target.
  17497. */
  17498. propertyPath: string;
  17499. /**
  17500. * The value we should increment the property by.
  17501. */
  17502. value: any;
  17503. private _target;
  17504. private _effectiveTarget;
  17505. private _property;
  17506. /**
  17507. * Instantiate the action
  17508. * @param triggerOptions defines the trigger options
  17509. * @param target defines the object containing the property
  17510. * @param propertyPath defines the path of the property to increment in the target
  17511. * @param value defines the value value we should increment the property by
  17512. * @param condition defines the trigger related conditions
  17513. */
  17514. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17515. /** @hidden */
  17516. _prepare(): void;
  17517. /**
  17518. * Execute the action and increment the target of the value amount.
  17519. */
  17520. execute(): void;
  17521. /**
  17522. * Serializes the actions and its related information.
  17523. * @param parent defines the object to serialize in
  17524. * @returns the serialized object
  17525. */
  17526. serialize(parent: any): any;
  17527. }
  17528. /**
  17529. * This defines an action responsible to start an animation once triggered.
  17530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17531. */
  17532. export class PlayAnimationAction extends Action {
  17533. /**
  17534. * Where the animation should start (animation frame)
  17535. */
  17536. from: number;
  17537. /**
  17538. * Where the animation should stop (animation frame)
  17539. */
  17540. to: number;
  17541. /**
  17542. * Define if the animation should loop or stop after the first play.
  17543. */
  17544. loop?: boolean;
  17545. private _target;
  17546. /**
  17547. * Instantiate the action
  17548. * @param triggerOptions defines the trigger options
  17549. * @param target defines the target animation or animation name
  17550. * @param from defines from where the animation should start (animation frame)
  17551. * @param end defines where the animation should stop (animation frame)
  17552. * @param loop defines if the animation should loop or stop after the first play
  17553. * @param condition defines the trigger related conditions
  17554. */
  17555. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17556. /** @hidden */
  17557. _prepare(): void;
  17558. /**
  17559. * Execute the action and play the animation.
  17560. */
  17561. execute(): void;
  17562. /**
  17563. * Serializes the actions and its related information.
  17564. * @param parent defines the object to serialize in
  17565. * @returns the serialized object
  17566. */
  17567. serialize(parent: any): any;
  17568. }
  17569. /**
  17570. * This defines an action responsible to stop an animation once triggered.
  17571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17572. */
  17573. export class StopAnimationAction extends Action {
  17574. private _target;
  17575. /**
  17576. * Instantiate the action
  17577. * @param triggerOptions defines the trigger options
  17578. * @param target defines the target animation or animation name
  17579. * @param condition defines the trigger related conditions
  17580. */
  17581. constructor(triggerOptions: any, target: any, condition?: Condition);
  17582. /** @hidden */
  17583. _prepare(): void;
  17584. /**
  17585. * Execute the action and stop the animation.
  17586. */
  17587. execute(): void;
  17588. /**
  17589. * Serializes the actions and its related information.
  17590. * @param parent defines the object to serialize in
  17591. * @returns the serialized object
  17592. */
  17593. serialize(parent: any): any;
  17594. }
  17595. /**
  17596. * This defines an action responsible that does nothing once triggered.
  17597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17598. */
  17599. export class DoNothingAction extends Action {
  17600. /**
  17601. * Instantiate the action
  17602. * @param triggerOptions defines the trigger options
  17603. * @param condition defines the trigger related conditions
  17604. */
  17605. constructor(triggerOptions?: any, condition?: Condition);
  17606. /**
  17607. * Execute the action and do nothing.
  17608. */
  17609. execute(): void;
  17610. /**
  17611. * Serializes the actions and its related information.
  17612. * @param parent defines the object to serialize in
  17613. * @returns the serialized object
  17614. */
  17615. serialize(parent: any): any;
  17616. }
  17617. /**
  17618. * This defines an action responsible to trigger several actions once triggered.
  17619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17620. */
  17621. export class CombineAction extends Action {
  17622. /**
  17623. * The list of aggregated animations to run.
  17624. */
  17625. children: Action[];
  17626. /**
  17627. * Instantiate the action
  17628. * @param triggerOptions defines the trigger options
  17629. * @param children defines the list of aggregated animations to run
  17630. * @param condition defines the trigger related conditions
  17631. */
  17632. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17633. /** @hidden */
  17634. _prepare(): void;
  17635. /**
  17636. * Execute the action and executes all the aggregated actions.
  17637. */
  17638. execute(evt: ActionEvent): void;
  17639. /**
  17640. * Serializes the actions and its related information.
  17641. * @param parent defines the object to serialize in
  17642. * @returns the serialized object
  17643. */
  17644. serialize(parent: any): any;
  17645. }
  17646. /**
  17647. * This defines an action responsible to run code (external event) once triggered.
  17648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17649. */
  17650. export class ExecuteCodeAction extends Action {
  17651. /**
  17652. * The callback function to run.
  17653. */
  17654. func: (evt: ActionEvent) => void;
  17655. /**
  17656. * Instantiate the action
  17657. * @param triggerOptions defines the trigger options
  17658. * @param func defines the callback function to run
  17659. * @param condition defines the trigger related conditions
  17660. */
  17661. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17662. /**
  17663. * Execute the action and run the attached code.
  17664. */
  17665. execute(evt: ActionEvent): void;
  17666. }
  17667. /**
  17668. * This defines an action responsible to set the parent property of the target once triggered.
  17669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17670. */
  17671. export class SetParentAction extends Action {
  17672. private _parent;
  17673. private _target;
  17674. /**
  17675. * Instantiate the action
  17676. * @param triggerOptions defines the trigger options
  17677. * @param target defines the target containing the parent property
  17678. * @param parent defines from where the animation should start (animation frame)
  17679. * @param condition defines the trigger related conditions
  17680. */
  17681. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17682. /** @hidden */
  17683. _prepare(): void;
  17684. /**
  17685. * Execute the action and set the parent property.
  17686. */
  17687. execute(): void;
  17688. /**
  17689. * Serializes the actions and its related information.
  17690. * @param parent defines the object to serialize in
  17691. * @returns the serialized object
  17692. */
  17693. serialize(parent: any): any;
  17694. }
  17695. }
  17696. declare module BABYLON {
  17697. /**
  17698. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17699. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17701. */
  17702. export class ActionManager extends AbstractActionManager {
  17703. /**
  17704. * Nothing
  17705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17706. */
  17707. static readonly NothingTrigger: number;
  17708. /**
  17709. * On pick
  17710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17711. */
  17712. static readonly OnPickTrigger: number;
  17713. /**
  17714. * On left pick
  17715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17716. */
  17717. static readonly OnLeftPickTrigger: number;
  17718. /**
  17719. * On right pick
  17720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17721. */
  17722. static readonly OnRightPickTrigger: number;
  17723. /**
  17724. * On center pick
  17725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17726. */
  17727. static readonly OnCenterPickTrigger: number;
  17728. /**
  17729. * On pick down
  17730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17731. */
  17732. static readonly OnPickDownTrigger: number;
  17733. /**
  17734. * On double pick
  17735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17736. */
  17737. static readonly OnDoublePickTrigger: number;
  17738. /**
  17739. * On pick up
  17740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17741. */
  17742. static readonly OnPickUpTrigger: number;
  17743. /**
  17744. * On pick out.
  17745. * This trigger will only be raised if you also declared a OnPickDown
  17746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17747. */
  17748. static readonly OnPickOutTrigger: number;
  17749. /**
  17750. * On long press
  17751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17752. */
  17753. static readonly OnLongPressTrigger: number;
  17754. /**
  17755. * On pointer over
  17756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17757. */
  17758. static readonly OnPointerOverTrigger: number;
  17759. /**
  17760. * On pointer out
  17761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17762. */
  17763. static readonly OnPointerOutTrigger: number;
  17764. /**
  17765. * On every frame
  17766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17767. */
  17768. static readonly OnEveryFrameTrigger: number;
  17769. /**
  17770. * On intersection enter
  17771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17772. */
  17773. static readonly OnIntersectionEnterTrigger: number;
  17774. /**
  17775. * On intersection exit
  17776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17777. */
  17778. static readonly OnIntersectionExitTrigger: number;
  17779. /**
  17780. * On key down
  17781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17782. */
  17783. static readonly OnKeyDownTrigger: number;
  17784. /**
  17785. * On key up
  17786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17787. */
  17788. static readonly OnKeyUpTrigger: number;
  17789. private _scene;
  17790. /**
  17791. * Creates a new action manager
  17792. * @param scene defines the hosting scene
  17793. */
  17794. constructor(scene: Scene);
  17795. /**
  17796. * Releases all associated resources
  17797. */
  17798. dispose(): void;
  17799. /**
  17800. * Gets hosting scene
  17801. * @returns the hosting scene
  17802. */
  17803. getScene(): Scene;
  17804. /**
  17805. * Does this action manager handles actions of any of the given triggers
  17806. * @param triggers defines the triggers to be tested
  17807. * @return a boolean indicating whether one (or more) of the triggers is handled
  17808. */
  17809. hasSpecificTriggers(triggers: number[]): boolean;
  17810. /**
  17811. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17812. * speed.
  17813. * @param triggerA defines the trigger to be tested
  17814. * @param triggerB defines the trigger to be tested
  17815. * @return a boolean indicating whether one (or more) of the triggers is handled
  17816. */
  17817. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17818. /**
  17819. * Does this action manager handles actions of a given trigger
  17820. * @param trigger defines the trigger to be tested
  17821. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17822. * @return whether the trigger is handled
  17823. */
  17824. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17825. /**
  17826. * Does this action manager has pointer triggers
  17827. */
  17828. get hasPointerTriggers(): boolean;
  17829. /**
  17830. * Does this action manager has pick triggers
  17831. */
  17832. get hasPickTriggers(): boolean;
  17833. /**
  17834. * Registers an action to this action manager
  17835. * @param action defines the action to be registered
  17836. * @return the action amended (prepared) after registration
  17837. */
  17838. registerAction(action: IAction): Nullable<IAction>;
  17839. /**
  17840. * Unregisters an action to this action manager
  17841. * @param action defines the action to be unregistered
  17842. * @return a boolean indicating whether the action has been unregistered
  17843. */
  17844. unregisterAction(action: IAction): Boolean;
  17845. /**
  17846. * Process a specific trigger
  17847. * @param trigger defines the trigger to process
  17848. * @param evt defines the event details to be processed
  17849. */
  17850. processTrigger(trigger: number, evt?: IActionEvent): void;
  17851. /** @hidden */
  17852. _getEffectiveTarget(target: any, propertyPath: string): any;
  17853. /** @hidden */
  17854. _getProperty(propertyPath: string): string;
  17855. /**
  17856. * Serialize this manager to a JSON object
  17857. * @param name defines the property name to store this manager
  17858. * @returns a JSON representation of this manager
  17859. */
  17860. serialize(name: string): any;
  17861. /**
  17862. * Creates a new ActionManager from a JSON data
  17863. * @param parsedActions defines the JSON data to read from
  17864. * @param object defines the hosting mesh
  17865. * @param scene defines the hosting scene
  17866. */
  17867. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17868. /**
  17869. * Get a trigger name by index
  17870. * @param trigger defines the trigger index
  17871. * @returns a trigger name
  17872. */
  17873. static GetTriggerName(trigger: number): string;
  17874. }
  17875. }
  17876. declare module BABYLON {
  17877. /**
  17878. * Class used to represent a sprite
  17879. * @see http://doc.babylonjs.com/babylon101/sprites
  17880. */
  17881. export class Sprite {
  17882. /** defines the name */
  17883. name: string;
  17884. /** Gets or sets the current world position */
  17885. position: Vector3;
  17886. /** Gets or sets the main color */
  17887. color: Color4;
  17888. /** Gets or sets the width */
  17889. width: number;
  17890. /** Gets or sets the height */
  17891. height: number;
  17892. /** Gets or sets rotation angle */
  17893. angle: number;
  17894. /** Gets or sets the cell index in the sprite sheet */
  17895. cellIndex: number;
  17896. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17897. cellRef: string;
  17898. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17899. invertU: number;
  17900. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17901. invertV: number;
  17902. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17903. disposeWhenFinishedAnimating: boolean;
  17904. /** Gets the list of attached animations */
  17905. animations: Animation[];
  17906. /** Gets or sets a boolean indicating if the sprite can be picked */
  17907. isPickable: boolean;
  17908. /**
  17909. * Gets or sets the associated action manager
  17910. */
  17911. actionManager: Nullable<ActionManager>;
  17912. private _animationStarted;
  17913. private _loopAnimation;
  17914. private _fromIndex;
  17915. private _toIndex;
  17916. private _delay;
  17917. private _direction;
  17918. private _manager;
  17919. private _time;
  17920. private _onAnimationEnd;
  17921. /**
  17922. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17923. */
  17924. isVisible: boolean;
  17925. /**
  17926. * Gets or sets the sprite size
  17927. */
  17928. get size(): number;
  17929. set size(value: number);
  17930. /**
  17931. * Creates a new Sprite
  17932. * @param name defines the name
  17933. * @param manager defines the manager
  17934. */
  17935. constructor(
  17936. /** defines the name */
  17937. name: string, manager: ISpriteManager);
  17938. /**
  17939. * Starts an animation
  17940. * @param from defines the initial key
  17941. * @param to defines the end key
  17942. * @param loop defines if the animation must loop
  17943. * @param delay defines the start delay (in ms)
  17944. * @param onAnimationEnd defines a callback to call when animation ends
  17945. */
  17946. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17947. /** Stops current animation (if any) */
  17948. stopAnimation(): void;
  17949. /** @hidden */
  17950. _animate(deltaTime: number): void;
  17951. /** Release associated resources */
  17952. dispose(): void;
  17953. }
  17954. }
  17955. declare module BABYLON {
  17956. /**
  17957. * Information about the result of picking within a scene
  17958. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17959. */
  17960. export class PickingInfo {
  17961. /** @hidden */
  17962. _pickingUnavailable: boolean;
  17963. /**
  17964. * If the pick collided with an object
  17965. */
  17966. hit: boolean;
  17967. /**
  17968. * Distance away where the pick collided
  17969. */
  17970. distance: number;
  17971. /**
  17972. * The location of pick collision
  17973. */
  17974. pickedPoint: Nullable<Vector3>;
  17975. /**
  17976. * The mesh corresponding the the pick collision
  17977. */
  17978. pickedMesh: Nullable<AbstractMesh>;
  17979. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  17980. bu: number;
  17981. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  17982. bv: number;
  17983. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  17984. faceId: number;
  17985. /** Id of the the submesh that was picked */
  17986. subMeshId: number;
  17987. /** If a sprite was picked, this will be the sprite the pick collided with */
  17988. pickedSprite: Nullable<Sprite>;
  17989. /**
  17990. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  17991. */
  17992. originMesh: Nullable<AbstractMesh>;
  17993. /**
  17994. * The ray that was used to perform the picking.
  17995. */
  17996. ray: Nullable<Ray>;
  17997. /**
  17998. * Gets the normal correspodning to the face the pick collided with
  17999. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18000. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18001. * @returns The normal correspodning to the face the pick collided with
  18002. */
  18003. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18004. /**
  18005. * Gets the texture coordinates of where the pick occured
  18006. * @returns the vector containing the coordnates of the texture
  18007. */
  18008. getTextureCoordinates(): Nullable<Vector2>;
  18009. }
  18010. }
  18011. declare module BABYLON {
  18012. /**
  18013. * Gather the list of pointer event types as constants.
  18014. */
  18015. export class PointerEventTypes {
  18016. /**
  18017. * 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.
  18018. */
  18019. static readonly POINTERDOWN: number;
  18020. /**
  18021. * The pointerup event is fired when a pointer is no longer active.
  18022. */
  18023. static readonly POINTERUP: number;
  18024. /**
  18025. * The pointermove event is fired when a pointer changes coordinates.
  18026. */
  18027. static readonly POINTERMOVE: number;
  18028. /**
  18029. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18030. */
  18031. static readonly POINTERWHEEL: number;
  18032. /**
  18033. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18034. */
  18035. static readonly POINTERPICK: number;
  18036. /**
  18037. * The pointertap event is fired when a the object has been touched and released without drag.
  18038. */
  18039. static readonly POINTERTAP: number;
  18040. /**
  18041. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18042. */
  18043. static readonly POINTERDOUBLETAP: number;
  18044. }
  18045. /**
  18046. * Base class of pointer info types.
  18047. */
  18048. export class PointerInfoBase {
  18049. /**
  18050. * Defines the type of event (PointerEventTypes)
  18051. */
  18052. type: number;
  18053. /**
  18054. * Defines the related dom event
  18055. */
  18056. event: PointerEvent | MouseWheelEvent;
  18057. /**
  18058. * Instantiates the base class of pointers info.
  18059. * @param type Defines the type of event (PointerEventTypes)
  18060. * @param event Defines the related dom event
  18061. */
  18062. constructor(
  18063. /**
  18064. * Defines the type of event (PointerEventTypes)
  18065. */
  18066. type: number,
  18067. /**
  18068. * Defines the related dom event
  18069. */
  18070. event: PointerEvent | MouseWheelEvent);
  18071. }
  18072. /**
  18073. * This class is used to store pointer related info for the onPrePointerObservable event.
  18074. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18075. */
  18076. export class PointerInfoPre extends PointerInfoBase {
  18077. /**
  18078. * Ray from a pointer if availible (eg. 6dof controller)
  18079. */
  18080. ray: Nullable<Ray>;
  18081. /**
  18082. * Defines the local position of the pointer on the canvas.
  18083. */
  18084. localPosition: Vector2;
  18085. /**
  18086. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18087. */
  18088. skipOnPointerObservable: boolean;
  18089. /**
  18090. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18091. * @param type Defines the type of event (PointerEventTypes)
  18092. * @param event Defines the related dom event
  18093. * @param localX Defines the local x coordinates of the pointer when the event occured
  18094. * @param localY Defines the local y coordinates of the pointer when the event occured
  18095. */
  18096. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18097. }
  18098. /**
  18099. * This type contains all the data related to a pointer event in Babylon.js.
  18100. * 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.
  18101. */
  18102. export class PointerInfo extends PointerInfoBase {
  18103. /**
  18104. * Defines the picking info associated to the info (if any)\
  18105. */
  18106. pickInfo: Nullable<PickingInfo>;
  18107. /**
  18108. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18109. * @param type Defines the type of event (PointerEventTypes)
  18110. * @param event Defines the related dom event
  18111. * @param pickInfo Defines the picking info associated to the info (if any)\
  18112. */
  18113. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18114. /**
  18115. * Defines the picking info associated to the info (if any)\
  18116. */
  18117. pickInfo: Nullable<PickingInfo>);
  18118. }
  18119. /**
  18120. * Data relating to a touch event on the screen.
  18121. */
  18122. export interface PointerTouch {
  18123. /**
  18124. * X coordinate of touch.
  18125. */
  18126. x: number;
  18127. /**
  18128. * Y coordinate of touch.
  18129. */
  18130. y: number;
  18131. /**
  18132. * Id of touch. Unique for each finger.
  18133. */
  18134. pointerId: number;
  18135. /**
  18136. * Event type passed from DOM.
  18137. */
  18138. type: any;
  18139. }
  18140. }
  18141. declare module BABYLON {
  18142. /**
  18143. * Manage the mouse inputs to control the movement of a free camera.
  18144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18145. */
  18146. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18147. /**
  18148. * Define if touch is enabled in the mouse input
  18149. */
  18150. touchEnabled: boolean;
  18151. /**
  18152. * Defines the camera the input is attached to.
  18153. */
  18154. camera: FreeCamera;
  18155. /**
  18156. * Defines the buttons associated with the input to handle camera move.
  18157. */
  18158. buttons: number[];
  18159. /**
  18160. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18161. */
  18162. angularSensibility: number;
  18163. private _pointerInput;
  18164. private _onMouseMove;
  18165. private _observer;
  18166. private previousPosition;
  18167. /**
  18168. * Observable for when a pointer move event occurs containing the move offset
  18169. */
  18170. onPointerMovedObservable: Observable<{
  18171. offsetX: number;
  18172. offsetY: number;
  18173. }>;
  18174. /**
  18175. * @hidden
  18176. * If the camera should be rotated automatically based on pointer movement
  18177. */
  18178. _allowCameraRotation: boolean;
  18179. /**
  18180. * Manage the mouse inputs to control the movement of a free camera.
  18181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18182. * @param touchEnabled Defines if touch is enabled or not
  18183. */
  18184. constructor(
  18185. /**
  18186. * Define if touch is enabled in the mouse input
  18187. */
  18188. touchEnabled?: boolean);
  18189. /**
  18190. * Attach the input controls to a specific dom element to get the input from.
  18191. * @param element Defines the element the controls should be listened from
  18192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18193. */
  18194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18195. /**
  18196. * Called on JS contextmenu event.
  18197. * Override this method to provide functionality.
  18198. */
  18199. protected onContextMenu(evt: PointerEvent): void;
  18200. /**
  18201. * Detach the current controls from the specified dom element.
  18202. * @param element Defines the element to stop listening the inputs from
  18203. */
  18204. detachControl(element: Nullable<HTMLElement>): void;
  18205. /**
  18206. * Gets the class name of the current intput.
  18207. * @returns the class name
  18208. */
  18209. getClassName(): string;
  18210. /**
  18211. * Get the friendly name associated with the input class.
  18212. * @returns the input friendly name
  18213. */
  18214. getSimpleName(): string;
  18215. }
  18216. }
  18217. declare module BABYLON {
  18218. /**
  18219. * Manage the touch inputs to control the movement of a free camera.
  18220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18221. */
  18222. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18223. /**
  18224. * Defines the camera the input is attached to.
  18225. */
  18226. camera: FreeCamera;
  18227. /**
  18228. * Defines the touch sensibility for rotation.
  18229. * The higher the faster.
  18230. */
  18231. touchAngularSensibility: number;
  18232. /**
  18233. * Defines the touch sensibility for move.
  18234. * The higher the faster.
  18235. */
  18236. touchMoveSensibility: number;
  18237. private _offsetX;
  18238. private _offsetY;
  18239. private _pointerPressed;
  18240. private _pointerInput;
  18241. private _observer;
  18242. private _onLostFocus;
  18243. /**
  18244. * Attach the input controls to a specific dom element to get the input from.
  18245. * @param element Defines the element the controls should be listened from
  18246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18247. */
  18248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18249. /**
  18250. * Detach the current controls from the specified dom element.
  18251. * @param element Defines the element to stop listening the inputs from
  18252. */
  18253. detachControl(element: Nullable<HTMLElement>): void;
  18254. /**
  18255. * Update the current camera state depending on the inputs that have been used this frame.
  18256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18257. */
  18258. checkInputs(): void;
  18259. /**
  18260. * Gets the class name of the current intput.
  18261. * @returns the class name
  18262. */
  18263. getClassName(): string;
  18264. /**
  18265. * Get the friendly name associated with the input class.
  18266. * @returns the input friendly name
  18267. */
  18268. getSimpleName(): string;
  18269. }
  18270. }
  18271. declare module BABYLON {
  18272. /**
  18273. * Default Inputs manager for the FreeCamera.
  18274. * It groups all the default supported inputs for ease of use.
  18275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18276. */
  18277. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18278. /**
  18279. * @hidden
  18280. */
  18281. _mouseInput: Nullable<FreeCameraMouseInput>;
  18282. /**
  18283. * Instantiates a new FreeCameraInputsManager.
  18284. * @param camera Defines the camera the inputs belong to
  18285. */
  18286. constructor(camera: FreeCamera);
  18287. /**
  18288. * Add keyboard input support to the input manager.
  18289. * @returns the current input manager
  18290. */
  18291. addKeyboard(): FreeCameraInputsManager;
  18292. /**
  18293. * Add mouse input support to the input manager.
  18294. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18295. * @returns the current input manager
  18296. */
  18297. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18298. /**
  18299. * Removes the mouse input support from the manager
  18300. * @returns the current input manager
  18301. */
  18302. removeMouse(): FreeCameraInputsManager;
  18303. /**
  18304. * Add touch input support to the input manager.
  18305. * @returns the current input manager
  18306. */
  18307. addTouch(): FreeCameraInputsManager;
  18308. /**
  18309. * Remove all attached input methods from a camera
  18310. */
  18311. clear(): void;
  18312. }
  18313. }
  18314. declare module BABYLON {
  18315. /**
  18316. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18317. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18319. */
  18320. export class FreeCamera extends TargetCamera {
  18321. /**
  18322. * Define the collision ellipsoid of the camera.
  18323. * This is helpful to simulate a camera body like the player body around the camera
  18324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18325. */
  18326. ellipsoid: Vector3;
  18327. /**
  18328. * Define an offset for the position of the ellipsoid around the camera.
  18329. * This can be helpful to determine the center of the body near the gravity center of the body
  18330. * instead of its head.
  18331. */
  18332. ellipsoidOffset: Vector3;
  18333. /**
  18334. * Enable or disable collisions of the camera with the rest of the scene objects.
  18335. */
  18336. checkCollisions: boolean;
  18337. /**
  18338. * Enable or disable gravity on the camera.
  18339. */
  18340. applyGravity: boolean;
  18341. /**
  18342. * Define the input manager associated to the camera.
  18343. */
  18344. inputs: FreeCameraInputsManager;
  18345. /**
  18346. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18347. * Higher values reduce sensitivity.
  18348. */
  18349. get angularSensibility(): number;
  18350. /**
  18351. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18352. * Higher values reduce sensitivity.
  18353. */
  18354. set angularSensibility(value: number);
  18355. /**
  18356. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18357. */
  18358. get keysUp(): number[];
  18359. set keysUp(value: number[]);
  18360. /**
  18361. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18362. */
  18363. get keysDown(): number[];
  18364. set keysDown(value: number[]);
  18365. /**
  18366. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18367. */
  18368. get keysLeft(): number[];
  18369. set keysLeft(value: number[]);
  18370. /**
  18371. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18372. */
  18373. get keysRight(): number[];
  18374. set keysRight(value: number[]);
  18375. /**
  18376. * Event raised when the camera collide with a mesh in the scene.
  18377. */
  18378. onCollide: (collidedMesh: AbstractMesh) => void;
  18379. private _collider;
  18380. private _needMoveForGravity;
  18381. private _oldPosition;
  18382. private _diffPosition;
  18383. private _newPosition;
  18384. /** @hidden */
  18385. _localDirection: Vector3;
  18386. /** @hidden */
  18387. _transformedDirection: Vector3;
  18388. /**
  18389. * Instantiates a Free Camera.
  18390. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18391. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18392. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18393. * @param name Define the name of the camera in the scene
  18394. * @param position Define the start position of the camera in the scene
  18395. * @param scene Define the scene the camera belongs to
  18396. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18397. */
  18398. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18399. /**
  18400. * Attached controls to the current camera.
  18401. * @param element Defines the element the controls should be listened from
  18402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18403. */
  18404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18405. /**
  18406. * Detach the current controls from the camera.
  18407. * The camera will stop reacting to inputs.
  18408. * @param element Defines the element to stop listening the inputs from
  18409. */
  18410. detachControl(element: HTMLElement): void;
  18411. private _collisionMask;
  18412. /**
  18413. * Define a collision mask to limit the list of object the camera can collide with
  18414. */
  18415. get collisionMask(): number;
  18416. set collisionMask(mask: number);
  18417. /** @hidden */
  18418. _collideWithWorld(displacement: Vector3): void;
  18419. private _onCollisionPositionChange;
  18420. /** @hidden */
  18421. _checkInputs(): void;
  18422. /** @hidden */
  18423. _decideIfNeedsToMove(): boolean;
  18424. /** @hidden */
  18425. _updatePosition(): void;
  18426. /**
  18427. * Destroy the camera and release the current resources hold by it.
  18428. */
  18429. dispose(): void;
  18430. /**
  18431. * Gets the current object class name.
  18432. * @return the class name
  18433. */
  18434. getClassName(): string;
  18435. }
  18436. }
  18437. declare module BABYLON {
  18438. /**
  18439. * Represents a gamepad control stick position
  18440. */
  18441. export class StickValues {
  18442. /**
  18443. * The x component of the control stick
  18444. */
  18445. x: number;
  18446. /**
  18447. * The y component of the control stick
  18448. */
  18449. y: number;
  18450. /**
  18451. * Initializes the gamepad x and y control stick values
  18452. * @param x The x component of the gamepad control stick value
  18453. * @param y The y component of the gamepad control stick value
  18454. */
  18455. constructor(
  18456. /**
  18457. * The x component of the control stick
  18458. */
  18459. x: number,
  18460. /**
  18461. * The y component of the control stick
  18462. */
  18463. y: number);
  18464. }
  18465. /**
  18466. * An interface which manages callbacks for gamepad button changes
  18467. */
  18468. export interface GamepadButtonChanges {
  18469. /**
  18470. * Called when a gamepad has been changed
  18471. */
  18472. changed: boolean;
  18473. /**
  18474. * Called when a gamepad press event has been triggered
  18475. */
  18476. pressChanged: boolean;
  18477. /**
  18478. * Called when a touch event has been triggered
  18479. */
  18480. touchChanged: boolean;
  18481. /**
  18482. * Called when a value has changed
  18483. */
  18484. valueChanged: boolean;
  18485. }
  18486. /**
  18487. * Represents a gamepad
  18488. */
  18489. export class Gamepad {
  18490. /**
  18491. * The id of the gamepad
  18492. */
  18493. id: string;
  18494. /**
  18495. * The index of the gamepad
  18496. */
  18497. index: number;
  18498. /**
  18499. * The browser gamepad
  18500. */
  18501. browserGamepad: any;
  18502. /**
  18503. * Specifies what type of gamepad this represents
  18504. */
  18505. type: number;
  18506. private _leftStick;
  18507. private _rightStick;
  18508. /** @hidden */
  18509. _isConnected: boolean;
  18510. private _leftStickAxisX;
  18511. private _leftStickAxisY;
  18512. private _rightStickAxisX;
  18513. private _rightStickAxisY;
  18514. /**
  18515. * Triggered when the left control stick has been changed
  18516. */
  18517. private _onleftstickchanged;
  18518. /**
  18519. * Triggered when the right control stick has been changed
  18520. */
  18521. private _onrightstickchanged;
  18522. /**
  18523. * Represents a gamepad controller
  18524. */
  18525. static GAMEPAD: number;
  18526. /**
  18527. * Represents a generic controller
  18528. */
  18529. static GENERIC: number;
  18530. /**
  18531. * Represents an XBox controller
  18532. */
  18533. static XBOX: number;
  18534. /**
  18535. * Represents a pose-enabled controller
  18536. */
  18537. static POSE_ENABLED: number;
  18538. /**
  18539. * Represents an Dual Shock controller
  18540. */
  18541. static DUALSHOCK: number;
  18542. /**
  18543. * Specifies whether the left control stick should be Y-inverted
  18544. */
  18545. protected _invertLeftStickY: boolean;
  18546. /**
  18547. * Specifies if the gamepad has been connected
  18548. */
  18549. get isConnected(): boolean;
  18550. /**
  18551. * Initializes the gamepad
  18552. * @param id The id of the gamepad
  18553. * @param index The index of the gamepad
  18554. * @param browserGamepad The browser gamepad
  18555. * @param leftStickX The x component of the left joystick
  18556. * @param leftStickY The y component of the left joystick
  18557. * @param rightStickX The x component of the right joystick
  18558. * @param rightStickY The y component of the right joystick
  18559. */
  18560. constructor(
  18561. /**
  18562. * The id of the gamepad
  18563. */
  18564. id: string,
  18565. /**
  18566. * The index of the gamepad
  18567. */
  18568. index: number,
  18569. /**
  18570. * The browser gamepad
  18571. */
  18572. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18573. /**
  18574. * Callback triggered when the left joystick has changed
  18575. * @param callback
  18576. */
  18577. onleftstickchanged(callback: (values: StickValues) => void): void;
  18578. /**
  18579. * Callback triggered when the right joystick has changed
  18580. * @param callback
  18581. */
  18582. onrightstickchanged(callback: (values: StickValues) => void): void;
  18583. /**
  18584. * Gets the left joystick
  18585. */
  18586. get leftStick(): StickValues;
  18587. /**
  18588. * Sets the left joystick values
  18589. */
  18590. set leftStick(newValues: StickValues);
  18591. /**
  18592. * Gets the right joystick
  18593. */
  18594. get rightStick(): StickValues;
  18595. /**
  18596. * Sets the right joystick value
  18597. */
  18598. set rightStick(newValues: StickValues);
  18599. /**
  18600. * Updates the gamepad joystick positions
  18601. */
  18602. update(): void;
  18603. /**
  18604. * Disposes the gamepad
  18605. */
  18606. dispose(): void;
  18607. }
  18608. /**
  18609. * Represents a generic gamepad
  18610. */
  18611. export class GenericPad extends Gamepad {
  18612. private _buttons;
  18613. private _onbuttondown;
  18614. private _onbuttonup;
  18615. /**
  18616. * Observable triggered when a button has been pressed
  18617. */
  18618. onButtonDownObservable: Observable<number>;
  18619. /**
  18620. * Observable triggered when a button has been released
  18621. */
  18622. onButtonUpObservable: Observable<number>;
  18623. /**
  18624. * Callback triggered when a button has been pressed
  18625. * @param callback Called when a button has been pressed
  18626. */
  18627. onbuttondown(callback: (buttonPressed: number) => void): void;
  18628. /**
  18629. * Callback triggered when a button has been released
  18630. * @param callback Called when a button has been released
  18631. */
  18632. onbuttonup(callback: (buttonReleased: number) => void): void;
  18633. /**
  18634. * Initializes the generic gamepad
  18635. * @param id The id of the generic gamepad
  18636. * @param index The index of the generic gamepad
  18637. * @param browserGamepad The browser gamepad
  18638. */
  18639. constructor(id: string, index: number, browserGamepad: any);
  18640. private _setButtonValue;
  18641. /**
  18642. * Updates the generic gamepad
  18643. */
  18644. update(): void;
  18645. /**
  18646. * Disposes the generic gamepad
  18647. */
  18648. dispose(): void;
  18649. }
  18650. }
  18651. declare module BABYLON {
  18652. /**
  18653. * Defines the types of pose enabled controllers that are supported
  18654. */
  18655. export enum PoseEnabledControllerType {
  18656. /**
  18657. * HTC Vive
  18658. */
  18659. VIVE = 0,
  18660. /**
  18661. * Oculus Rift
  18662. */
  18663. OCULUS = 1,
  18664. /**
  18665. * Windows mixed reality
  18666. */
  18667. WINDOWS = 2,
  18668. /**
  18669. * Samsung gear VR
  18670. */
  18671. GEAR_VR = 3,
  18672. /**
  18673. * Google Daydream
  18674. */
  18675. DAYDREAM = 4,
  18676. /**
  18677. * Generic
  18678. */
  18679. GENERIC = 5
  18680. }
  18681. /**
  18682. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18683. */
  18684. export interface MutableGamepadButton {
  18685. /**
  18686. * Value of the button/trigger
  18687. */
  18688. value: number;
  18689. /**
  18690. * If the button/trigger is currently touched
  18691. */
  18692. touched: boolean;
  18693. /**
  18694. * If the button/trigger is currently pressed
  18695. */
  18696. pressed: boolean;
  18697. }
  18698. /**
  18699. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18700. * @hidden
  18701. */
  18702. export interface ExtendedGamepadButton extends GamepadButton {
  18703. /**
  18704. * If the button/trigger is currently pressed
  18705. */
  18706. readonly pressed: boolean;
  18707. /**
  18708. * If the button/trigger is currently touched
  18709. */
  18710. readonly touched: boolean;
  18711. /**
  18712. * Value of the button/trigger
  18713. */
  18714. readonly value: number;
  18715. }
  18716. /** @hidden */
  18717. export interface _GamePadFactory {
  18718. /**
  18719. * Returns whether or not the current gamepad can be created for this type of controller.
  18720. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18721. * @returns true if it can be created, otherwise false
  18722. */
  18723. canCreate(gamepadInfo: any): boolean;
  18724. /**
  18725. * Creates a new instance of the Gamepad.
  18726. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18727. * @returns the new gamepad instance
  18728. */
  18729. create(gamepadInfo: any): Gamepad;
  18730. }
  18731. /**
  18732. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18733. */
  18734. export class PoseEnabledControllerHelper {
  18735. /** @hidden */
  18736. static _ControllerFactories: _GamePadFactory[];
  18737. /** @hidden */
  18738. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18739. /**
  18740. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18741. * @param vrGamepad the gamepad to initialized
  18742. * @returns a vr controller of the type the gamepad identified as
  18743. */
  18744. static InitiateController(vrGamepad: any): Gamepad;
  18745. }
  18746. /**
  18747. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18748. */
  18749. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18750. /**
  18751. * If the controller is used in a webXR session
  18752. */
  18753. isXR: boolean;
  18754. private _deviceRoomPosition;
  18755. private _deviceRoomRotationQuaternion;
  18756. /**
  18757. * The device position in babylon space
  18758. */
  18759. devicePosition: Vector3;
  18760. /**
  18761. * The device rotation in babylon space
  18762. */
  18763. deviceRotationQuaternion: Quaternion;
  18764. /**
  18765. * The scale factor of the device in babylon space
  18766. */
  18767. deviceScaleFactor: number;
  18768. /**
  18769. * (Likely devicePosition should be used instead) The device position in its room space
  18770. */
  18771. position: Vector3;
  18772. /**
  18773. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18774. */
  18775. rotationQuaternion: Quaternion;
  18776. /**
  18777. * The type of controller (Eg. Windows mixed reality)
  18778. */
  18779. controllerType: PoseEnabledControllerType;
  18780. protected _calculatedPosition: Vector3;
  18781. private _calculatedRotation;
  18782. /**
  18783. * The raw pose from the device
  18784. */
  18785. rawPose: DevicePose;
  18786. private _trackPosition;
  18787. private _maxRotationDistFromHeadset;
  18788. private _draggedRoomRotation;
  18789. /**
  18790. * @hidden
  18791. */
  18792. _disableTrackPosition(fixedPosition: Vector3): void;
  18793. /**
  18794. * Internal, the mesh attached to the controller
  18795. * @hidden
  18796. */
  18797. _mesh: Nullable<AbstractMesh>;
  18798. private _poseControlledCamera;
  18799. private _leftHandSystemQuaternion;
  18800. /**
  18801. * Internal, matrix used to convert room space to babylon space
  18802. * @hidden
  18803. */
  18804. _deviceToWorld: Matrix;
  18805. /**
  18806. * Node to be used when casting a ray from the controller
  18807. * @hidden
  18808. */
  18809. _pointingPoseNode: Nullable<TransformNode>;
  18810. /**
  18811. * Name of the child mesh that can be used to cast a ray from the controller
  18812. */
  18813. static readonly POINTING_POSE: string;
  18814. /**
  18815. * Creates a new PoseEnabledController from a gamepad
  18816. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18817. */
  18818. constructor(browserGamepad: any);
  18819. private _workingMatrix;
  18820. /**
  18821. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18822. */
  18823. update(): void;
  18824. /**
  18825. * Updates only the pose device and mesh without doing any button event checking
  18826. */
  18827. protected _updatePoseAndMesh(): void;
  18828. /**
  18829. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18830. * @param poseData raw pose fromthe device
  18831. */
  18832. updateFromDevice(poseData: DevicePose): void;
  18833. /**
  18834. * @hidden
  18835. */
  18836. _meshAttachedObservable: Observable<AbstractMesh>;
  18837. /**
  18838. * Attaches a mesh to the controller
  18839. * @param mesh the mesh to be attached
  18840. */
  18841. attachToMesh(mesh: AbstractMesh): void;
  18842. /**
  18843. * Attaches the controllers mesh to a camera
  18844. * @param camera the camera the mesh should be attached to
  18845. */
  18846. attachToPoseControlledCamera(camera: TargetCamera): void;
  18847. /**
  18848. * Disposes of the controller
  18849. */
  18850. dispose(): void;
  18851. /**
  18852. * The mesh that is attached to the controller
  18853. */
  18854. get mesh(): Nullable<AbstractMesh>;
  18855. /**
  18856. * Gets the ray of the controller in the direction the controller is pointing
  18857. * @param length the length the resulting ray should be
  18858. * @returns a ray in the direction the controller is pointing
  18859. */
  18860. getForwardRay(length?: number): Ray;
  18861. }
  18862. }
  18863. declare module BABYLON {
  18864. /**
  18865. * Defines the WebVRController object that represents controllers tracked in 3D space
  18866. */
  18867. export abstract class WebVRController extends PoseEnabledController {
  18868. /**
  18869. * Internal, the default controller model for the controller
  18870. */
  18871. protected _defaultModel: Nullable<AbstractMesh>;
  18872. /**
  18873. * Fired when the trigger state has changed
  18874. */
  18875. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18876. /**
  18877. * Fired when the main button state has changed
  18878. */
  18879. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18880. /**
  18881. * Fired when the secondary button state has changed
  18882. */
  18883. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18884. /**
  18885. * Fired when the pad state has changed
  18886. */
  18887. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18888. /**
  18889. * Fired when controllers stick values have changed
  18890. */
  18891. onPadValuesChangedObservable: Observable<StickValues>;
  18892. /**
  18893. * Array of button availible on the controller
  18894. */
  18895. protected _buttons: Array<MutableGamepadButton>;
  18896. private _onButtonStateChange;
  18897. /**
  18898. * Fired when a controller button's state has changed
  18899. * @param callback the callback containing the button that was modified
  18900. */
  18901. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18902. /**
  18903. * X and Y axis corresponding to the controllers joystick
  18904. */
  18905. pad: StickValues;
  18906. /**
  18907. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18908. */
  18909. hand: string;
  18910. /**
  18911. * The default controller model for the controller
  18912. */
  18913. get defaultModel(): Nullable<AbstractMesh>;
  18914. /**
  18915. * Creates a new WebVRController from a gamepad
  18916. * @param vrGamepad the gamepad that the WebVRController should be created from
  18917. */
  18918. constructor(vrGamepad: any);
  18919. /**
  18920. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18921. */
  18922. update(): void;
  18923. /**
  18924. * Function to be called when a button is modified
  18925. */
  18926. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18927. /**
  18928. * Loads a mesh and attaches it to the controller
  18929. * @param scene the scene the mesh should be added to
  18930. * @param meshLoaded callback for when the mesh has been loaded
  18931. */
  18932. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18933. private _setButtonValue;
  18934. private _changes;
  18935. private _checkChanges;
  18936. /**
  18937. * Disposes of th webVRCOntroller
  18938. */
  18939. dispose(): void;
  18940. }
  18941. }
  18942. declare module BABYLON {
  18943. /**
  18944. * The HemisphericLight simulates the ambient environment light,
  18945. * so the passed direction is the light reflection direction, not the incoming direction.
  18946. */
  18947. export class HemisphericLight extends Light {
  18948. /**
  18949. * The groundColor is the light in the opposite direction to the one specified during creation.
  18950. * 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.
  18951. */
  18952. groundColor: Color3;
  18953. /**
  18954. * The light reflection direction, not the incoming direction.
  18955. */
  18956. direction: Vector3;
  18957. /**
  18958. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18959. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18960. * The HemisphericLight can't cast shadows.
  18961. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18962. * @param name The friendly name of the light
  18963. * @param direction The direction of the light reflection
  18964. * @param scene The scene the light belongs to
  18965. */
  18966. constructor(name: string, direction: Vector3, scene: Scene);
  18967. protected _buildUniformLayout(): void;
  18968. /**
  18969. * Returns the string "HemisphericLight".
  18970. * @return The class name
  18971. */
  18972. getClassName(): string;
  18973. /**
  18974. * Sets the HemisphericLight direction towards the passed target (Vector3).
  18975. * Returns the updated direction.
  18976. * @param target The target the direction should point to
  18977. * @return The computed direction
  18978. */
  18979. setDirectionToTarget(target: Vector3): Vector3;
  18980. /**
  18981. * Returns the shadow generator associated to the light.
  18982. * @returns Always null for hemispheric lights because it does not support shadows.
  18983. */
  18984. getShadowGenerator(): Nullable<IShadowGenerator>;
  18985. /**
  18986. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  18987. * @param effect The effect to update
  18988. * @param lightIndex The index of the light in the effect to update
  18989. * @returns The hemispheric light
  18990. */
  18991. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  18992. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  18993. /**
  18994. * Computes the world matrix of the node
  18995. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  18996. * @param useWasUpdatedFlag defines a reserved property
  18997. * @returns the world matrix
  18998. */
  18999. computeWorldMatrix(): Matrix;
  19000. /**
  19001. * Returns the integer 3.
  19002. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19003. */
  19004. getTypeID(): number;
  19005. /**
  19006. * Prepares the list of defines specific to the light type.
  19007. * @param defines the list of defines
  19008. * @param lightIndex defines the index of the light for the effect
  19009. */
  19010. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19011. }
  19012. }
  19013. declare module BABYLON {
  19014. /** @hidden */
  19015. export var vrMultiviewToSingleviewPixelShader: {
  19016. name: string;
  19017. shader: string;
  19018. };
  19019. }
  19020. declare module BABYLON {
  19021. /**
  19022. * Renders to multiple views with a single draw call
  19023. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19024. */
  19025. export class MultiviewRenderTarget extends RenderTargetTexture {
  19026. /**
  19027. * Creates a multiview render target
  19028. * @param scene scene used with the render target
  19029. * @param size the size of the render target (used for each view)
  19030. */
  19031. constructor(scene: Scene, size?: number | {
  19032. width: number;
  19033. height: number;
  19034. } | {
  19035. ratio: number;
  19036. });
  19037. /**
  19038. * @hidden
  19039. * @param faceIndex the face index, if its a cube texture
  19040. */
  19041. _bindFrameBuffer(faceIndex?: number): void;
  19042. /**
  19043. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19044. * @returns the view count
  19045. */
  19046. getViewCount(): number;
  19047. }
  19048. }
  19049. declare module BABYLON {
  19050. /**
  19051. * Represents a camera frustum
  19052. */
  19053. export class Frustum {
  19054. /**
  19055. * Gets the planes representing the frustum
  19056. * @param transform matrix to be applied to the returned planes
  19057. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19058. */
  19059. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19060. /**
  19061. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19066. /**
  19067. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19072. /**
  19073. * Gets the left frustum plane transformed by the transform matrix
  19074. * @param transform transformation matrix to be applied to the resulting frustum plane
  19075. * @param frustumPlane the resuling frustum plane
  19076. */
  19077. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19078. /**
  19079. * Gets the right frustum plane transformed by the transform matrix
  19080. * @param transform transformation matrix to be applied to the resulting frustum plane
  19081. * @param frustumPlane the resuling frustum plane
  19082. */
  19083. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19084. /**
  19085. * Gets the top frustum plane transformed by the transform matrix
  19086. * @param transform transformation matrix to be applied to the resulting frustum plane
  19087. * @param frustumPlane the resuling frustum plane
  19088. */
  19089. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19090. /**
  19091. * Gets the bottom frustum plane transformed by the transform matrix
  19092. * @param transform transformation matrix to be applied to the resulting frustum plane
  19093. * @param frustumPlane the resuling frustum plane
  19094. */
  19095. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19096. /**
  19097. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19098. * @param transform transformation matrix to be applied to the resulting frustum planes
  19099. * @param frustumPlanes the resuling frustum planes
  19100. */
  19101. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19102. }
  19103. }
  19104. declare module BABYLON {
  19105. interface Engine {
  19106. /**
  19107. * Creates a new multiview render target
  19108. * @param width defines the width of the texture
  19109. * @param height defines the height of the texture
  19110. * @returns the created multiview texture
  19111. */
  19112. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19113. /**
  19114. * Binds a multiview framebuffer to be drawn to
  19115. * @param multiviewTexture texture to bind
  19116. */
  19117. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19118. }
  19119. interface Camera {
  19120. /**
  19121. * @hidden
  19122. * 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)
  19123. */
  19124. _useMultiviewToSingleView: boolean;
  19125. /**
  19126. * @hidden
  19127. * 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)
  19128. */
  19129. _multiviewTexture: Nullable<RenderTargetTexture>;
  19130. /**
  19131. * @hidden
  19132. * ensures the multiview texture of the camera exists and has the specified width/height
  19133. * @param width height to set on the multiview texture
  19134. * @param height width to set on the multiview texture
  19135. */
  19136. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19137. }
  19138. interface Scene {
  19139. /** @hidden */
  19140. _transformMatrixR: Matrix;
  19141. /** @hidden */
  19142. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19143. /** @hidden */
  19144. _createMultiviewUbo(): void;
  19145. /** @hidden */
  19146. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19147. /** @hidden */
  19148. _renderMultiviewToSingleView(camera: Camera): void;
  19149. }
  19150. }
  19151. declare module BABYLON {
  19152. /**
  19153. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19154. * This will not be used for webXR as it supports displaying texture arrays directly
  19155. */
  19156. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19157. /**
  19158. * Initializes a VRMultiviewToSingleview
  19159. * @param name name of the post process
  19160. * @param camera camera to be applied to
  19161. * @param scaleFactor scaling factor to the size of the output texture
  19162. */
  19163. constructor(name: string, camera: Camera, scaleFactor: number);
  19164. }
  19165. }
  19166. declare module BABYLON {
  19167. /**
  19168. * Interface used to define additional presentation attributes
  19169. */
  19170. export interface IVRPresentationAttributes {
  19171. /**
  19172. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19173. */
  19174. highRefreshRate: boolean;
  19175. /**
  19176. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19177. */
  19178. foveationLevel: number;
  19179. }
  19180. interface Engine {
  19181. /** @hidden */
  19182. _vrDisplay: any;
  19183. /** @hidden */
  19184. _vrSupported: boolean;
  19185. /** @hidden */
  19186. _oldSize: Size;
  19187. /** @hidden */
  19188. _oldHardwareScaleFactor: number;
  19189. /** @hidden */
  19190. _vrExclusivePointerMode: boolean;
  19191. /** @hidden */
  19192. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19193. /** @hidden */
  19194. _onVRDisplayPointerRestricted: () => void;
  19195. /** @hidden */
  19196. _onVRDisplayPointerUnrestricted: () => void;
  19197. /** @hidden */
  19198. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19199. /** @hidden */
  19200. _onVrDisplayDisconnect: Nullable<() => void>;
  19201. /** @hidden */
  19202. _onVrDisplayPresentChange: Nullable<() => void>;
  19203. /**
  19204. * Observable signaled when VR display mode changes
  19205. */
  19206. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19207. /**
  19208. * Observable signaled when VR request present is complete
  19209. */
  19210. onVRRequestPresentComplete: Observable<boolean>;
  19211. /**
  19212. * Observable signaled when VR request present starts
  19213. */
  19214. onVRRequestPresentStart: Observable<Engine>;
  19215. /**
  19216. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19217. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19218. */
  19219. isInVRExclusivePointerMode: boolean;
  19220. /**
  19221. * Gets a boolean indicating if a webVR device was detected
  19222. * @returns true if a webVR device was detected
  19223. */
  19224. isVRDevicePresent(): boolean;
  19225. /**
  19226. * Gets the current webVR device
  19227. * @returns the current webVR device (or null)
  19228. */
  19229. getVRDevice(): any;
  19230. /**
  19231. * Initializes a webVR display and starts listening to display change events
  19232. * The onVRDisplayChangedObservable will be notified upon these changes
  19233. * @returns A promise containing a VRDisplay and if vr is supported
  19234. */
  19235. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19236. /** @hidden */
  19237. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19238. /**
  19239. * Gets or sets the presentation attributes used to configure VR rendering
  19240. */
  19241. vrPresentationAttributes?: IVRPresentationAttributes;
  19242. /**
  19243. * Call this function to switch to webVR mode
  19244. * Will do nothing if webVR is not supported or if there is no webVR device
  19245. * @param options the webvr options provided to the camera. mainly used for multiview
  19246. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19247. */
  19248. enableVR(options: WebVROptions): void;
  19249. /** @hidden */
  19250. _onVRFullScreenTriggered(): void;
  19251. }
  19252. }
  19253. declare module BABYLON {
  19254. /**
  19255. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19256. * IMPORTANT!! The data is right-hand data.
  19257. * @export
  19258. * @interface DevicePose
  19259. */
  19260. export interface DevicePose {
  19261. /**
  19262. * The position of the device, values in array are [x,y,z].
  19263. */
  19264. readonly position: Nullable<Float32Array>;
  19265. /**
  19266. * The linearVelocity of the device, values in array are [x,y,z].
  19267. */
  19268. readonly linearVelocity: Nullable<Float32Array>;
  19269. /**
  19270. * The linearAcceleration of the device, values in array are [x,y,z].
  19271. */
  19272. readonly linearAcceleration: Nullable<Float32Array>;
  19273. /**
  19274. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19275. */
  19276. readonly orientation: Nullable<Float32Array>;
  19277. /**
  19278. * The angularVelocity of the device, values in array are [x,y,z].
  19279. */
  19280. readonly angularVelocity: Nullable<Float32Array>;
  19281. /**
  19282. * The angularAcceleration of the device, values in array are [x,y,z].
  19283. */
  19284. readonly angularAcceleration: Nullable<Float32Array>;
  19285. }
  19286. /**
  19287. * Interface representing a pose controlled object in Babylon.
  19288. * A pose controlled object has both regular pose values as well as pose values
  19289. * from an external device such as a VR head mounted display
  19290. */
  19291. export interface PoseControlled {
  19292. /**
  19293. * The position of the object in babylon space.
  19294. */
  19295. position: Vector3;
  19296. /**
  19297. * The rotation quaternion of the object in babylon space.
  19298. */
  19299. rotationQuaternion: Quaternion;
  19300. /**
  19301. * The position of the device in babylon space.
  19302. */
  19303. devicePosition?: Vector3;
  19304. /**
  19305. * The rotation quaternion of the device in babylon space.
  19306. */
  19307. deviceRotationQuaternion: Quaternion;
  19308. /**
  19309. * The raw pose coming from the device.
  19310. */
  19311. rawPose: Nullable<DevicePose>;
  19312. /**
  19313. * The scale of the device to be used when translating from device space to babylon space.
  19314. */
  19315. deviceScaleFactor: number;
  19316. /**
  19317. * Updates the poseControlled values based on the input device pose.
  19318. * @param poseData the pose data to update the object with
  19319. */
  19320. updateFromDevice(poseData: DevicePose): void;
  19321. }
  19322. /**
  19323. * Set of options to customize the webVRCamera
  19324. */
  19325. export interface WebVROptions {
  19326. /**
  19327. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19328. */
  19329. trackPosition?: boolean;
  19330. /**
  19331. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19332. */
  19333. positionScale?: number;
  19334. /**
  19335. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19336. */
  19337. displayName?: string;
  19338. /**
  19339. * Should the native controller meshes be initialized. (default: true)
  19340. */
  19341. controllerMeshes?: boolean;
  19342. /**
  19343. * Creating a default HemiLight only on controllers. (default: true)
  19344. */
  19345. defaultLightingOnControllers?: boolean;
  19346. /**
  19347. * If you don't want to use the default VR button of the helper. (default: false)
  19348. */
  19349. useCustomVRButton?: boolean;
  19350. /**
  19351. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19352. */
  19353. customVRButton?: HTMLButtonElement;
  19354. /**
  19355. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19356. */
  19357. rayLength?: number;
  19358. /**
  19359. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19360. */
  19361. defaultHeight?: number;
  19362. /**
  19363. * If multiview should be used if availible (default: false)
  19364. */
  19365. useMultiview?: boolean;
  19366. }
  19367. /**
  19368. * This represents a WebVR camera.
  19369. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19370. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19371. */
  19372. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19373. private webVROptions;
  19374. /**
  19375. * @hidden
  19376. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19377. */
  19378. _vrDevice: any;
  19379. /**
  19380. * The rawPose of the vrDevice.
  19381. */
  19382. rawPose: Nullable<DevicePose>;
  19383. private _onVREnabled;
  19384. private _specsVersion;
  19385. private _attached;
  19386. private _frameData;
  19387. protected _descendants: Array<Node>;
  19388. private _deviceRoomPosition;
  19389. /** @hidden */
  19390. _deviceRoomRotationQuaternion: Quaternion;
  19391. private _standingMatrix;
  19392. /**
  19393. * Represents device position in babylon space.
  19394. */
  19395. devicePosition: Vector3;
  19396. /**
  19397. * Represents device rotation in babylon space.
  19398. */
  19399. deviceRotationQuaternion: Quaternion;
  19400. /**
  19401. * The scale of the device to be used when translating from device space to babylon space.
  19402. */
  19403. deviceScaleFactor: number;
  19404. private _deviceToWorld;
  19405. private _worldToDevice;
  19406. /**
  19407. * References to the webVR controllers for the vrDevice.
  19408. */
  19409. controllers: Array<WebVRController>;
  19410. /**
  19411. * Emits an event when a controller is attached.
  19412. */
  19413. onControllersAttachedObservable: Observable<WebVRController[]>;
  19414. /**
  19415. * Emits an event when a controller's mesh has been loaded;
  19416. */
  19417. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19418. /**
  19419. * Emits an event when the HMD's pose has been updated.
  19420. */
  19421. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19422. private _poseSet;
  19423. /**
  19424. * If the rig cameras be used as parent instead of this camera.
  19425. */
  19426. rigParenting: boolean;
  19427. private _lightOnControllers;
  19428. private _defaultHeight?;
  19429. /**
  19430. * Instantiates a WebVRFreeCamera.
  19431. * @param name The name of the WebVRFreeCamera
  19432. * @param position The starting anchor position for the camera
  19433. * @param scene The scene the camera belongs to
  19434. * @param webVROptions a set of customizable options for the webVRCamera
  19435. */
  19436. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19437. /**
  19438. * Gets the device distance from the ground in meters.
  19439. * @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.
  19440. */
  19441. deviceDistanceToRoomGround(): number;
  19442. /**
  19443. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19444. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19445. */
  19446. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19447. /**
  19448. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19449. * @returns A promise with a boolean set to if the standing matrix is supported.
  19450. */
  19451. useStandingMatrixAsync(): Promise<boolean>;
  19452. /**
  19453. * Disposes the camera
  19454. */
  19455. dispose(): void;
  19456. /**
  19457. * Gets a vrController by name.
  19458. * @param name The name of the controller to retreive
  19459. * @returns the controller matching the name specified or null if not found
  19460. */
  19461. getControllerByName(name: string): Nullable<WebVRController>;
  19462. private _leftController;
  19463. /**
  19464. * The controller corresponding to the users left hand.
  19465. */
  19466. get leftController(): Nullable<WebVRController>;
  19467. private _rightController;
  19468. /**
  19469. * The controller corresponding to the users right hand.
  19470. */
  19471. get rightController(): Nullable<WebVRController>;
  19472. /**
  19473. * Casts a ray forward from the vrCamera's gaze.
  19474. * @param length Length of the ray (default: 100)
  19475. * @returns the ray corresponding to the gaze
  19476. */
  19477. getForwardRay(length?: number): Ray;
  19478. /**
  19479. * @hidden
  19480. * Updates the camera based on device's frame data
  19481. */
  19482. _checkInputs(): void;
  19483. /**
  19484. * Updates the poseControlled values based on the input device pose.
  19485. * @param poseData Pose coming from the device
  19486. */
  19487. updateFromDevice(poseData: DevicePose): void;
  19488. private _htmlElementAttached;
  19489. private _detachIfAttached;
  19490. /**
  19491. * WebVR's attach control will start broadcasting frames to the device.
  19492. * Note that in certain browsers (chrome for example) this function must be called
  19493. * within a user-interaction callback. Example:
  19494. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19495. *
  19496. * @param element html element to attach the vrDevice to
  19497. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19498. */
  19499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19500. /**
  19501. * Detaches the camera from the html element and disables VR
  19502. *
  19503. * @param element html element to detach from
  19504. */
  19505. detachControl(element: HTMLElement): void;
  19506. /**
  19507. * @returns the name of this class
  19508. */
  19509. getClassName(): string;
  19510. /**
  19511. * Calls resetPose on the vrDisplay
  19512. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19513. */
  19514. resetToCurrentRotation(): void;
  19515. /**
  19516. * @hidden
  19517. * Updates the rig cameras (left and right eye)
  19518. */
  19519. _updateRigCameras(): void;
  19520. private _workingVector;
  19521. private _oneVector;
  19522. private _workingMatrix;
  19523. private updateCacheCalled;
  19524. private _correctPositionIfNotTrackPosition;
  19525. /**
  19526. * @hidden
  19527. * Updates the cached values of the camera
  19528. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19529. */
  19530. _updateCache(ignoreParentClass?: boolean): void;
  19531. /**
  19532. * @hidden
  19533. * Get current device position in babylon world
  19534. */
  19535. _computeDevicePosition(): void;
  19536. /**
  19537. * Updates the current device position and rotation in the babylon world
  19538. */
  19539. update(): void;
  19540. /**
  19541. * @hidden
  19542. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19543. * @returns an identity matrix
  19544. */
  19545. _getViewMatrix(): Matrix;
  19546. private _tmpMatrix;
  19547. /**
  19548. * This function is called by the two RIG cameras.
  19549. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19550. * @hidden
  19551. */
  19552. _getWebVRViewMatrix(): Matrix;
  19553. /** @hidden */
  19554. _getWebVRProjectionMatrix(): Matrix;
  19555. private _onGamepadConnectedObserver;
  19556. private _onGamepadDisconnectedObserver;
  19557. private _updateCacheWhenTrackingDisabledObserver;
  19558. /**
  19559. * Initializes the controllers and their meshes
  19560. */
  19561. initControllers(): void;
  19562. }
  19563. }
  19564. declare module BABYLON {
  19565. /**
  19566. * Size options for a post process
  19567. */
  19568. export type PostProcessOptions = {
  19569. width: number;
  19570. height: number;
  19571. };
  19572. /**
  19573. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19574. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19575. */
  19576. export class PostProcess {
  19577. /** Name of the PostProcess. */
  19578. name: string;
  19579. /**
  19580. * Gets or sets the unique id of the post process
  19581. */
  19582. uniqueId: number;
  19583. /**
  19584. * Width of the texture to apply the post process on
  19585. */
  19586. width: number;
  19587. /**
  19588. * Height of the texture to apply the post process on
  19589. */
  19590. height: number;
  19591. /**
  19592. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19593. * @hidden
  19594. */
  19595. _outputTexture: Nullable<InternalTexture>;
  19596. /**
  19597. * Sampling mode used by the shader
  19598. * See https://doc.babylonjs.com/classes/3.1/texture
  19599. */
  19600. renderTargetSamplingMode: number;
  19601. /**
  19602. * Clear color to use when screen clearing
  19603. */
  19604. clearColor: Color4;
  19605. /**
  19606. * If the buffer needs to be cleared before applying the post process. (default: true)
  19607. * Should be set to false if shader will overwrite all previous pixels.
  19608. */
  19609. autoClear: boolean;
  19610. /**
  19611. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19612. */
  19613. alphaMode: number;
  19614. /**
  19615. * Sets the setAlphaBlendConstants of the babylon engine
  19616. */
  19617. alphaConstants: Color4;
  19618. /**
  19619. * Animations to be used for the post processing
  19620. */
  19621. animations: Animation[];
  19622. /**
  19623. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19624. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19625. */
  19626. enablePixelPerfectMode: boolean;
  19627. /**
  19628. * Force the postprocess to be applied without taking in account viewport
  19629. */
  19630. forceFullscreenViewport: boolean;
  19631. /**
  19632. * List of inspectable custom properties (used by the Inspector)
  19633. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19634. */
  19635. inspectableCustomProperties: IInspectable[];
  19636. /**
  19637. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19638. *
  19639. * | Value | Type | Description |
  19640. * | ----- | ----------------------------------- | ----------- |
  19641. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19642. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19643. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19644. *
  19645. */
  19646. scaleMode: number;
  19647. /**
  19648. * Force textures to be a power of two (default: false)
  19649. */
  19650. alwaysForcePOT: boolean;
  19651. private _samples;
  19652. /**
  19653. * Number of sample textures (default: 1)
  19654. */
  19655. get samples(): number;
  19656. set samples(n: number);
  19657. /**
  19658. * Modify the scale of the post process to be the same as the viewport (default: false)
  19659. */
  19660. adaptScaleToCurrentViewport: boolean;
  19661. private _camera;
  19662. private _scene;
  19663. private _engine;
  19664. private _options;
  19665. private _reusable;
  19666. private _textureType;
  19667. private _textureFormat;
  19668. /**
  19669. * Smart array of input and output textures for the post process.
  19670. * @hidden
  19671. */
  19672. _textures: SmartArray<InternalTexture>;
  19673. /**
  19674. * The index in _textures that corresponds to the output texture.
  19675. * @hidden
  19676. */
  19677. _currentRenderTextureInd: number;
  19678. private _effect;
  19679. private _samplers;
  19680. private _fragmentUrl;
  19681. private _vertexUrl;
  19682. private _parameters;
  19683. private _scaleRatio;
  19684. protected _indexParameters: any;
  19685. private _shareOutputWithPostProcess;
  19686. private _texelSize;
  19687. private _forcedOutputTexture;
  19688. /**
  19689. * Returns the fragment url or shader name used in the post process.
  19690. * @returns the fragment url or name in the shader store.
  19691. */
  19692. getEffectName(): string;
  19693. /**
  19694. * An event triggered when the postprocess is activated.
  19695. */
  19696. onActivateObservable: Observable<Camera>;
  19697. private _onActivateObserver;
  19698. /**
  19699. * A function that is added to the onActivateObservable
  19700. */
  19701. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19702. /**
  19703. * An event triggered when the postprocess changes its size.
  19704. */
  19705. onSizeChangedObservable: Observable<PostProcess>;
  19706. private _onSizeChangedObserver;
  19707. /**
  19708. * A function that is added to the onSizeChangedObservable
  19709. */
  19710. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19711. /**
  19712. * An event triggered when the postprocess applies its effect.
  19713. */
  19714. onApplyObservable: Observable<Effect>;
  19715. private _onApplyObserver;
  19716. /**
  19717. * A function that is added to the onApplyObservable
  19718. */
  19719. set onApply(callback: (effect: Effect) => void);
  19720. /**
  19721. * An event triggered before rendering the postprocess
  19722. */
  19723. onBeforeRenderObservable: Observable<Effect>;
  19724. private _onBeforeRenderObserver;
  19725. /**
  19726. * A function that is added to the onBeforeRenderObservable
  19727. */
  19728. set onBeforeRender(callback: (effect: Effect) => void);
  19729. /**
  19730. * An event triggered after rendering the postprocess
  19731. */
  19732. onAfterRenderObservable: Observable<Effect>;
  19733. private _onAfterRenderObserver;
  19734. /**
  19735. * A function that is added to the onAfterRenderObservable
  19736. */
  19737. set onAfterRender(callback: (efect: Effect) => void);
  19738. /**
  19739. * 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
  19740. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19741. */
  19742. get inputTexture(): InternalTexture;
  19743. set inputTexture(value: InternalTexture);
  19744. /**
  19745. * Gets the camera which post process is applied to.
  19746. * @returns The camera the post process is applied to.
  19747. */
  19748. getCamera(): Camera;
  19749. /**
  19750. * Gets the texel size of the postprocess.
  19751. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19752. */
  19753. get texelSize(): Vector2;
  19754. /**
  19755. * Creates a new instance PostProcess
  19756. * @param name The name of the PostProcess.
  19757. * @param fragmentUrl The url of the fragment shader to be used.
  19758. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19759. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19760. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19761. * @param camera The camera to apply the render pass to.
  19762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19763. * @param engine The engine which the post process will be applied. (default: current engine)
  19764. * @param reusable If the post process can be reused on the same frame. (default: false)
  19765. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19766. * @param textureType Type of textures used when performing the post process. (default: 0)
  19767. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19768. * @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
  19769. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19770. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19771. */
  19772. constructor(
  19773. /** Name of the PostProcess. */
  19774. 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);
  19775. /**
  19776. * Gets a string idenfifying the name of the class
  19777. * @returns "PostProcess" string
  19778. */
  19779. getClassName(): string;
  19780. /**
  19781. * Gets the engine which this post process belongs to.
  19782. * @returns The engine the post process was enabled with.
  19783. */
  19784. getEngine(): Engine;
  19785. /**
  19786. * The effect that is created when initializing the post process.
  19787. * @returns The created effect corresponding the the postprocess.
  19788. */
  19789. getEffect(): Effect;
  19790. /**
  19791. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19792. * @param postProcess The post process to share the output with.
  19793. * @returns This post process.
  19794. */
  19795. shareOutputWith(postProcess: PostProcess): PostProcess;
  19796. /**
  19797. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19798. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19799. */
  19800. useOwnOutput(): void;
  19801. /**
  19802. * Updates the effect with the current post process compile time values and recompiles the shader.
  19803. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19804. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19805. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19806. * @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
  19807. * @param onCompiled Called when the shader has been compiled.
  19808. * @param onError Called if there is an error when compiling a shader.
  19809. */
  19810. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19811. /**
  19812. * The post process is reusable if it can be used multiple times within one frame.
  19813. * @returns If the post process is reusable
  19814. */
  19815. isReusable(): boolean;
  19816. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19817. markTextureDirty(): void;
  19818. /**
  19819. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19820. * 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.
  19821. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19822. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19823. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19824. * @returns The target texture that was bound to be written to.
  19825. */
  19826. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19827. /**
  19828. * If the post process is supported.
  19829. */
  19830. get isSupported(): boolean;
  19831. /**
  19832. * The aspect ratio of the output texture.
  19833. */
  19834. get aspectRatio(): number;
  19835. /**
  19836. * Get a value indicating if the post-process is ready to be used
  19837. * @returns true if the post-process is ready (shader is compiled)
  19838. */
  19839. isReady(): boolean;
  19840. /**
  19841. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19842. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19843. */
  19844. apply(): Nullable<Effect>;
  19845. private _disposeTextures;
  19846. /**
  19847. * Disposes the post process.
  19848. * @param camera The camera to dispose the post process on.
  19849. */
  19850. dispose(camera?: Camera): void;
  19851. }
  19852. }
  19853. declare module BABYLON {
  19854. /** @hidden */
  19855. export var kernelBlurVaryingDeclaration: {
  19856. name: string;
  19857. shader: string;
  19858. };
  19859. }
  19860. declare module BABYLON {
  19861. /** @hidden */
  19862. export var kernelBlurFragment: {
  19863. name: string;
  19864. shader: string;
  19865. };
  19866. }
  19867. declare module BABYLON {
  19868. /** @hidden */
  19869. export var kernelBlurFragment2: {
  19870. name: string;
  19871. shader: string;
  19872. };
  19873. }
  19874. declare module BABYLON {
  19875. /** @hidden */
  19876. export var kernelBlurPixelShader: {
  19877. name: string;
  19878. shader: string;
  19879. };
  19880. }
  19881. declare module BABYLON {
  19882. /** @hidden */
  19883. export var kernelBlurVertex: {
  19884. name: string;
  19885. shader: string;
  19886. };
  19887. }
  19888. declare module BABYLON {
  19889. /** @hidden */
  19890. export var kernelBlurVertexShader: {
  19891. name: string;
  19892. shader: string;
  19893. };
  19894. }
  19895. declare module BABYLON {
  19896. /**
  19897. * The Blur Post Process which blurs an image based on a kernel and direction.
  19898. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19899. */
  19900. export class BlurPostProcess extends PostProcess {
  19901. /** The direction in which to blur the image. */
  19902. direction: Vector2;
  19903. private blockCompilation;
  19904. protected _kernel: number;
  19905. protected _idealKernel: number;
  19906. protected _packedFloat: boolean;
  19907. private _staticDefines;
  19908. /**
  19909. * Sets the length in pixels of the blur sample region
  19910. */
  19911. set kernel(v: number);
  19912. /**
  19913. * Gets the length in pixels of the blur sample region
  19914. */
  19915. get kernel(): number;
  19916. /**
  19917. * Sets wether or not the blur needs to unpack/repack floats
  19918. */
  19919. set packedFloat(v: boolean);
  19920. /**
  19921. * Gets wether or not the blur is unpacking/repacking floats
  19922. */
  19923. get packedFloat(): boolean;
  19924. /**
  19925. * Creates a new instance BlurPostProcess
  19926. * @param name The name of the effect.
  19927. * @param direction The direction in which to blur the image.
  19928. * @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.
  19929. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19930. * @param camera The camera to apply the render pass to.
  19931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19932. * @param engine The engine which the post process will be applied. (default: current engine)
  19933. * @param reusable If the post process can be reused on the same frame. (default: false)
  19934. * @param textureType Type of textures used when performing the post process. (default: 0)
  19935. * @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)
  19936. */
  19937. constructor(name: string,
  19938. /** The direction in which to blur the image. */
  19939. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19940. /**
  19941. * Updates the effect with the current post process compile time values and recompiles the shader.
  19942. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19943. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19944. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19945. * @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
  19946. * @param onCompiled Called when the shader has been compiled.
  19947. * @param onError Called if there is an error when compiling a shader.
  19948. */
  19949. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19950. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19951. /**
  19952. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19953. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19954. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19955. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19956. * The gaps between physical kernels are compensated for in the weighting of the samples
  19957. * @param idealKernel Ideal blur kernel.
  19958. * @return Nearest best kernel.
  19959. */
  19960. protected _nearestBestKernel(idealKernel: number): number;
  19961. /**
  19962. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19963. * @param x The point on the Gaussian distribution to sample.
  19964. * @return the value of the Gaussian function at x.
  19965. */
  19966. protected _gaussianWeight(x: number): number;
  19967. /**
  19968. * Generates a string that can be used as a floating point number in GLSL.
  19969. * @param x Value to print.
  19970. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19971. * @return GLSL float string.
  19972. */
  19973. protected _glslFloat(x: number, decimalFigures?: number): string;
  19974. }
  19975. }
  19976. declare module BABYLON {
  19977. /**
  19978. * Mirror texture can be used to simulate the view from a mirror in a scene.
  19979. * It will dynamically be rendered every frame to adapt to the camera point of view.
  19980. * You can then easily use it as a reflectionTexture on a flat surface.
  19981. * In case the surface is not a plane, please consider relying on reflection probes.
  19982. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19983. */
  19984. export class MirrorTexture extends RenderTargetTexture {
  19985. private scene;
  19986. /**
  19987. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  19988. * 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.
  19989. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19990. */
  19991. mirrorPlane: Plane;
  19992. /**
  19993. * Define the blur ratio used to blur the reflection if needed.
  19994. */
  19995. set blurRatio(value: number);
  19996. get blurRatio(): number;
  19997. /**
  19998. * Define the adaptive blur kernel used to blur the reflection if needed.
  19999. * This will autocompute the closest best match for the `blurKernel`
  20000. */
  20001. set adaptiveBlurKernel(value: number);
  20002. /**
  20003. * Define the blur kernel used to blur the reflection if needed.
  20004. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20005. */
  20006. set blurKernel(value: number);
  20007. /**
  20008. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20009. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20010. */
  20011. set blurKernelX(value: number);
  20012. get blurKernelX(): number;
  20013. /**
  20014. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20015. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20016. */
  20017. set blurKernelY(value: number);
  20018. get blurKernelY(): number;
  20019. private _autoComputeBlurKernel;
  20020. protected _onRatioRescale(): void;
  20021. private _updateGammaSpace;
  20022. private _imageProcessingConfigChangeObserver;
  20023. private _transformMatrix;
  20024. private _mirrorMatrix;
  20025. private _savedViewMatrix;
  20026. private _blurX;
  20027. private _blurY;
  20028. private _adaptiveBlurKernel;
  20029. private _blurKernelX;
  20030. private _blurKernelY;
  20031. private _blurRatio;
  20032. /**
  20033. * Instantiates a Mirror Texture.
  20034. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20035. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20036. * You can then easily use it as a reflectionTexture on a flat surface.
  20037. * In case the surface is not a plane, please consider relying on reflection probes.
  20038. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20039. * @param name
  20040. * @param size
  20041. * @param scene
  20042. * @param generateMipMaps
  20043. * @param type
  20044. * @param samplingMode
  20045. * @param generateDepthBuffer
  20046. */
  20047. constructor(name: string, size: number | {
  20048. width: number;
  20049. height: number;
  20050. } | {
  20051. ratio: number;
  20052. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20053. private _preparePostProcesses;
  20054. /**
  20055. * Clone the mirror texture.
  20056. * @returns the cloned texture
  20057. */
  20058. clone(): MirrorTexture;
  20059. /**
  20060. * Serialize the texture to a JSON representation you could use in Parse later on
  20061. * @returns the serialized JSON representation
  20062. */
  20063. serialize(): any;
  20064. /**
  20065. * Dispose the texture and release its associated resources.
  20066. */
  20067. dispose(): void;
  20068. }
  20069. }
  20070. declare module BABYLON {
  20071. /**
  20072. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20073. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20074. */
  20075. export class Texture extends BaseTexture {
  20076. /**
  20077. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20078. */
  20079. static SerializeBuffers: boolean;
  20080. /** @hidden */
  20081. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20082. /** @hidden */
  20083. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20084. /** @hidden */
  20085. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20086. /** nearest is mag = nearest and min = nearest and mip = linear */
  20087. static readonly NEAREST_SAMPLINGMODE: number;
  20088. /** nearest is mag = nearest and min = nearest and mip = linear */
  20089. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20090. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20091. static readonly BILINEAR_SAMPLINGMODE: number;
  20092. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20093. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20094. /** Trilinear is mag = linear and min = linear and mip = linear */
  20095. static readonly TRILINEAR_SAMPLINGMODE: number;
  20096. /** Trilinear is mag = linear and min = linear and mip = linear */
  20097. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20098. /** mag = nearest and min = nearest and mip = nearest */
  20099. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20100. /** mag = nearest and min = linear and mip = nearest */
  20101. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20102. /** mag = nearest and min = linear and mip = linear */
  20103. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20104. /** mag = nearest and min = linear and mip = none */
  20105. static readonly NEAREST_LINEAR: number;
  20106. /** mag = nearest and min = nearest and mip = none */
  20107. static readonly NEAREST_NEAREST: number;
  20108. /** mag = linear and min = nearest and mip = nearest */
  20109. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20110. /** mag = linear and min = nearest and mip = linear */
  20111. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20112. /** mag = linear and min = linear and mip = none */
  20113. static readonly LINEAR_LINEAR: number;
  20114. /** mag = linear and min = nearest and mip = none */
  20115. static readonly LINEAR_NEAREST: number;
  20116. /** Explicit coordinates mode */
  20117. static readonly EXPLICIT_MODE: number;
  20118. /** Spherical coordinates mode */
  20119. static readonly SPHERICAL_MODE: number;
  20120. /** Planar coordinates mode */
  20121. static readonly PLANAR_MODE: number;
  20122. /** Cubic coordinates mode */
  20123. static readonly CUBIC_MODE: number;
  20124. /** Projection coordinates mode */
  20125. static readonly PROJECTION_MODE: number;
  20126. /** Inverse Cubic coordinates mode */
  20127. static readonly SKYBOX_MODE: number;
  20128. /** Inverse Cubic coordinates mode */
  20129. static readonly INVCUBIC_MODE: number;
  20130. /** Equirectangular coordinates mode */
  20131. static readonly EQUIRECTANGULAR_MODE: number;
  20132. /** Equirectangular Fixed coordinates mode */
  20133. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20134. /** Equirectangular Fixed Mirrored coordinates mode */
  20135. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20136. /** Texture is not repeating outside of 0..1 UVs */
  20137. static readonly CLAMP_ADDRESSMODE: number;
  20138. /** Texture is repeating outside of 0..1 UVs */
  20139. static readonly WRAP_ADDRESSMODE: number;
  20140. /** Texture is repeating and mirrored */
  20141. static readonly MIRROR_ADDRESSMODE: number;
  20142. /**
  20143. * 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
  20144. */
  20145. static UseSerializedUrlIfAny: boolean;
  20146. /**
  20147. * Define the url of the texture.
  20148. */
  20149. url: Nullable<string>;
  20150. /**
  20151. * Define an offset on the texture to offset the u coordinates of the UVs
  20152. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20153. */
  20154. uOffset: number;
  20155. /**
  20156. * Define an offset on the texture to offset the v coordinates of the UVs
  20157. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20158. */
  20159. vOffset: number;
  20160. /**
  20161. * Define an offset on the texture to scale the u coordinates of the UVs
  20162. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20163. */
  20164. uScale: number;
  20165. /**
  20166. * Define an offset on the texture to scale the v coordinates of the UVs
  20167. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20168. */
  20169. vScale: number;
  20170. /**
  20171. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20172. * @see http://doc.babylonjs.com/how_to/more_materials
  20173. */
  20174. uAng: number;
  20175. /**
  20176. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20177. * @see http://doc.babylonjs.com/how_to/more_materials
  20178. */
  20179. vAng: number;
  20180. /**
  20181. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20182. * @see http://doc.babylonjs.com/how_to/more_materials
  20183. */
  20184. wAng: number;
  20185. /**
  20186. * Defines the center of rotation (U)
  20187. */
  20188. uRotationCenter: number;
  20189. /**
  20190. * Defines the center of rotation (V)
  20191. */
  20192. vRotationCenter: number;
  20193. /**
  20194. * Defines the center of rotation (W)
  20195. */
  20196. wRotationCenter: number;
  20197. /**
  20198. * Are mip maps generated for this texture or not.
  20199. */
  20200. get noMipmap(): boolean;
  20201. /**
  20202. * List of inspectable custom properties (used by the Inspector)
  20203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20204. */
  20205. inspectableCustomProperties: Nullable<IInspectable[]>;
  20206. private _noMipmap;
  20207. /** @hidden */
  20208. _invertY: boolean;
  20209. private _rowGenerationMatrix;
  20210. private _cachedTextureMatrix;
  20211. private _projectionModeMatrix;
  20212. private _t0;
  20213. private _t1;
  20214. private _t2;
  20215. private _cachedUOffset;
  20216. private _cachedVOffset;
  20217. private _cachedUScale;
  20218. private _cachedVScale;
  20219. private _cachedUAng;
  20220. private _cachedVAng;
  20221. private _cachedWAng;
  20222. private _cachedProjectionMatrixId;
  20223. private _cachedCoordinatesMode;
  20224. /** @hidden */
  20225. protected _initialSamplingMode: number;
  20226. /** @hidden */
  20227. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20228. private _deleteBuffer;
  20229. protected _format: Nullable<number>;
  20230. private _delayedOnLoad;
  20231. private _delayedOnError;
  20232. private _mimeType?;
  20233. /**
  20234. * Observable triggered once the texture has been loaded.
  20235. */
  20236. onLoadObservable: Observable<Texture>;
  20237. protected _isBlocking: boolean;
  20238. /**
  20239. * Is the texture preventing material to render while loading.
  20240. * If false, a default texture will be used instead of the loading one during the preparation step.
  20241. */
  20242. set isBlocking(value: boolean);
  20243. get isBlocking(): boolean;
  20244. /**
  20245. * Get the current sampling mode associated with the texture.
  20246. */
  20247. get samplingMode(): number;
  20248. /**
  20249. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20250. */
  20251. get invertY(): boolean;
  20252. /**
  20253. * Instantiates a new texture.
  20254. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20255. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20256. * @param url defines the url of the picture to load as a texture
  20257. * @param scene defines the scene or engine the texture will belong to
  20258. * @param noMipmap defines if the texture will require mip maps or not
  20259. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20260. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20261. * @param onLoad defines a callback triggered when the texture has been loaded
  20262. * @param onError defines a callback triggered when an error occurred during the loading session
  20263. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20264. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20265. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20266. * @param mimeType defines an optional mime type information
  20267. */
  20268. 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);
  20269. /**
  20270. * Update the url (and optional buffer) of this texture if url was null during construction.
  20271. * @param url the url of the texture
  20272. * @param buffer the buffer of the texture (defaults to null)
  20273. * @param onLoad callback called when the texture is loaded (defaults to null)
  20274. */
  20275. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20276. /**
  20277. * Finish the loading sequence of a texture flagged as delayed load.
  20278. * @hidden
  20279. */
  20280. delayLoad(): void;
  20281. private _prepareRowForTextureGeneration;
  20282. /**
  20283. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20284. * @returns the transform matrix of the texture.
  20285. */
  20286. getTextureMatrix(uBase?: number): Matrix;
  20287. /**
  20288. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20289. * @returns The reflection texture transform
  20290. */
  20291. getReflectionTextureMatrix(): Matrix;
  20292. /**
  20293. * Clones the texture.
  20294. * @returns the cloned texture
  20295. */
  20296. clone(): Texture;
  20297. /**
  20298. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20299. * @returns The JSON representation of the texture
  20300. */
  20301. serialize(): any;
  20302. /**
  20303. * Get the current class name of the texture useful for serialization or dynamic coding.
  20304. * @returns "Texture"
  20305. */
  20306. getClassName(): string;
  20307. /**
  20308. * Dispose the texture and release its associated resources.
  20309. */
  20310. dispose(): void;
  20311. /**
  20312. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20313. * @param parsedTexture Define the JSON representation of the texture
  20314. * @param scene Define the scene the parsed texture should be instantiated in
  20315. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20316. * @returns The parsed texture if successful
  20317. */
  20318. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20319. /**
  20320. * Creates a texture from its base 64 representation.
  20321. * @param data Define the base64 payload without the data: prefix
  20322. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20323. * @param scene Define the scene the texture should belong to
  20324. * @param noMipmap Forces the texture to not create mip map information if true
  20325. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20326. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20327. * @param onLoad define a callback triggered when the texture has been loaded
  20328. * @param onError define a callback triggered when an error occurred during the loading session
  20329. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20330. * @returns the created texture
  20331. */
  20332. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20333. /**
  20334. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20335. * @param data Define the base64 payload without the data: prefix
  20336. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20337. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20338. * @param scene Define the scene the texture should belong to
  20339. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20340. * @param noMipmap Forces the texture to not create mip map information if true
  20341. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20342. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20343. * @param onLoad define a callback triggered when the texture has been loaded
  20344. * @param onError define a callback triggered when an error occurred during the loading session
  20345. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20346. * @returns the created texture
  20347. */
  20348. 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;
  20349. }
  20350. }
  20351. declare module BABYLON {
  20352. /**
  20353. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20354. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20355. */
  20356. export class PostProcessManager {
  20357. private _scene;
  20358. private _indexBuffer;
  20359. private _vertexBuffers;
  20360. /**
  20361. * Creates a new instance PostProcess
  20362. * @param scene The scene that the post process is associated with.
  20363. */
  20364. constructor(scene: Scene);
  20365. private _prepareBuffers;
  20366. private _buildIndexBuffer;
  20367. /**
  20368. * Rebuilds the vertex buffers of the manager.
  20369. * @hidden
  20370. */
  20371. _rebuild(): void;
  20372. /**
  20373. * Prepares a frame to be run through a post process.
  20374. * @param sourceTexture The input texture to the post procesess. (default: null)
  20375. * @param postProcesses An array of post processes to be run. (default: null)
  20376. * @returns True if the post processes were able to be run.
  20377. * @hidden
  20378. */
  20379. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20380. /**
  20381. * Manually render a set of post processes to a texture.
  20382. * @param postProcesses An array of post processes to be run.
  20383. * @param targetTexture The target texture to render to.
  20384. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20385. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20386. * @param lodLevel defines which lod of the texture to render to
  20387. */
  20388. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20389. /**
  20390. * Finalize the result of the output of the postprocesses.
  20391. * @param doNotPresent If true the result will not be displayed to the screen.
  20392. * @param targetTexture The target texture to render to.
  20393. * @param faceIndex The index of the face to bind the target texture to.
  20394. * @param postProcesses The array of post processes to render.
  20395. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20396. * @hidden
  20397. */
  20398. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20399. /**
  20400. * Disposes of the post process manager.
  20401. */
  20402. dispose(): void;
  20403. }
  20404. }
  20405. declare module BABYLON {
  20406. /**
  20407. * This Helps creating a texture that will be created from a camera in your scene.
  20408. * It is basically a dynamic texture that could be used to create special effects for instance.
  20409. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20410. */
  20411. export class RenderTargetTexture extends Texture {
  20412. isCube: boolean;
  20413. /**
  20414. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20415. */
  20416. static readonly REFRESHRATE_RENDER_ONCE: number;
  20417. /**
  20418. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20419. */
  20420. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20421. /**
  20422. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20423. * the central point of your effect and can save a lot of performances.
  20424. */
  20425. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20426. /**
  20427. * Use this predicate to dynamically define the list of mesh you want to render.
  20428. * If set, the renderList property will be overwritten.
  20429. */
  20430. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20431. private _renderList;
  20432. /**
  20433. * Use this list to define the list of mesh you want to render.
  20434. */
  20435. get renderList(): Nullable<Array<AbstractMesh>>;
  20436. set renderList(value: Nullable<Array<AbstractMesh>>);
  20437. /**
  20438. * Use this function to overload the renderList array at rendering time.
  20439. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20440. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20441. * the cube (if the RTT is a cube, else layerOrFace=0).
  20442. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20443. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20444. * hold dummy elements!
  20445. */
  20446. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20447. private _hookArray;
  20448. /**
  20449. * Define if particles should be rendered in your texture.
  20450. */
  20451. renderParticles: boolean;
  20452. /**
  20453. * Define if sprites should be rendered in your texture.
  20454. */
  20455. renderSprites: boolean;
  20456. /**
  20457. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20458. */
  20459. coordinatesMode: number;
  20460. /**
  20461. * Define the camera used to render the texture.
  20462. */
  20463. activeCamera: Nullable<Camera>;
  20464. /**
  20465. * Override the render function of the texture with your own one.
  20466. */
  20467. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20468. /**
  20469. * Define if camera post processes should be use while rendering the texture.
  20470. */
  20471. useCameraPostProcesses: boolean;
  20472. /**
  20473. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20474. */
  20475. ignoreCameraViewport: boolean;
  20476. private _postProcessManager;
  20477. private _postProcesses;
  20478. private _resizeObserver;
  20479. /**
  20480. * An event triggered when the texture is unbind.
  20481. */
  20482. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20483. /**
  20484. * An event triggered when the texture is unbind.
  20485. */
  20486. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20487. private _onAfterUnbindObserver;
  20488. /**
  20489. * Set a after unbind callback in the texture.
  20490. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20491. */
  20492. set onAfterUnbind(callback: () => void);
  20493. /**
  20494. * An event triggered before rendering the texture
  20495. */
  20496. onBeforeRenderObservable: Observable<number>;
  20497. private _onBeforeRenderObserver;
  20498. /**
  20499. * Set a before render callback in the texture.
  20500. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20501. */
  20502. set onBeforeRender(callback: (faceIndex: number) => void);
  20503. /**
  20504. * An event triggered after rendering the texture
  20505. */
  20506. onAfterRenderObservable: Observable<number>;
  20507. private _onAfterRenderObserver;
  20508. /**
  20509. * Set a after render callback in the texture.
  20510. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20511. */
  20512. set onAfterRender(callback: (faceIndex: number) => void);
  20513. /**
  20514. * An event triggered after the texture clear
  20515. */
  20516. onClearObservable: Observable<Engine>;
  20517. private _onClearObserver;
  20518. /**
  20519. * Set a clear callback in the texture.
  20520. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20521. */
  20522. set onClear(callback: (Engine: Engine) => void);
  20523. /**
  20524. * An event triggered when the texture is resized.
  20525. */
  20526. onResizeObservable: Observable<RenderTargetTexture>;
  20527. /**
  20528. * Define the clear color of the Render Target if it should be different from the scene.
  20529. */
  20530. clearColor: Color4;
  20531. protected _size: number | {
  20532. width: number;
  20533. height: number;
  20534. layers?: number;
  20535. };
  20536. protected _initialSizeParameter: number | {
  20537. width: number;
  20538. height: number;
  20539. } | {
  20540. ratio: number;
  20541. };
  20542. protected _sizeRatio: Nullable<number>;
  20543. /** @hidden */
  20544. _generateMipMaps: boolean;
  20545. protected _renderingManager: RenderingManager;
  20546. /** @hidden */
  20547. _waitingRenderList: string[];
  20548. protected _doNotChangeAspectRatio: boolean;
  20549. protected _currentRefreshId: number;
  20550. protected _refreshRate: number;
  20551. protected _textureMatrix: Matrix;
  20552. protected _samples: number;
  20553. protected _renderTargetOptions: RenderTargetCreationOptions;
  20554. /**
  20555. * Gets render target creation options that were used.
  20556. */
  20557. get renderTargetOptions(): RenderTargetCreationOptions;
  20558. protected _engine: Engine;
  20559. protected _onRatioRescale(): void;
  20560. /**
  20561. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20562. * It must define where the camera used to render the texture is set
  20563. */
  20564. boundingBoxPosition: Vector3;
  20565. private _boundingBoxSize;
  20566. /**
  20567. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20568. * When defined, the cubemap will switch to local mode
  20569. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20570. * @example https://www.babylonjs-playground.com/#RNASML
  20571. */
  20572. set boundingBoxSize(value: Vector3);
  20573. get boundingBoxSize(): Vector3;
  20574. /**
  20575. * In case the RTT has been created with a depth texture, get the associated
  20576. * depth texture.
  20577. * Otherwise, return null.
  20578. */
  20579. get depthStencilTexture(): Nullable<InternalTexture>;
  20580. /**
  20581. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20582. * or used a shadow, depth texture...
  20583. * @param name The friendly name of the texture
  20584. * @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)
  20585. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20586. * @param generateMipMaps True if mip maps need to be generated after render.
  20587. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20588. * @param type The type of the buffer in the RTT (int, half float, float...)
  20589. * @param isCube True if a cube texture needs to be created
  20590. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20591. * @param generateDepthBuffer True to generate a depth buffer
  20592. * @param generateStencilBuffer True to generate a stencil buffer
  20593. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20594. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20595. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20596. */
  20597. constructor(name: string, size: number | {
  20598. width: number;
  20599. height: number;
  20600. layers?: number;
  20601. } | {
  20602. ratio: number;
  20603. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20604. /**
  20605. * Creates a depth stencil texture.
  20606. * This is only available in WebGL 2 or with the depth texture extension available.
  20607. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20608. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20609. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20610. */
  20611. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20612. private _processSizeParameter;
  20613. /**
  20614. * Define the number of samples to use in case of MSAA.
  20615. * It defaults to one meaning no MSAA has been enabled.
  20616. */
  20617. get samples(): number;
  20618. set samples(value: number);
  20619. /**
  20620. * Resets the refresh counter of the texture and start bak from scratch.
  20621. * Could be useful to regenerate the texture if it is setup to render only once.
  20622. */
  20623. resetRefreshCounter(): void;
  20624. /**
  20625. * Define the refresh rate of the texture or the rendering frequency.
  20626. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20627. */
  20628. get refreshRate(): number;
  20629. set refreshRate(value: number);
  20630. /**
  20631. * Adds a post process to the render target rendering passes.
  20632. * @param postProcess define the post process to add
  20633. */
  20634. addPostProcess(postProcess: PostProcess): void;
  20635. /**
  20636. * Clear all the post processes attached to the render target
  20637. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20638. */
  20639. clearPostProcesses(dispose?: boolean): void;
  20640. /**
  20641. * Remove one of the post process from the list of attached post processes to the texture
  20642. * @param postProcess define the post process to remove from the list
  20643. */
  20644. removePostProcess(postProcess: PostProcess): void;
  20645. /** @hidden */
  20646. _shouldRender(): boolean;
  20647. /**
  20648. * Gets the actual render size of the texture.
  20649. * @returns the width of the render size
  20650. */
  20651. getRenderSize(): number;
  20652. /**
  20653. * Gets the actual render width of the texture.
  20654. * @returns the width of the render size
  20655. */
  20656. getRenderWidth(): number;
  20657. /**
  20658. * Gets the actual render height of the texture.
  20659. * @returns the height of the render size
  20660. */
  20661. getRenderHeight(): number;
  20662. /**
  20663. * Gets the actual number of layers of the texture.
  20664. * @returns the number of layers
  20665. */
  20666. getRenderLayers(): number;
  20667. /**
  20668. * Get if the texture can be rescaled or not.
  20669. */
  20670. get canRescale(): boolean;
  20671. /**
  20672. * Resize the texture using a ratio.
  20673. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20674. */
  20675. scale(ratio: number): void;
  20676. /**
  20677. * Get the texture reflection matrix used to rotate/transform the reflection.
  20678. * @returns the reflection matrix
  20679. */
  20680. getReflectionTextureMatrix(): Matrix;
  20681. /**
  20682. * Resize the texture to a new desired size.
  20683. * Be carrefull as it will recreate all the data in the new texture.
  20684. * @param size Define the new size. It can be:
  20685. * - a number for squared texture,
  20686. * - an object containing { width: number, height: number }
  20687. * - or an object containing a ratio { ratio: number }
  20688. */
  20689. resize(size: number | {
  20690. width: number;
  20691. height: number;
  20692. } | {
  20693. ratio: number;
  20694. }): void;
  20695. private _defaultRenderListPrepared;
  20696. /**
  20697. * Renders all the objects from the render list into the texture.
  20698. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20699. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20700. */
  20701. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20702. private _bestReflectionRenderTargetDimension;
  20703. private _prepareRenderingManager;
  20704. /**
  20705. * @hidden
  20706. * @param faceIndex face index to bind to if this is a cubetexture
  20707. * @param layer defines the index of the texture to bind in the array
  20708. */
  20709. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20710. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20711. private renderToTarget;
  20712. /**
  20713. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20714. * This allowed control for front to back rendering or reversly depending of the special needs.
  20715. *
  20716. * @param renderingGroupId The rendering group id corresponding to its index
  20717. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20718. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20719. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20720. */
  20721. 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;
  20722. /**
  20723. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20724. *
  20725. * @param renderingGroupId The rendering group id corresponding to its index
  20726. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20727. */
  20728. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20729. /**
  20730. * Clones the texture.
  20731. * @returns the cloned texture
  20732. */
  20733. clone(): RenderTargetTexture;
  20734. /**
  20735. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20736. * @returns The JSON representation of the texture
  20737. */
  20738. serialize(): any;
  20739. /**
  20740. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20741. */
  20742. disposeFramebufferObjects(): void;
  20743. /**
  20744. * Dispose the texture and release its associated resources.
  20745. */
  20746. dispose(): void;
  20747. /** @hidden */
  20748. _rebuild(): void;
  20749. /**
  20750. * Clear the info related to rendering groups preventing retention point in material dispose.
  20751. */
  20752. freeRenderingGroups(): void;
  20753. /**
  20754. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20755. * @returns the view count
  20756. */
  20757. getViewCount(): number;
  20758. }
  20759. }
  20760. declare module BABYLON {
  20761. /**
  20762. * Options for compiling materials.
  20763. */
  20764. export interface IMaterialCompilationOptions {
  20765. /**
  20766. * Defines whether clip planes are enabled.
  20767. */
  20768. clipPlane: boolean;
  20769. /**
  20770. * Defines whether instances are enabled.
  20771. */
  20772. useInstances: boolean;
  20773. }
  20774. /**
  20775. * Base class for the main features of a material in Babylon.js
  20776. */
  20777. export class Material implements IAnimatable {
  20778. /**
  20779. * Returns the triangle fill mode
  20780. */
  20781. static readonly TriangleFillMode: number;
  20782. /**
  20783. * Returns the wireframe mode
  20784. */
  20785. static readonly WireFrameFillMode: number;
  20786. /**
  20787. * Returns the point fill mode
  20788. */
  20789. static readonly PointFillMode: number;
  20790. /**
  20791. * Returns the point list draw mode
  20792. */
  20793. static readonly PointListDrawMode: number;
  20794. /**
  20795. * Returns the line list draw mode
  20796. */
  20797. static readonly LineListDrawMode: number;
  20798. /**
  20799. * Returns the line loop draw mode
  20800. */
  20801. static readonly LineLoopDrawMode: number;
  20802. /**
  20803. * Returns the line strip draw mode
  20804. */
  20805. static readonly LineStripDrawMode: number;
  20806. /**
  20807. * Returns the triangle strip draw mode
  20808. */
  20809. static readonly TriangleStripDrawMode: number;
  20810. /**
  20811. * Returns the triangle fan draw mode
  20812. */
  20813. static readonly TriangleFanDrawMode: number;
  20814. /**
  20815. * Stores the clock-wise side orientation
  20816. */
  20817. static readonly ClockWiseSideOrientation: number;
  20818. /**
  20819. * Stores the counter clock-wise side orientation
  20820. */
  20821. static readonly CounterClockWiseSideOrientation: number;
  20822. /**
  20823. * The dirty texture flag value
  20824. */
  20825. static readonly TextureDirtyFlag: number;
  20826. /**
  20827. * The dirty light flag value
  20828. */
  20829. static readonly LightDirtyFlag: number;
  20830. /**
  20831. * The dirty fresnel flag value
  20832. */
  20833. static readonly FresnelDirtyFlag: number;
  20834. /**
  20835. * The dirty attribute flag value
  20836. */
  20837. static readonly AttributesDirtyFlag: number;
  20838. /**
  20839. * The dirty misc flag value
  20840. */
  20841. static readonly MiscDirtyFlag: number;
  20842. /**
  20843. * The all dirty flag value
  20844. */
  20845. static readonly AllDirtyFlag: number;
  20846. /**
  20847. * The ID of the material
  20848. */
  20849. id: string;
  20850. /**
  20851. * Gets or sets the unique id of the material
  20852. */
  20853. uniqueId: number;
  20854. /**
  20855. * The name of the material
  20856. */
  20857. name: string;
  20858. /**
  20859. * Gets or sets user defined metadata
  20860. */
  20861. metadata: any;
  20862. /**
  20863. * For internal use only. Please do not use.
  20864. */
  20865. reservedDataStore: any;
  20866. /**
  20867. * Specifies if the ready state should be checked on each call
  20868. */
  20869. checkReadyOnEveryCall: boolean;
  20870. /**
  20871. * Specifies if the ready state should be checked once
  20872. */
  20873. checkReadyOnlyOnce: boolean;
  20874. /**
  20875. * The state of the material
  20876. */
  20877. state: string;
  20878. /**
  20879. * The alpha value of the material
  20880. */
  20881. protected _alpha: number;
  20882. /**
  20883. * List of inspectable custom properties (used by the Inspector)
  20884. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20885. */
  20886. inspectableCustomProperties: IInspectable[];
  20887. /**
  20888. * Sets the alpha value of the material
  20889. */
  20890. set alpha(value: number);
  20891. /**
  20892. * Gets the alpha value of the material
  20893. */
  20894. get alpha(): number;
  20895. /**
  20896. * Specifies if back face culling is enabled
  20897. */
  20898. protected _backFaceCulling: boolean;
  20899. /**
  20900. * Sets the back-face culling state
  20901. */
  20902. set backFaceCulling(value: boolean);
  20903. /**
  20904. * Gets the back-face culling state
  20905. */
  20906. get backFaceCulling(): boolean;
  20907. /**
  20908. * Stores the value for side orientation
  20909. */
  20910. sideOrientation: number;
  20911. /**
  20912. * Callback triggered when the material is compiled
  20913. */
  20914. onCompiled: Nullable<(effect: Effect) => void>;
  20915. /**
  20916. * Callback triggered when an error occurs
  20917. */
  20918. onError: Nullable<(effect: Effect, errors: string) => void>;
  20919. /**
  20920. * Callback triggered to get the render target textures
  20921. */
  20922. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20923. /**
  20924. * Gets a boolean indicating that current material needs to register RTT
  20925. */
  20926. get hasRenderTargetTextures(): boolean;
  20927. /**
  20928. * Specifies if the material should be serialized
  20929. */
  20930. doNotSerialize: boolean;
  20931. /**
  20932. * @hidden
  20933. */
  20934. _storeEffectOnSubMeshes: boolean;
  20935. /**
  20936. * Stores the animations for the material
  20937. */
  20938. animations: Nullable<Array<Animation>>;
  20939. /**
  20940. * An event triggered when the material is disposed
  20941. */
  20942. onDisposeObservable: Observable<Material>;
  20943. /**
  20944. * An observer which watches for dispose events
  20945. */
  20946. private _onDisposeObserver;
  20947. private _onUnBindObservable;
  20948. /**
  20949. * Called during a dispose event
  20950. */
  20951. set onDispose(callback: () => void);
  20952. private _onBindObservable;
  20953. /**
  20954. * An event triggered when the material is bound
  20955. */
  20956. get onBindObservable(): Observable<AbstractMesh>;
  20957. /**
  20958. * An observer which watches for bind events
  20959. */
  20960. private _onBindObserver;
  20961. /**
  20962. * Called during a bind event
  20963. */
  20964. set onBind(callback: (Mesh: AbstractMesh) => void);
  20965. /**
  20966. * An event triggered when the material is unbound
  20967. */
  20968. get onUnBindObservable(): Observable<Material>;
  20969. /**
  20970. * Stores the value of the alpha mode
  20971. */
  20972. private _alphaMode;
  20973. /**
  20974. * Sets the value of the alpha mode.
  20975. *
  20976. * | Value | Type | Description |
  20977. * | --- | --- | --- |
  20978. * | 0 | ALPHA_DISABLE | |
  20979. * | 1 | ALPHA_ADD | |
  20980. * | 2 | ALPHA_COMBINE | |
  20981. * | 3 | ALPHA_SUBTRACT | |
  20982. * | 4 | ALPHA_MULTIPLY | |
  20983. * | 5 | ALPHA_MAXIMIZED | |
  20984. * | 6 | ALPHA_ONEONE | |
  20985. * | 7 | ALPHA_PREMULTIPLIED | |
  20986. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20987. * | 9 | ALPHA_INTERPOLATE | |
  20988. * | 10 | ALPHA_SCREENMODE | |
  20989. *
  20990. */
  20991. set alphaMode(value: number);
  20992. /**
  20993. * Gets the value of the alpha mode
  20994. */
  20995. get alphaMode(): number;
  20996. /**
  20997. * Stores the state of the need depth pre-pass value
  20998. */
  20999. private _needDepthPrePass;
  21000. /**
  21001. * Sets the need depth pre-pass value
  21002. */
  21003. set needDepthPrePass(value: boolean);
  21004. /**
  21005. * Gets the depth pre-pass value
  21006. */
  21007. get needDepthPrePass(): boolean;
  21008. /**
  21009. * Specifies if depth writing should be disabled
  21010. */
  21011. disableDepthWrite: boolean;
  21012. /**
  21013. * Specifies if depth writing should be forced
  21014. */
  21015. forceDepthWrite: boolean;
  21016. /**
  21017. * Specifies the depth function that should be used. 0 means the default engine function
  21018. */
  21019. depthFunction: number;
  21020. /**
  21021. * Specifies if there should be a separate pass for culling
  21022. */
  21023. separateCullingPass: boolean;
  21024. /**
  21025. * Stores the state specifing if fog should be enabled
  21026. */
  21027. private _fogEnabled;
  21028. /**
  21029. * Sets the state for enabling fog
  21030. */
  21031. set fogEnabled(value: boolean);
  21032. /**
  21033. * Gets the value of the fog enabled state
  21034. */
  21035. get fogEnabled(): boolean;
  21036. /**
  21037. * Stores the size of points
  21038. */
  21039. pointSize: number;
  21040. /**
  21041. * Stores the z offset value
  21042. */
  21043. zOffset: number;
  21044. /**
  21045. * Gets a value specifying if wireframe mode is enabled
  21046. */
  21047. get wireframe(): boolean;
  21048. /**
  21049. * Sets the state of wireframe mode
  21050. */
  21051. set wireframe(value: boolean);
  21052. /**
  21053. * Gets the value specifying if point clouds are enabled
  21054. */
  21055. get pointsCloud(): boolean;
  21056. /**
  21057. * Sets the state of point cloud mode
  21058. */
  21059. set pointsCloud(value: boolean);
  21060. /**
  21061. * Gets the material fill mode
  21062. */
  21063. get fillMode(): number;
  21064. /**
  21065. * Sets the material fill mode
  21066. */
  21067. set fillMode(value: number);
  21068. /**
  21069. * @hidden
  21070. * Stores the effects for the material
  21071. */
  21072. _effect: Nullable<Effect>;
  21073. /**
  21074. * Specifies if uniform buffers should be used
  21075. */
  21076. private _useUBO;
  21077. /**
  21078. * Stores a reference to the scene
  21079. */
  21080. private _scene;
  21081. /**
  21082. * Stores the fill mode state
  21083. */
  21084. private _fillMode;
  21085. /**
  21086. * Specifies if the depth write state should be cached
  21087. */
  21088. private _cachedDepthWriteState;
  21089. /**
  21090. * Specifies if the depth function state should be cached
  21091. */
  21092. private _cachedDepthFunctionState;
  21093. /**
  21094. * Stores the uniform buffer
  21095. */
  21096. protected _uniformBuffer: UniformBuffer;
  21097. /** @hidden */
  21098. _indexInSceneMaterialArray: number;
  21099. /** @hidden */
  21100. meshMap: Nullable<{
  21101. [id: string]: AbstractMesh | undefined;
  21102. }>;
  21103. /**
  21104. * Creates a material instance
  21105. * @param name defines the name of the material
  21106. * @param scene defines the scene to reference
  21107. * @param doNotAdd specifies if the material should be added to the scene
  21108. */
  21109. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21110. /**
  21111. * Returns a string representation of the current material
  21112. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21113. * @returns a string with material information
  21114. */
  21115. toString(fullDetails?: boolean): string;
  21116. /**
  21117. * Gets the class name of the material
  21118. * @returns a string with the class name of the material
  21119. */
  21120. getClassName(): string;
  21121. /**
  21122. * Specifies if updates for the material been locked
  21123. */
  21124. get isFrozen(): boolean;
  21125. /**
  21126. * Locks updates for the material
  21127. */
  21128. freeze(): void;
  21129. /**
  21130. * Unlocks updates for the material
  21131. */
  21132. unfreeze(): void;
  21133. /**
  21134. * Specifies if the material is ready to be used
  21135. * @param mesh defines the mesh to check
  21136. * @param useInstances specifies if instances should be used
  21137. * @returns a boolean indicating if the material is ready to be used
  21138. */
  21139. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21140. /**
  21141. * Specifies that the submesh is ready to be used
  21142. * @param mesh defines the mesh to check
  21143. * @param subMesh defines which submesh to check
  21144. * @param useInstances specifies that instances should be used
  21145. * @returns a boolean indicating that the submesh is ready or not
  21146. */
  21147. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21148. /**
  21149. * Returns the material effect
  21150. * @returns the effect associated with the material
  21151. */
  21152. getEffect(): Nullable<Effect>;
  21153. /**
  21154. * Returns the current scene
  21155. * @returns a Scene
  21156. */
  21157. getScene(): Scene;
  21158. /**
  21159. * Specifies if the material will require alpha blending
  21160. * @returns a boolean specifying if alpha blending is needed
  21161. */
  21162. needAlphaBlending(): boolean;
  21163. /**
  21164. * Specifies if the mesh will require alpha blending
  21165. * @param mesh defines the mesh to check
  21166. * @returns a boolean specifying if alpha blending is needed for the mesh
  21167. */
  21168. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21169. /**
  21170. * Specifies if this material should be rendered in alpha test mode
  21171. * @returns a boolean specifying if an alpha test is needed.
  21172. */
  21173. needAlphaTesting(): boolean;
  21174. /**
  21175. * Gets the texture used for the alpha test
  21176. * @returns the texture to use for alpha testing
  21177. */
  21178. getAlphaTestTexture(): Nullable<BaseTexture>;
  21179. /**
  21180. * Marks the material to indicate that it needs to be re-calculated
  21181. */
  21182. markDirty(): void;
  21183. /** @hidden */
  21184. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21185. /**
  21186. * Binds the material to the mesh
  21187. * @param world defines the world transformation matrix
  21188. * @param mesh defines the mesh to bind the material to
  21189. */
  21190. bind(world: Matrix, mesh?: Mesh): void;
  21191. /**
  21192. * Binds the submesh to the material
  21193. * @param world defines the world transformation matrix
  21194. * @param mesh defines the mesh containing the submesh
  21195. * @param subMesh defines the submesh to bind the material to
  21196. */
  21197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21198. /**
  21199. * Binds the world matrix to the material
  21200. * @param world defines the world transformation matrix
  21201. */
  21202. bindOnlyWorldMatrix(world: Matrix): void;
  21203. /**
  21204. * Binds the scene's uniform buffer to the effect.
  21205. * @param effect defines the effect to bind to the scene uniform buffer
  21206. * @param sceneUbo defines the uniform buffer storing scene data
  21207. */
  21208. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21209. /**
  21210. * Binds the view matrix to the effect
  21211. * @param effect defines the effect to bind the view matrix to
  21212. */
  21213. bindView(effect: Effect): void;
  21214. /**
  21215. * Binds the view projection matrix to the effect
  21216. * @param effect defines the effect to bind the view projection matrix to
  21217. */
  21218. bindViewProjection(effect: Effect): void;
  21219. /**
  21220. * Specifies if material alpha testing should be turned on for the mesh
  21221. * @param mesh defines the mesh to check
  21222. */
  21223. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21224. /**
  21225. * Processes to execute after binding the material to a mesh
  21226. * @param mesh defines the rendered mesh
  21227. */
  21228. protected _afterBind(mesh?: Mesh): void;
  21229. /**
  21230. * Unbinds the material from the mesh
  21231. */
  21232. unbind(): void;
  21233. /**
  21234. * Gets the active textures from the material
  21235. * @returns an array of textures
  21236. */
  21237. getActiveTextures(): BaseTexture[];
  21238. /**
  21239. * Specifies if the material uses a texture
  21240. * @param texture defines the texture to check against the material
  21241. * @returns a boolean specifying if the material uses the texture
  21242. */
  21243. hasTexture(texture: BaseTexture): boolean;
  21244. /**
  21245. * Makes a duplicate of the material, and gives it a new name
  21246. * @param name defines the new name for the duplicated material
  21247. * @returns the cloned material
  21248. */
  21249. clone(name: string): Nullable<Material>;
  21250. /**
  21251. * Gets the meshes bound to the material
  21252. * @returns an array of meshes bound to the material
  21253. */
  21254. getBindedMeshes(): AbstractMesh[];
  21255. /**
  21256. * Force shader compilation
  21257. * @param mesh defines the mesh associated with this material
  21258. * @param onCompiled defines a function to execute once the material is compiled
  21259. * @param options defines the options to configure the compilation
  21260. * @param onError defines a function to execute if the material fails compiling
  21261. */
  21262. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21263. /**
  21264. * Force shader compilation
  21265. * @param mesh defines the mesh that will use this material
  21266. * @param options defines additional options for compiling the shaders
  21267. * @returns a promise that resolves when the compilation completes
  21268. */
  21269. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21270. private static readonly _AllDirtyCallBack;
  21271. private static readonly _ImageProcessingDirtyCallBack;
  21272. private static readonly _TextureDirtyCallBack;
  21273. private static readonly _FresnelDirtyCallBack;
  21274. private static readonly _MiscDirtyCallBack;
  21275. private static readonly _LightsDirtyCallBack;
  21276. private static readonly _AttributeDirtyCallBack;
  21277. private static _FresnelAndMiscDirtyCallBack;
  21278. private static _TextureAndMiscDirtyCallBack;
  21279. private static readonly _DirtyCallbackArray;
  21280. private static readonly _RunDirtyCallBacks;
  21281. /**
  21282. * Marks a define in the material to indicate that it needs to be re-computed
  21283. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21284. */
  21285. markAsDirty(flag: number): void;
  21286. /**
  21287. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21288. * @param func defines a function which checks material defines against the submeshes
  21289. */
  21290. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21291. /**
  21292. * Indicates that we need to re-calculated for all submeshes
  21293. */
  21294. protected _markAllSubMeshesAsAllDirty(): void;
  21295. /**
  21296. * Indicates that image processing needs to be re-calculated for all submeshes
  21297. */
  21298. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21299. /**
  21300. * Indicates that textures need to be re-calculated for all submeshes
  21301. */
  21302. protected _markAllSubMeshesAsTexturesDirty(): void;
  21303. /**
  21304. * Indicates that fresnel needs to be re-calculated for all submeshes
  21305. */
  21306. protected _markAllSubMeshesAsFresnelDirty(): void;
  21307. /**
  21308. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21309. */
  21310. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21311. /**
  21312. * Indicates that lights need to be re-calculated for all submeshes
  21313. */
  21314. protected _markAllSubMeshesAsLightsDirty(): void;
  21315. /**
  21316. * Indicates that attributes need to be re-calculated for all submeshes
  21317. */
  21318. protected _markAllSubMeshesAsAttributesDirty(): void;
  21319. /**
  21320. * Indicates that misc needs to be re-calculated for all submeshes
  21321. */
  21322. protected _markAllSubMeshesAsMiscDirty(): void;
  21323. /**
  21324. * Indicates that textures and misc need to be re-calculated for all submeshes
  21325. */
  21326. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21327. /**
  21328. * Disposes the material
  21329. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21330. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21331. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21332. */
  21333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21334. /** @hidden */
  21335. private releaseVertexArrayObject;
  21336. /**
  21337. * Serializes this material
  21338. * @returns the serialized material object
  21339. */
  21340. serialize(): any;
  21341. /**
  21342. * Creates a material from parsed material data
  21343. * @param parsedMaterial defines parsed material data
  21344. * @param scene defines the hosting scene
  21345. * @param rootUrl defines the root URL to use to load textures
  21346. * @returns a new material
  21347. */
  21348. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21349. }
  21350. }
  21351. declare module BABYLON {
  21352. /**
  21353. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21354. * separate meshes. This can be use to improve performances.
  21355. * @see http://doc.babylonjs.com/how_to/multi_materials
  21356. */
  21357. export class MultiMaterial extends Material {
  21358. private _subMaterials;
  21359. /**
  21360. * Gets or Sets the list of Materials used within the multi material.
  21361. * They need to be ordered according to the submeshes order in the associated mesh
  21362. */
  21363. get subMaterials(): Nullable<Material>[];
  21364. set subMaterials(value: Nullable<Material>[]);
  21365. /**
  21366. * Function used to align with Node.getChildren()
  21367. * @returns the list of Materials used within the multi material
  21368. */
  21369. getChildren(): Nullable<Material>[];
  21370. /**
  21371. * Instantiates a new Multi Material
  21372. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21373. * separate meshes. This can be use to improve performances.
  21374. * @see http://doc.babylonjs.com/how_to/multi_materials
  21375. * @param name Define the name in the scene
  21376. * @param scene Define the scene the material belongs to
  21377. */
  21378. constructor(name: string, scene: Scene);
  21379. private _hookArray;
  21380. /**
  21381. * Get one of the submaterial by its index in the submaterials array
  21382. * @param index The index to look the sub material at
  21383. * @returns The Material if the index has been defined
  21384. */
  21385. getSubMaterial(index: number): Nullable<Material>;
  21386. /**
  21387. * Get the list of active textures for the whole sub materials list.
  21388. * @returns All the textures that will be used during the rendering
  21389. */
  21390. getActiveTextures(): BaseTexture[];
  21391. /**
  21392. * Gets the current class name of the material e.g. "MultiMaterial"
  21393. * Mainly use in serialization.
  21394. * @returns the class name
  21395. */
  21396. getClassName(): string;
  21397. /**
  21398. * Checks if the material is ready to render the requested sub mesh
  21399. * @param mesh Define the mesh the submesh belongs to
  21400. * @param subMesh Define the sub mesh to look readyness for
  21401. * @param useInstances Define whether or not the material is used with instances
  21402. * @returns true if ready, otherwise false
  21403. */
  21404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21405. /**
  21406. * Clones the current material and its related sub materials
  21407. * @param name Define the name of the newly cloned material
  21408. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21409. * @returns the cloned material
  21410. */
  21411. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21412. /**
  21413. * Serializes the materials into a JSON representation.
  21414. * @returns the JSON representation
  21415. */
  21416. serialize(): any;
  21417. /**
  21418. * Dispose the material and release its associated resources
  21419. * @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)
  21420. * @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)
  21421. * @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)
  21422. */
  21423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21424. /**
  21425. * Creates a MultiMaterial from parsed MultiMaterial data.
  21426. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21427. * @param scene defines the hosting scene
  21428. * @returns a new MultiMaterial
  21429. */
  21430. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21431. }
  21432. }
  21433. declare module BABYLON {
  21434. /**
  21435. * Base class for submeshes
  21436. */
  21437. export class BaseSubMesh {
  21438. /** @hidden */
  21439. _materialDefines: Nullable<MaterialDefines>;
  21440. /** @hidden */
  21441. _materialEffect: Nullable<Effect>;
  21442. /**
  21443. * Gets material defines used by the effect associated to the sub mesh
  21444. */
  21445. get materialDefines(): Nullable<MaterialDefines>;
  21446. /**
  21447. * Sets material defines used by the effect associated to the sub mesh
  21448. */
  21449. set materialDefines(defines: Nullable<MaterialDefines>);
  21450. /**
  21451. * Gets associated effect
  21452. */
  21453. get effect(): Nullable<Effect>;
  21454. /**
  21455. * Sets associated effect (effect used to render this submesh)
  21456. * @param effect defines the effect to associate with
  21457. * @param defines defines the set of defines used to compile this effect
  21458. */
  21459. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21460. }
  21461. /**
  21462. * Defines a subdivision inside a mesh
  21463. */
  21464. export class SubMesh extends BaseSubMesh implements ICullable {
  21465. /** the material index to use */
  21466. materialIndex: number;
  21467. /** vertex index start */
  21468. verticesStart: number;
  21469. /** vertices count */
  21470. verticesCount: number;
  21471. /** index start */
  21472. indexStart: number;
  21473. /** indices count */
  21474. indexCount: number;
  21475. /** @hidden */
  21476. _linesIndexCount: number;
  21477. private _mesh;
  21478. private _renderingMesh;
  21479. private _boundingInfo;
  21480. private _linesIndexBuffer;
  21481. /** @hidden */
  21482. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21483. /** @hidden */
  21484. _trianglePlanes: Plane[];
  21485. /** @hidden */
  21486. _lastColliderTransformMatrix: Nullable<Matrix>;
  21487. /** @hidden */
  21488. _renderId: number;
  21489. /** @hidden */
  21490. _alphaIndex: number;
  21491. /** @hidden */
  21492. _distanceToCamera: number;
  21493. /** @hidden */
  21494. _id: number;
  21495. private _currentMaterial;
  21496. /**
  21497. * Add a new submesh to a mesh
  21498. * @param materialIndex defines the material index to use
  21499. * @param verticesStart defines vertex index start
  21500. * @param verticesCount defines vertices count
  21501. * @param indexStart defines index start
  21502. * @param indexCount defines indices count
  21503. * @param mesh defines the parent mesh
  21504. * @param renderingMesh defines an optional rendering mesh
  21505. * @param createBoundingBox defines if bounding box should be created for this submesh
  21506. * @returns the new submesh
  21507. */
  21508. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21509. /**
  21510. * Creates a new submesh
  21511. * @param materialIndex defines the material index to use
  21512. * @param verticesStart defines vertex index start
  21513. * @param verticesCount defines vertices count
  21514. * @param indexStart defines index start
  21515. * @param indexCount defines indices count
  21516. * @param mesh defines the parent mesh
  21517. * @param renderingMesh defines an optional rendering mesh
  21518. * @param createBoundingBox defines if bounding box should be created for this submesh
  21519. */
  21520. constructor(
  21521. /** the material index to use */
  21522. materialIndex: number,
  21523. /** vertex index start */
  21524. verticesStart: number,
  21525. /** vertices count */
  21526. verticesCount: number,
  21527. /** index start */
  21528. indexStart: number,
  21529. /** indices count */
  21530. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21531. /**
  21532. * Returns true if this submesh covers the entire parent mesh
  21533. * @ignorenaming
  21534. */
  21535. get IsGlobal(): boolean;
  21536. /**
  21537. * Returns the submesh BoudingInfo object
  21538. * @returns current bounding info (or mesh's one if the submesh is global)
  21539. */
  21540. getBoundingInfo(): BoundingInfo;
  21541. /**
  21542. * Sets the submesh BoundingInfo
  21543. * @param boundingInfo defines the new bounding info to use
  21544. * @returns the SubMesh
  21545. */
  21546. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21547. /**
  21548. * Returns the mesh of the current submesh
  21549. * @return the parent mesh
  21550. */
  21551. getMesh(): AbstractMesh;
  21552. /**
  21553. * Returns the rendering mesh of the submesh
  21554. * @returns the rendering mesh (could be different from parent mesh)
  21555. */
  21556. getRenderingMesh(): Mesh;
  21557. /**
  21558. * Returns the submesh material
  21559. * @returns null or the current material
  21560. */
  21561. getMaterial(): Nullable<Material>;
  21562. /**
  21563. * Sets a new updated BoundingInfo object to the submesh
  21564. * @param data defines an optional position array to use to determine the bounding info
  21565. * @returns the SubMesh
  21566. */
  21567. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21568. /** @hidden */
  21569. _checkCollision(collider: Collider): boolean;
  21570. /**
  21571. * Updates the submesh BoundingInfo
  21572. * @param world defines the world matrix to use to update the bounding info
  21573. * @returns the submesh
  21574. */
  21575. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21576. /**
  21577. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21578. * @param frustumPlanes defines the frustum planes
  21579. * @returns true if the submesh is intersecting with the frustum
  21580. */
  21581. isInFrustum(frustumPlanes: Plane[]): boolean;
  21582. /**
  21583. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21584. * @param frustumPlanes defines the frustum planes
  21585. * @returns true if the submesh is inside the frustum
  21586. */
  21587. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21588. /**
  21589. * Renders the submesh
  21590. * @param enableAlphaMode defines if alpha needs to be used
  21591. * @returns the submesh
  21592. */
  21593. render(enableAlphaMode: boolean): SubMesh;
  21594. /**
  21595. * @hidden
  21596. */
  21597. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21598. /**
  21599. * Checks if the submesh intersects with a ray
  21600. * @param ray defines the ray to test
  21601. * @returns true is the passed ray intersects the submesh bounding box
  21602. */
  21603. canIntersects(ray: Ray): boolean;
  21604. /**
  21605. * Intersects current submesh with a ray
  21606. * @param ray defines the ray to test
  21607. * @param positions defines mesh's positions array
  21608. * @param indices defines mesh's indices array
  21609. * @param fastCheck defines if only bounding info should be used
  21610. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21611. * @returns intersection info or null if no intersection
  21612. */
  21613. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21614. /** @hidden */
  21615. private _intersectLines;
  21616. /** @hidden */
  21617. private _intersectUnIndexedLines;
  21618. /** @hidden */
  21619. private _intersectTriangles;
  21620. /** @hidden */
  21621. private _intersectUnIndexedTriangles;
  21622. /** @hidden */
  21623. _rebuild(): void;
  21624. /**
  21625. * Creates a new submesh from the passed mesh
  21626. * @param newMesh defines the new hosting mesh
  21627. * @param newRenderingMesh defines an optional rendering mesh
  21628. * @returns the new submesh
  21629. */
  21630. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21631. /**
  21632. * Release associated resources
  21633. */
  21634. dispose(): void;
  21635. /**
  21636. * Gets the class name
  21637. * @returns the string "SubMesh".
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Creates a new submesh from indices data
  21642. * @param materialIndex the index of the main mesh material
  21643. * @param startIndex the index where to start the copy in the mesh indices array
  21644. * @param indexCount the number of indices to copy then from the startIndex
  21645. * @param mesh the main mesh to create the submesh from
  21646. * @param renderingMesh the optional rendering mesh
  21647. * @returns a new submesh
  21648. */
  21649. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21650. }
  21651. }
  21652. declare module BABYLON {
  21653. /**
  21654. * Class used to represent data loading progression
  21655. */
  21656. export class SceneLoaderFlags {
  21657. private static _ForceFullSceneLoadingForIncremental;
  21658. private static _ShowLoadingScreen;
  21659. private static _CleanBoneMatrixWeights;
  21660. private static _loggingLevel;
  21661. /**
  21662. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21663. */
  21664. static get ForceFullSceneLoadingForIncremental(): boolean;
  21665. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21666. /**
  21667. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21668. */
  21669. static get ShowLoadingScreen(): boolean;
  21670. static set ShowLoadingScreen(value: boolean);
  21671. /**
  21672. * Defines the current logging level (while loading the scene)
  21673. * @ignorenaming
  21674. */
  21675. static get loggingLevel(): number;
  21676. static set loggingLevel(value: number);
  21677. /**
  21678. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21679. */
  21680. static get CleanBoneMatrixWeights(): boolean;
  21681. static set CleanBoneMatrixWeights(value: boolean);
  21682. }
  21683. }
  21684. declare module BABYLON {
  21685. /**
  21686. * Class used to store geometry data (vertex buffers + index buffer)
  21687. */
  21688. export class Geometry implements IGetSetVerticesData {
  21689. /**
  21690. * Gets or sets the ID of the geometry
  21691. */
  21692. id: string;
  21693. /**
  21694. * Gets or sets the unique ID of the geometry
  21695. */
  21696. uniqueId: number;
  21697. /**
  21698. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21699. */
  21700. delayLoadState: number;
  21701. /**
  21702. * Gets the file containing the data to load when running in delay load state
  21703. */
  21704. delayLoadingFile: Nullable<string>;
  21705. /**
  21706. * Callback called when the geometry is updated
  21707. */
  21708. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21709. private _scene;
  21710. private _engine;
  21711. private _meshes;
  21712. private _totalVertices;
  21713. /** @hidden */
  21714. _indices: IndicesArray;
  21715. /** @hidden */
  21716. _vertexBuffers: {
  21717. [key: string]: VertexBuffer;
  21718. };
  21719. private _isDisposed;
  21720. private _extend;
  21721. private _boundingBias;
  21722. /** @hidden */
  21723. _delayInfo: Array<string>;
  21724. private _indexBuffer;
  21725. private _indexBufferIsUpdatable;
  21726. /** @hidden */
  21727. _boundingInfo: Nullable<BoundingInfo>;
  21728. /** @hidden */
  21729. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21730. /** @hidden */
  21731. _softwareSkinningFrameId: number;
  21732. private _vertexArrayObjects;
  21733. private _updatable;
  21734. /** @hidden */
  21735. _positions: Nullable<Vector3[]>;
  21736. /**
  21737. * 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
  21738. */
  21739. get boundingBias(): Vector2;
  21740. /**
  21741. * 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
  21742. */
  21743. set boundingBias(value: Vector2);
  21744. /**
  21745. * Static function used to attach a new empty geometry to a mesh
  21746. * @param mesh defines the mesh to attach the geometry to
  21747. * @returns the new Geometry
  21748. */
  21749. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21750. /**
  21751. * Creates a new geometry
  21752. * @param id defines the unique ID
  21753. * @param scene defines the hosting scene
  21754. * @param vertexData defines the VertexData used to get geometry data
  21755. * @param updatable defines if geometry must be updatable (false by default)
  21756. * @param mesh defines the mesh that will be associated with the geometry
  21757. */
  21758. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21759. /**
  21760. * Gets the current extend of the geometry
  21761. */
  21762. get extend(): {
  21763. minimum: Vector3;
  21764. maximum: Vector3;
  21765. };
  21766. /**
  21767. * Gets the hosting scene
  21768. * @returns the hosting Scene
  21769. */
  21770. getScene(): Scene;
  21771. /**
  21772. * Gets the hosting engine
  21773. * @returns the hosting Engine
  21774. */
  21775. getEngine(): Engine;
  21776. /**
  21777. * Defines if the geometry is ready to use
  21778. * @returns true if the geometry is ready to be used
  21779. */
  21780. isReady(): boolean;
  21781. /**
  21782. * Gets a value indicating that the geometry should not be serialized
  21783. */
  21784. get doNotSerialize(): boolean;
  21785. /** @hidden */
  21786. _rebuild(): void;
  21787. /**
  21788. * Affects all geometry data in one call
  21789. * @param vertexData defines the geometry data
  21790. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21791. */
  21792. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21793. /**
  21794. * Set specific vertex data
  21795. * @param kind defines the data kind (Position, normal, etc...)
  21796. * @param data defines the vertex data to use
  21797. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21798. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21799. */
  21800. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21801. /**
  21802. * Removes a specific vertex data
  21803. * @param kind defines the data kind (Position, normal, etc...)
  21804. */
  21805. removeVerticesData(kind: string): void;
  21806. /**
  21807. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21808. * @param buffer defines the vertex buffer to use
  21809. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21810. */
  21811. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21812. /**
  21813. * Update a specific vertex buffer
  21814. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21815. * It will do nothing if the buffer is not updatable
  21816. * @param kind defines the data kind (Position, normal, etc...)
  21817. * @param data defines the data to use
  21818. * @param offset defines the offset in the target buffer where to store the data
  21819. * @param useBytes set to true if the offset is in bytes
  21820. */
  21821. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21822. /**
  21823. * Update a specific vertex buffer
  21824. * This function will create a new buffer if the current one is not updatable
  21825. * @param kind defines the data kind (Position, normal, etc...)
  21826. * @param data defines the data to use
  21827. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21828. */
  21829. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21830. private _updateBoundingInfo;
  21831. /** @hidden */
  21832. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21833. /**
  21834. * Gets total number of vertices
  21835. * @returns the total number of vertices
  21836. */
  21837. getTotalVertices(): number;
  21838. /**
  21839. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21840. * @param kind defines the data kind (Position, normal, etc...)
  21841. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21843. * @returns a float array containing vertex data
  21844. */
  21845. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21846. /**
  21847. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21848. * @param kind defines the data kind (Position, normal, etc...)
  21849. * @returns true if the vertex buffer with the specified kind is updatable
  21850. */
  21851. isVertexBufferUpdatable(kind: string): boolean;
  21852. /**
  21853. * Gets a specific vertex buffer
  21854. * @param kind defines the data kind (Position, normal, etc...)
  21855. * @returns a VertexBuffer
  21856. */
  21857. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21858. /**
  21859. * Returns all vertex buffers
  21860. * @return an object holding all vertex buffers indexed by kind
  21861. */
  21862. getVertexBuffers(): Nullable<{
  21863. [key: string]: VertexBuffer;
  21864. }>;
  21865. /**
  21866. * Gets a boolean indicating if specific vertex buffer is present
  21867. * @param kind defines the data kind (Position, normal, etc...)
  21868. * @returns true if data is present
  21869. */
  21870. isVerticesDataPresent(kind: string): boolean;
  21871. /**
  21872. * Gets a list of all attached data kinds (Position, normal, etc...)
  21873. * @returns a list of string containing all kinds
  21874. */
  21875. getVerticesDataKinds(): string[];
  21876. /**
  21877. * Update index buffer
  21878. * @param indices defines the indices to store in the index buffer
  21879. * @param offset defines the offset in the target buffer where to store the data
  21880. * @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)
  21881. */
  21882. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21883. /**
  21884. * Creates a new index buffer
  21885. * @param indices defines the indices to store in the index buffer
  21886. * @param totalVertices defines the total number of vertices (could be null)
  21887. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21888. */
  21889. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21890. /**
  21891. * Return the total number of indices
  21892. * @returns the total number of indices
  21893. */
  21894. getTotalIndices(): number;
  21895. /**
  21896. * Gets the index buffer array
  21897. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21898. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21899. * @returns the index buffer array
  21900. */
  21901. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21902. /**
  21903. * Gets the index buffer
  21904. * @return the index buffer
  21905. */
  21906. getIndexBuffer(): Nullable<DataBuffer>;
  21907. /** @hidden */
  21908. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21909. /**
  21910. * Release the associated resources for a specific mesh
  21911. * @param mesh defines the source mesh
  21912. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21913. */
  21914. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21915. /**
  21916. * Apply current geometry to a given mesh
  21917. * @param mesh defines the mesh to apply geometry to
  21918. */
  21919. applyToMesh(mesh: Mesh): void;
  21920. private _updateExtend;
  21921. private _applyToMesh;
  21922. private notifyUpdate;
  21923. /**
  21924. * Load the geometry if it was flagged as delay loaded
  21925. * @param scene defines the hosting scene
  21926. * @param onLoaded defines a callback called when the geometry is loaded
  21927. */
  21928. load(scene: Scene, onLoaded?: () => void): void;
  21929. private _queueLoad;
  21930. /**
  21931. * Invert the geometry to move from a right handed system to a left handed one.
  21932. */
  21933. toLeftHanded(): void;
  21934. /** @hidden */
  21935. _resetPointsArrayCache(): void;
  21936. /** @hidden */
  21937. _generatePointsArray(): boolean;
  21938. /**
  21939. * Gets a value indicating if the geometry is disposed
  21940. * @returns true if the geometry was disposed
  21941. */
  21942. isDisposed(): boolean;
  21943. private _disposeVertexArrayObjects;
  21944. /**
  21945. * Free all associated resources
  21946. */
  21947. dispose(): void;
  21948. /**
  21949. * Clone the current geometry into a new geometry
  21950. * @param id defines the unique ID of the new geometry
  21951. * @returns a new geometry object
  21952. */
  21953. copy(id: string): Geometry;
  21954. /**
  21955. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21956. * @return a JSON representation of the current geometry data (without the vertices data)
  21957. */
  21958. serialize(): any;
  21959. private toNumberArray;
  21960. /**
  21961. * Serialize all vertices data into a JSON oject
  21962. * @returns a JSON representation of the current geometry data
  21963. */
  21964. serializeVerticeData(): any;
  21965. /**
  21966. * Extracts a clone of a mesh geometry
  21967. * @param mesh defines the source mesh
  21968. * @param id defines the unique ID of the new geometry object
  21969. * @returns the new geometry object
  21970. */
  21971. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21972. /**
  21973. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21974. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21975. * Be aware Math.random() could cause collisions, but:
  21976. * "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"
  21977. * @returns a string containing a new GUID
  21978. */
  21979. static RandomId(): string;
  21980. /** @hidden */
  21981. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21982. private static _CleanMatricesWeights;
  21983. /**
  21984. * Create a new geometry from persisted data (Using .babylon file format)
  21985. * @param parsedVertexData defines the persisted data
  21986. * @param scene defines the hosting scene
  21987. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21988. * @returns the new geometry object
  21989. */
  21990. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21991. }
  21992. }
  21993. declare module BABYLON {
  21994. /**
  21995. * Define an interface for all classes that will get and set the data on vertices
  21996. */
  21997. export interface IGetSetVerticesData {
  21998. /**
  21999. * Gets a boolean indicating if specific vertex data is present
  22000. * @param kind defines the vertex data kind to use
  22001. * @returns true is data kind is present
  22002. */
  22003. isVerticesDataPresent(kind: string): boolean;
  22004. /**
  22005. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22006. * @param kind defines the data kind (Position, normal, etc...)
  22007. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22008. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22009. * @returns a float array containing vertex data
  22010. */
  22011. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22012. /**
  22013. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22014. * @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.
  22015. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22016. * @returns the indices array or an empty array if the mesh has no geometry
  22017. */
  22018. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22019. /**
  22020. * Set specific vertex data
  22021. * @param kind defines the data kind (Position, normal, etc...)
  22022. * @param data defines the vertex data to use
  22023. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22024. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22025. */
  22026. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22027. /**
  22028. * Update a specific associated vertex buffer
  22029. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22030. * - VertexBuffer.PositionKind
  22031. * - VertexBuffer.UVKind
  22032. * - VertexBuffer.UV2Kind
  22033. * - VertexBuffer.UV3Kind
  22034. * - VertexBuffer.UV4Kind
  22035. * - VertexBuffer.UV5Kind
  22036. * - VertexBuffer.UV6Kind
  22037. * - VertexBuffer.ColorKind
  22038. * - VertexBuffer.MatricesIndicesKind
  22039. * - VertexBuffer.MatricesIndicesExtraKind
  22040. * - VertexBuffer.MatricesWeightsKind
  22041. * - VertexBuffer.MatricesWeightsExtraKind
  22042. * @param data defines the data source
  22043. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22044. * @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)
  22045. */
  22046. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22047. /**
  22048. * Creates a new index buffer
  22049. * @param indices defines the indices to store in the index buffer
  22050. * @param totalVertices defines the total number of vertices (could be null)
  22051. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22052. */
  22053. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22054. }
  22055. /**
  22056. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22057. */
  22058. export class VertexData {
  22059. /**
  22060. * Mesh side orientation : usually the external or front surface
  22061. */
  22062. static readonly FRONTSIDE: number;
  22063. /**
  22064. * Mesh side orientation : usually the internal or back surface
  22065. */
  22066. static readonly BACKSIDE: number;
  22067. /**
  22068. * Mesh side orientation : both internal and external or front and back surfaces
  22069. */
  22070. static readonly DOUBLESIDE: number;
  22071. /**
  22072. * Mesh side orientation : by default, `FRONTSIDE`
  22073. */
  22074. static readonly DEFAULTSIDE: number;
  22075. /**
  22076. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22077. */
  22078. positions: Nullable<FloatArray>;
  22079. /**
  22080. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22081. */
  22082. normals: Nullable<FloatArray>;
  22083. /**
  22084. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22085. */
  22086. tangents: Nullable<FloatArray>;
  22087. /**
  22088. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22089. */
  22090. uvs: Nullable<FloatArray>;
  22091. /**
  22092. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22093. */
  22094. uvs2: Nullable<FloatArray>;
  22095. /**
  22096. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22097. */
  22098. uvs3: Nullable<FloatArray>;
  22099. /**
  22100. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22101. */
  22102. uvs4: Nullable<FloatArray>;
  22103. /**
  22104. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22105. */
  22106. uvs5: Nullable<FloatArray>;
  22107. /**
  22108. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22109. */
  22110. uvs6: Nullable<FloatArray>;
  22111. /**
  22112. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22113. */
  22114. colors: Nullable<FloatArray>;
  22115. /**
  22116. * 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).
  22117. */
  22118. matricesIndices: Nullable<FloatArray>;
  22119. /**
  22120. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22121. */
  22122. matricesWeights: Nullable<FloatArray>;
  22123. /**
  22124. * An array extending the number of possible indices
  22125. */
  22126. matricesIndicesExtra: Nullable<FloatArray>;
  22127. /**
  22128. * An array extending the number of possible weights when the number of indices is extended
  22129. */
  22130. matricesWeightsExtra: Nullable<FloatArray>;
  22131. /**
  22132. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22133. */
  22134. indices: Nullable<IndicesArray>;
  22135. /**
  22136. * Uses the passed data array to set the set the values for the specified kind of data
  22137. * @param data a linear array of floating numbers
  22138. * @param kind the type of data that is being set, eg positions, colors etc
  22139. */
  22140. set(data: FloatArray, kind: string): void;
  22141. /**
  22142. * Associates the vertexData to the passed Mesh.
  22143. * Sets it as updatable or not (default `false`)
  22144. * @param mesh the mesh the vertexData is applied to
  22145. * @param updatable when used and having the value true allows new data to update the vertexData
  22146. * @returns the VertexData
  22147. */
  22148. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22149. /**
  22150. * Associates the vertexData to the passed Geometry.
  22151. * Sets it as updatable or not (default `false`)
  22152. * @param geometry the geometry the vertexData is applied to
  22153. * @param updatable when used and having the value true allows new data to update the vertexData
  22154. * @returns VertexData
  22155. */
  22156. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22157. /**
  22158. * Updates the associated mesh
  22159. * @param mesh the mesh to be updated
  22160. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22161. * @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
  22162. * @returns VertexData
  22163. */
  22164. updateMesh(mesh: Mesh): VertexData;
  22165. /**
  22166. * Updates the associated geometry
  22167. * @param geometry the geometry to be updated
  22168. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22169. * @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
  22170. * @returns VertexData.
  22171. */
  22172. updateGeometry(geometry: Geometry): VertexData;
  22173. private _applyTo;
  22174. private _update;
  22175. /**
  22176. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22177. * @param matrix the transforming matrix
  22178. * @returns the VertexData
  22179. */
  22180. transform(matrix: Matrix): VertexData;
  22181. /**
  22182. * Merges the passed VertexData into the current one
  22183. * @param other the VertexData to be merged into the current one
  22184. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22185. * @returns the modified VertexData
  22186. */
  22187. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22188. private _mergeElement;
  22189. private _validate;
  22190. /**
  22191. * Serializes the VertexData
  22192. * @returns a serialized object
  22193. */
  22194. serialize(): any;
  22195. /**
  22196. * Extracts the vertexData from a mesh
  22197. * @param mesh the mesh from which to extract the VertexData
  22198. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22199. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22200. * @returns the object VertexData associated to the passed mesh
  22201. */
  22202. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22203. /**
  22204. * Extracts the vertexData from the geometry
  22205. * @param geometry the geometry from which to extract the VertexData
  22206. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22207. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22208. * @returns the object VertexData associated to the passed mesh
  22209. */
  22210. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22211. private static _ExtractFrom;
  22212. /**
  22213. * Creates the VertexData for a Ribbon
  22214. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22215. * * pathArray array of paths, each of which an array of successive Vector3
  22216. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22217. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22218. * * 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
  22219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22220. * * 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)
  22221. * * 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)
  22222. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22223. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22224. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22225. * @returns the VertexData of the ribbon
  22226. */
  22227. static CreateRibbon(options: {
  22228. pathArray: Vector3[][];
  22229. closeArray?: boolean;
  22230. closePath?: boolean;
  22231. offset?: number;
  22232. sideOrientation?: number;
  22233. frontUVs?: Vector4;
  22234. backUVs?: Vector4;
  22235. invertUV?: boolean;
  22236. uvs?: Vector2[];
  22237. colors?: Color4[];
  22238. }): VertexData;
  22239. /**
  22240. * Creates the VertexData for a box
  22241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22242. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22243. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22244. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22245. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22246. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22247. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22248. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22249. * * 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)
  22250. * * 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)
  22251. * @returns the VertexData of the box
  22252. */
  22253. static CreateBox(options: {
  22254. size?: number;
  22255. width?: number;
  22256. height?: number;
  22257. depth?: number;
  22258. faceUV?: Vector4[];
  22259. faceColors?: Color4[];
  22260. sideOrientation?: number;
  22261. frontUVs?: Vector4;
  22262. backUVs?: Vector4;
  22263. }): VertexData;
  22264. /**
  22265. * Creates the VertexData for a tiled box
  22266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22267. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22268. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22269. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22270. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22271. * @returns the VertexData of the box
  22272. */
  22273. static CreateTiledBox(options: {
  22274. pattern?: number;
  22275. width?: number;
  22276. height?: number;
  22277. depth?: number;
  22278. tileSize?: number;
  22279. tileWidth?: number;
  22280. tileHeight?: number;
  22281. alignHorizontal?: number;
  22282. alignVertical?: number;
  22283. faceUV?: Vector4[];
  22284. faceColors?: Color4[];
  22285. sideOrientation?: number;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a tiled plane
  22289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22290. * * pattern a limited pattern arrangement depending on the number
  22291. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22292. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22293. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22295. * * 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)
  22296. * * 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)
  22297. * @returns the VertexData of the tiled plane
  22298. */
  22299. static CreateTiledPlane(options: {
  22300. pattern?: number;
  22301. tileSize?: number;
  22302. tileWidth?: number;
  22303. tileHeight?: number;
  22304. size?: number;
  22305. width?: number;
  22306. height?: number;
  22307. alignHorizontal?: number;
  22308. alignVertical?: number;
  22309. sideOrientation?: number;
  22310. frontUVs?: Vector4;
  22311. backUVs?: Vector4;
  22312. }): VertexData;
  22313. /**
  22314. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22315. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22316. * * segments sets the number of horizontal strips optional, default 32
  22317. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22318. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22319. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22320. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22321. * * 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
  22322. * * 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
  22323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22324. * * 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)
  22325. * * 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)
  22326. * @returns the VertexData of the ellipsoid
  22327. */
  22328. static CreateSphere(options: {
  22329. segments?: number;
  22330. diameter?: number;
  22331. diameterX?: number;
  22332. diameterY?: number;
  22333. diameterZ?: number;
  22334. arc?: number;
  22335. slice?: number;
  22336. sideOrientation?: number;
  22337. frontUVs?: Vector4;
  22338. backUVs?: Vector4;
  22339. }): VertexData;
  22340. /**
  22341. * Creates the VertexData for a cylinder, cone or prism
  22342. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22343. * * height sets the height (y direction) of the cylinder, optional, default 2
  22344. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22345. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22346. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22347. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22348. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22349. * * 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
  22350. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22351. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22352. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22353. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22355. * * 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)
  22356. * * 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)
  22357. * @returns the VertexData of the cylinder, cone or prism
  22358. */
  22359. static CreateCylinder(options: {
  22360. height?: number;
  22361. diameterTop?: number;
  22362. diameterBottom?: number;
  22363. diameter?: number;
  22364. tessellation?: number;
  22365. subdivisions?: number;
  22366. arc?: number;
  22367. faceColors?: Color4[];
  22368. faceUV?: Vector4[];
  22369. hasRings?: boolean;
  22370. enclose?: boolean;
  22371. sideOrientation?: number;
  22372. frontUVs?: Vector4;
  22373. backUVs?: Vector4;
  22374. }): VertexData;
  22375. /**
  22376. * Creates the VertexData for a torus
  22377. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22378. * * diameter the diameter of the torus, optional default 1
  22379. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22380. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22382. * * 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)
  22383. * * 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)
  22384. * @returns the VertexData of the torus
  22385. */
  22386. static CreateTorus(options: {
  22387. diameter?: number;
  22388. thickness?: number;
  22389. tessellation?: number;
  22390. sideOrientation?: number;
  22391. frontUVs?: Vector4;
  22392. backUVs?: Vector4;
  22393. }): VertexData;
  22394. /**
  22395. * Creates the VertexData of the LineSystem
  22396. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22397. * - lines an array of lines, each line being an array of successive Vector3
  22398. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22399. * @returns the VertexData of the LineSystem
  22400. */
  22401. static CreateLineSystem(options: {
  22402. lines: Vector3[][];
  22403. colors?: Nullable<Color4[][]>;
  22404. }): VertexData;
  22405. /**
  22406. * Create the VertexData for a DashedLines
  22407. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22408. * - points an array successive Vector3
  22409. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22410. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22411. * - dashNb the intended total number of dashes, optional, default 200
  22412. * @returns the VertexData for the DashedLines
  22413. */
  22414. static CreateDashedLines(options: {
  22415. points: Vector3[];
  22416. dashSize?: number;
  22417. gapSize?: number;
  22418. dashNb?: number;
  22419. }): VertexData;
  22420. /**
  22421. * Creates the VertexData for a Ground
  22422. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22423. * - width the width (x direction) of the ground, optional, default 1
  22424. * - height the height (z direction) of the ground, optional, default 1
  22425. * - subdivisions the number of subdivisions per side, optional, default 1
  22426. * @returns the VertexData of the Ground
  22427. */
  22428. static CreateGround(options: {
  22429. width?: number;
  22430. height?: number;
  22431. subdivisions?: number;
  22432. subdivisionsX?: number;
  22433. subdivisionsY?: number;
  22434. }): VertexData;
  22435. /**
  22436. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22437. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22438. * * xmin the ground minimum X coordinate, optional, default -1
  22439. * * zmin the ground minimum Z coordinate, optional, default -1
  22440. * * xmax the ground maximum X coordinate, optional, default 1
  22441. * * zmax the ground maximum Z coordinate, optional, default 1
  22442. * * 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}
  22443. * * 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}
  22444. * @returns the VertexData of the TiledGround
  22445. */
  22446. static CreateTiledGround(options: {
  22447. xmin: number;
  22448. zmin: number;
  22449. xmax: number;
  22450. zmax: number;
  22451. subdivisions?: {
  22452. w: number;
  22453. h: number;
  22454. };
  22455. precision?: {
  22456. w: number;
  22457. h: number;
  22458. };
  22459. }): VertexData;
  22460. /**
  22461. * Creates the VertexData of the Ground designed from a heightmap
  22462. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22463. * * width the width (x direction) of the ground
  22464. * * height the height (z direction) of the ground
  22465. * * subdivisions the number of subdivisions per side
  22466. * * minHeight the minimum altitude on the ground, optional, default 0
  22467. * * maxHeight the maximum altitude on the ground, optional default 1
  22468. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22469. * * buffer the array holding the image color data
  22470. * * bufferWidth the width of image
  22471. * * bufferHeight the height of image
  22472. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22473. * @returns the VertexData of the Ground designed from a heightmap
  22474. */
  22475. static CreateGroundFromHeightMap(options: {
  22476. width: number;
  22477. height: number;
  22478. subdivisions: number;
  22479. minHeight: number;
  22480. maxHeight: number;
  22481. colorFilter: Color3;
  22482. buffer: Uint8Array;
  22483. bufferWidth: number;
  22484. bufferHeight: number;
  22485. alphaFilter: number;
  22486. }): VertexData;
  22487. /**
  22488. * Creates the VertexData for a Plane
  22489. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22490. * * size sets the width and height of the plane to the value of size, optional default 1
  22491. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22492. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22493. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22494. * * 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)
  22495. * * 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)
  22496. * @returns the VertexData of the box
  22497. */
  22498. static CreatePlane(options: {
  22499. size?: number;
  22500. width?: number;
  22501. height?: number;
  22502. sideOrientation?: number;
  22503. frontUVs?: Vector4;
  22504. backUVs?: Vector4;
  22505. }): VertexData;
  22506. /**
  22507. * Creates the VertexData of the Disc or regular Polygon
  22508. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22509. * * radius the radius of the disc, optional default 0.5
  22510. * * tessellation the number of polygon sides, optional, default 64
  22511. * * 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
  22512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22513. * * 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)
  22514. * * 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)
  22515. * @returns the VertexData of the box
  22516. */
  22517. static CreateDisc(options: {
  22518. radius?: number;
  22519. tessellation?: number;
  22520. arc?: number;
  22521. sideOrientation?: number;
  22522. frontUVs?: Vector4;
  22523. backUVs?: Vector4;
  22524. }): VertexData;
  22525. /**
  22526. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22527. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22528. * @param polygon a mesh built from polygonTriangulation.build()
  22529. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22530. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22531. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22532. * @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)
  22533. * @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)
  22534. * @returns the VertexData of the Polygon
  22535. */
  22536. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22537. /**
  22538. * Creates the VertexData of the IcoSphere
  22539. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22540. * * radius the radius of the IcoSphere, optional default 1
  22541. * * radiusX allows stretching in the x direction, optional, default radius
  22542. * * radiusY allows stretching in the y direction, optional, default radius
  22543. * * radiusZ allows stretching in the z direction, optional, default radius
  22544. * * flat when true creates a flat shaded mesh, optional, default true
  22545. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22547. * * 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)
  22548. * * 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)
  22549. * @returns the VertexData of the IcoSphere
  22550. */
  22551. static CreateIcoSphere(options: {
  22552. radius?: number;
  22553. radiusX?: number;
  22554. radiusY?: number;
  22555. radiusZ?: number;
  22556. flat?: boolean;
  22557. subdivisions?: number;
  22558. sideOrientation?: number;
  22559. frontUVs?: Vector4;
  22560. backUVs?: Vector4;
  22561. }): VertexData;
  22562. /**
  22563. * Creates the VertexData for a Polyhedron
  22564. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22565. * * type provided types are:
  22566. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22567. * * 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)
  22568. * * size the size of the IcoSphere, optional default 1
  22569. * * sizeX allows stretching in the x direction, optional, default size
  22570. * * sizeY allows stretching in the y direction, optional, default size
  22571. * * sizeZ allows stretching in the z direction, optional, default size
  22572. * * 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
  22573. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22574. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22575. * * flat when true creates a flat shaded mesh, optional, default true
  22576. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22578. * * 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)
  22579. * * 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)
  22580. * @returns the VertexData of the Polyhedron
  22581. */
  22582. static CreatePolyhedron(options: {
  22583. type?: number;
  22584. size?: number;
  22585. sizeX?: number;
  22586. sizeY?: number;
  22587. sizeZ?: number;
  22588. custom?: any;
  22589. faceUV?: Vector4[];
  22590. faceColors?: Color4[];
  22591. flat?: boolean;
  22592. sideOrientation?: number;
  22593. frontUVs?: Vector4;
  22594. backUVs?: Vector4;
  22595. }): VertexData;
  22596. /**
  22597. * Creates the VertexData for a TorusKnot
  22598. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22599. * * radius the radius of the torus knot, optional, default 2
  22600. * * tube the thickness of the tube, optional, default 0.5
  22601. * * radialSegments the number of sides on each tube segments, optional, default 32
  22602. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22603. * * p the number of windings around the z axis, optional, default 2
  22604. * * q the number of windings around the x axis, optional, default 3
  22605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22606. * * 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)
  22607. * * 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)
  22608. * @returns the VertexData of the Torus Knot
  22609. */
  22610. static CreateTorusKnot(options: {
  22611. radius?: number;
  22612. tube?: number;
  22613. radialSegments?: number;
  22614. tubularSegments?: number;
  22615. p?: number;
  22616. q?: number;
  22617. sideOrientation?: number;
  22618. frontUVs?: Vector4;
  22619. backUVs?: Vector4;
  22620. }): VertexData;
  22621. /**
  22622. * Compute normals for given positions and indices
  22623. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22624. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22625. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22626. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22627. * * facetNormals : optional array of facet normals (vector3)
  22628. * * facetPositions : optional array of facet positions (vector3)
  22629. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22630. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22631. * * bInfo : optional bounding info, required for facetPartitioning computation
  22632. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22633. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22634. * * useRightHandedSystem: optional boolean to for right handed system computation
  22635. * * depthSort : optional boolean to enable the facet depth sort computation
  22636. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22637. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22638. */
  22639. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22640. facetNormals?: any;
  22641. facetPositions?: any;
  22642. facetPartitioning?: any;
  22643. ratio?: number;
  22644. bInfo?: any;
  22645. bbSize?: Vector3;
  22646. subDiv?: any;
  22647. useRightHandedSystem?: boolean;
  22648. depthSort?: boolean;
  22649. distanceTo?: Vector3;
  22650. depthSortedFacets?: any;
  22651. }): void;
  22652. /** @hidden */
  22653. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22654. /**
  22655. * Applies VertexData created from the imported parameters to the geometry
  22656. * @param parsedVertexData the parsed data from an imported file
  22657. * @param geometry the geometry to apply the VertexData to
  22658. */
  22659. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22660. }
  22661. }
  22662. declare module BABYLON {
  22663. /**
  22664. * Defines a target to use with MorphTargetManager
  22665. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22666. */
  22667. export class MorphTarget implements IAnimatable {
  22668. /** defines the name of the target */
  22669. name: string;
  22670. /**
  22671. * Gets or sets the list of animations
  22672. */
  22673. animations: Animation[];
  22674. private _scene;
  22675. private _positions;
  22676. private _normals;
  22677. private _tangents;
  22678. private _uvs;
  22679. private _influence;
  22680. private _uniqueId;
  22681. /**
  22682. * Observable raised when the influence changes
  22683. */
  22684. onInfluenceChanged: Observable<boolean>;
  22685. /** @hidden */
  22686. _onDataLayoutChanged: Observable<void>;
  22687. /**
  22688. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22689. */
  22690. get influence(): number;
  22691. set influence(influence: number);
  22692. /**
  22693. * Gets or sets the id of the morph Target
  22694. */
  22695. id: string;
  22696. private _animationPropertiesOverride;
  22697. /**
  22698. * Gets or sets the animation properties override
  22699. */
  22700. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22701. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22702. /**
  22703. * Creates a new MorphTarget
  22704. * @param name defines the name of the target
  22705. * @param influence defines the influence to use
  22706. * @param scene defines the scene the morphtarget belongs to
  22707. */
  22708. constructor(
  22709. /** defines the name of the target */
  22710. name: string, influence?: number, scene?: Nullable<Scene>);
  22711. /**
  22712. * Gets the unique ID of this manager
  22713. */
  22714. get uniqueId(): number;
  22715. /**
  22716. * Gets a boolean defining if the target contains position data
  22717. */
  22718. get hasPositions(): boolean;
  22719. /**
  22720. * Gets a boolean defining if the target contains normal data
  22721. */
  22722. get hasNormals(): boolean;
  22723. /**
  22724. * Gets a boolean defining if the target contains tangent data
  22725. */
  22726. get hasTangents(): boolean;
  22727. /**
  22728. * Gets a boolean defining if the target contains texture coordinates data
  22729. */
  22730. get hasUVs(): boolean;
  22731. /**
  22732. * Affects position data to this target
  22733. * @param data defines the position data to use
  22734. */
  22735. setPositions(data: Nullable<FloatArray>): void;
  22736. /**
  22737. * Gets the position data stored in this target
  22738. * @returns a FloatArray containing the position data (or null if not present)
  22739. */
  22740. getPositions(): Nullable<FloatArray>;
  22741. /**
  22742. * Affects normal data to this target
  22743. * @param data defines the normal data to use
  22744. */
  22745. setNormals(data: Nullable<FloatArray>): void;
  22746. /**
  22747. * Gets the normal data stored in this target
  22748. * @returns a FloatArray containing the normal data (or null if not present)
  22749. */
  22750. getNormals(): Nullable<FloatArray>;
  22751. /**
  22752. * Affects tangent data to this target
  22753. * @param data defines the tangent data to use
  22754. */
  22755. setTangents(data: Nullable<FloatArray>): void;
  22756. /**
  22757. * Gets the tangent data stored in this target
  22758. * @returns a FloatArray containing the tangent data (or null if not present)
  22759. */
  22760. getTangents(): Nullable<FloatArray>;
  22761. /**
  22762. * Affects texture coordinates data to this target
  22763. * @param data defines the texture coordinates data to use
  22764. */
  22765. setUVs(data: Nullable<FloatArray>): void;
  22766. /**
  22767. * Gets the texture coordinates data stored in this target
  22768. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22769. */
  22770. getUVs(): Nullable<FloatArray>;
  22771. /**
  22772. * Clone the current target
  22773. * @returns a new MorphTarget
  22774. */
  22775. clone(): MorphTarget;
  22776. /**
  22777. * Serializes the current target into a Serialization object
  22778. * @returns the serialized object
  22779. */
  22780. serialize(): any;
  22781. /**
  22782. * Returns the string "MorphTarget"
  22783. * @returns "MorphTarget"
  22784. */
  22785. getClassName(): string;
  22786. /**
  22787. * Creates a new target from serialized data
  22788. * @param serializationObject defines the serialized data to use
  22789. * @returns a new MorphTarget
  22790. */
  22791. static Parse(serializationObject: any): MorphTarget;
  22792. /**
  22793. * Creates a MorphTarget from mesh data
  22794. * @param mesh defines the source mesh
  22795. * @param name defines the name to use for the new target
  22796. * @param influence defines the influence to attach to the target
  22797. * @returns a new MorphTarget
  22798. */
  22799. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22800. }
  22801. }
  22802. declare module BABYLON {
  22803. /**
  22804. * This class is used to deform meshes using morphing between different targets
  22805. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22806. */
  22807. export class MorphTargetManager {
  22808. private _targets;
  22809. private _targetInfluenceChangedObservers;
  22810. private _targetDataLayoutChangedObservers;
  22811. private _activeTargets;
  22812. private _scene;
  22813. private _influences;
  22814. private _supportsNormals;
  22815. private _supportsTangents;
  22816. private _supportsUVs;
  22817. private _vertexCount;
  22818. private _uniqueId;
  22819. private _tempInfluences;
  22820. /**
  22821. * Gets or sets a boolean indicating if normals must be morphed
  22822. */
  22823. enableNormalMorphing: boolean;
  22824. /**
  22825. * Gets or sets a boolean indicating if tangents must be morphed
  22826. */
  22827. enableTangentMorphing: boolean;
  22828. /**
  22829. * Gets or sets a boolean indicating if UV must be morphed
  22830. */
  22831. enableUVMorphing: boolean;
  22832. /**
  22833. * Creates a new MorphTargetManager
  22834. * @param scene defines the current scene
  22835. */
  22836. constructor(scene?: Nullable<Scene>);
  22837. /**
  22838. * Gets the unique ID of this manager
  22839. */
  22840. get uniqueId(): number;
  22841. /**
  22842. * Gets the number of vertices handled by this manager
  22843. */
  22844. get vertexCount(): number;
  22845. /**
  22846. * Gets a boolean indicating if this manager supports morphing of normals
  22847. */
  22848. get supportsNormals(): boolean;
  22849. /**
  22850. * Gets a boolean indicating if this manager supports morphing of tangents
  22851. */
  22852. get supportsTangents(): boolean;
  22853. /**
  22854. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22855. */
  22856. get supportsUVs(): boolean;
  22857. /**
  22858. * Gets the number of targets stored in this manager
  22859. */
  22860. get numTargets(): number;
  22861. /**
  22862. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22863. */
  22864. get numInfluencers(): number;
  22865. /**
  22866. * Gets the list of influences (one per target)
  22867. */
  22868. get influences(): Float32Array;
  22869. /**
  22870. * Gets the active target at specified index. An active target is a target with an influence > 0
  22871. * @param index defines the index to check
  22872. * @returns the requested target
  22873. */
  22874. getActiveTarget(index: number): MorphTarget;
  22875. /**
  22876. * Gets the target at specified index
  22877. * @param index defines the index to check
  22878. * @returns the requested target
  22879. */
  22880. getTarget(index: number): MorphTarget;
  22881. /**
  22882. * Add a new target to this manager
  22883. * @param target defines the target to add
  22884. */
  22885. addTarget(target: MorphTarget): void;
  22886. /**
  22887. * Removes a target from the manager
  22888. * @param target defines the target to remove
  22889. */
  22890. removeTarget(target: MorphTarget): void;
  22891. /**
  22892. * Clone the current manager
  22893. * @returns a new MorphTargetManager
  22894. */
  22895. clone(): MorphTargetManager;
  22896. /**
  22897. * Serializes the current manager into a Serialization object
  22898. * @returns the serialized object
  22899. */
  22900. serialize(): any;
  22901. private _syncActiveTargets;
  22902. /**
  22903. * Syncrhonize the targets with all the meshes using this morph target manager
  22904. */
  22905. synchronize(): void;
  22906. /**
  22907. * Creates a new MorphTargetManager from serialized data
  22908. * @param serializationObject defines the serialized data
  22909. * @param scene defines the hosting scene
  22910. * @returns the new MorphTargetManager
  22911. */
  22912. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22913. }
  22914. }
  22915. declare module BABYLON {
  22916. /**
  22917. * Class used to represent a specific level of detail of a mesh
  22918. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22919. */
  22920. export class MeshLODLevel {
  22921. /** Defines the distance where this level should start being displayed */
  22922. distance: number;
  22923. /** Defines the mesh to use to render this level */
  22924. mesh: Nullable<Mesh>;
  22925. /**
  22926. * Creates a new LOD level
  22927. * @param distance defines the distance where this level should star being displayed
  22928. * @param mesh defines the mesh to use to render this level
  22929. */
  22930. constructor(
  22931. /** Defines the distance where this level should start being displayed */
  22932. distance: number,
  22933. /** Defines the mesh to use to render this level */
  22934. mesh: Nullable<Mesh>);
  22935. }
  22936. }
  22937. declare module BABYLON {
  22938. /**
  22939. * Mesh representing the gorund
  22940. */
  22941. export class GroundMesh extends Mesh {
  22942. /** If octree should be generated */
  22943. generateOctree: boolean;
  22944. private _heightQuads;
  22945. /** @hidden */
  22946. _subdivisionsX: number;
  22947. /** @hidden */
  22948. _subdivisionsY: number;
  22949. /** @hidden */
  22950. _width: number;
  22951. /** @hidden */
  22952. _height: number;
  22953. /** @hidden */
  22954. _minX: number;
  22955. /** @hidden */
  22956. _maxX: number;
  22957. /** @hidden */
  22958. _minZ: number;
  22959. /** @hidden */
  22960. _maxZ: number;
  22961. constructor(name: string, scene: Scene);
  22962. /**
  22963. * "GroundMesh"
  22964. * @returns "GroundMesh"
  22965. */
  22966. getClassName(): string;
  22967. /**
  22968. * The minimum of x and y subdivisions
  22969. */
  22970. get subdivisions(): number;
  22971. /**
  22972. * X subdivisions
  22973. */
  22974. get subdivisionsX(): number;
  22975. /**
  22976. * Y subdivisions
  22977. */
  22978. get subdivisionsY(): number;
  22979. /**
  22980. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22981. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22982. * @param chunksCount the number of subdivisions for x and y
  22983. * @param octreeBlocksSize (Default: 32)
  22984. */
  22985. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22986. /**
  22987. * Returns a height (y) value in the Worl system :
  22988. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22989. * @param x x coordinate
  22990. * @param z z coordinate
  22991. * @returns the ground y position if (x, z) are outside the ground surface.
  22992. */
  22993. getHeightAtCoordinates(x: number, z: number): number;
  22994. /**
  22995. * Returns a normalized vector (Vector3) orthogonal to the ground
  22996. * at the ground coordinates (x, z) expressed in the World system.
  22997. * @param x x coordinate
  22998. * @param z z coordinate
  22999. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23000. */
  23001. getNormalAtCoordinates(x: number, z: number): Vector3;
  23002. /**
  23003. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23004. * at the ground coordinates (x, z) expressed in the World system.
  23005. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23006. * @param x x coordinate
  23007. * @param z z coordinate
  23008. * @param ref vector to store the result
  23009. * @returns the GroundMesh.
  23010. */
  23011. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23012. /**
  23013. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23014. * if the ground has been updated.
  23015. * This can be used in the render loop.
  23016. * @returns the GroundMesh.
  23017. */
  23018. updateCoordinateHeights(): GroundMesh;
  23019. private _getFacetAt;
  23020. private _initHeightQuads;
  23021. private _computeHeightQuads;
  23022. /**
  23023. * Serializes this ground mesh
  23024. * @param serializationObject object to write serialization to
  23025. */
  23026. serialize(serializationObject: any): void;
  23027. /**
  23028. * Parses a serialized ground mesh
  23029. * @param parsedMesh the serialized mesh
  23030. * @param scene the scene to create the ground mesh in
  23031. * @returns the created ground mesh
  23032. */
  23033. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23034. }
  23035. }
  23036. declare module BABYLON {
  23037. /**
  23038. * Interface for Physics-Joint data
  23039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23040. */
  23041. export interface PhysicsJointData {
  23042. /**
  23043. * The main pivot of the joint
  23044. */
  23045. mainPivot?: Vector3;
  23046. /**
  23047. * The connected pivot of the joint
  23048. */
  23049. connectedPivot?: Vector3;
  23050. /**
  23051. * The main axis of the joint
  23052. */
  23053. mainAxis?: Vector3;
  23054. /**
  23055. * The connected axis of the joint
  23056. */
  23057. connectedAxis?: Vector3;
  23058. /**
  23059. * The collision of the joint
  23060. */
  23061. collision?: boolean;
  23062. /**
  23063. * Native Oimo/Cannon/Energy data
  23064. */
  23065. nativeParams?: any;
  23066. }
  23067. /**
  23068. * This is a holder class for the physics joint created by the physics plugin
  23069. * It holds a set of functions to control the underlying joint
  23070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23071. */
  23072. export class PhysicsJoint {
  23073. /**
  23074. * The type of the physics joint
  23075. */
  23076. type: number;
  23077. /**
  23078. * The data for the physics joint
  23079. */
  23080. jointData: PhysicsJointData;
  23081. private _physicsJoint;
  23082. protected _physicsPlugin: IPhysicsEnginePlugin;
  23083. /**
  23084. * Initializes the physics joint
  23085. * @param type The type of the physics joint
  23086. * @param jointData The data for the physics joint
  23087. */
  23088. constructor(
  23089. /**
  23090. * The type of the physics joint
  23091. */
  23092. type: number,
  23093. /**
  23094. * The data for the physics joint
  23095. */
  23096. jointData: PhysicsJointData);
  23097. /**
  23098. * Gets the physics joint
  23099. */
  23100. get physicsJoint(): any;
  23101. /**
  23102. * Sets the physics joint
  23103. */
  23104. set physicsJoint(newJoint: any);
  23105. /**
  23106. * Sets the physics plugin
  23107. */
  23108. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23109. /**
  23110. * Execute a function that is physics-plugin specific.
  23111. * @param {Function} func the function that will be executed.
  23112. * It accepts two parameters: the physics world and the physics joint
  23113. */
  23114. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23115. /**
  23116. * Distance-Joint type
  23117. */
  23118. static DistanceJoint: number;
  23119. /**
  23120. * Hinge-Joint type
  23121. */
  23122. static HingeJoint: number;
  23123. /**
  23124. * Ball-and-Socket joint type
  23125. */
  23126. static BallAndSocketJoint: number;
  23127. /**
  23128. * Wheel-Joint type
  23129. */
  23130. static WheelJoint: number;
  23131. /**
  23132. * Slider-Joint type
  23133. */
  23134. static SliderJoint: number;
  23135. /**
  23136. * Prismatic-Joint type
  23137. */
  23138. static PrismaticJoint: number;
  23139. /**
  23140. * Universal-Joint type
  23141. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23142. */
  23143. static UniversalJoint: number;
  23144. /**
  23145. * Hinge-Joint 2 type
  23146. */
  23147. static Hinge2Joint: number;
  23148. /**
  23149. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23150. */
  23151. static PointToPointJoint: number;
  23152. /**
  23153. * Spring-Joint type
  23154. */
  23155. static SpringJoint: number;
  23156. /**
  23157. * Lock-Joint type
  23158. */
  23159. static LockJoint: number;
  23160. }
  23161. /**
  23162. * A class representing a physics distance joint
  23163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23164. */
  23165. export class DistanceJoint extends PhysicsJoint {
  23166. /**
  23167. *
  23168. * @param jointData The data for the Distance-Joint
  23169. */
  23170. constructor(jointData: DistanceJointData);
  23171. /**
  23172. * Update the predefined distance.
  23173. * @param maxDistance The maximum preferred distance
  23174. * @param minDistance The minimum preferred distance
  23175. */
  23176. updateDistance(maxDistance: number, minDistance?: number): void;
  23177. }
  23178. /**
  23179. * Represents a Motor-Enabled Joint
  23180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23181. */
  23182. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23183. /**
  23184. * Initializes the Motor-Enabled Joint
  23185. * @param type The type of the joint
  23186. * @param jointData The physica joint data for the joint
  23187. */
  23188. constructor(type: number, jointData: PhysicsJointData);
  23189. /**
  23190. * Set the motor values.
  23191. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23192. * @param force the force to apply
  23193. * @param maxForce max force for this motor.
  23194. */
  23195. setMotor(force?: number, maxForce?: number): void;
  23196. /**
  23197. * Set the motor's limits.
  23198. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23199. * @param upperLimit The upper limit of the motor
  23200. * @param lowerLimit The lower limit of the motor
  23201. */
  23202. setLimit(upperLimit: number, lowerLimit?: number): void;
  23203. }
  23204. /**
  23205. * This class represents a single physics Hinge-Joint
  23206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23207. */
  23208. export class HingeJoint extends MotorEnabledJoint {
  23209. /**
  23210. * Initializes the Hinge-Joint
  23211. * @param jointData The joint data for the Hinge-Joint
  23212. */
  23213. constructor(jointData: PhysicsJointData);
  23214. /**
  23215. * Set the motor values.
  23216. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23217. * @param {number} force the force to apply
  23218. * @param {number} maxForce max force for this motor.
  23219. */
  23220. setMotor(force?: number, maxForce?: number): void;
  23221. /**
  23222. * Set the motor's limits.
  23223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23224. * @param upperLimit The upper limit of the motor
  23225. * @param lowerLimit The lower limit of the motor
  23226. */
  23227. setLimit(upperLimit: number, lowerLimit?: number): void;
  23228. }
  23229. /**
  23230. * This class represents a dual hinge physics joint (same as wheel joint)
  23231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23232. */
  23233. export class Hinge2Joint extends MotorEnabledJoint {
  23234. /**
  23235. * Initializes the Hinge2-Joint
  23236. * @param jointData The joint data for the Hinge2-Joint
  23237. */
  23238. constructor(jointData: PhysicsJointData);
  23239. /**
  23240. * Set the motor values.
  23241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23242. * @param {number} targetSpeed the speed the motor is to reach
  23243. * @param {number} maxForce max force for this motor.
  23244. * @param {motorIndex} the motor's index, 0 or 1.
  23245. */
  23246. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23247. /**
  23248. * Set the motor limits.
  23249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23250. * @param {number} upperLimit the upper limit
  23251. * @param {number} lowerLimit lower limit
  23252. * @param {motorIndex} the motor's index, 0 or 1.
  23253. */
  23254. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23255. }
  23256. /**
  23257. * Interface for a motor enabled joint
  23258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23259. */
  23260. export interface IMotorEnabledJoint {
  23261. /**
  23262. * Physics joint
  23263. */
  23264. physicsJoint: any;
  23265. /**
  23266. * Sets the motor of the motor-enabled joint
  23267. * @param force The force of the motor
  23268. * @param maxForce The maximum force of the motor
  23269. * @param motorIndex The index of the motor
  23270. */
  23271. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23272. /**
  23273. * Sets the limit of the motor
  23274. * @param upperLimit The upper limit of the motor
  23275. * @param lowerLimit The lower limit of the motor
  23276. * @param motorIndex The index of the motor
  23277. */
  23278. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23279. }
  23280. /**
  23281. * Joint data for a Distance-Joint
  23282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23283. */
  23284. export interface DistanceJointData extends PhysicsJointData {
  23285. /**
  23286. * Max distance the 2 joint objects can be apart
  23287. */
  23288. maxDistance: number;
  23289. }
  23290. /**
  23291. * Joint data from a spring joint
  23292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23293. */
  23294. export interface SpringJointData extends PhysicsJointData {
  23295. /**
  23296. * Length of the spring
  23297. */
  23298. length: number;
  23299. /**
  23300. * Stiffness of the spring
  23301. */
  23302. stiffness: number;
  23303. /**
  23304. * Damping of the spring
  23305. */
  23306. damping: number;
  23307. /** this callback will be called when applying the force to the impostors. */
  23308. forceApplicationCallback: () => void;
  23309. }
  23310. }
  23311. declare module BABYLON {
  23312. /**
  23313. * Holds the data for the raycast result
  23314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23315. */
  23316. export class PhysicsRaycastResult {
  23317. private _hasHit;
  23318. private _hitDistance;
  23319. private _hitNormalWorld;
  23320. private _hitPointWorld;
  23321. private _rayFromWorld;
  23322. private _rayToWorld;
  23323. /**
  23324. * Gets if there was a hit
  23325. */
  23326. get hasHit(): boolean;
  23327. /**
  23328. * Gets the distance from the hit
  23329. */
  23330. get hitDistance(): number;
  23331. /**
  23332. * Gets the hit normal/direction in the world
  23333. */
  23334. get hitNormalWorld(): Vector3;
  23335. /**
  23336. * Gets the hit point in the world
  23337. */
  23338. get hitPointWorld(): Vector3;
  23339. /**
  23340. * Gets the ray "start point" of the ray in the world
  23341. */
  23342. get rayFromWorld(): Vector3;
  23343. /**
  23344. * Gets the ray "end point" of the ray in the world
  23345. */
  23346. get rayToWorld(): Vector3;
  23347. /**
  23348. * Sets the hit data (normal & point in world space)
  23349. * @param hitNormalWorld defines the normal in world space
  23350. * @param hitPointWorld defines the point in world space
  23351. */
  23352. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23353. /**
  23354. * Sets the distance from the start point to the hit point
  23355. * @param distance
  23356. */
  23357. setHitDistance(distance: number): void;
  23358. /**
  23359. * Calculates the distance manually
  23360. */
  23361. calculateHitDistance(): void;
  23362. /**
  23363. * Resets all the values to default
  23364. * @param from The from point on world space
  23365. * @param to The to point on world space
  23366. */
  23367. reset(from?: Vector3, to?: Vector3): void;
  23368. }
  23369. /**
  23370. * Interface for the size containing width and height
  23371. */
  23372. interface IXYZ {
  23373. /**
  23374. * X
  23375. */
  23376. x: number;
  23377. /**
  23378. * Y
  23379. */
  23380. y: number;
  23381. /**
  23382. * Z
  23383. */
  23384. z: number;
  23385. }
  23386. }
  23387. declare module BABYLON {
  23388. /**
  23389. * Interface used to describe a physics joint
  23390. */
  23391. export interface PhysicsImpostorJoint {
  23392. /** Defines the main impostor to which the joint is linked */
  23393. mainImpostor: PhysicsImpostor;
  23394. /** Defines the impostor that is connected to the main impostor using this joint */
  23395. connectedImpostor: PhysicsImpostor;
  23396. /** Defines the joint itself */
  23397. joint: PhysicsJoint;
  23398. }
  23399. /** @hidden */
  23400. export interface IPhysicsEnginePlugin {
  23401. world: any;
  23402. name: string;
  23403. setGravity(gravity: Vector3): void;
  23404. setTimeStep(timeStep: number): void;
  23405. getTimeStep(): number;
  23406. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23407. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23408. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23409. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23410. removePhysicsBody(impostor: PhysicsImpostor): void;
  23411. generateJoint(joint: PhysicsImpostorJoint): void;
  23412. removeJoint(joint: PhysicsImpostorJoint): void;
  23413. isSupported(): boolean;
  23414. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23420. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23421. getBodyMass(impostor: PhysicsImpostor): number;
  23422. getBodyFriction(impostor: PhysicsImpostor): number;
  23423. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23424. getBodyRestitution(impostor: PhysicsImpostor): number;
  23425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23426. getBodyPressure?(impostor: PhysicsImpostor): number;
  23427. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23428. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23429. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23430. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23431. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23432. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23433. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23434. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23435. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23436. sleepBody(impostor: PhysicsImpostor): void;
  23437. wakeUpBody(impostor: PhysicsImpostor): void;
  23438. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23439. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23440. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23441. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23442. getRadius(impostor: PhysicsImpostor): number;
  23443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23444. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23445. dispose(): void;
  23446. }
  23447. /**
  23448. * Interface used to define a physics engine
  23449. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23450. */
  23451. export interface IPhysicsEngine {
  23452. /**
  23453. * Gets the gravity vector used by the simulation
  23454. */
  23455. gravity: Vector3;
  23456. /**
  23457. * Sets the gravity vector used by the simulation
  23458. * @param gravity defines the gravity vector to use
  23459. */
  23460. setGravity(gravity: Vector3): void;
  23461. /**
  23462. * Set the time step of the physics engine.
  23463. * Default is 1/60.
  23464. * To slow it down, enter 1/600 for example.
  23465. * To speed it up, 1/30
  23466. * @param newTimeStep the new timestep to apply to this world.
  23467. */
  23468. setTimeStep(newTimeStep: number): void;
  23469. /**
  23470. * Get the time step of the physics engine.
  23471. * @returns the current time step
  23472. */
  23473. getTimeStep(): number;
  23474. /**
  23475. * Set the sub time step of the physics engine.
  23476. * Default is 0 meaning there is no sub steps
  23477. * To increase physics resolution precision, set a small value (like 1 ms)
  23478. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23479. */
  23480. setSubTimeStep(subTimeStep: number): void;
  23481. /**
  23482. * Get the sub time step of the physics engine.
  23483. * @returns the current sub time step
  23484. */
  23485. getSubTimeStep(): number;
  23486. /**
  23487. * Release all resources
  23488. */
  23489. dispose(): void;
  23490. /**
  23491. * Gets the name of the current physics plugin
  23492. * @returns the name of the plugin
  23493. */
  23494. getPhysicsPluginName(): string;
  23495. /**
  23496. * Adding a new impostor for the impostor tracking.
  23497. * This will be done by the impostor itself.
  23498. * @param impostor the impostor to add
  23499. */
  23500. addImpostor(impostor: PhysicsImpostor): void;
  23501. /**
  23502. * Remove an impostor from the engine.
  23503. * This impostor and its mesh will not longer be updated by the physics engine.
  23504. * @param impostor the impostor to remove
  23505. */
  23506. removeImpostor(impostor: PhysicsImpostor): void;
  23507. /**
  23508. * Add a joint to the physics engine
  23509. * @param mainImpostor defines the main impostor to which the joint is added.
  23510. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23511. * @param joint defines the joint that will connect both impostors.
  23512. */
  23513. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23514. /**
  23515. * Removes a joint from the simulation
  23516. * @param mainImpostor defines the impostor used with the joint
  23517. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23518. * @param joint defines the joint to remove
  23519. */
  23520. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23521. /**
  23522. * Gets the current plugin used to run the simulation
  23523. * @returns current plugin
  23524. */
  23525. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23526. /**
  23527. * Gets the list of physic impostors
  23528. * @returns an array of PhysicsImpostor
  23529. */
  23530. getImpostors(): Array<PhysicsImpostor>;
  23531. /**
  23532. * Gets the impostor for a physics enabled object
  23533. * @param object defines the object impersonated by the impostor
  23534. * @returns the PhysicsImpostor or null if not found
  23535. */
  23536. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23537. /**
  23538. * Gets the impostor for a physics body object
  23539. * @param body defines physics body used by the impostor
  23540. * @returns the PhysicsImpostor or null if not found
  23541. */
  23542. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23543. /**
  23544. * Does a raycast in the physics world
  23545. * @param from when should the ray start?
  23546. * @param to when should the ray end?
  23547. * @returns PhysicsRaycastResult
  23548. */
  23549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23550. /**
  23551. * Called by the scene. No need to call it.
  23552. * @param delta defines the timespam between frames
  23553. */
  23554. _step(delta: number): void;
  23555. }
  23556. }
  23557. declare module BABYLON {
  23558. /**
  23559. * The interface for the physics imposter parameters
  23560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23561. */
  23562. export interface PhysicsImpostorParameters {
  23563. /**
  23564. * The mass of the physics imposter
  23565. */
  23566. mass: number;
  23567. /**
  23568. * The friction of the physics imposter
  23569. */
  23570. friction?: number;
  23571. /**
  23572. * The coefficient of restitution of the physics imposter
  23573. */
  23574. restitution?: number;
  23575. /**
  23576. * The native options of the physics imposter
  23577. */
  23578. nativeOptions?: any;
  23579. /**
  23580. * Specifies if the parent should be ignored
  23581. */
  23582. ignoreParent?: boolean;
  23583. /**
  23584. * Specifies if bi-directional transformations should be disabled
  23585. */
  23586. disableBidirectionalTransformation?: boolean;
  23587. /**
  23588. * The pressure inside the physics imposter, soft object only
  23589. */
  23590. pressure?: number;
  23591. /**
  23592. * The stiffness the physics imposter, soft object only
  23593. */
  23594. stiffness?: number;
  23595. /**
  23596. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23597. */
  23598. velocityIterations?: number;
  23599. /**
  23600. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23601. */
  23602. positionIterations?: number;
  23603. /**
  23604. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23605. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23606. * Add to fix multiple points
  23607. */
  23608. fixedPoints?: number;
  23609. /**
  23610. * The collision margin around a soft object
  23611. */
  23612. margin?: number;
  23613. /**
  23614. * The collision margin around a soft object
  23615. */
  23616. damping?: number;
  23617. /**
  23618. * The path for a rope based on an extrusion
  23619. */
  23620. path?: any;
  23621. /**
  23622. * The shape of an extrusion used for a rope based on an extrusion
  23623. */
  23624. shape?: any;
  23625. }
  23626. /**
  23627. * Interface for a physics-enabled object
  23628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23629. */
  23630. export interface IPhysicsEnabledObject {
  23631. /**
  23632. * The position of the physics-enabled object
  23633. */
  23634. position: Vector3;
  23635. /**
  23636. * The rotation of the physics-enabled object
  23637. */
  23638. rotationQuaternion: Nullable<Quaternion>;
  23639. /**
  23640. * The scale of the physics-enabled object
  23641. */
  23642. scaling: Vector3;
  23643. /**
  23644. * The rotation of the physics-enabled object
  23645. */
  23646. rotation?: Vector3;
  23647. /**
  23648. * The parent of the physics-enabled object
  23649. */
  23650. parent?: any;
  23651. /**
  23652. * The bounding info of the physics-enabled object
  23653. * @returns The bounding info of the physics-enabled object
  23654. */
  23655. getBoundingInfo(): BoundingInfo;
  23656. /**
  23657. * Computes the world matrix
  23658. * @param force Specifies if the world matrix should be computed by force
  23659. * @returns A world matrix
  23660. */
  23661. computeWorldMatrix(force: boolean): Matrix;
  23662. /**
  23663. * Gets the world matrix
  23664. * @returns A world matrix
  23665. */
  23666. getWorldMatrix?(): Matrix;
  23667. /**
  23668. * Gets the child meshes
  23669. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23670. * @returns An array of abstract meshes
  23671. */
  23672. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23673. /**
  23674. * Gets the vertex data
  23675. * @param kind The type of vertex data
  23676. * @returns A nullable array of numbers, or a float32 array
  23677. */
  23678. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23679. /**
  23680. * Gets the indices from the mesh
  23681. * @returns A nullable array of index arrays
  23682. */
  23683. getIndices?(): Nullable<IndicesArray>;
  23684. /**
  23685. * Gets the scene from the mesh
  23686. * @returns the indices array or null
  23687. */
  23688. getScene?(): Scene;
  23689. /**
  23690. * Gets the absolute position from the mesh
  23691. * @returns the absolute position
  23692. */
  23693. getAbsolutePosition(): Vector3;
  23694. /**
  23695. * Gets the absolute pivot point from the mesh
  23696. * @returns the absolute pivot point
  23697. */
  23698. getAbsolutePivotPoint(): Vector3;
  23699. /**
  23700. * Rotates the mesh
  23701. * @param axis The axis of rotation
  23702. * @param amount The amount of rotation
  23703. * @param space The space of the rotation
  23704. * @returns The rotation transform node
  23705. */
  23706. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23707. /**
  23708. * Translates the mesh
  23709. * @param axis The axis of translation
  23710. * @param distance The distance of translation
  23711. * @param space The space of the translation
  23712. * @returns The transform node
  23713. */
  23714. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23715. /**
  23716. * Sets the absolute position of the mesh
  23717. * @param absolutePosition The absolute position of the mesh
  23718. * @returns The transform node
  23719. */
  23720. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23721. /**
  23722. * Gets the class name of the mesh
  23723. * @returns The class name
  23724. */
  23725. getClassName(): string;
  23726. }
  23727. /**
  23728. * Represents a physics imposter
  23729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23730. */
  23731. export class PhysicsImpostor {
  23732. /**
  23733. * The physics-enabled object used as the physics imposter
  23734. */
  23735. object: IPhysicsEnabledObject;
  23736. /**
  23737. * The type of the physics imposter
  23738. */
  23739. type: number;
  23740. private _options;
  23741. private _scene?;
  23742. /**
  23743. * The default object size of the imposter
  23744. */
  23745. static DEFAULT_OBJECT_SIZE: Vector3;
  23746. /**
  23747. * The identity quaternion of the imposter
  23748. */
  23749. static IDENTITY_QUATERNION: Quaternion;
  23750. /** @hidden */
  23751. _pluginData: any;
  23752. private _physicsEngine;
  23753. private _physicsBody;
  23754. private _bodyUpdateRequired;
  23755. private _onBeforePhysicsStepCallbacks;
  23756. private _onAfterPhysicsStepCallbacks;
  23757. /** @hidden */
  23758. _onPhysicsCollideCallbacks: Array<{
  23759. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23760. otherImpostors: Array<PhysicsImpostor>;
  23761. }>;
  23762. private _deltaPosition;
  23763. private _deltaRotation;
  23764. private _deltaRotationConjugated;
  23765. /** @hidden */
  23766. _isFromLine: boolean;
  23767. private _parent;
  23768. private _isDisposed;
  23769. private static _tmpVecs;
  23770. private static _tmpQuat;
  23771. /**
  23772. * Specifies if the physics imposter is disposed
  23773. */
  23774. get isDisposed(): boolean;
  23775. /**
  23776. * Gets the mass of the physics imposter
  23777. */
  23778. get mass(): number;
  23779. set mass(value: number);
  23780. /**
  23781. * Gets the coefficient of friction
  23782. */
  23783. get friction(): number;
  23784. /**
  23785. * Sets the coefficient of friction
  23786. */
  23787. set friction(value: number);
  23788. /**
  23789. * Gets the coefficient of restitution
  23790. */
  23791. get restitution(): number;
  23792. /**
  23793. * Sets the coefficient of restitution
  23794. */
  23795. set restitution(value: number);
  23796. /**
  23797. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23798. */
  23799. get pressure(): number;
  23800. /**
  23801. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23802. */
  23803. set pressure(value: number);
  23804. /**
  23805. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23806. */
  23807. get stiffness(): number;
  23808. /**
  23809. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23810. */
  23811. set stiffness(value: number);
  23812. /**
  23813. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23814. */
  23815. get velocityIterations(): number;
  23816. /**
  23817. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23818. */
  23819. set velocityIterations(value: number);
  23820. /**
  23821. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23822. */
  23823. get positionIterations(): number;
  23824. /**
  23825. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23826. */
  23827. set positionIterations(value: number);
  23828. /**
  23829. * The unique id of the physics imposter
  23830. * set by the physics engine when adding this impostor to the array
  23831. */
  23832. uniqueId: number;
  23833. /**
  23834. * @hidden
  23835. */
  23836. soft: boolean;
  23837. /**
  23838. * @hidden
  23839. */
  23840. segments: number;
  23841. private _joints;
  23842. /**
  23843. * Initializes the physics imposter
  23844. * @param object The physics-enabled object used as the physics imposter
  23845. * @param type The type of the physics imposter
  23846. * @param _options The options for the physics imposter
  23847. * @param _scene The Babylon scene
  23848. */
  23849. constructor(
  23850. /**
  23851. * The physics-enabled object used as the physics imposter
  23852. */
  23853. object: IPhysicsEnabledObject,
  23854. /**
  23855. * The type of the physics imposter
  23856. */
  23857. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23858. /**
  23859. * This function will completly initialize this impostor.
  23860. * It will create a new body - but only if this mesh has no parent.
  23861. * If it has, this impostor will not be used other than to define the impostor
  23862. * of the child mesh.
  23863. * @hidden
  23864. */
  23865. _init(): void;
  23866. private _getPhysicsParent;
  23867. /**
  23868. * Should a new body be generated.
  23869. * @returns boolean specifying if body initialization is required
  23870. */
  23871. isBodyInitRequired(): boolean;
  23872. /**
  23873. * Sets the updated scaling
  23874. * @param updated Specifies if the scaling is updated
  23875. */
  23876. setScalingUpdated(): void;
  23877. /**
  23878. * Force a regeneration of this or the parent's impostor's body.
  23879. * Use under cautious - This will remove all joints already implemented.
  23880. */
  23881. forceUpdate(): void;
  23882. /**
  23883. * Gets the body that holds this impostor. Either its own, or its parent.
  23884. */
  23885. get physicsBody(): any;
  23886. /**
  23887. * Get the parent of the physics imposter
  23888. * @returns Physics imposter or null
  23889. */
  23890. get parent(): Nullable<PhysicsImpostor>;
  23891. /**
  23892. * Sets the parent of the physics imposter
  23893. */
  23894. set parent(value: Nullable<PhysicsImpostor>);
  23895. /**
  23896. * Set the physics body. Used mainly by the physics engine/plugin
  23897. */
  23898. set physicsBody(physicsBody: any);
  23899. /**
  23900. * Resets the update flags
  23901. */
  23902. resetUpdateFlags(): void;
  23903. /**
  23904. * Gets the object extend size
  23905. * @returns the object extend size
  23906. */
  23907. getObjectExtendSize(): Vector3;
  23908. /**
  23909. * Gets the object center
  23910. * @returns The object center
  23911. */
  23912. getObjectCenter(): Vector3;
  23913. /**
  23914. * Get a specific parameter from the options parameters
  23915. * @param paramName The object parameter name
  23916. * @returns The object parameter
  23917. */
  23918. getParam(paramName: string): any;
  23919. /**
  23920. * Sets a specific parameter in the options given to the physics plugin
  23921. * @param paramName The parameter name
  23922. * @param value The value of the parameter
  23923. */
  23924. setParam(paramName: string, value: number): void;
  23925. /**
  23926. * Specifically change the body's mass option. Won't recreate the physics body object
  23927. * @param mass The mass of the physics imposter
  23928. */
  23929. setMass(mass: number): void;
  23930. /**
  23931. * Gets the linear velocity
  23932. * @returns linear velocity or null
  23933. */
  23934. getLinearVelocity(): Nullable<Vector3>;
  23935. /**
  23936. * Sets the linear velocity
  23937. * @param velocity linear velocity or null
  23938. */
  23939. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23940. /**
  23941. * Gets the angular velocity
  23942. * @returns angular velocity or null
  23943. */
  23944. getAngularVelocity(): Nullable<Vector3>;
  23945. /**
  23946. * Sets the angular velocity
  23947. * @param velocity The velocity or null
  23948. */
  23949. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23950. /**
  23951. * Execute a function with the physics plugin native code
  23952. * Provide a function the will have two variables - the world object and the physics body object
  23953. * @param func The function to execute with the physics plugin native code
  23954. */
  23955. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23956. /**
  23957. * Register a function that will be executed before the physics world is stepping forward
  23958. * @param func The function to execute before the physics world is stepped forward
  23959. */
  23960. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23961. /**
  23962. * Unregister a function that will be executed before the physics world is stepping forward
  23963. * @param func The function to execute before the physics world is stepped forward
  23964. */
  23965. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23966. /**
  23967. * Register a function that will be executed after the physics step
  23968. * @param func The function to execute after physics step
  23969. */
  23970. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23971. /**
  23972. * Unregisters a function that will be executed after the physics step
  23973. * @param func The function to execute after physics step
  23974. */
  23975. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23976. /**
  23977. * register a function that will be executed when this impostor collides against a different body
  23978. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23979. * @param func Callback that is executed on collision
  23980. */
  23981. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23982. /**
  23983. * Unregisters the physics imposter on contact
  23984. * @param collideAgainst The physics object to collide against
  23985. * @param func Callback to execute on collision
  23986. */
  23987. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23988. private _tmpQuat;
  23989. private _tmpQuat2;
  23990. /**
  23991. * Get the parent rotation
  23992. * @returns The parent rotation
  23993. */
  23994. getParentsRotation(): Quaternion;
  23995. /**
  23996. * this function is executed by the physics engine.
  23997. */
  23998. beforeStep: () => void;
  23999. /**
  24000. * this function is executed by the physics engine
  24001. */
  24002. afterStep: () => void;
  24003. /**
  24004. * Legacy collision detection event support
  24005. */
  24006. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24007. /**
  24008. * event and body object due to cannon's event-based architecture.
  24009. */
  24010. onCollide: (e: {
  24011. body: any;
  24012. }) => void;
  24013. /**
  24014. * Apply a force
  24015. * @param force The force to apply
  24016. * @param contactPoint The contact point for the force
  24017. * @returns The physics imposter
  24018. */
  24019. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24020. /**
  24021. * Apply an impulse
  24022. * @param force The impulse force
  24023. * @param contactPoint The contact point for the impulse force
  24024. * @returns The physics imposter
  24025. */
  24026. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24027. /**
  24028. * A help function to create a joint
  24029. * @param otherImpostor A physics imposter used to create a joint
  24030. * @param jointType The type of joint
  24031. * @param jointData The data for the joint
  24032. * @returns The physics imposter
  24033. */
  24034. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24035. /**
  24036. * Add a joint to this impostor with a different impostor
  24037. * @param otherImpostor A physics imposter used to add a joint
  24038. * @param joint The joint to add
  24039. * @returns The physics imposter
  24040. */
  24041. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24042. /**
  24043. * Add an anchor to a cloth impostor
  24044. * @param otherImpostor rigid impostor to anchor to
  24045. * @param width ratio across width from 0 to 1
  24046. * @param height ratio up height from 0 to 1
  24047. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24048. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24049. * @returns impostor the soft imposter
  24050. */
  24051. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24052. /**
  24053. * Add a hook to a rope impostor
  24054. * @param otherImpostor rigid impostor to anchor to
  24055. * @param length ratio across rope from 0 to 1
  24056. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24057. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24058. * @returns impostor the rope imposter
  24059. */
  24060. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24061. /**
  24062. * Will keep this body still, in a sleep mode.
  24063. * @returns the physics imposter
  24064. */
  24065. sleep(): PhysicsImpostor;
  24066. /**
  24067. * Wake the body up.
  24068. * @returns The physics imposter
  24069. */
  24070. wakeUp(): PhysicsImpostor;
  24071. /**
  24072. * Clones the physics imposter
  24073. * @param newObject The physics imposter clones to this physics-enabled object
  24074. * @returns A nullable physics imposter
  24075. */
  24076. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24077. /**
  24078. * Disposes the physics imposter
  24079. */
  24080. dispose(): void;
  24081. /**
  24082. * Sets the delta position
  24083. * @param position The delta position amount
  24084. */
  24085. setDeltaPosition(position: Vector3): void;
  24086. /**
  24087. * Sets the delta rotation
  24088. * @param rotation The delta rotation amount
  24089. */
  24090. setDeltaRotation(rotation: Quaternion): void;
  24091. /**
  24092. * Gets the box size of the physics imposter and stores the result in the input parameter
  24093. * @param result Stores the box size
  24094. * @returns The physics imposter
  24095. */
  24096. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24097. /**
  24098. * Gets the radius of the physics imposter
  24099. * @returns Radius of the physics imposter
  24100. */
  24101. getRadius(): number;
  24102. /**
  24103. * Sync a bone with this impostor
  24104. * @param bone The bone to sync to the impostor.
  24105. * @param boneMesh The mesh that the bone is influencing.
  24106. * @param jointPivot The pivot of the joint / bone in local space.
  24107. * @param distToJoint Optional distance from the impostor to the joint.
  24108. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24109. */
  24110. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24111. /**
  24112. * Sync impostor to a bone
  24113. * @param bone The bone that the impostor will be synced to.
  24114. * @param boneMesh The mesh that the bone is influencing.
  24115. * @param jointPivot The pivot of the joint / bone in local space.
  24116. * @param distToJoint Optional distance from the impostor to the joint.
  24117. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24118. * @param boneAxis Optional vector3 axis the bone is aligned with
  24119. */
  24120. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24121. /**
  24122. * No-Imposter type
  24123. */
  24124. static NoImpostor: number;
  24125. /**
  24126. * Sphere-Imposter type
  24127. */
  24128. static SphereImpostor: number;
  24129. /**
  24130. * Box-Imposter type
  24131. */
  24132. static BoxImpostor: number;
  24133. /**
  24134. * Plane-Imposter type
  24135. */
  24136. static PlaneImpostor: number;
  24137. /**
  24138. * Mesh-imposter type
  24139. */
  24140. static MeshImpostor: number;
  24141. /**
  24142. * Capsule-Impostor type (Ammo.js plugin only)
  24143. */
  24144. static CapsuleImpostor: number;
  24145. /**
  24146. * Cylinder-Imposter type
  24147. */
  24148. static CylinderImpostor: number;
  24149. /**
  24150. * Particle-Imposter type
  24151. */
  24152. static ParticleImpostor: number;
  24153. /**
  24154. * Heightmap-Imposter type
  24155. */
  24156. static HeightmapImpostor: number;
  24157. /**
  24158. * ConvexHull-Impostor type (Ammo.js plugin only)
  24159. */
  24160. static ConvexHullImpostor: number;
  24161. /**
  24162. * Custom-Imposter type (Ammo.js plugin only)
  24163. */
  24164. static CustomImpostor: number;
  24165. /**
  24166. * Rope-Imposter type
  24167. */
  24168. static RopeImpostor: number;
  24169. /**
  24170. * Cloth-Imposter type
  24171. */
  24172. static ClothImpostor: number;
  24173. /**
  24174. * Softbody-Imposter type
  24175. */
  24176. static SoftbodyImpostor: number;
  24177. }
  24178. }
  24179. declare module BABYLON {
  24180. /**
  24181. * @hidden
  24182. **/
  24183. export class _CreationDataStorage {
  24184. closePath?: boolean;
  24185. closeArray?: boolean;
  24186. idx: number[];
  24187. dashSize: number;
  24188. gapSize: number;
  24189. path3D: Path3D;
  24190. pathArray: Vector3[][];
  24191. arc: number;
  24192. radius: number;
  24193. cap: number;
  24194. tessellation: number;
  24195. }
  24196. /**
  24197. * @hidden
  24198. **/
  24199. class _InstanceDataStorage {
  24200. visibleInstances: any;
  24201. batchCache: _InstancesBatch;
  24202. instancesBufferSize: number;
  24203. instancesBuffer: Nullable<Buffer>;
  24204. instancesData: Float32Array;
  24205. overridenInstanceCount: number;
  24206. isFrozen: boolean;
  24207. previousBatch: Nullable<_InstancesBatch>;
  24208. hardwareInstancedRendering: boolean;
  24209. sideOrientation: number;
  24210. manualUpdate: boolean;
  24211. }
  24212. /**
  24213. * @hidden
  24214. **/
  24215. export class _InstancesBatch {
  24216. mustReturn: boolean;
  24217. visibleInstances: Nullable<InstancedMesh[]>[];
  24218. renderSelf: boolean[];
  24219. hardwareInstancedRendering: boolean[];
  24220. }
  24221. /**
  24222. * Class used to represent renderable models
  24223. */
  24224. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24225. /**
  24226. * Mesh side orientation : usually the external or front surface
  24227. */
  24228. static readonly FRONTSIDE: number;
  24229. /**
  24230. * Mesh side orientation : usually the internal or back surface
  24231. */
  24232. static readonly BACKSIDE: number;
  24233. /**
  24234. * Mesh side orientation : both internal and external or front and back surfaces
  24235. */
  24236. static readonly DOUBLESIDE: number;
  24237. /**
  24238. * Mesh side orientation : by default, `FRONTSIDE`
  24239. */
  24240. static readonly DEFAULTSIDE: number;
  24241. /**
  24242. * Mesh cap setting : no cap
  24243. */
  24244. static readonly NO_CAP: number;
  24245. /**
  24246. * Mesh cap setting : one cap at the beginning of the mesh
  24247. */
  24248. static readonly CAP_START: number;
  24249. /**
  24250. * Mesh cap setting : one cap at the end of the mesh
  24251. */
  24252. static readonly CAP_END: number;
  24253. /**
  24254. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24255. */
  24256. static readonly CAP_ALL: number;
  24257. /**
  24258. * Mesh pattern setting : no flip or rotate
  24259. */
  24260. static readonly NO_FLIP: number;
  24261. /**
  24262. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24263. */
  24264. static readonly FLIP_TILE: number;
  24265. /**
  24266. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24267. */
  24268. static readonly ROTATE_TILE: number;
  24269. /**
  24270. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24271. */
  24272. static readonly FLIP_ROW: number;
  24273. /**
  24274. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24275. */
  24276. static readonly ROTATE_ROW: number;
  24277. /**
  24278. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24279. */
  24280. static readonly FLIP_N_ROTATE_TILE: number;
  24281. /**
  24282. * Mesh pattern setting : rotate pattern and rotate
  24283. */
  24284. static readonly FLIP_N_ROTATE_ROW: number;
  24285. /**
  24286. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24287. */
  24288. static readonly CENTER: number;
  24289. /**
  24290. * Mesh tile positioning : part tiles on left
  24291. */
  24292. static readonly LEFT: number;
  24293. /**
  24294. * Mesh tile positioning : part tiles on right
  24295. */
  24296. static readonly RIGHT: number;
  24297. /**
  24298. * Mesh tile positioning : part tiles on top
  24299. */
  24300. static readonly TOP: number;
  24301. /**
  24302. * Mesh tile positioning : part tiles on bottom
  24303. */
  24304. static readonly BOTTOM: number;
  24305. /**
  24306. * Gets the default side orientation.
  24307. * @param orientation the orientation to value to attempt to get
  24308. * @returns the default orientation
  24309. * @hidden
  24310. */
  24311. static _GetDefaultSideOrientation(orientation?: number): number;
  24312. private _internalMeshDataInfo;
  24313. /**
  24314. * An event triggered before rendering the mesh
  24315. */
  24316. get onBeforeRenderObservable(): Observable<Mesh>;
  24317. /**
  24318. * An event triggered before binding the mesh
  24319. */
  24320. get onBeforeBindObservable(): Observable<Mesh>;
  24321. /**
  24322. * An event triggered after rendering the mesh
  24323. */
  24324. get onAfterRenderObservable(): Observable<Mesh>;
  24325. /**
  24326. * An event triggered before drawing the mesh
  24327. */
  24328. get onBeforeDrawObservable(): Observable<Mesh>;
  24329. private _onBeforeDrawObserver;
  24330. /**
  24331. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24332. */
  24333. set onBeforeDraw(callback: () => void);
  24334. get hasInstances(): boolean;
  24335. /**
  24336. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24337. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24338. */
  24339. delayLoadState: number;
  24340. /**
  24341. * Gets the list of instances created from this mesh
  24342. * it is not supposed to be modified manually.
  24343. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24344. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24345. */
  24346. instances: InstancedMesh[];
  24347. /**
  24348. * Gets the file containing delay loading data for this mesh
  24349. */
  24350. delayLoadingFile: string;
  24351. /** @hidden */
  24352. _binaryInfo: any;
  24353. /**
  24354. * User defined function used to change how LOD level selection is done
  24355. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24356. */
  24357. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24358. /**
  24359. * Gets or sets the morph target manager
  24360. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24361. */
  24362. get morphTargetManager(): Nullable<MorphTargetManager>;
  24363. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24364. /** @hidden */
  24365. _creationDataStorage: Nullable<_CreationDataStorage>;
  24366. /** @hidden */
  24367. _geometry: Nullable<Geometry>;
  24368. /** @hidden */
  24369. _delayInfo: Array<string>;
  24370. /** @hidden */
  24371. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24372. /** @hidden */
  24373. _instanceDataStorage: _InstanceDataStorage;
  24374. private _effectiveMaterial;
  24375. /** @hidden */
  24376. _shouldGenerateFlatShading: boolean;
  24377. /** @hidden */
  24378. _originalBuilderSideOrientation: number;
  24379. /**
  24380. * Use this property to change the original side orientation defined at construction time
  24381. */
  24382. overrideMaterialSideOrientation: Nullable<number>;
  24383. /**
  24384. * Gets the source mesh (the one used to clone this one from)
  24385. */
  24386. get source(): Nullable<Mesh>;
  24387. /**
  24388. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24389. */
  24390. get isUnIndexed(): boolean;
  24391. set isUnIndexed(value: boolean);
  24392. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24393. get worldMatrixInstancedBuffer(): Float32Array;
  24394. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24395. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24396. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24397. /**
  24398. * @constructor
  24399. * @param name The value used by scene.getMeshByName() to do a lookup.
  24400. * @param scene The scene to add this mesh to.
  24401. * @param parent The parent of this mesh, if it has one
  24402. * @param source An optional Mesh from which geometry is shared, cloned.
  24403. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24404. * When false, achieved by calling a clone(), also passing False.
  24405. * This will make creation of children, recursive.
  24406. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24407. */
  24408. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24409. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24410. doNotInstantiate: boolean;
  24411. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24412. /**
  24413. * Gets the class name
  24414. * @returns the string "Mesh".
  24415. */
  24416. getClassName(): string;
  24417. /** @hidden */
  24418. get _isMesh(): boolean;
  24419. /**
  24420. * Returns a description of this mesh
  24421. * @param fullDetails define if full details about this mesh must be used
  24422. * @returns a descriptive string representing this mesh
  24423. */
  24424. toString(fullDetails?: boolean): string;
  24425. /** @hidden */
  24426. _unBindEffect(): void;
  24427. /**
  24428. * Gets a boolean indicating if this mesh has LOD
  24429. */
  24430. get hasLODLevels(): boolean;
  24431. /**
  24432. * Gets the list of MeshLODLevel associated with the current mesh
  24433. * @returns an array of MeshLODLevel
  24434. */
  24435. getLODLevels(): MeshLODLevel[];
  24436. private _sortLODLevels;
  24437. /**
  24438. * Add a mesh as LOD level triggered at the given distance.
  24439. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24440. * @param distance The distance from the center of the object to show this level
  24441. * @param mesh The mesh to be added as LOD level (can be null)
  24442. * @return This mesh (for chaining)
  24443. */
  24444. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24445. /**
  24446. * Returns the LOD level mesh at the passed distance or null if not found.
  24447. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24448. * @param distance The distance from the center of the object to show this level
  24449. * @returns a Mesh or `null`
  24450. */
  24451. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24452. /**
  24453. * Remove a mesh from the LOD array
  24454. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24455. * @param mesh defines the mesh to be removed
  24456. * @return This mesh (for chaining)
  24457. */
  24458. removeLODLevel(mesh: Mesh): Mesh;
  24459. /**
  24460. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24461. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24462. * @param camera defines the camera to use to compute distance
  24463. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24464. * @return This mesh (for chaining)
  24465. */
  24466. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24467. /**
  24468. * Gets the mesh internal Geometry object
  24469. */
  24470. get geometry(): Nullable<Geometry>;
  24471. /**
  24472. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24473. * @returns the total number of vertices
  24474. */
  24475. getTotalVertices(): number;
  24476. /**
  24477. * Returns the content of an associated vertex buffer
  24478. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24479. * - VertexBuffer.PositionKind
  24480. * - VertexBuffer.UVKind
  24481. * - VertexBuffer.UV2Kind
  24482. * - VertexBuffer.UV3Kind
  24483. * - VertexBuffer.UV4Kind
  24484. * - VertexBuffer.UV5Kind
  24485. * - VertexBuffer.UV6Kind
  24486. * - VertexBuffer.ColorKind
  24487. * - VertexBuffer.MatricesIndicesKind
  24488. * - VertexBuffer.MatricesIndicesExtraKind
  24489. * - VertexBuffer.MatricesWeightsKind
  24490. * - VertexBuffer.MatricesWeightsExtraKind
  24491. * @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
  24492. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24493. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24494. */
  24495. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24496. /**
  24497. * Returns the mesh VertexBuffer object from the requested `kind`
  24498. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24499. * - VertexBuffer.PositionKind
  24500. * - VertexBuffer.NormalKind
  24501. * - VertexBuffer.UVKind
  24502. * - VertexBuffer.UV2Kind
  24503. * - VertexBuffer.UV3Kind
  24504. * - VertexBuffer.UV4Kind
  24505. * - VertexBuffer.UV5Kind
  24506. * - VertexBuffer.UV6Kind
  24507. * - VertexBuffer.ColorKind
  24508. * - VertexBuffer.MatricesIndicesKind
  24509. * - VertexBuffer.MatricesIndicesExtraKind
  24510. * - VertexBuffer.MatricesWeightsKind
  24511. * - VertexBuffer.MatricesWeightsExtraKind
  24512. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24513. */
  24514. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24515. /**
  24516. * Tests if a specific vertex buffer is associated with this mesh
  24517. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24518. * - VertexBuffer.PositionKind
  24519. * - VertexBuffer.NormalKind
  24520. * - VertexBuffer.UVKind
  24521. * - VertexBuffer.UV2Kind
  24522. * - VertexBuffer.UV3Kind
  24523. * - VertexBuffer.UV4Kind
  24524. * - VertexBuffer.UV5Kind
  24525. * - VertexBuffer.UV6Kind
  24526. * - VertexBuffer.ColorKind
  24527. * - VertexBuffer.MatricesIndicesKind
  24528. * - VertexBuffer.MatricesIndicesExtraKind
  24529. * - VertexBuffer.MatricesWeightsKind
  24530. * - VertexBuffer.MatricesWeightsExtraKind
  24531. * @returns a boolean
  24532. */
  24533. isVerticesDataPresent(kind: string): boolean;
  24534. /**
  24535. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24536. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24537. * - VertexBuffer.PositionKind
  24538. * - VertexBuffer.UVKind
  24539. * - VertexBuffer.UV2Kind
  24540. * - VertexBuffer.UV3Kind
  24541. * - VertexBuffer.UV4Kind
  24542. * - VertexBuffer.UV5Kind
  24543. * - VertexBuffer.UV6Kind
  24544. * - VertexBuffer.ColorKind
  24545. * - VertexBuffer.MatricesIndicesKind
  24546. * - VertexBuffer.MatricesIndicesExtraKind
  24547. * - VertexBuffer.MatricesWeightsKind
  24548. * - VertexBuffer.MatricesWeightsExtraKind
  24549. * @returns a boolean
  24550. */
  24551. isVertexBufferUpdatable(kind: string): boolean;
  24552. /**
  24553. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24554. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24555. * - VertexBuffer.PositionKind
  24556. * - VertexBuffer.NormalKind
  24557. * - VertexBuffer.UVKind
  24558. * - VertexBuffer.UV2Kind
  24559. * - VertexBuffer.UV3Kind
  24560. * - VertexBuffer.UV4Kind
  24561. * - VertexBuffer.UV5Kind
  24562. * - VertexBuffer.UV6Kind
  24563. * - VertexBuffer.ColorKind
  24564. * - VertexBuffer.MatricesIndicesKind
  24565. * - VertexBuffer.MatricesIndicesExtraKind
  24566. * - VertexBuffer.MatricesWeightsKind
  24567. * - VertexBuffer.MatricesWeightsExtraKind
  24568. * @returns an array of strings
  24569. */
  24570. getVerticesDataKinds(): string[];
  24571. /**
  24572. * Returns a positive integer : the total number of indices in this mesh geometry.
  24573. * @returns the numner of indices or zero if the mesh has no geometry.
  24574. */
  24575. getTotalIndices(): number;
  24576. /**
  24577. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24578. * @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.
  24579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24580. * @returns the indices array or an empty array if the mesh has no geometry
  24581. */
  24582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24583. get isBlocked(): boolean;
  24584. /**
  24585. * Determine if the current mesh is ready to be rendered
  24586. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24587. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24588. * @returns true if all associated assets are ready (material, textures, shaders)
  24589. */
  24590. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24591. /**
  24592. * 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.
  24593. */
  24594. get areNormalsFrozen(): boolean;
  24595. /**
  24596. * 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.
  24597. * @returns the current mesh
  24598. */
  24599. freezeNormals(): Mesh;
  24600. /**
  24601. * 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
  24602. * @returns the current mesh
  24603. */
  24604. unfreezeNormals(): Mesh;
  24605. /**
  24606. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24607. */
  24608. set overridenInstanceCount(count: number);
  24609. /** @hidden */
  24610. _preActivate(): Mesh;
  24611. /** @hidden */
  24612. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24613. /** @hidden */
  24614. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24615. /**
  24616. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24617. * This means the mesh underlying bounding box and sphere are recomputed.
  24618. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24619. * @returns the current mesh
  24620. */
  24621. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24622. /** @hidden */
  24623. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24624. /**
  24625. * This function will subdivide the mesh into multiple submeshes
  24626. * @param count defines the expected number of submeshes
  24627. */
  24628. subdivide(count: number): void;
  24629. /**
  24630. * Copy a FloatArray into a specific associated vertex buffer
  24631. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24632. * - VertexBuffer.PositionKind
  24633. * - VertexBuffer.UVKind
  24634. * - VertexBuffer.UV2Kind
  24635. * - VertexBuffer.UV3Kind
  24636. * - VertexBuffer.UV4Kind
  24637. * - VertexBuffer.UV5Kind
  24638. * - VertexBuffer.UV6Kind
  24639. * - VertexBuffer.ColorKind
  24640. * - VertexBuffer.MatricesIndicesKind
  24641. * - VertexBuffer.MatricesIndicesExtraKind
  24642. * - VertexBuffer.MatricesWeightsKind
  24643. * - VertexBuffer.MatricesWeightsExtraKind
  24644. * @param data defines the data source
  24645. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24646. * @param stride defines the data stride size (can be null)
  24647. * @returns the current mesh
  24648. */
  24649. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24650. /**
  24651. * Delete a vertex buffer associated with this mesh
  24652. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24653. * - VertexBuffer.PositionKind
  24654. * - VertexBuffer.UVKind
  24655. * - VertexBuffer.UV2Kind
  24656. * - VertexBuffer.UV3Kind
  24657. * - VertexBuffer.UV4Kind
  24658. * - VertexBuffer.UV5Kind
  24659. * - VertexBuffer.UV6Kind
  24660. * - VertexBuffer.ColorKind
  24661. * - VertexBuffer.MatricesIndicesKind
  24662. * - VertexBuffer.MatricesIndicesExtraKind
  24663. * - VertexBuffer.MatricesWeightsKind
  24664. * - VertexBuffer.MatricesWeightsExtraKind
  24665. */
  24666. removeVerticesData(kind: string): void;
  24667. /**
  24668. * Flags an associated vertex buffer as updatable
  24669. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24670. * - VertexBuffer.PositionKind
  24671. * - VertexBuffer.UVKind
  24672. * - VertexBuffer.UV2Kind
  24673. * - VertexBuffer.UV3Kind
  24674. * - VertexBuffer.UV4Kind
  24675. * - VertexBuffer.UV5Kind
  24676. * - VertexBuffer.UV6Kind
  24677. * - VertexBuffer.ColorKind
  24678. * - VertexBuffer.MatricesIndicesKind
  24679. * - VertexBuffer.MatricesIndicesExtraKind
  24680. * - VertexBuffer.MatricesWeightsKind
  24681. * - VertexBuffer.MatricesWeightsExtraKind
  24682. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24683. */
  24684. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24685. /**
  24686. * Sets the mesh global Vertex Buffer
  24687. * @param buffer defines the buffer to use
  24688. * @returns the current mesh
  24689. */
  24690. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24691. /**
  24692. * Update a specific associated vertex buffer
  24693. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24694. * - VertexBuffer.PositionKind
  24695. * - VertexBuffer.UVKind
  24696. * - VertexBuffer.UV2Kind
  24697. * - VertexBuffer.UV3Kind
  24698. * - VertexBuffer.UV4Kind
  24699. * - VertexBuffer.UV5Kind
  24700. * - VertexBuffer.UV6Kind
  24701. * - VertexBuffer.ColorKind
  24702. * - VertexBuffer.MatricesIndicesKind
  24703. * - VertexBuffer.MatricesIndicesExtraKind
  24704. * - VertexBuffer.MatricesWeightsKind
  24705. * - VertexBuffer.MatricesWeightsExtraKind
  24706. * @param data defines the data source
  24707. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24708. * @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)
  24709. * @returns the current mesh
  24710. */
  24711. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24712. /**
  24713. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24714. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24715. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24716. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24717. * @returns the current mesh
  24718. */
  24719. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24720. /**
  24721. * Creates a un-shared specific occurence of the geometry for the mesh.
  24722. * @returns the current mesh
  24723. */
  24724. makeGeometryUnique(): Mesh;
  24725. /**
  24726. * Set the index buffer of this mesh
  24727. * @param indices defines the source data
  24728. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24729. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24730. * @returns the current mesh
  24731. */
  24732. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24733. /**
  24734. * Update the current index buffer
  24735. * @param indices defines the source data
  24736. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24737. * @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)
  24738. * @returns the current mesh
  24739. */
  24740. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24741. /**
  24742. * Invert the geometry to move from a right handed system to a left handed one.
  24743. * @returns the current mesh
  24744. */
  24745. toLeftHanded(): Mesh;
  24746. /** @hidden */
  24747. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24748. /** @hidden */
  24749. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24750. /**
  24751. * Registers for this mesh a javascript function called just before the rendering process
  24752. * @param func defines the function to call before rendering this mesh
  24753. * @returns the current mesh
  24754. */
  24755. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24756. /**
  24757. * Disposes a previously registered javascript function called before the rendering
  24758. * @param func defines the function to remove
  24759. * @returns the current mesh
  24760. */
  24761. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24762. /**
  24763. * Registers for this mesh a javascript function called just after the rendering is complete
  24764. * @param func defines the function to call after rendering this mesh
  24765. * @returns the current mesh
  24766. */
  24767. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24768. /**
  24769. * Disposes a previously registered javascript function called after the rendering.
  24770. * @param func defines the function to remove
  24771. * @returns the current mesh
  24772. */
  24773. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24774. /** @hidden */
  24775. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24776. /** @hidden */
  24777. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24778. /** @hidden */
  24779. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24780. /** @hidden */
  24781. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24782. /** @hidden */
  24783. _rebuild(): void;
  24784. /** @hidden */
  24785. _freeze(): void;
  24786. /** @hidden */
  24787. _unFreeze(): void;
  24788. /**
  24789. * 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
  24790. * @param subMesh defines the subMesh to render
  24791. * @param enableAlphaMode defines if alpha mode can be changed
  24792. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24793. * @returns the current mesh
  24794. */
  24795. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24796. private _onBeforeDraw;
  24797. /**
  24798. * Renormalize the mesh and patch it up if there are no weights
  24799. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24800. * However in the case of zero weights then we set just a single influence to 1.
  24801. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24802. */
  24803. cleanMatrixWeights(): void;
  24804. private normalizeSkinFourWeights;
  24805. private normalizeSkinWeightsAndExtra;
  24806. /**
  24807. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24808. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24809. * the user know there was an issue with importing the mesh
  24810. * @returns a validation object with skinned, valid and report string
  24811. */
  24812. validateSkinning(): {
  24813. skinned: boolean;
  24814. valid: boolean;
  24815. report: string;
  24816. };
  24817. /** @hidden */
  24818. _checkDelayState(): Mesh;
  24819. private _queueLoad;
  24820. /**
  24821. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24822. * A mesh is in the frustum if its bounding box intersects the frustum
  24823. * @param frustumPlanes defines the frustum to test
  24824. * @returns true if the mesh is in the frustum planes
  24825. */
  24826. isInFrustum(frustumPlanes: Plane[]): boolean;
  24827. /**
  24828. * Sets the mesh material by the material or multiMaterial `id` property
  24829. * @param id is a string identifying the material or the multiMaterial
  24830. * @returns the current mesh
  24831. */
  24832. setMaterialByID(id: string): Mesh;
  24833. /**
  24834. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24835. * @returns an array of IAnimatable
  24836. */
  24837. getAnimatables(): IAnimatable[];
  24838. /**
  24839. * Modifies the mesh geometry according to the passed transformation matrix.
  24840. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24841. * The mesh normals are modified using the same transformation.
  24842. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24843. * @param transform defines the transform matrix to use
  24844. * @see http://doc.babylonjs.com/resources/baking_transformations
  24845. * @returns the current mesh
  24846. */
  24847. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24848. /**
  24849. * Modifies the mesh geometry according to its own current World Matrix.
  24850. * The mesh World Matrix is then reset.
  24851. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24852. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24853. * @see http://doc.babylonjs.com/resources/baking_transformations
  24854. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24855. * @returns the current mesh
  24856. */
  24857. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24858. /** @hidden */
  24859. get _positions(): Nullable<Vector3[]>;
  24860. /** @hidden */
  24861. _resetPointsArrayCache(): Mesh;
  24862. /** @hidden */
  24863. _generatePointsArray(): boolean;
  24864. /**
  24865. * Returns a new Mesh object generated from the current mesh properties.
  24866. * This method must not get confused with createInstance()
  24867. * @param name is a string, the name given to the new mesh
  24868. * @param newParent can be any Node object (default `null`)
  24869. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24870. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24871. * @returns a new mesh
  24872. */
  24873. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24874. /**
  24875. * Releases resources associated with this mesh.
  24876. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24877. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24878. */
  24879. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24880. /** @hidden */
  24881. _disposeInstanceSpecificData(): void;
  24882. /**
  24883. * Modifies the mesh geometry according to a displacement map.
  24884. * 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.
  24885. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24886. * @param url is a string, the URL from the image file is to be downloaded.
  24887. * @param minHeight is the lower limit of the displacement.
  24888. * @param maxHeight is the upper limit of the displacement.
  24889. * @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.
  24890. * @param uvOffset is an optional vector2 used to offset UV.
  24891. * @param uvScale is an optional vector2 used to scale UV.
  24892. * @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.
  24893. * @returns the Mesh.
  24894. */
  24895. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24896. /**
  24897. * Modifies the mesh geometry according to a displacementMap buffer.
  24898. * 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.
  24899. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24900. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24901. * @param heightMapWidth is the width of the buffer image.
  24902. * @param heightMapHeight is the height of the buffer image.
  24903. * @param minHeight is the lower limit of the displacement.
  24904. * @param maxHeight is the upper limit of the displacement.
  24905. * @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.
  24906. * @param uvOffset is an optional vector2 used to offset UV.
  24907. * @param uvScale is an optional vector2 used to scale UV.
  24908. * @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.
  24909. * @returns the Mesh.
  24910. */
  24911. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24912. /**
  24913. * Modify the mesh to get a flat shading rendering.
  24914. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24915. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24916. * @returns current mesh
  24917. */
  24918. convertToFlatShadedMesh(): Mesh;
  24919. /**
  24920. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24921. * In other words, more vertices, no more indices and a single bigger VBO.
  24922. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24923. * @returns current mesh
  24924. */
  24925. convertToUnIndexedMesh(): Mesh;
  24926. /**
  24927. * Inverses facet orientations.
  24928. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24929. * @param flipNormals will also inverts the normals
  24930. * @returns current mesh
  24931. */
  24932. flipFaces(flipNormals?: boolean): Mesh;
  24933. /**
  24934. * Increase the number of facets and hence vertices in a mesh
  24935. * Vertex normals are interpolated from existing vertex normals
  24936. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24937. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24938. */
  24939. increaseVertices(numberPerEdge: number): void;
  24940. /**
  24941. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24942. * This will undo any application of covertToFlatShadedMesh
  24943. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24944. */
  24945. forceSharedVertices(): void;
  24946. /** @hidden */
  24947. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24948. /** @hidden */
  24949. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24950. /**
  24951. * Creates a new InstancedMesh object from the mesh model.
  24952. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24953. * @param name defines the name of the new instance
  24954. * @returns a new InstancedMesh
  24955. */
  24956. createInstance(name: string): InstancedMesh;
  24957. /**
  24958. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24959. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24960. * @returns the current mesh
  24961. */
  24962. synchronizeInstances(): Mesh;
  24963. /**
  24964. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24965. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24966. * This should be used together with the simplification to avoid disappearing triangles.
  24967. * @param successCallback an optional success callback to be called after the optimization finished.
  24968. * @returns the current mesh
  24969. */
  24970. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24971. /**
  24972. * Serialize current mesh
  24973. * @param serializationObject defines the object which will receive the serialization data
  24974. */
  24975. serialize(serializationObject: any): void;
  24976. /** @hidden */
  24977. _syncGeometryWithMorphTargetManager(): void;
  24978. /** @hidden */
  24979. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24980. /**
  24981. * Returns a new Mesh object parsed from the source provided.
  24982. * @param parsedMesh is the source
  24983. * @param scene defines the hosting scene
  24984. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24985. * @returns a new Mesh
  24986. */
  24987. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24988. /**
  24989. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24990. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24991. * @param name defines the name of the mesh to create
  24992. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24993. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24994. * @param closePath creates a seam between the first and the last points of each path of the path array
  24995. * @param offset is taken in account only if the `pathArray` is containing a single path
  24996. * @param scene defines the hosting scene
  24997. * @param updatable defines if the mesh must be flagged as updatable
  24998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24999. * @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)
  25000. * @returns a new Mesh
  25001. */
  25002. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25003. /**
  25004. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25005. * @param name defines the name of the mesh to create
  25006. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25007. * @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
  25008. * @param scene defines the hosting scene
  25009. * @param updatable defines if the mesh must be flagged as updatable
  25010. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25011. * @returns a new Mesh
  25012. */
  25013. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25014. /**
  25015. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25016. * @param name defines the name of the mesh to create
  25017. * @param size sets the size (float) of each box side (default 1)
  25018. * @param scene defines the hosting scene
  25019. * @param updatable defines if the mesh must be flagged as updatable
  25020. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25021. * @returns a new Mesh
  25022. */
  25023. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25024. /**
  25025. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25026. * @param name defines the name of the mesh to create
  25027. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25028. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25029. * @param scene defines the hosting scene
  25030. * @param updatable defines if the mesh must be flagged as updatable
  25031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25032. * @returns a new Mesh
  25033. */
  25034. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25035. /**
  25036. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25037. * @param name defines the name of the mesh to create
  25038. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25039. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25040. * @param scene defines the hosting scene
  25041. * @returns a new Mesh
  25042. */
  25043. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25044. /**
  25045. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  25048. * @param diameterTop set the top cap diameter (floats, default 1)
  25049. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25050. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25051. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25052. * @param scene defines the hosting scene
  25053. * @param updatable defines if the mesh must be flagged as updatable
  25054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25055. * @returns a new Mesh
  25056. */
  25057. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25058. /**
  25059. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25060. * @param name defines the name of the mesh to create
  25061. * @param diameter sets the diameter size (float) of the torus (default 1)
  25062. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25063. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25064. * @param scene defines the hosting scene
  25065. * @param updatable defines if the mesh must be flagged as updatable
  25066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25067. * @returns a new Mesh
  25068. */
  25069. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25070. /**
  25071. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25072. * @param name defines the name of the mesh to create
  25073. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25074. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25075. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25076. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25077. * @param p the number of windings on X axis (positive integers, default 2)
  25078. * @param q the number of windings on Y axis (positive integers, default 3)
  25079. * @param scene defines the hosting scene
  25080. * @param updatable defines if the mesh must be flagged as updatable
  25081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25082. * @returns a new Mesh
  25083. */
  25084. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25085. /**
  25086. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25087. * @param name defines the name of the mesh to create
  25088. * @param points is an array successive Vector3
  25089. * @param scene defines the hosting scene
  25090. * @param updatable defines if the mesh must be flagged as updatable
  25091. * @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).
  25092. * @returns a new Mesh
  25093. */
  25094. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25095. /**
  25096. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25097. * @param name defines the name of the mesh to create
  25098. * @param points is an array successive Vector3
  25099. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25100. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25101. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25102. * @param scene defines the hosting scene
  25103. * @param updatable defines if the mesh must be flagged as updatable
  25104. * @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)
  25105. * @returns a new Mesh
  25106. */
  25107. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25108. /**
  25109. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25110. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25111. * 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.
  25112. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25113. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25114. * Remember you can only change the shape positions, not their number when updating a polygon.
  25115. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25116. * @param name defines the name of the mesh to create
  25117. * @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
  25118. * @param scene defines the hosting scene
  25119. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25120. * @param updatable defines if the mesh must be flagged as updatable
  25121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25122. * @param earcutInjection can be used to inject your own earcut reference
  25123. * @returns a new Mesh
  25124. */
  25125. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25126. /**
  25127. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25128. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25129. * @param name defines the name of the mesh to create
  25130. * @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
  25131. * @param depth defines the height of extrusion
  25132. * @param scene defines the hosting scene
  25133. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25134. * @param updatable defines if the mesh must be flagged as updatable
  25135. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25136. * @param earcutInjection can be used to inject your own earcut reference
  25137. * @returns a new Mesh
  25138. */
  25139. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25140. /**
  25141. * Creates an extruded shape mesh.
  25142. * 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
  25143. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25144. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25145. * @param name defines the name of the mesh to create
  25146. * @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
  25147. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25148. * @param scale is the value to scale the shape
  25149. * @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
  25150. * @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
  25151. * @param scene defines the hosting scene
  25152. * @param updatable defines if the mesh must be flagged as updatable
  25153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25154. * @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)
  25155. * @returns a new Mesh
  25156. */
  25157. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25158. /**
  25159. * Creates an custom extruded shape mesh.
  25160. * The custom extrusion is a parametric shape.
  25161. * It has no predefined shape. Its final shape will depend on the input parameters.
  25162. * Please consider using the same method from the MeshBuilder class instead
  25163. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25164. * @param name defines the name of the mesh to create
  25165. * @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
  25166. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25167. * @param scaleFunction is a custom Javascript function called on each path point
  25168. * @param rotationFunction is a custom Javascript function called on each path point
  25169. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25170. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25171. * @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
  25172. * @param scene defines the hosting scene
  25173. * @param updatable defines if the mesh must be flagged as updatable
  25174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25175. * @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)
  25176. * @returns a new Mesh
  25177. */
  25178. 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;
  25179. /**
  25180. * Creates lathe mesh.
  25181. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25182. * Please consider using the same method from the MeshBuilder class instead
  25183. * @param name defines the name of the mesh to create
  25184. * @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
  25185. * @param radius is the radius value of the lathe
  25186. * @param tessellation is the side number of the lathe.
  25187. * @param scene defines the hosting scene
  25188. * @param updatable defines if the mesh must be flagged as updatable
  25189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25190. * @returns a new Mesh
  25191. */
  25192. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25193. /**
  25194. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25195. * @param name defines the name of the mesh to create
  25196. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25197. * @param scene defines the hosting scene
  25198. * @param updatable defines if the mesh must be flagged as updatable
  25199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25200. * @returns a new Mesh
  25201. */
  25202. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25203. /**
  25204. * Creates a ground mesh.
  25205. * Please consider using the same method from the MeshBuilder class instead
  25206. * @param name defines the name of the mesh to create
  25207. * @param width set the width of the ground
  25208. * @param height set the height of the ground
  25209. * @param subdivisions sets the number of subdivisions per side
  25210. * @param scene defines the hosting scene
  25211. * @param updatable defines if the mesh must be flagged as updatable
  25212. * @returns a new Mesh
  25213. */
  25214. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25215. /**
  25216. * Creates a tiled ground mesh.
  25217. * Please consider using the same method from the MeshBuilder class instead
  25218. * @param name defines the name of the mesh to create
  25219. * @param xmin set the ground minimum X coordinate
  25220. * @param zmin set the ground minimum Y coordinate
  25221. * @param xmax set the ground maximum X coordinate
  25222. * @param zmax set the ground maximum Z coordinate
  25223. * @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
  25224. * @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
  25225. * @param scene defines the hosting scene
  25226. * @param updatable defines if the mesh must be flagged as updatable
  25227. * @returns a new Mesh
  25228. */
  25229. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25230. w: number;
  25231. h: number;
  25232. }, precision: {
  25233. w: number;
  25234. h: number;
  25235. }, scene: Scene, updatable?: boolean): Mesh;
  25236. /**
  25237. * Creates a ground mesh from a height map.
  25238. * Please consider using the same method from the MeshBuilder class instead
  25239. * @see http://doc.babylonjs.com/babylon101/height_map
  25240. * @param name defines the name of the mesh to create
  25241. * @param url sets the URL of the height map image resource
  25242. * @param width set the ground width size
  25243. * @param height set the ground height size
  25244. * @param subdivisions sets the number of subdivision per side
  25245. * @param minHeight is the minimum altitude on the ground
  25246. * @param maxHeight is the maximum altitude on the ground
  25247. * @param scene defines the hosting scene
  25248. * @param updatable defines if the mesh must be flagged as updatable
  25249. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25250. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25251. * @returns a new Mesh
  25252. */
  25253. 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;
  25254. /**
  25255. * Creates a tube mesh.
  25256. * The tube is a parametric shape.
  25257. * It has no predefined shape. Its final shape will depend on the input parameters.
  25258. * Please consider using the same method from the MeshBuilder class instead
  25259. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25260. * @param name defines the name of the mesh to create
  25261. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25262. * @param radius sets the tube radius size
  25263. * @param tessellation is the number of sides on the tubular surface
  25264. * @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
  25265. * @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
  25266. * @param scene defines the hosting scene
  25267. * @param updatable defines if the mesh must be flagged as updatable
  25268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25269. * @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)
  25270. * @returns a new Mesh
  25271. */
  25272. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25273. (i: number, distance: number): number;
  25274. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25275. /**
  25276. * Creates a polyhedron mesh.
  25277. * Please consider using the same method from the MeshBuilder class instead.
  25278. * * 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
  25279. * * The parameter `size` (positive float, default 1) sets the polygon size
  25280. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25281. * * 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`
  25282. * * 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
  25283. * * 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)`)
  25284. * * 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
  25285. * * 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
  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 to create
  25290. * @param options defines the options used to create the mesh
  25291. * @param scene defines the hosting scene
  25292. * @returns a new Mesh
  25293. */
  25294. static CreatePolyhedron(name: string, options: {
  25295. type?: number;
  25296. size?: number;
  25297. sizeX?: number;
  25298. sizeY?: number;
  25299. sizeZ?: number;
  25300. custom?: any;
  25301. faceUV?: Vector4[];
  25302. faceColors?: Color4[];
  25303. updatable?: boolean;
  25304. sideOrientation?: number;
  25305. }, scene: Scene): Mesh;
  25306. /**
  25307. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25308. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25309. * * 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`)
  25310. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25311. * * 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
  25312. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25313. * * 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
  25314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25315. * @param name defines the name of the mesh
  25316. * @param options defines the options used to create the mesh
  25317. * @param scene defines the hosting scene
  25318. * @returns a new Mesh
  25319. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25320. */
  25321. static CreateIcoSphere(name: string, options: {
  25322. radius?: number;
  25323. flat?: boolean;
  25324. subdivisions?: number;
  25325. sideOrientation?: number;
  25326. updatable?: boolean;
  25327. }, scene: Scene): Mesh;
  25328. /**
  25329. * Creates a decal mesh.
  25330. * Please consider using the same method from the MeshBuilder class instead.
  25331. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25332. * @param name defines the name of the mesh
  25333. * @param sourceMesh defines the mesh receiving the decal
  25334. * @param position sets the position of the decal in world coordinates
  25335. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25336. * @param size sets the decal scaling
  25337. * @param angle sets the angle to rotate the decal
  25338. * @returns a new Mesh
  25339. */
  25340. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25341. /**
  25342. * Prepare internal position array for software CPU skinning
  25343. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25344. */
  25345. setPositionsForCPUSkinning(): Float32Array;
  25346. /**
  25347. * Prepare internal normal array for software CPU skinning
  25348. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25349. */
  25350. setNormalsForCPUSkinning(): Float32Array;
  25351. /**
  25352. * Updates the vertex buffer by applying transformation from the bones
  25353. * @param skeleton defines the skeleton to apply to current mesh
  25354. * @returns the current mesh
  25355. */
  25356. applySkeleton(skeleton: Skeleton): Mesh;
  25357. /**
  25358. * 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
  25359. * @param meshes defines the list of meshes to scan
  25360. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25361. */
  25362. static MinMax(meshes: AbstractMesh[]): {
  25363. min: Vector3;
  25364. max: Vector3;
  25365. };
  25366. /**
  25367. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25368. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25369. * @returns a vector3
  25370. */
  25371. static Center(meshesOrMinMaxVector: {
  25372. min: Vector3;
  25373. max: Vector3;
  25374. } | AbstractMesh[]): Vector3;
  25375. /**
  25376. * Merge the array of meshes into a single mesh for performance reasons.
  25377. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25378. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25379. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25380. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25381. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25382. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25383. * @returns a new mesh
  25384. */
  25385. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25386. /** @hidden */
  25387. addInstance(instance: InstancedMesh): void;
  25388. /** @hidden */
  25389. removeInstance(instance: InstancedMesh): void;
  25390. }
  25391. }
  25392. declare module BABYLON {
  25393. /**
  25394. * This is the base class of all the camera used in the application.
  25395. * @see http://doc.babylonjs.com/features/cameras
  25396. */
  25397. export class Camera extends Node {
  25398. /** @hidden */
  25399. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25400. /**
  25401. * This is the default projection mode used by the cameras.
  25402. * It helps recreating a feeling of perspective and better appreciate depth.
  25403. * This is the best way to simulate real life cameras.
  25404. */
  25405. static readonly PERSPECTIVE_CAMERA: number;
  25406. /**
  25407. * This helps creating camera with an orthographic mode.
  25408. * 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.
  25409. */
  25410. static readonly ORTHOGRAPHIC_CAMERA: number;
  25411. /**
  25412. * This is the default FOV mode for perspective cameras.
  25413. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25414. */
  25415. static readonly FOVMODE_VERTICAL_FIXED: number;
  25416. /**
  25417. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25418. */
  25419. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25420. /**
  25421. * This specifies ther is no need for a camera rig.
  25422. * Basically only one eye is rendered corresponding to the camera.
  25423. */
  25424. static readonly RIG_MODE_NONE: number;
  25425. /**
  25426. * Simulates a camera Rig with one blue eye and one red eye.
  25427. * This can be use with 3d blue and red glasses.
  25428. */
  25429. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25430. /**
  25431. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25432. */
  25433. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25434. /**
  25435. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25436. */
  25437. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25438. /**
  25439. * Defines that both eyes of the camera will be rendered over under each other.
  25440. */
  25441. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25442. /**
  25443. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25444. */
  25445. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25446. /**
  25447. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25448. */
  25449. static readonly RIG_MODE_VR: number;
  25450. /**
  25451. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25452. */
  25453. static readonly RIG_MODE_WEBVR: number;
  25454. /**
  25455. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25456. */
  25457. static readonly RIG_MODE_CUSTOM: number;
  25458. /**
  25459. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25460. */
  25461. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25462. /**
  25463. * Define the input manager associated with the camera.
  25464. */
  25465. inputs: CameraInputsManager<Camera>;
  25466. /** @hidden */
  25467. _position: Vector3;
  25468. /**
  25469. * Define the current local position of the camera in the scene
  25470. */
  25471. get position(): Vector3;
  25472. set position(newPosition: Vector3);
  25473. /**
  25474. * The vector the camera should consider as up.
  25475. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25476. */
  25477. upVector: Vector3;
  25478. /**
  25479. * Define the current limit on the left side for an orthographic camera
  25480. * In scene unit
  25481. */
  25482. orthoLeft: Nullable<number>;
  25483. /**
  25484. * Define the current limit on the right side for an orthographic camera
  25485. * In scene unit
  25486. */
  25487. orthoRight: Nullable<number>;
  25488. /**
  25489. * Define the current limit on the bottom side for an orthographic camera
  25490. * In scene unit
  25491. */
  25492. orthoBottom: Nullable<number>;
  25493. /**
  25494. * Define the current limit on the top side for an orthographic camera
  25495. * In scene unit
  25496. */
  25497. orthoTop: Nullable<number>;
  25498. /**
  25499. * Field Of View is set in Radians. (default is 0.8)
  25500. */
  25501. fov: number;
  25502. /**
  25503. * Define the minimum distance the camera can see from.
  25504. * This is important to note that the depth buffer are not infinite and the closer it starts
  25505. * the more your scene might encounter depth fighting issue.
  25506. */
  25507. minZ: number;
  25508. /**
  25509. * Define the maximum distance the camera can see to.
  25510. * This is important to note that the depth buffer are not infinite and the further it end
  25511. * the more your scene might encounter depth fighting issue.
  25512. */
  25513. maxZ: number;
  25514. /**
  25515. * Define the default inertia of the camera.
  25516. * This helps giving a smooth feeling to the camera movement.
  25517. */
  25518. inertia: number;
  25519. /**
  25520. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25521. */
  25522. mode: number;
  25523. /**
  25524. * Define whether the camera is intermediate.
  25525. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25526. */
  25527. isIntermediate: boolean;
  25528. /**
  25529. * Define the viewport of the camera.
  25530. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25531. */
  25532. viewport: Viewport;
  25533. /**
  25534. * Restricts the camera to viewing objects with the same layerMask.
  25535. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25536. */
  25537. layerMask: number;
  25538. /**
  25539. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25540. */
  25541. fovMode: number;
  25542. /**
  25543. * Rig mode of the camera.
  25544. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25545. * This is normally controlled byt the camera themselves as internal use.
  25546. */
  25547. cameraRigMode: number;
  25548. /**
  25549. * Defines the distance between both "eyes" in case of a RIG
  25550. */
  25551. interaxialDistance: number;
  25552. /**
  25553. * Defines if stereoscopic rendering is done side by side or over under.
  25554. */
  25555. isStereoscopicSideBySide: boolean;
  25556. /**
  25557. * 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
  25558. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25559. * else in the scene. (Eg. security camera)
  25560. *
  25561. * 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)
  25562. */
  25563. customRenderTargets: RenderTargetTexture[];
  25564. /**
  25565. * When set, the camera will render to this render target instead of the default canvas
  25566. *
  25567. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25568. */
  25569. outputRenderTarget: Nullable<RenderTargetTexture>;
  25570. /**
  25571. * Observable triggered when the camera view matrix has changed.
  25572. */
  25573. onViewMatrixChangedObservable: Observable<Camera>;
  25574. /**
  25575. * Observable triggered when the camera Projection matrix has changed.
  25576. */
  25577. onProjectionMatrixChangedObservable: Observable<Camera>;
  25578. /**
  25579. * Observable triggered when the inputs have been processed.
  25580. */
  25581. onAfterCheckInputsObservable: Observable<Camera>;
  25582. /**
  25583. * Observable triggered when reset has been called and applied to the camera.
  25584. */
  25585. onRestoreStateObservable: Observable<Camera>;
  25586. /**
  25587. * Is this camera a part of a rig system?
  25588. */
  25589. isRigCamera: boolean;
  25590. /**
  25591. * If isRigCamera set to true this will be set with the parent camera.
  25592. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25593. */
  25594. rigParent?: Camera;
  25595. /** @hidden */
  25596. _cameraRigParams: any;
  25597. /** @hidden */
  25598. _rigCameras: Camera[];
  25599. /** @hidden */
  25600. _rigPostProcess: Nullable<PostProcess>;
  25601. protected _webvrViewMatrix: Matrix;
  25602. /** @hidden */
  25603. _skipRendering: boolean;
  25604. /** @hidden */
  25605. _projectionMatrix: Matrix;
  25606. /** @hidden */
  25607. _postProcesses: Nullable<PostProcess>[];
  25608. /** @hidden */
  25609. _activeMeshes: SmartArray<AbstractMesh>;
  25610. protected _globalPosition: Vector3;
  25611. /** @hidden */
  25612. _computedViewMatrix: Matrix;
  25613. private _doNotComputeProjectionMatrix;
  25614. private _transformMatrix;
  25615. private _frustumPlanes;
  25616. private _refreshFrustumPlanes;
  25617. private _storedFov;
  25618. private _stateStored;
  25619. /**
  25620. * Instantiates a new camera object.
  25621. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25622. * @see http://doc.babylonjs.com/features/cameras
  25623. * @param name Defines the name of the camera in the scene
  25624. * @param position Defines the position of the camera
  25625. * @param scene Defines the scene the camera belongs too
  25626. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25627. */
  25628. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25629. /**
  25630. * Store current camera state (fov, position, etc..)
  25631. * @returns the camera
  25632. */
  25633. storeState(): Camera;
  25634. /**
  25635. * Restores the camera state values if it has been stored. You must call storeState() first
  25636. */
  25637. protected _restoreStateValues(): boolean;
  25638. /**
  25639. * Restored camera state. You must call storeState() first.
  25640. * @returns true if restored and false otherwise
  25641. */
  25642. restoreState(): boolean;
  25643. /**
  25644. * Gets the class name of the camera.
  25645. * @returns the class name
  25646. */
  25647. getClassName(): string;
  25648. /** @hidden */
  25649. readonly _isCamera: boolean;
  25650. /**
  25651. * Gets a string representation of the camera useful for debug purpose.
  25652. * @param fullDetails Defines that a more verboe level of logging is required
  25653. * @returns the string representation
  25654. */
  25655. toString(fullDetails?: boolean): string;
  25656. /**
  25657. * Gets the current world space position of the camera.
  25658. */
  25659. get globalPosition(): Vector3;
  25660. /**
  25661. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25662. * @returns the active meshe list
  25663. */
  25664. getActiveMeshes(): SmartArray<AbstractMesh>;
  25665. /**
  25666. * Check whether a mesh is part of the current active mesh list of the camera
  25667. * @param mesh Defines the mesh to check
  25668. * @returns true if active, false otherwise
  25669. */
  25670. isActiveMesh(mesh: Mesh): boolean;
  25671. /**
  25672. * Is this camera ready to be used/rendered
  25673. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25674. * @return true if the camera is ready
  25675. */
  25676. isReady(completeCheck?: boolean): boolean;
  25677. /** @hidden */
  25678. _initCache(): void;
  25679. /** @hidden */
  25680. _updateCache(ignoreParentClass?: boolean): void;
  25681. /** @hidden */
  25682. _isSynchronized(): boolean;
  25683. /** @hidden */
  25684. _isSynchronizedViewMatrix(): boolean;
  25685. /** @hidden */
  25686. _isSynchronizedProjectionMatrix(): boolean;
  25687. /**
  25688. * Attach the input controls to a specific dom element to get the input from.
  25689. * @param element Defines the element the controls should be listened from
  25690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25691. */
  25692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25693. /**
  25694. * Detach the current controls from the specified dom element.
  25695. * @param element Defines the element to stop listening the inputs from
  25696. */
  25697. detachControl(element: HTMLElement): void;
  25698. /**
  25699. * Update the camera state according to the different inputs gathered during the frame.
  25700. */
  25701. update(): void;
  25702. /** @hidden */
  25703. _checkInputs(): void;
  25704. /** @hidden */
  25705. get rigCameras(): Camera[];
  25706. /**
  25707. * Gets the post process used by the rig cameras
  25708. */
  25709. get rigPostProcess(): Nullable<PostProcess>;
  25710. /**
  25711. * Internal, gets the first post proces.
  25712. * @returns the first post process to be run on this camera.
  25713. */
  25714. _getFirstPostProcess(): Nullable<PostProcess>;
  25715. private _cascadePostProcessesToRigCams;
  25716. /**
  25717. * Attach a post process to the camera.
  25718. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25719. * @param postProcess The post process to attach to the camera
  25720. * @param insertAt The position of the post process in case several of them are in use in the scene
  25721. * @returns the position the post process has been inserted at
  25722. */
  25723. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25724. /**
  25725. * Detach a post process to the camera.
  25726. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25727. * @param postProcess The post process to detach from the camera
  25728. */
  25729. detachPostProcess(postProcess: PostProcess): void;
  25730. /**
  25731. * Gets the current world matrix of the camera
  25732. */
  25733. getWorldMatrix(): Matrix;
  25734. /** @hidden */
  25735. _getViewMatrix(): Matrix;
  25736. /**
  25737. * Gets the current view matrix of the camera.
  25738. * @param force forces the camera to recompute the matrix without looking at the cached state
  25739. * @returns the view matrix
  25740. */
  25741. getViewMatrix(force?: boolean): Matrix;
  25742. /**
  25743. * Freeze the projection matrix.
  25744. * It will prevent the cache check of the camera projection compute and can speed up perf
  25745. * if no parameter of the camera are meant to change
  25746. * @param projection Defines manually a projection if necessary
  25747. */
  25748. freezeProjectionMatrix(projection?: Matrix): void;
  25749. /**
  25750. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25751. */
  25752. unfreezeProjectionMatrix(): void;
  25753. /**
  25754. * Gets the current projection matrix of the camera.
  25755. * @param force forces the camera to recompute the matrix without looking at the cached state
  25756. * @returns the projection matrix
  25757. */
  25758. getProjectionMatrix(force?: boolean): Matrix;
  25759. /**
  25760. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25761. * @returns a Matrix
  25762. */
  25763. getTransformationMatrix(): Matrix;
  25764. private _updateFrustumPlanes;
  25765. /**
  25766. * Checks if a cullable object (mesh...) is in the camera frustum
  25767. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25768. * @param target The object to check
  25769. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25770. * @returns true if the object is in frustum otherwise false
  25771. */
  25772. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25773. /**
  25774. * Checks if a cullable object (mesh...) is in the camera frustum
  25775. * Unlike isInFrustum this cheks the full bounding box
  25776. * @param target The object to check
  25777. * @returns true if the object is in frustum otherwise false
  25778. */
  25779. isCompletelyInFrustum(target: ICullable): boolean;
  25780. /**
  25781. * Gets a ray in the forward direction from the camera.
  25782. * @param length Defines the length of the ray to create
  25783. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25784. * @param origin Defines the start point of the ray which defaults to the camera position
  25785. * @returns the forward ray
  25786. */
  25787. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25788. /**
  25789. * Releases resources associated with this node.
  25790. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25791. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25792. */
  25793. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25794. /** @hidden */
  25795. _isLeftCamera: boolean;
  25796. /**
  25797. * Gets the left camera of a rig setup in case of Rigged Camera
  25798. */
  25799. get isLeftCamera(): boolean;
  25800. /** @hidden */
  25801. _isRightCamera: boolean;
  25802. /**
  25803. * Gets the right camera of a rig setup in case of Rigged Camera
  25804. */
  25805. get isRightCamera(): boolean;
  25806. /**
  25807. * Gets the left camera of a rig setup in case of Rigged Camera
  25808. */
  25809. get leftCamera(): Nullable<FreeCamera>;
  25810. /**
  25811. * Gets the right camera of a rig setup in case of Rigged Camera
  25812. */
  25813. get rightCamera(): Nullable<FreeCamera>;
  25814. /**
  25815. * Gets the left camera target of a rig setup in case of Rigged Camera
  25816. * @returns the target position
  25817. */
  25818. getLeftTarget(): Nullable<Vector3>;
  25819. /**
  25820. * Gets the right camera target of a rig setup in case of Rigged Camera
  25821. * @returns the target position
  25822. */
  25823. getRightTarget(): Nullable<Vector3>;
  25824. /**
  25825. * @hidden
  25826. */
  25827. setCameraRigMode(mode: number, rigParams: any): void;
  25828. /** @hidden */
  25829. static _setStereoscopicRigMode(camera: Camera): void;
  25830. /** @hidden */
  25831. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25832. /** @hidden */
  25833. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25834. /** @hidden */
  25835. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25836. /** @hidden */
  25837. _getVRProjectionMatrix(): Matrix;
  25838. protected _updateCameraRotationMatrix(): void;
  25839. protected _updateWebVRCameraRotationMatrix(): void;
  25840. /**
  25841. * This function MUST be overwritten by the different WebVR cameras available.
  25842. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25843. * @hidden
  25844. */
  25845. _getWebVRProjectionMatrix(): Matrix;
  25846. /**
  25847. * This function MUST be overwritten by the different WebVR cameras available.
  25848. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25849. * @hidden
  25850. */
  25851. _getWebVRViewMatrix(): Matrix;
  25852. /** @hidden */
  25853. setCameraRigParameter(name: string, value: any): void;
  25854. /**
  25855. * needs to be overridden by children so sub has required properties to be copied
  25856. * @hidden
  25857. */
  25858. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25859. /**
  25860. * May need to be overridden by children
  25861. * @hidden
  25862. */
  25863. _updateRigCameras(): void;
  25864. /** @hidden */
  25865. _setupInputs(): void;
  25866. /**
  25867. * Serialiaze the camera setup to a json represention
  25868. * @returns the JSON representation
  25869. */
  25870. serialize(): any;
  25871. /**
  25872. * Clones the current camera.
  25873. * @param name The cloned camera name
  25874. * @returns the cloned camera
  25875. */
  25876. clone(name: string): Camera;
  25877. /**
  25878. * Gets the direction of the camera relative to a given local axis.
  25879. * @param localAxis Defines the reference axis to provide a relative direction.
  25880. * @return the direction
  25881. */
  25882. getDirection(localAxis: Vector3): Vector3;
  25883. /**
  25884. * Returns the current camera absolute rotation
  25885. */
  25886. get absoluteRotation(): Quaternion;
  25887. /**
  25888. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25889. * @param localAxis Defines the reference axis to provide a relative direction.
  25890. * @param result Defines the vector to store the result in
  25891. */
  25892. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25893. /**
  25894. * Gets a camera constructor for a given camera type
  25895. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25896. * @param name The name of the camera the result will be able to instantiate
  25897. * @param scene The scene the result will construct the camera in
  25898. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25899. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25900. * @returns a factory method to construc the camera
  25901. */
  25902. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25903. /**
  25904. * Compute the world matrix of the camera.
  25905. * @returns the camera world matrix
  25906. */
  25907. computeWorldMatrix(): Matrix;
  25908. /**
  25909. * Parse a JSON and creates the camera from the parsed information
  25910. * @param parsedCamera The JSON to parse
  25911. * @param scene The scene to instantiate the camera in
  25912. * @returns the newly constructed camera
  25913. */
  25914. static Parse(parsedCamera: any, scene: Scene): Camera;
  25915. }
  25916. }
  25917. declare module BABYLON {
  25918. /**
  25919. * Class containing static functions to help procedurally build meshes
  25920. */
  25921. export class DiscBuilder {
  25922. /**
  25923. * Creates a plane polygonal mesh. By default, this is a disc
  25924. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25925. * * 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
  25926. * * 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
  25927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25928. * * 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
  25929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25930. * @param name defines the name of the mesh
  25931. * @param options defines the options used to create the mesh
  25932. * @param scene defines the hosting scene
  25933. * @returns the plane polygonal mesh
  25934. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25935. */
  25936. static CreateDisc(name: string, options: {
  25937. radius?: number;
  25938. tessellation?: number;
  25939. arc?: number;
  25940. updatable?: boolean;
  25941. sideOrientation?: number;
  25942. frontUVs?: Vector4;
  25943. backUVs?: Vector4;
  25944. }, scene?: Nullable<Scene>): Mesh;
  25945. }
  25946. }
  25947. declare module BABYLON {
  25948. /**
  25949. * This represents all the required information to add a fresnel effect on a material:
  25950. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25951. */
  25952. export class FresnelParameters {
  25953. private _isEnabled;
  25954. /**
  25955. * Define if the fresnel effect is enable or not.
  25956. */
  25957. get isEnabled(): boolean;
  25958. set isEnabled(value: boolean);
  25959. /**
  25960. * Define the color used on edges (grazing angle)
  25961. */
  25962. leftColor: Color3;
  25963. /**
  25964. * Define the color used on center
  25965. */
  25966. rightColor: Color3;
  25967. /**
  25968. * Define bias applied to computed fresnel term
  25969. */
  25970. bias: number;
  25971. /**
  25972. * Defined the power exponent applied to fresnel term
  25973. */
  25974. power: number;
  25975. /**
  25976. * Clones the current fresnel and its valuues
  25977. * @returns a clone fresnel configuration
  25978. */
  25979. clone(): FresnelParameters;
  25980. /**
  25981. * Serializes the current fresnel parameters to a JSON representation.
  25982. * @return the JSON serialization
  25983. */
  25984. serialize(): any;
  25985. /**
  25986. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25987. * @param parsedFresnelParameters Define the JSON representation
  25988. * @returns the parsed parameters
  25989. */
  25990. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25991. }
  25992. }
  25993. declare module BABYLON {
  25994. /**
  25995. * Base class of materials working in push mode in babylon JS
  25996. * @hidden
  25997. */
  25998. export class PushMaterial extends Material {
  25999. protected _activeEffect: Effect;
  26000. protected _normalMatrix: Matrix;
  26001. /**
  26002. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26003. * This means that the material can keep using a previous shader while a new one is being compiled.
  26004. * This is mostly used when shader parallel compilation is supported (true by default)
  26005. */
  26006. allowShaderHotSwapping: boolean;
  26007. constructor(name: string, scene: Scene);
  26008. getEffect(): Effect;
  26009. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26010. /**
  26011. * Binds the given world matrix to the active effect
  26012. *
  26013. * @param world the matrix to bind
  26014. */
  26015. bindOnlyWorldMatrix(world: Matrix): void;
  26016. /**
  26017. * Binds the given normal matrix to the active effect
  26018. *
  26019. * @param normalMatrix the matrix to bind
  26020. */
  26021. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26022. bind(world: Matrix, mesh?: Mesh): void;
  26023. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26024. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26025. }
  26026. }
  26027. declare module BABYLON {
  26028. /**
  26029. * This groups all the flags used to control the materials channel.
  26030. */
  26031. export class MaterialFlags {
  26032. private static _DiffuseTextureEnabled;
  26033. /**
  26034. * Are diffuse textures enabled in the application.
  26035. */
  26036. static get DiffuseTextureEnabled(): boolean;
  26037. static set DiffuseTextureEnabled(value: boolean);
  26038. private static _AmbientTextureEnabled;
  26039. /**
  26040. * Are ambient textures enabled in the application.
  26041. */
  26042. static get AmbientTextureEnabled(): boolean;
  26043. static set AmbientTextureEnabled(value: boolean);
  26044. private static _OpacityTextureEnabled;
  26045. /**
  26046. * Are opacity textures enabled in the application.
  26047. */
  26048. static get OpacityTextureEnabled(): boolean;
  26049. static set OpacityTextureEnabled(value: boolean);
  26050. private static _ReflectionTextureEnabled;
  26051. /**
  26052. * Are reflection textures enabled in the application.
  26053. */
  26054. static get ReflectionTextureEnabled(): boolean;
  26055. static set ReflectionTextureEnabled(value: boolean);
  26056. private static _EmissiveTextureEnabled;
  26057. /**
  26058. * Are emissive textures enabled in the application.
  26059. */
  26060. static get EmissiveTextureEnabled(): boolean;
  26061. static set EmissiveTextureEnabled(value: boolean);
  26062. private static _SpecularTextureEnabled;
  26063. /**
  26064. * Are specular textures enabled in the application.
  26065. */
  26066. static get SpecularTextureEnabled(): boolean;
  26067. static set SpecularTextureEnabled(value: boolean);
  26068. private static _BumpTextureEnabled;
  26069. /**
  26070. * Are bump textures enabled in the application.
  26071. */
  26072. static get BumpTextureEnabled(): boolean;
  26073. static set BumpTextureEnabled(value: boolean);
  26074. private static _LightmapTextureEnabled;
  26075. /**
  26076. * Are lightmap textures enabled in the application.
  26077. */
  26078. static get LightmapTextureEnabled(): boolean;
  26079. static set LightmapTextureEnabled(value: boolean);
  26080. private static _RefractionTextureEnabled;
  26081. /**
  26082. * Are refraction textures enabled in the application.
  26083. */
  26084. static get RefractionTextureEnabled(): boolean;
  26085. static set RefractionTextureEnabled(value: boolean);
  26086. private static _ColorGradingTextureEnabled;
  26087. /**
  26088. * Are color grading textures enabled in the application.
  26089. */
  26090. static get ColorGradingTextureEnabled(): boolean;
  26091. static set ColorGradingTextureEnabled(value: boolean);
  26092. private static _FresnelEnabled;
  26093. /**
  26094. * Are fresnels enabled in the application.
  26095. */
  26096. static get FresnelEnabled(): boolean;
  26097. static set FresnelEnabled(value: boolean);
  26098. private static _ClearCoatTextureEnabled;
  26099. /**
  26100. * Are clear coat textures enabled in the application.
  26101. */
  26102. static get ClearCoatTextureEnabled(): boolean;
  26103. static set ClearCoatTextureEnabled(value: boolean);
  26104. private static _ClearCoatBumpTextureEnabled;
  26105. /**
  26106. * Are clear coat bump textures enabled in the application.
  26107. */
  26108. static get ClearCoatBumpTextureEnabled(): boolean;
  26109. static set ClearCoatBumpTextureEnabled(value: boolean);
  26110. private static _ClearCoatTintTextureEnabled;
  26111. /**
  26112. * Are clear coat tint textures enabled in the application.
  26113. */
  26114. static get ClearCoatTintTextureEnabled(): boolean;
  26115. static set ClearCoatTintTextureEnabled(value: boolean);
  26116. private static _SheenTextureEnabled;
  26117. /**
  26118. * Are sheen textures enabled in the application.
  26119. */
  26120. static get SheenTextureEnabled(): boolean;
  26121. static set SheenTextureEnabled(value: boolean);
  26122. private static _AnisotropicTextureEnabled;
  26123. /**
  26124. * Are anisotropic textures enabled in the application.
  26125. */
  26126. static get AnisotropicTextureEnabled(): boolean;
  26127. static set AnisotropicTextureEnabled(value: boolean);
  26128. private static _ThicknessTextureEnabled;
  26129. /**
  26130. * Are thickness textures enabled in the application.
  26131. */
  26132. static get ThicknessTextureEnabled(): boolean;
  26133. static set ThicknessTextureEnabled(value: boolean);
  26134. }
  26135. }
  26136. declare module BABYLON {
  26137. /** @hidden */
  26138. export var defaultFragmentDeclaration: {
  26139. name: string;
  26140. shader: string;
  26141. };
  26142. }
  26143. declare module BABYLON {
  26144. /** @hidden */
  26145. export var defaultUboDeclaration: {
  26146. name: string;
  26147. shader: string;
  26148. };
  26149. }
  26150. declare module BABYLON {
  26151. /** @hidden */
  26152. export var lightFragmentDeclaration: {
  26153. name: string;
  26154. shader: string;
  26155. };
  26156. }
  26157. declare module BABYLON {
  26158. /** @hidden */
  26159. export var lightUboDeclaration: {
  26160. name: string;
  26161. shader: string;
  26162. };
  26163. }
  26164. declare module BABYLON {
  26165. /** @hidden */
  26166. export var lightsFragmentFunctions: {
  26167. name: string;
  26168. shader: string;
  26169. };
  26170. }
  26171. declare module BABYLON {
  26172. /** @hidden */
  26173. export var shadowsFragmentFunctions: {
  26174. name: string;
  26175. shader: string;
  26176. };
  26177. }
  26178. declare module BABYLON {
  26179. /** @hidden */
  26180. export var fresnelFunction: {
  26181. name: string;
  26182. shader: string;
  26183. };
  26184. }
  26185. declare module BABYLON {
  26186. /** @hidden */
  26187. export var reflectionFunction: {
  26188. name: string;
  26189. shader: string;
  26190. };
  26191. }
  26192. declare module BABYLON {
  26193. /** @hidden */
  26194. export var bumpFragmentFunctions: {
  26195. name: string;
  26196. shader: string;
  26197. };
  26198. }
  26199. declare module BABYLON {
  26200. /** @hidden */
  26201. export var logDepthDeclaration: {
  26202. name: string;
  26203. shader: string;
  26204. };
  26205. }
  26206. declare module BABYLON {
  26207. /** @hidden */
  26208. export var bumpFragment: {
  26209. name: string;
  26210. shader: string;
  26211. };
  26212. }
  26213. declare module BABYLON {
  26214. /** @hidden */
  26215. export var depthPrePass: {
  26216. name: string;
  26217. shader: string;
  26218. };
  26219. }
  26220. declare module BABYLON {
  26221. /** @hidden */
  26222. export var lightFragment: {
  26223. name: string;
  26224. shader: string;
  26225. };
  26226. }
  26227. declare module BABYLON {
  26228. /** @hidden */
  26229. export var logDepthFragment: {
  26230. name: string;
  26231. shader: string;
  26232. };
  26233. }
  26234. declare module BABYLON {
  26235. /** @hidden */
  26236. export var defaultPixelShader: {
  26237. name: string;
  26238. shader: string;
  26239. };
  26240. }
  26241. declare module BABYLON {
  26242. /** @hidden */
  26243. export var defaultVertexDeclaration: {
  26244. name: string;
  26245. shader: string;
  26246. };
  26247. }
  26248. declare module BABYLON {
  26249. /** @hidden */
  26250. export var bumpVertexDeclaration: {
  26251. name: string;
  26252. shader: string;
  26253. };
  26254. }
  26255. declare module BABYLON {
  26256. /** @hidden */
  26257. export var bumpVertex: {
  26258. name: string;
  26259. shader: string;
  26260. };
  26261. }
  26262. declare module BABYLON {
  26263. /** @hidden */
  26264. export var fogVertex: {
  26265. name: string;
  26266. shader: string;
  26267. };
  26268. }
  26269. declare module BABYLON {
  26270. /** @hidden */
  26271. export var shadowsVertex: {
  26272. name: string;
  26273. shader: string;
  26274. };
  26275. }
  26276. declare module BABYLON {
  26277. /** @hidden */
  26278. export var pointCloudVertex: {
  26279. name: string;
  26280. shader: string;
  26281. };
  26282. }
  26283. declare module BABYLON {
  26284. /** @hidden */
  26285. export var logDepthVertex: {
  26286. name: string;
  26287. shader: string;
  26288. };
  26289. }
  26290. declare module BABYLON {
  26291. /** @hidden */
  26292. export var defaultVertexShader: {
  26293. name: string;
  26294. shader: string;
  26295. };
  26296. }
  26297. declare module BABYLON {
  26298. /** @hidden */
  26299. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26300. MAINUV1: boolean;
  26301. MAINUV2: boolean;
  26302. DIFFUSE: boolean;
  26303. DIFFUSEDIRECTUV: number;
  26304. AMBIENT: boolean;
  26305. AMBIENTDIRECTUV: number;
  26306. OPACITY: boolean;
  26307. OPACITYDIRECTUV: number;
  26308. OPACITYRGB: boolean;
  26309. REFLECTION: boolean;
  26310. EMISSIVE: boolean;
  26311. EMISSIVEDIRECTUV: number;
  26312. SPECULAR: boolean;
  26313. SPECULARDIRECTUV: number;
  26314. BUMP: boolean;
  26315. BUMPDIRECTUV: number;
  26316. PARALLAX: boolean;
  26317. PARALLAXOCCLUSION: boolean;
  26318. SPECULAROVERALPHA: boolean;
  26319. CLIPPLANE: boolean;
  26320. CLIPPLANE2: boolean;
  26321. CLIPPLANE3: boolean;
  26322. CLIPPLANE4: boolean;
  26323. CLIPPLANE5: boolean;
  26324. CLIPPLANE6: boolean;
  26325. ALPHATEST: boolean;
  26326. DEPTHPREPASS: boolean;
  26327. ALPHAFROMDIFFUSE: boolean;
  26328. POINTSIZE: boolean;
  26329. FOG: boolean;
  26330. SPECULARTERM: boolean;
  26331. DIFFUSEFRESNEL: boolean;
  26332. OPACITYFRESNEL: boolean;
  26333. REFLECTIONFRESNEL: boolean;
  26334. REFRACTIONFRESNEL: boolean;
  26335. EMISSIVEFRESNEL: boolean;
  26336. FRESNEL: boolean;
  26337. NORMAL: boolean;
  26338. UV1: boolean;
  26339. UV2: boolean;
  26340. VERTEXCOLOR: boolean;
  26341. VERTEXALPHA: boolean;
  26342. NUM_BONE_INFLUENCERS: number;
  26343. BonesPerMesh: number;
  26344. BONETEXTURE: boolean;
  26345. INSTANCES: boolean;
  26346. GLOSSINESS: boolean;
  26347. ROUGHNESS: boolean;
  26348. EMISSIVEASILLUMINATION: boolean;
  26349. LINKEMISSIVEWITHDIFFUSE: boolean;
  26350. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26351. LIGHTMAP: boolean;
  26352. LIGHTMAPDIRECTUV: number;
  26353. OBJECTSPACE_NORMALMAP: boolean;
  26354. USELIGHTMAPASSHADOWMAP: boolean;
  26355. REFLECTIONMAP_3D: boolean;
  26356. REFLECTIONMAP_SPHERICAL: boolean;
  26357. REFLECTIONMAP_PLANAR: boolean;
  26358. REFLECTIONMAP_CUBIC: boolean;
  26359. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26360. REFLECTIONMAP_PROJECTION: boolean;
  26361. REFLECTIONMAP_SKYBOX: boolean;
  26362. REFLECTIONMAP_EXPLICIT: boolean;
  26363. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26364. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26365. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26366. INVERTCUBICMAP: boolean;
  26367. LOGARITHMICDEPTH: boolean;
  26368. REFRACTION: boolean;
  26369. REFRACTIONMAP_3D: boolean;
  26370. REFLECTIONOVERALPHA: boolean;
  26371. TWOSIDEDLIGHTING: boolean;
  26372. SHADOWFLOAT: boolean;
  26373. MORPHTARGETS: boolean;
  26374. MORPHTARGETS_NORMAL: boolean;
  26375. MORPHTARGETS_TANGENT: boolean;
  26376. MORPHTARGETS_UV: boolean;
  26377. NUM_MORPH_INFLUENCERS: number;
  26378. NONUNIFORMSCALING: boolean;
  26379. PREMULTIPLYALPHA: boolean;
  26380. IMAGEPROCESSING: boolean;
  26381. VIGNETTE: boolean;
  26382. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26383. VIGNETTEBLENDMODEOPAQUE: boolean;
  26384. TONEMAPPING: boolean;
  26385. TONEMAPPING_ACES: boolean;
  26386. CONTRAST: boolean;
  26387. COLORCURVES: boolean;
  26388. COLORGRADING: boolean;
  26389. COLORGRADING3D: boolean;
  26390. SAMPLER3DGREENDEPTH: boolean;
  26391. SAMPLER3DBGRMAP: boolean;
  26392. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26393. MULTIVIEW: boolean;
  26394. /**
  26395. * If the reflection texture on this material is in linear color space
  26396. * @hidden
  26397. */
  26398. IS_REFLECTION_LINEAR: boolean;
  26399. /**
  26400. * If the refraction texture on this material is in linear color space
  26401. * @hidden
  26402. */
  26403. IS_REFRACTION_LINEAR: boolean;
  26404. EXPOSURE: boolean;
  26405. constructor();
  26406. setReflectionMode(modeToEnable: string): void;
  26407. }
  26408. /**
  26409. * This is the default material used in Babylon. It is the best trade off between quality
  26410. * and performances.
  26411. * @see http://doc.babylonjs.com/babylon101/materials
  26412. */
  26413. export class StandardMaterial extends PushMaterial {
  26414. private _diffuseTexture;
  26415. /**
  26416. * The basic texture of the material as viewed under a light.
  26417. */
  26418. diffuseTexture: Nullable<BaseTexture>;
  26419. private _ambientTexture;
  26420. /**
  26421. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26422. */
  26423. ambientTexture: Nullable<BaseTexture>;
  26424. private _opacityTexture;
  26425. /**
  26426. * Define the transparency of the material from a texture.
  26427. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26428. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26429. */
  26430. opacityTexture: Nullable<BaseTexture>;
  26431. private _reflectionTexture;
  26432. /**
  26433. * Define the texture used to display the reflection.
  26434. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26435. */
  26436. reflectionTexture: Nullable<BaseTexture>;
  26437. private _emissiveTexture;
  26438. /**
  26439. * Define texture of the material as if self lit.
  26440. * This will be mixed in the final result even in the absence of light.
  26441. */
  26442. emissiveTexture: Nullable<BaseTexture>;
  26443. private _specularTexture;
  26444. /**
  26445. * Define how the color and intensity of the highlight given by the light in the material.
  26446. */
  26447. specularTexture: Nullable<BaseTexture>;
  26448. private _bumpTexture;
  26449. /**
  26450. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26451. * 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.
  26452. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26453. */
  26454. bumpTexture: Nullable<BaseTexture>;
  26455. private _lightmapTexture;
  26456. /**
  26457. * Complex lighting can be computationally expensive to compute at runtime.
  26458. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26459. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26460. */
  26461. lightmapTexture: Nullable<BaseTexture>;
  26462. private _refractionTexture;
  26463. /**
  26464. * Define the texture used to display the refraction.
  26465. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26466. */
  26467. refractionTexture: Nullable<BaseTexture>;
  26468. /**
  26469. * The color of the material lit by the environmental background lighting.
  26470. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26471. */
  26472. ambientColor: Color3;
  26473. /**
  26474. * The basic color of the material as viewed under a light.
  26475. */
  26476. diffuseColor: Color3;
  26477. /**
  26478. * Define how the color and intensity of the highlight given by the light in the material.
  26479. */
  26480. specularColor: Color3;
  26481. /**
  26482. * Define the color of the material as if self lit.
  26483. * This will be mixed in the final result even in the absence of light.
  26484. */
  26485. emissiveColor: Color3;
  26486. /**
  26487. * Defines how sharp are the highlights in the material.
  26488. * The bigger the value the sharper giving a more glossy feeling to the result.
  26489. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26490. */
  26491. specularPower: number;
  26492. private _useAlphaFromDiffuseTexture;
  26493. /**
  26494. * Does the transparency come from the diffuse texture alpha channel.
  26495. */
  26496. useAlphaFromDiffuseTexture: boolean;
  26497. private _useEmissiveAsIllumination;
  26498. /**
  26499. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26500. */
  26501. useEmissiveAsIllumination: boolean;
  26502. private _linkEmissiveWithDiffuse;
  26503. /**
  26504. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26505. * the emissive level when the final color is close to one.
  26506. */
  26507. linkEmissiveWithDiffuse: boolean;
  26508. private _useSpecularOverAlpha;
  26509. /**
  26510. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26511. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26512. */
  26513. useSpecularOverAlpha: boolean;
  26514. private _useReflectionOverAlpha;
  26515. /**
  26516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26518. */
  26519. useReflectionOverAlpha: boolean;
  26520. private _disableLighting;
  26521. /**
  26522. * Does lights from the scene impacts this material.
  26523. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26524. */
  26525. disableLighting: boolean;
  26526. private _useObjectSpaceNormalMap;
  26527. /**
  26528. * Allows using an object space normal map (instead of tangent space).
  26529. */
  26530. useObjectSpaceNormalMap: boolean;
  26531. private _useParallax;
  26532. /**
  26533. * Is parallax enabled or not.
  26534. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26535. */
  26536. useParallax: boolean;
  26537. private _useParallaxOcclusion;
  26538. /**
  26539. * Is parallax occlusion enabled or not.
  26540. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26541. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26542. */
  26543. useParallaxOcclusion: boolean;
  26544. /**
  26545. * 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.
  26546. */
  26547. parallaxScaleBias: number;
  26548. private _roughness;
  26549. /**
  26550. * Helps to define how blurry the reflections should appears in the material.
  26551. */
  26552. roughness: number;
  26553. /**
  26554. * In case of refraction, define the value of the index of refraction.
  26555. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26556. */
  26557. indexOfRefraction: number;
  26558. /**
  26559. * Invert the refraction texture alongside the y axis.
  26560. * It can be useful with procedural textures or probe for instance.
  26561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26562. */
  26563. invertRefractionY: boolean;
  26564. /**
  26565. * Defines the alpha limits in alpha test mode.
  26566. */
  26567. alphaCutOff: number;
  26568. private _useLightmapAsShadowmap;
  26569. /**
  26570. * In case of light mapping, define whether the map contains light or shadow informations.
  26571. */
  26572. useLightmapAsShadowmap: boolean;
  26573. private _diffuseFresnelParameters;
  26574. /**
  26575. * Define the diffuse fresnel parameters of the material.
  26576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26577. */
  26578. diffuseFresnelParameters: FresnelParameters;
  26579. private _opacityFresnelParameters;
  26580. /**
  26581. * Define the opacity fresnel parameters of the material.
  26582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26583. */
  26584. opacityFresnelParameters: FresnelParameters;
  26585. private _reflectionFresnelParameters;
  26586. /**
  26587. * Define the reflection fresnel parameters of the material.
  26588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26589. */
  26590. reflectionFresnelParameters: FresnelParameters;
  26591. private _refractionFresnelParameters;
  26592. /**
  26593. * Define the refraction fresnel parameters of the material.
  26594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26595. */
  26596. refractionFresnelParameters: FresnelParameters;
  26597. private _emissiveFresnelParameters;
  26598. /**
  26599. * Define the emissive fresnel parameters of the material.
  26600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26601. */
  26602. emissiveFresnelParameters: FresnelParameters;
  26603. private _useReflectionFresnelFromSpecular;
  26604. /**
  26605. * If true automatically deducts the fresnels values from the material specularity.
  26606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26607. */
  26608. useReflectionFresnelFromSpecular: boolean;
  26609. private _useGlossinessFromSpecularMapAlpha;
  26610. /**
  26611. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26612. */
  26613. useGlossinessFromSpecularMapAlpha: boolean;
  26614. private _maxSimultaneousLights;
  26615. /**
  26616. * Defines the maximum number of lights that can be used in the material
  26617. */
  26618. maxSimultaneousLights: number;
  26619. private _invertNormalMapX;
  26620. /**
  26621. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26622. */
  26623. invertNormalMapX: boolean;
  26624. private _invertNormalMapY;
  26625. /**
  26626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26627. */
  26628. invertNormalMapY: boolean;
  26629. private _twoSidedLighting;
  26630. /**
  26631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26632. */
  26633. twoSidedLighting: boolean;
  26634. /**
  26635. * Default configuration related to image processing available in the standard Material.
  26636. */
  26637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26638. /**
  26639. * Gets the image processing configuration used either in this material.
  26640. */
  26641. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26642. /**
  26643. * Sets the Default image processing configuration used either in the this material.
  26644. *
  26645. * If sets to null, the scene one is in use.
  26646. */
  26647. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26648. /**
  26649. * Keep track of the image processing observer to allow dispose and replace.
  26650. */
  26651. private _imageProcessingObserver;
  26652. /**
  26653. * Attaches a new image processing configuration to the Standard Material.
  26654. * @param configuration
  26655. */
  26656. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26657. /**
  26658. * Gets wether the color curves effect is enabled.
  26659. */
  26660. get cameraColorCurvesEnabled(): boolean;
  26661. /**
  26662. * Sets wether the color curves effect is enabled.
  26663. */
  26664. set cameraColorCurvesEnabled(value: boolean);
  26665. /**
  26666. * Gets wether the color grading effect is enabled.
  26667. */
  26668. get cameraColorGradingEnabled(): boolean;
  26669. /**
  26670. * Gets wether the color grading effect is enabled.
  26671. */
  26672. set cameraColorGradingEnabled(value: boolean);
  26673. /**
  26674. * Gets wether tonemapping is enabled or not.
  26675. */
  26676. get cameraToneMappingEnabled(): boolean;
  26677. /**
  26678. * Sets wether tonemapping is enabled or not
  26679. */
  26680. set cameraToneMappingEnabled(value: boolean);
  26681. /**
  26682. * The camera exposure used on this material.
  26683. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26684. * This corresponds to a photographic exposure.
  26685. */
  26686. get cameraExposure(): number;
  26687. /**
  26688. * The camera exposure used on this material.
  26689. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26690. * This corresponds to a photographic exposure.
  26691. */
  26692. set cameraExposure(value: number);
  26693. /**
  26694. * Gets The camera contrast used on this material.
  26695. */
  26696. get cameraContrast(): number;
  26697. /**
  26698. * Sets The camera contrast used on this material.
  26699. */
  26700. set cameraContrast(value: number);
  26701. /**
  26702. * Gets the Color Grading 2D Lookup Texture.
  26703. */
  26704. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26705. /**
  26706. * Sets the Color Grading 2D Lookup Texture.
  26707. */
  26708. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26709. /**
  26710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26712. * 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;
  26713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26714. */
  26715. get cameraColorCurves(): Nullable<ColorCurves>;
  26716. /**
  26717. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26718. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26719. * 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;
  26720. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26721. */
  26722. set cameraColorCurves(value: Nullable<ColorCurves>);
  26723. /**
  26724. * Custom callback helping to override the default shader used in the material.
  26725. */
  26726. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26727. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26728. protected _worldViewProjectionMatrix: Matrix;
  26729. protected _globalAmbientColor: Color3;
  26730. protected _useLogarithmicDepth: boolean;
  26731. protected _rebuildInParallel: boolean;
  26732. /**
  26733. * Instantiates a new standard material.
  26734. * This is the default material used in Babylon. It is the best trade off between quality
  26735. * and performances.
  26736. * @see http://doc.babylonjs.com/babylon101/materials
  26737. * @param name Define the name of the material in the scene
  26738. * @param scene Define the scene the material belong to
  26739. */
  26740. constructor(name: string, scene: Scene);
  26741. /**
  26742. * Gets a boolean indicating that current material needs to register RTT
  26743. */
  26744. get hasRenderTargetTextures(): boolean;
  26745. /**
  26746. * Gets the current class name of the material e.g. "StandardMaterial"
  26747. * Mainly use in serialization.
  26748. * @returns the class name
  26749. */
  26750. getClassName(): string;
  26751. /**
  26752. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26753. * You can try switching to logarithmic depth.
  26754. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26755. */
  26756. get useLogarithmicDepth(): boolean;
  26757. set useLogarithmicDepth(value: boolean);
  26758. /**
  26759. * Specifies if the material will require alpha blending
  26760. * @returns a boolean specifying if alpha blending is needed
  26761. */
  26762. needAlphaBlending(): boolean;
  26763. /**
  26764. * Specifies if this material should be rendered in alpha test mode
  26765. * @returns a boolean specifying if an alpha test is needed.
  26766. */
  26767. needAlphaTesting(): boolean;
  26768. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26769. /**
  26770. * Get the texture used for alpha test purpose.
  26771. * @returns the diffuse texture in case of the standard material.
  26772. */
  26773. getAlphaTestTexture(): Nullable<BaseTexture>;
  26774. /**
  26775. * Get if the submesh is ready to be used and all its information available.
  26776. * Child classes can use it to update shaders
  26777. * @param mesh defines the mesh to check
  26778. * @param subMesh defines which submesh to check
  26779. * @param useInstances specifies that instances should be used
  26780. * @returns a boolean indicating that the submesh is ready or not
  26781. */
  26782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26783. /**
  26784. * Builds the material UBO layouts.
  26785. * Used internally during the effect preparation.
  26786. */
  26787. buildUniformLayout(): void;
  26788. /**
  26789. * Unbinds the material from the mesh
  26790. */
  26791. unbind(): void;
  26792. /**
  26793. * Binds the submesh to this material by preparing the effect and shader to draw
  26794. * @param world defines the world transformation matrix
  26795. * @param mesh defines the mesh containing the submesh
  26796. * @param subMesh defines the submesh to bind the material to
  26797. */
  26798. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26799. /**
  26800. * Get the list of animatables in the material.
  26801. * @returns the list of animatables object used in the material
  26802. */
  26803. getAnimatables(): IAnimatable[];
  26804. /**
  26805. * Gets the active textures from the material
  26806. * @returns an array of textures
  26807. */
  26808. getActiveTextures(): BaseTexture[];
  26809. /**
  26810. * Specifies if the material uses a texture
  26811. * @param texture defines the texture to check against the material
  26812. * @returns a boolean specifying if the material uses the texture
  26813. */
  26814. hasTexture(texture: BaseTexture): boolean;
  26815. /**
  26816. * Disposes the material
  26817. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26818. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26819. */
  26820. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26821. /**
  26822. * Makes a duplicate of the material, and gives it a new name
  26823. * @param name defines the new name for the duplicated material
  26824. * @returns the cloned material
  26825. */
  26826. clone(name: string): StandardMaterial;
  26827. /**
  26828. * Serializes this material in a JSON representation
  26829. * @returns the serialized material object
  26830. */
  26831. serialize(): any;
  26832. /**
  26833. * Creates a standard material from parsed material data
  26834. * @param source defines the JSON representation of the material
  26835. * @param scene defines the hosting scene
  26836. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26837. * @returns a new standard material
  26838. */
  26839. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26840. /**
  26841. * Are diffuse textures enabled in the application.
  26842. */
  26843. static get DiffuseTextureEnabled(): boolean;
  26844. static set DiffuseTextureEnabled(value: boolean);
  26845. /**
  26846. * Are ambient textures enabled in the application.
  26847. */
  26848. static get AmbientTextureEnabled(): boolean;
  26849. static set AmbientTextureEnabled(value: boolean);
  26850. /**
  26851. * Are opacity textures enabled in the application.
  26852. */
  26853. static get OpacityTextureEnabled(): boolean;
  26854. static set OpacityTextureEnabled(value: boolean);
  26855. /**
  26856. * Are reflection textures enabled in the application.
  26857. */
  26858. static get ReflectionTextureEnabled(): boolean;
  26859. static set ReflectionTextureEnabled(value: boolean);
  26860. /**
  26861. * Are emissive textures enabled in the application.
  26862. */
  26863. static get EmissiveTextureEnabled(): boolean;
  26864. static set EmissiveTextureEnabled(value: boolean);
  26865. /**
  26866. * Are specular textures enabled in the application.
  26867. */
  26868. static get SpecularTextureEnabled(): boolean;
  26869. static set SpecularTextureEnabled(value: boolean);
  26870. /**
  26871. * Are bump textures enabled in the application.
  26872. */
  26873. static get BumpTextureEnabled(): boolean;
  26874. static set BumpTextureEnabled(value: boolean);
  26875. /**
  26876. * Are lightmap textures enabled in the application.
  26877. */
  26878. static get LightmapTextureEnabled(): boolean;
  26879. static set LightmapTextureEnabled(value: boolean);
  26880. /**
  26881. * Are refraction textures enabled in the application.
  26882. */
  26883. static get RefractionTextureEnabled(): boolean;
  26884. static set RefractionTextureEnabled(value: boolean);
  26885. /**
  26886. * Are color grading textures enabled in the application.
  26887. */
  26888. static get ColorGradingTextureEnabled(): boolean;
  26889. static set ColorGradingTextureEnabled(value: boolean);
  26890. /**
  26891. * Are fresnels enabled in the application.
  26892. */
  26893. static get FresnelEnabled(): boolean;
  26894. static set FresnelEnabled(value: boolean);
  26895. }
  26896. }
  26897. declare module BABYLON {
  26898. /**
  26899. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26900. *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.
  26901. * The SPS is also a particle system. It provides some methods to manage the particles.
  26902. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26903. *
  26904. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26905. */
  26906. export class SolidParticleSystem implements IDisposable {
  26907. /**
  26908. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26909. * Example : var p = SPS.particles[i];
  26910. */
  26911. particles: SolidParticle[];
  26912. /**
  26913. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26914. */
  26915. nbParticles: number;
  26916. /**
  26917. * If the particles must ever face the camera (default false). Useful for planar particles.
  26918. */
  26919. billboard: boolean;
  26920. /**
  26921. * Recompute normals when adding a shape
  26922. */
  26923. recomputeNormals: boolean;
  26924. /**
  26925. * This a counter ofr your own usage. It's not set by any SPS functions.
  26926. */
  26927. counter: number;
  26928. /**
  26929. * The SPS name. This name is also given to the underlying mesh.
  26930. */
  26931. name: string;
  26932. /**
  26933. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26934. */
  26935. mesh: Mesh;
  26936. /**
  26937. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26938. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26939. */
  26940. vars: any;
  26941. /**
  26942. * This array is populated when the SPS is set as 'pickable'.
  26943. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26944. * Each element of this array is an object `{idx: int, faceId: int}`.
  26945. * `idx` is the picked particle index in the `SPS.particles` array
  26946. * `faceId` is the picked face index counted within this particle.
  26947. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26948. */
  26949. pickedParticles: {
  26950. idx: number;
  26951. faceId: number;
  26952. }[];
  26953. /**
  26954. * This array is populated when `enableDepthSort` is set to true.
  26955. * Each element of this array is an instance of the class DepthSortedParticle.
  26956. */
  26957. depthSortedParticles: DepthSortedParticle[];
  26958. /**
  26959. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26960. * @hidden
  26961. */
  26962. _bSphereOnly: boolean;
  26963. /**
  26964. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26965. * @hidden
  26966. */
  26967. _bSphereRadiusFactor: number;
  26968. private _scene;
  26969. private _positions;
  26970. private _indices;
  26971. private _normals;
  26972. private _colors;
  26973. private _uvs;
  26974. private _indices32;
  26975. private _positions32;
  26976. private _normals32;
  26977. private _fixedNormal32;
  26978. private _colors32;
  26979. private _uvs32;
  26980. private _index;
  26981. private _updatable;
  26982. private _pickable;
  26983. private _isVisibilityBoxLocked;
  26984. private _alwaysVisible;
  26985. private _depthSort;
  26986. private _expandable;
  26987. private _shapeCounter;
  26988. private _copy;
  26989. private _color;
  26990. private _computeParticleColor;
  26991. private _computeParticleTexture;
  26992. private _computeParticleRotation;
  26993. private _computeParticleVertex;
  26994. private _computeBoundingBox;
  26995. private _depthSortParticles;
  26996. private _camera;
  26997. private _mustUnrotateFixedNormals;
  26998. private _particlesIntersect;
  26999. private _needs32Bits;
  27000. private _isNotBuilt;
  27001. private _lastParticleId;
  27002. private _idxOfId;
  27003. private _multimaterialEnabled;
  27004. private _useModelMaterial;
  27005. private _indicesByMaterial;
  27006. private _materialIndexes;
  27007. private _depthSortFunction;
  27008. private _materialSortFunction;
  27009. private _materials;
  27010. private _multimaterial;
  27011. private _materialIndexesById;
  27012. private _defaultMaterial;
  27013. private _autoUpdateSubMeshes;
  27014. /**
  27015. * Creates a SPS (Solid Particle System) object.
  27016. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27017. * @param scene (Scene) is the scene in which the SPS is added.
  27018. * @param options defines the options of the sps e.g.
  27019. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27020. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27021. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27022. * * 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.
  27023. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27024. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27025. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27026. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27027. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27028. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27029. */
  27030. constructor(name: string, scene: Scene, options?: {
  27031. updatable?: boolean;
  27032. isPickable?: boolean;
  27033. enableDepthSort?: boolean;
  27034. particleIntersection?: boolean;
  27035. boundingSphereOnly?: boolean;
  27036. bSphereRadiusFactor?: number;
  27037. expandable?: boolean;
  27038. useModelMaterial?: boolean;
  27039. enableMultiMaterial?: boolean;
  27040. });
  27041. /**
  27042. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27043. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27044. * @returns the created mesh
  27045. */
  27046. buildMesh(): Mesh;
  27047. /**
  27048. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27049. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27050. * Thus the particles generated from `digest()` have their property `position` set yet.
  27051. * @param mesh ( Mesh ) is the mesh to be digested
  27052. * @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
  27053. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27054. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27055. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27056. * @returns the current SPS
  27057. */
  27058. digest(mesh: Mesh, options?: {
  27059. facetNb?: number;
  27060. number?: number;
  27061. delta?: number;
  27062. storage?: [];
  27063. }): SolidParticleSystem;
  27064. /**
  27065. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27066. * @hidden
  27067. */
  27068. private _unrotateFixedNormals;
  27069. /**
  27070. * Resets the temporary working copy particle
  27071. * @hidden
  27072. */
  27073. private _resetCopy;
  27074. /**
  27075. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27076. * @param p the current index in the positions array to be updated
  27077. * @param ind the current index in the indices array
  27078. * @param shape a Vector3 array, the shape geometry
  27079. * @param positions the positions array to be updated
  27080. * @param meshInd the shape indices array
  27081. * @param indices the indices array to be updated
  27082. * @param meshUV the shape uv array
  27083. * @param uvs the uv array to be updated
  27084. * @param meshCol the shape color array
  27085. * @param colors the color array to be updated
  27086. * @param meshNor the shape normals array
  27087. * @param normals the normals array to be updated
  27088. * @param idx the particle index
  27089. * @param idxInShape the particle index in its shape
  27090. * @param options the addShape() method passed options
  27091. * @model the particle model
  27092. * @hidden
  27093. */
  27094. private _meshBuilder;
  27095. /**
  27096. * Returns a shape Vector3 array from positions float array
  27097. * @param positions float array
  27098. * @returns a vector3 array
  27099. * @hidden
  27100. */
  27101. private _posToShape;
  27102. /**
  27103. * Returns a shapeUV array from a float uvs (array deep copy)
  27104. * @param uvs as a float array
  27105. * @returns a shapeUV array
  27106. * @hidden
  27107. */
  27108. private _uvsToShapeUV;
  27109. /**
  27110. * Adds a new particle object in the particles array
  27111. * @param idx particle index in particles array
  27112. * @param id particle id
  27113. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27114. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27115. * @param model particle ModelShape object
  27116. * @param shapeId model shape identifier
  27117. * @param idxInShape index of the particle in the current model
  27118. * @param bInfo model bounding info object
  27119. * @param storage target storage array, if any
  27120. * @hidden
  27121. */
  27122. private _addParticle;
  27123. /**
  27124. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27125. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27126. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27127. * @param nb (positive integer) the number of particles to be created from this model
  27128. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27129. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27130. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27131. * @returns the number of shapes in the system
  27132. */
  27133. addShape(mesh: Mesh, nb: number, options?: {
  27134. positionFunction?: any;
  27135. vertexFunction?: any;
  27136. storage?: [];
  27137. }): number;
  27138. /**
  27139. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27140. * @hidden
  27141. */
  27142. private _rebuildParticle;
  27143. /**
  27144. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27145. * @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.
  27146. * @returns the SPS.
  27147. */
  27148. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27149. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27150. * Returns an array with the removed particles.
  27151. * 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.
  27152. * The SPS can't be empty so at least one particle needs to remain in place.
  27153. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27154. * @param start index of the first particle to remove
  27155. * @param end index of the last particle to remove (included)
  27156. * @returns an array populated with the removed particles
  27157. */
  27158. removeParticles(start: number, end: number): SolidParticle[];
  27159. /**
  27160. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27161. * @param solidParticleArray an array populated with Solid Particles objects
  27162. * @returns the SPS
  27163. */
  27164. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27165. /**
  27166. * Creates a new particle and modifies the SPS mesh geometry :
  27167. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27168. * - calls _addParticle() to populate the particle array
  27169. * factorized code from addShape() and insertParticlesFromArray()
  27170. * @param idx particle index in the particles array
  27171. * @param i particle index in its shape
  27172. * @param modelShape particle ModelShape object
  27173. * @param shape shape vertex array
  27174. * @param meshInd shape indices array
  27175. * @param meshUV shape uv array
  27176. * @param meshCol shape color array
  27177. * @param meshNor shape normals array
  27178. * @param bbInfo shape bounding info
  27179. * @param storage target particle storage
  27180. * @options addShape() passed options
  27181. * @hidden
  27182. */
  27183. private _insertNewParticle;
  27184. /**
  27185. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27186. * This method calls `updateParticle()` for each particle of the SPS.
  27187. * For an animated SPS, it is usually called within the render loop.
  27188. * 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.
  27189. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27190. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27191. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27192. * @returns the SPS.
  27193. */
  27194. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27195. /**
  27196. * Disposes the SPS.
  27197. */
  27198. dispose(): void;
  27199. /**
  27200. * Returns a SolidParticle object from its identifier : particle.id
  27201. * @param id (integer) the particle Id
  27202. * @returns the searched particle or null if not found in the SPS.
  27203. */
  27204. getParticleById(id: number): Nullable<SolidParticle>;
  27205. /**
  27206. * Returns a new array populated with the particles having the passed shapeId.
  27207. * @param shapeId (integer) the shape identifier
  27208. * @returns a new solid particle array
  27209. */
  27210. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27211. /**
  27212. * Populates the passed array "ref" with the particles having the passed shapeId.
  27213. * @param shapeId the shape identifier
  27214. * @returns the SPS
  27215. * @param ref
  27216. */
  27217. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27218. /**
  27219. * Computes the required SubMeshes according the materials assigned to the particles.
  27220. * @returns the solid particle system.
  27221. * Does nothing if called before the SPS mesh is built.
  27222. */
  27223. computeSubMeshes(): SolidParticleSystem;
  27224. /**
  27225. * Sorts the solid particles by material when MultiMaterial is enabled.
  27226. * Updates the indices32 array.
  27227. * Updates the indicesByMaterial array.
  27228. * Updates the mesh indices array.
  27229. * @returns the SPS
  27230. * @hidden
  27231. */
  27232. private _sortParticlesByMaterial;
  27233. /**
  27234. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27235. * @hidden
  27236. */
  27237. private _setMaterialIndexesById;
  27238. /**
  27239. * Returns an array with unique values of Materials from the passed array
  27240. * @param array the material array to be checked and filtered
  27241. * @hidden
  27242. */
  27243. private _filterUniqueMaterialId;
  27244. /**
  27245. * Sets a new Standard Material as _defaultMaterial if not already set.
  27246. * @hidden
  27247. */
  27248. private _setDefaultMaterial;
  27249. /**
  27250. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27252. * @returns the SPS.
  27253. */
  27254. refreshVisibleSize(): SolidParticleSystem;
  27255. /**
  27256. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27257. * @param size the size (float) of the visibility box
  27258. * note : this doesn't lock the SPS mesh bounding box.
  27259. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27260. */
  27261. setVisibilityBox(size: number): void;
  27262. /**
  27263. * Gets whether the SPS as always visible or not
  27264. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27265. */
  27266. get isAlwaysVisible(): boolean;
  27267. /**
  27268. * Sets the SPS as always visible or not
  27269. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27270. */
  27271. set isAlwaysVisible(val: boolean);
  27272. /**
  27273. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27274. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27275. */
  27276. set isVisibilityBoxLocked(val: boolean);
  27277. /**
  27278. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27279. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27280. */
  27281. get isVisibilityBoxLocked(): boolean;
  27282. /**
  27283. * Tells to `setParticles()` to compute the particle rotations or not.
  27284. * Default value : true. The SPS is faster when it's set to false.
  27285. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27286. */
  27287. set computeParticleRotation(val: boolean);
  27288. /**
  27289. * Tells to `setParticles()` to compute the particle colors or not.
  27290. * Default value : true. The SPS is faster when it's set to false.
  27291. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27292. */
  27293. set computeParticleColor(val: boolean);
  27294. set computeParticleTexture(val: boolean);
  27295. /**
  27296. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27297. * Default value : false. The SPS is faster when it's set to false.
  27298. * Note : the particle custom vertex positions aren't stored values.
  27299. */
  27300. set computeParticleVertex(val: boolean);
  27301. /**
  27302. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27303. */
  27304. set computeBoundingBox(val: boolean);
  27305. /**
  27306. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27307. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27308. * Default : `true`
  27309. */
  27310. set depthSortParticles(val: boolean);
  27311. /**
  27312. * Gets if `setParticles()` computes the particle rotations or not.
  27313. * Default value : true. The SPS is faster when it's set to false.
  27314. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27315. */
  27316. get computeParticleRotation(): boolean;
  27317. /**
  27318. * Gets if `setParticles()` computes the particle colors or not.
  27319. * Default value : true. The SPS is faster when it's set to false.
  27320. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27321. */
  27322. get computeParticleColor(): boolean;
  27323. /**
  27324. * Gets if `setParticles()` computes the particle textures or not.
  27325. * Default value : true. The SPS is faster when it's set to false.
  27326. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27327. */
  27328. get computeParticleTexture(): boolean;
  27329. /**
  27330. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27331. * Default value : false. The SPS is faster when it's set to false.
  27332. * Note : the particle custom vertex positions aren't stored values.
  27333. */
  27334. get computeParticleVertex(): boolean;
  27335. /**
  27336. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27337. */
  27338. get computeBoundingBox(): boolean;
  27339. /**
  27340. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27341. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27342. * Default : `true`
  27343. */
  27344. get depthSortParticles(): boolean;
  27345. /**
  27346. * Gets if the SPS is created as expandable at construction time.
  27347. * Default : `false`
  27348. */
  27349. get expandable(): boolean;
  27350. /**
  27351. * Gets if the SPS supports the Multi Materials
  27352. */
  27353. get multimaterialEnabled(): boolean;
  27354. /**
  27355. * Gets if the SPS uses the model materials for its own multimaterial.
  27356. */
  27357. get useModelMaterial(): boolean;
  27358. /**
  27359. * The SPS used material array.
  27360. */
  27361. get materials(): Material[];
  27362. /**
  27363. * Sets the SPS MultiMaterial from the passed materials.
  27364. * Note : the passed array is internally copied and not used then by reference.
  27365. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27366. */
  27367. setMultiMaterial(materials: Material[]): void;
  27368. /**
  27369. * The SPS computed multimaterial object
  27370. */
  27371. get multimaterial(): MultiMaterial;
  27372. set multimaterial(mm: MultiMaterial);
  27373. /**
  27374. * If the subMeshes must be updated on the next call to setParticles()
  27375. */
  27376. get autoUpdateSubMeshes(): boolean;
  27377. set autoUpdateSubMeshes(val: boolean);
  27378. /**
  27379. * This function does nothing. It may be overwritten to set all the particle first values.
  27380. * The SPS doesn't call this function, you may have to call it by your own.
  27381. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27382. */
  27383. initParticles(): void;
  27384. /**
  27385. * This function does nothing. It may be overwritten to recycle a particle.
  27386. * The SPS doesn't call this function, you may have to call it by your own.
  27387. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27388. * @param particle The particle to recycle
  27389. * @returns the recycled particle
  27390. */
  27391. recycleParticle(particle: SolidParticle): SolidParticle;
  27392. /**
  27393. * Updates a particle : this function should be overwritten by the user.
  27394. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27395. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27396. * @example : just set a particle position or velocity and recycle conditions
  27397. * @param particle The particle to update
  27398. * @returns the updated particle
  27399. */
  27400. updateParticle(particle: SolidParticle): SolidParticle;
  27401. /**
  27402. * Updates a vertex of a particle : it can be overwritten by the user.
  27403. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27404. * @param particle the current particle
  27405. * @param vertex the current index of the current particle
  27406. * @param pt the index of the current vertex in the particle shape
  27407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27408. * @example : just set a vertex particle position
  27409. * @returns the updated vertex
  27410. */
  27411. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27412. /**
  27413. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27414. * This does nothing and may be overwritten by the user.
  27415. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27416. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27417. * @param update the boolean update value actually passed to setParticles()
  27418. */
  27419. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27420. /**
  27421. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27422. * This will be passed three parameters.
  27423. * This does nothing and may be overwritten by the user.
  27424. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27425. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27426. * @param update the boolean update value actually passed to setParticles()
  27427. */
  27428. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27429. }
  27430. }
  27431. declare module BABYLON {
  27432. /**
  27433. * Represents one particle of a solid particle system.
  27434. */
  27435. export class SolidParticle {
  27436. /**
  27437. * particle global index
  27438. */
  27439. idx: number;
  27440. /**
  27441. * particle identifier
  27442. */
  27443. id: number;
  27444. /**
  27445. * The color of the particle
  27446. */
  27447. color: Nullable<Color4>;
  27448. /**
  27449. * The world space position of the particle.
  27450. */
  27451. position: Vector3;
  27452. /**
  27453. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27454. */
  27455. rotation: Vector3;
  27456. /**
  27457. * The world space rotation quaternion of the particle.
  27458. */
  27459. rotationQuaternion: Nullable<Quaternion>;
  27460. /**
  27461. * The scaling of the particle.
  27462. */
  27463. scaling: Vector3;
  27464. /**
  27465. * The uvs of the particle.
  27466. */
  27467. uvs: Vector4;
  27468. /**
  27469. * The current speed of the particle.
  27470. */
  27471. velocity: Vector3;
  27472. /**
  27473. * The pivot point in the particle local space.
  27474. */
  27475. pivot: Vector3;
  27476. /**
  27477. * Must the particle be translated from its pivot point in its local space ?
  27478. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27479. * Default : false
  27480. */
  27481. translateFromPivot: boolean;
  27482. /**
  27483. * Is the particle active or not ?
  27484. */
  27485. alive: boolean;
  27486. /**
  27487. * Is the particle visible or not ?
  27488. */
  27489. isVisible: boolean;
  27490. /**
  27491. * Index of this particle in the global "positions" array (Internal use)
  27492. * @hidden
  27493. */
  27494. _pos: number;
  27495. /**
  27496. * @hidden Index of this particle in the global "indices" array (Internal use)
  27497. */
  27498. _ind: number;
  27499. /**
  27500. * @hidden ModelShape of this particle (Internal use)
  27501. */
  27502. _model: ModelShape;
  27503. /**
  27504. * ModelShape id of this particle
  27505. */
  27506. shapeId: number;
  27507. /**
  27508. * Index of the particle in its shape id
  27509. */
  27510. idxInShape: number;
  27511. /**
  27512. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27513. */
  27514. _modelBoundingInfo: BoundingInfo;
  27515. /**
  27516. * @hidden Particle BoundingInfo object (Internal use)
  27517. */
  27518. _boundingInfo: BoundingInfo;
  27519. /**
  27520. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27521. */
  27522. _sps: SolidParticleSystem;
  27523. /**
  27524. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27525. */
  27526. _stillInvisible: boolean;
  27527. /**
  27528. * @hidden Last computed particle rotation matrix
  27529. */
  27530. _rotationMatrix: number[];
  27531. /**
  27532. * Parent particle Id, if any.
  27533. * Default null.
  27534. */
  27535. parentId: Nullable<number>;
  27536. /**
  27537. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27538. */
  27539. materialIndex: Nullable<number>;
  27540. /**
  27541. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27542. * The possible values are :
  27543. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27544. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27545. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27546. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27547. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27548. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27549. * */
  27550. cullingStrategy: number;
  27551. /**
  27552. * @hidden Internal global position in the SPS.
  27553. */
  27554. _globalPosition: Vector3;
  27555. /**
  27556. * Creates a Solid Particle object.
  27557. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27558. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27559. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27560. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27561. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27562. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27563. * @param shapeId (integer) is the model shape identifier in the SPS.
  27564. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27565. * @param sps defines the sps it is associated to
  27566. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27567. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27568. */
  27569. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27570. /**
  27571. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27572. * @param target the particle target
  27573. * @returns the current particle
  27574. */
  27575. copyToRef(target: SolidParticle): SolidParticle;
  27576. /**
  27577. * Legacy support, changed scale to scaling
  27578. */
  27579. get scale(): Vector3;
  27580. /**
  27581. * Legacy support, changed scale to scaling
  27582. */
  27583. set scale(scale: Vector3);
  27584. /**
  27585. * Legacy support, changed quaternion to rotationQuaternion
  27586. */
  27587. get quaternion(): Nullable<Quaternion>;
  27588. /**
  27589. * Legacy support, changed quaternion to rotationQuaternion
  27590. */
  27591. set quaternion(q: Nullable<Quaternion>);
  27592. /**
  27593. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27594. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27595. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27596. * @returns true if it intersects
  27597. */
  27598. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27599. /**
  27600. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27601. * A particle is in the frustum if its bounding box intersects the frustum
  27602. * @param frustumPlanes defines the frustum to test
  27603. * @returns true if the particle is in the frustum planes
  27604. */
  27605. isInFrustum(frustumPlanes: Plane[]): boolean;
  27606. /**
  27607. * get the rotation matrix of the particle
  27608. * @hidden
  27609. */
  27610. getRotationMatrix(m: Matrix): void;
  27611. }
  27612. /**
  27613. * Represents the shape of the model used by one particle of a solid particle system.
  27614. * SPS internal tool, don't use it manually.
  27615. */
  27616. export class ModelShape {
  27617. /**
  27618. * The shape id
  27619. * @hidden
  27620. */
  27621. shapeID: number;
  27622. /**
  27623. * flat array of model positions (internal use)
  27624. * @hidden
  27625. */
  27626. _shape: Vector3[];
  27627. /**
  27628. * flat array of model UVs (internal use)
  27629. * @hidden
  27630. */
  27631. _shapeUV: number[];
  27632. /**
  27633. * color array of the model
  27634. * @hidden
  27635. */
  27636. _shapeColors: number[];
  27637. /**
  27638. * indices array of the model
  27639. * @hidden
  27640. */
  27641. _indices: number[];
  27642. /**
  27643. * normals array of the model
  27644. * @hidden
  27645. */
  27646. _normals: number[];
  27647. /**
  27648. * length of the shape in the model indices array (internal use)
  27649. * @hidden
  27650. */
  27651. _indicesLength: number;
  27652. /**
  27653. * Custom position function (internal use)
  27654. * @hidden
  27655. */
  27656. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27657. /**
  27658. * Custom vertex function (internal use)
  27659. * @hidden
  27660. */
  27661. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27662. /**
  27663. * Model material (internal use)
  27664. * @hidden
  27665. */
  27666. _material: Nullable<Material>;
  27667. /**
  27668. * 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.
  27669. * SPS internal tool, don't use it manually.
  27670. * @hidden
  27671. */
  27672. 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>);
  27673. }
  27674. /**
  27675. * Represents a Depth Sorted Particle in the solid particle system.
  27676. * @hidden
  27677. */
  27678. export class DepthSortedParticle {
  27679. /**
  27680. * Index of the particle in the "indices" array
  27681. */
  27682. ind: number;
  27683. /**
  27684. * Length of the particle shape in the "indices" array
  27685. */
  27686. indicesLength: number;
  27687. /**
  27688. * Squared distance from the particle to the camera
  27689. */
  27690. sqDistance: number;
  27691. /**
  27692. * Material index when used with MultiMaterials
  27693. */
  27694. materialIndex: number;
  27695. /**
  27696. * Creates a new sorted particle
  27697. * @param materialIndex
  27698. */
  27699. constructor(ind: number, indLength: number, materialIndex: number);
  27700. }
  27701. }
  27702. declare module BABYLON {
  27703. /**
  27704. * @hidden
  27705. */
  27706. export class _MeshCollisionData {
  27707. _checkCollisions: boolean;
  27708. _collisionMask: number;
  27709. _collisionGroup: number;
  27710. _collider: Nullable<Collider>;
  27711. _oldPositionForCollisions: Vector3;
  27712. _diffPositionForCollisions: Vector3;
  27713. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27714. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27715. }
  27716. }
  27717. declare module BABYLON {
  27718. /** @hidden */
  27719. class _FacetDataStorage {
  27720. facetPositions: Vector3[];
  27721. facetNormals: Vector3[];
  27722. facetPartitioning: number[][];
  27723. facetNb: number;
  27724. partitioningSubdivisions: number;
  27725. partitioningBBoxRatio: number;
  27726. facetDataEnabled: boolean;
  27727. facetParameters: any;
  27728. bbSize: Vector3;
  27729. subDiv: {
  27730. max: number;
  27731. X: number;
  27732. Y: number;
  27733. Z: number;
  27734. };
  27735. facetDepthSort: boolean;
  27736. facetDepthSortEnabled: boolean;
  27737. depthSortedIndices: IndicesArray;
  27738. depthSortedFacets: {
  27739. ind: number;
  27740. sqDistance: number;
  27741. }[];
  27742. facetDepthSortFunction: (f1: {
  27743. ind: number;
  27744. sqDistance: number;
  27745. }, f2: {
  27746. ind: number;
  27747. sqDistance: number;
  27748. }) => number;
  27749. facetDepthSortFrom: Vector3;
  27750. facetDepthSortOrigin: Vector3;
  27751. invertedMatrix: Matrix;
  27752. }
  27753. /**
  27754. * @hidden
  27755. **/
  27756. class _InternalAbstractMeshDataInfo {
  27757. _hasVertexAlpha: boolean;
  27758. _useVertexColors: boolean;
  27759. _numBoneInfluencers: number;
  27760. _applyFog: boolean;
  27761. _receiveShadows: boolean;
  27762. _facetData: _FacetDataStorage;
  27763. _visibility: number;
  27764. _skeleton: Nullable<Skeleton>;
  27765. _layerMask: number;
  27766. _computeBonesUsingShaders: boolean;
  27767. _isActive: boolean;
  27768. _onlyForInstances: boolean;
  27769. _isActiveIntermediate: boolean;
  27770. _onlyForInstancesIntermediate: boolean;
  27771. _actAsRegularMesh: boolean;
  27772. }
  27773. /**
  27774. * Class used to store all common mesh properties
  27775. */
  27776. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27777. /** No occlusion */
  27778. static OCCLUSION_TYPE_NONE: number;
  27779. /** Occlusion set to optimisitic */
  27780. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27781. /** Occlusion set to strict */
  27782. static OCCLUSION_TYPE_STRICT: number;
  27783. /** Use an accurante occlusion algorithm */
  27784. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27785. /** Use a conservative occlusion algorithm */
  27786. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27787. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27788. * Test order :
  27789. * Is the bounding sphere outside the frustum ?
  27790. * If not, are the bounding box vertices outside the frustum ?
  27791. * It not, then the cullable object is in the frustum.
  27792. */
  27793. static readonly CULLINGSTRATEGY_STANDARD: number;
  27794. /** Culling strategy : Bounding Sphere Only.
  27795. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27796. * It's also less accurate than the standard because some not visible objects can still be selected.
  27797. * Test : is the bounding sphere outside the frustum ?
  27798. * If not, then the cullable object is in the frustum.
  27799. */
  27800. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27801. /** Culling strategy : Optimistic Inclusion.
  27802. * This in an inclusion test first, then the standard exclusion test.
  27803. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27804. * 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.
  27805. * Anyway, it's as accurate as the standard strategy.
  27806. * Test :
  27807. * Is the cullable object bounding sphere center in the frustum ?
  27808. * If not, apply the default culling strategy.
  27809. */
  27810. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27811. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27812. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27813. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27814. * 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.
  27815. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27816. * Test :
  27817. * Is the cullable object bounding sphere center in the frustum ?
  27818. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27819. */
  27820. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27821. /**
  27822. * No billboard
  27823. */
  27824. static get BILLBOARDMODE_NONE(): number;
  27825. /** Billboard on X axis */
  27826. static get BILLBOARDMODE_X(): number;
  27827. /** Billboard on Y axis */
  27828. static get BILLBOARDMODE_Y(): number;
  27829. /** Billboard on Z axis */
  27830. static get BILLBOARDMODE_Z(): number;
  27831. /** Billboard on all axes */
  27832. static get BILLBOARDMODE_ALL(): number;
  27833. /** Billboard on using position instead of orientation */
  27834. static get BILLBOARDMODE_USE_POSITION(): number;
  27835. /** @hidden */
  27836. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27837. /**
  27838. * The culling strategy to use to check whether the mesh must be rendered or not.
  27839. * This value can be changed at any time and will be used on the next render mesh selection.
  27840. * The possible values are :
  27841. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27842. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27843. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27844. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27845. * Please read each static variable documentation to get details about the culling process.
  27846. * */
  27847. cullingStrategy: number;
  27848. /**
  27849. * Gets the number of facets in the mesh
  27850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27851. */
  27852. get facetNb(): number;
  27853. /**
  27854. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27856. */
  27857. get partitioningSubdivisions(): number;
  27858. set partitioningSubdivisions(nb: number);
  27859. /**
  27860. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27861. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27863. */
  27864. get partitioningBBoxRatio(): number;
  27865. set partitioningBBoxRatio(ratio: number);
  27866. /**
  27867. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27868. * Works only for updatable meshes.
  27869. * Doesn't work with multi-materials
  27870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27871. */
  27872. get mustDepthSortFacets(): boolean;
  27873. set mustDepthSortFacets(sort: boolean);
  27874. /**
  27875. * The location (Vector3) where the facet depth sort must be computed from.
  27876. * By default, the active camera position.
  27877. * Used only when facet depth sort is enabled
  27878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27879. */
  27880. get facetDepthSortFrom(): Vector3;
  27881. set facetDepthSortFrom(location: Vector3);
  27882. /**
  27883. * gets a boolean indicating if facetData is enabled
  27884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27885. */
  27886. get isFacetDataEnabled(): boolean;
  27887. /** @hidden */
  27888. _updateNonUniformScalingState(value: boolean): boolean;
  27889. /**
  27890. * An event triggered when this mesh collides with another one
  27891. */
  27892. onCollideObservable: Observable<AbstractMesh>;
  27893. /** Set a function to call when this mesh collides with another one */
  27894. set onCollide(callback: () => void);
  27895. /**
  27896. * An event triggered when the collision's position changes
  27897. */
  27898. onCollisionPositionChangeObservable: Observable<Vector3>;
  27899. /** Set a function to call when the collision's position changes */
  27900. set onCollisionPositionChange(callback: () => void);
  27901. /**
  27902. * An event triggered when material is changed
  27903. */
  27904. onMaterialChangedObservable: Observable<AbstractMesh>;
  27905. /**
  27906. * Gets or sets the orientation for POV movement & rotation
  27907. */
  27908. definedFacingForward: boolean;
  27909. /** @hidden */
  27910. _occlusionQuery: Nullable<WebGLQuery>;
  27911. /** @hidden */
  27912. _renderingGroup: Nullable<RenderingGroup>;
  27913. /**
  27914. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27915. */
  27916. get visibility(): number;
  27917. /**
  27918. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27919. */
  27920. set visibility(value: number);
  27921. /** Gets or sets the alpha index used to sort transparent meshes
  27922. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27923. */
  27924. alphaIndex: number;
  27925. /**
  27926. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27927. */
  27928. isVisible: boolean;
  27929. /**
  27930. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27931. */
  27932. isPickable: boolean;
  27933. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27934. showSubMeshesBoundingBox: boolean;
  27935. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27936. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27937. */
  27938. isBlocker: boolean;
  27939. /**
  27940. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27941. */
  27942. enablePointerMoveEvents: boolean;
  27943. /**
  27944. * Specifies the rendering group id for this mesh (0 by default)
  27945. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27946. */
  27947. renderingGroupId: number;
  27948. private _material;
  27949. /** Gets or sets current material */
  27950. get material(): Nullable<Material>;
  27951. set material(value: Nullable<Material>);
  27952. /**
  27953. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27954. * @see http://doc.babylonjs.com/babylon101/shadows
  27955. */
  27956. get receiveShadows(): boolean;
  27957. set receiveShadows(value: boolean);
  27958. /** Defines color to use when rendering outline */
  27959. outlineColor: Color3;
  27960. /** Define width to use when rendering outline */
  27961. outlineWidth: number;
  27962. /** Defines color to use when rendering overlay */
  27963. overlayColor: Color3;
  27964. /** Defines alpha to use when rendering overlay */
  27965. overlayAlpha: number;
  27966. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27967. get hasVertexAlpha(): boolean;
  27968. set hasVertexAlpha(value: boolean);
  27969. /** 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) */
  27970. get useVertexColors(): boolean;
  27971. set useVertexColors(value: boolean);
  27972. /**
  27973. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27974. */
  27975. get computeBonesUsingShaders(): boolean;
  27976. set computeBonesUsingShaders(value: boolean);
  27977. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27978. get numBoneInfluencers(): number;
  27979. set numBoneInfluencers(value: number);
  27980. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27981. get applyFog(): boolean;
  27982. set applyFog(value: boolean);
  27983. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27984. useOctreeForRenderingSelection: boolean;
  27985. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27986. useOctreeForPicking: boolean;
  27987. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27988. useOctreeForCollisions: boolean;
  27989. /**
  27990. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27991. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27992. */
  27993. get layerMask(): number;
  27994. set layerMask(value: number);
  27995. /**
  27996. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27997. */
  27998. alwaysSelectAsActiveMesh: boolean;
  27999. /**
  28000. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28001. */
  28002. doNotSyncBoundingInfo: boolean;
  28003. /**
  28004. * Gets or sets the current action manager
  28005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28006. */
  28007. actionManager: Nullable<AbstractActionManager>;
  28008. private _meshCollisionData;
  28009. /**
  28010. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28011. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28012. */
  28013. ellipsoid: Vector3;
  28014. /**
  28015. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28017. */
  28018. ellipsoidOffset: Vector3;
  28019. /**
  28020. * Gets or sets a collision mask used to mask collisions (default is -1).
  28021. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28022. */
  28023. get collisionMask(): number;
  28024. set collisionMask(mask: number);
  28025. /**
  28026. * Gets or sets the current collision group mask (-1 by default).
  28027. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28028. */
  28029. get collisionGroup(): number;
  28030. set collisionGroup(mask: number);
  28031. /**
  28032. * Defines edge width used when edgesRenderer is enabled
  28033. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28034. */
  28035. edgesWidth: number;
  28036. /**
  28037. * Defines edge color used when edgesRenderer is enabled
  28038. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28039. */
  28040. edgesColor: Color4;
  28041. /** @hidden */
  28042. _edgesRenderer: Nullable<IEdgesRenderer>;
  28043. /** @hidden */
  28044. _masterMesh: Nullable<AbstractMesh>;
  28045. /** @hidden */
  28046. _boundingInfo: Nullable<BoundingInfo>;
  28047. /** @hidden */
  28048. _renderId: number;
  28049. /**
  28050. * Gets or sets the list of subMeshes
  28051. * @see http://doc.babylonjs.com/how_to/multi_materials
  28052. */
  28053. subMeshes: SubMesh[];
  28054. /** @hidden */
  28055. _intersectionsInProgress: AbstractMesh[];
  28056. /** @hidden */
  28057. _unIndexed: boolean;
  28058. /** @hidden */
  28059. _lightSources: Light[];
  28060. /** Gets the list of lights affecting that mesh */
  28061. get lightSources(): Light[];
  28062. /** @hidden */
  28063. get _positions(): Nullable<Vector3[]>;
  28064. /** @hidden */
  28065. _waitingData: {
  28066. lods: Nullable<any>;
  28067. actions: Nullable<any>;
  28068. freezeWorldMatrix: Nullable<boolean>;
  28069. };
  28070. /** @hidden */
  28071. _bonesTransformMatrices: Nullable<Float32Array>;
  28072. /** @hidden */
  28073. _transformMatrixTexture: Nullable<RawTexture>;
  28074. /**
  28075. * Gets or sets a skeleton to apply skining transformations
  28076. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28077. */
  28078. set skeleton(value: Nullable<Skeleton>);
  28079. get skeleton(): Nullable<Skeleton>;
  28080. /**
  28081. * An event triggered when the mesh is rebuilt.
  28082. */
  28083. onRebuildObservable: Observable<AbstractMesh>;
  28084. /**
  28085. * Creates a new AbstractMesh
  28086. * @param name defines the name of the mesh
  28087. * @param scene defines the hosting scene
  28088. */
  28089. constructor(name: string, scene?: Nullable<Scene>);
  28090. /**
  28091. * Returns the string "AbstractMesh"
  28092. * @returns "AbstractMesh"
  28093. */
  28094. getClassName(): string;
  28095. /**
  28096. * Gets a string representation of the current mesh
  28097. * @param fullDetails defines a boolean indicating if full details must be included
  28098. * @returns a string representation of the current mesh
  28099. */
  28100. toString(fullDetails?: boolean): string;
  28101. /**
  28102. * @hidden
  28103. */
  28104. protected _getEffectiveParent(): Nullable<Node>;
  28105. /** @hidden */
  28106. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28107. /** @hidden */
  28108. _rebuild(): void;
  28109. /** @hidden */
  28110. _resyncLightSources(): void;
  28111. /** @hidden */
  28112. _resyncLightSource(light: Light): void;
  28113. /** @hidden */
  28114. _unBindEffect(): void;
  28115. /** @hidden */
  28116. _removeLightSource(light: Light, dispose: boolean): void;
  28117. private _markSubMeshesAsDirty;
  28118. /** @hidden */
  28119. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28120. /** @hidden */
  28121. _markSubMeshesAsAttributesDirty(): void;
  28122. /** @hidden */
  28123. _markSubMeshesAsMiscDirty(): void;
  28124. /**
  28125. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28126. */
  28127. get scaling(): Vector3;
  28128. set scaling(newScaling: Vector3);
  28129. /**
  28130. * Returns true if the mesh is blocked. Implemented by child classes
  28131. */
  28132. get isBlocked(): boolean;
  28133. /**
  28134. * Returns the mesh itself by default. Implemented by child classes
  28135. * @param camera defines the camera to use to pick the right LOD level
  28136. * @returns the currentAbstractMesh
  28137. */
  28138. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28139. /**
  28140. * Returns 0 by default. Implemented by child classes
  28141. * @returns an integer
  28142. */
  28143. getTotalVertices(): number;
  28144. /**
  28145. * Returns a positive integer : the total number of indices in this mesh geometry.
  28146. * @returns the numner of indices or zero if the mesh has no geometry.
  28147. */
  28148. getTotalIndices(): number;
  28149. /**
  28150. * Returns null by default. Implemented by child classes
  28151. * @returns null
  28152. */
  28153. getIndices(): Nullable<IndicesArray>;
  28154. /**
  28155. * Returns the array of the requested vertex data kind. Implemented by child classes
  28156. * @param kind defines the vertex data kind to use
  28157. * @returns null
  28158. */
  28159. getVerticesData(kind: string): Nullable<FloatArray>;
  28160. /**
  28161. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28162. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28163. * Note that a new underlying VertexBuffer object is created each call.
  28164. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28165. * @param kind defines vertex data kind:
  28166. * * VertexBuffer.PositionKind
  28167. * * VertexBuffer.UVKind
  28168. * * VertexBuffer.UV2Kind
  28169. * * VertexBuffer.UV3Kind
  28170. * * VertexBuffer.UV4Kind
  28171. * * VertexBuffer.UV5Kind
  28172. * * VertexBuffer.UV6Kind
  28173. * * VertexBuffer.ColorKind
  28174. * * VertexBuffer.MatricesIndicesKind
  28175. * * VertexBuffer.MatricesIndicesExtraKind
  28176. * * VertexBuffer.MatricesWeightsKind
  28177. * * VertexBuffer.MatricesWeightsExtraKind
  28178. * @param data defines the data source
  28179. * @param updatable defines if the data must be flagged as updatable (or static)
  28180. * @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
  28181. * @returns the current mesh
  28182. */
  28183. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28184. /**
  28185. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28186. * If the mesh has no geometry, it is simply returned as it is.
  28187. * @param kind defines vertex data kind:
  28188. * * VertexBuffer.PositionKind
  28189. * * VertexBuffer.UVKind
  28190. * * VertexBuffer.UV2Kind
  28191. * * VertexBuffer.UV3Kind
  28192. * * VertexBuffer.UV4Kind
  28193. * * VertexBuffer.UV5Kind
  28194. * * VertexBuffer.UV6Kind
  28195. * * VertexBuffer.ColorKind
  28196. * * VertexBuffer.MatricesIndicesKind
  28197. * * VertexBuffer.MatricesIndicesExtraKind
  28198. * * VertexBuffer.MatricesWeightsKind
  28199. * * VertexBuffer.MatricesWeightsExtraKind
  28200. * @param data defines the data source
  28201. * @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
  28202. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28203. * @returns the current mesh
  28204. */
  28205. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28206. /**
  28207. * Sets the mesh indices,
  28208. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28209. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28210. * @param totalVertices Defines the total number of vertices
  28211. * @returns the current mesh
  28212. */
  28213. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28214. /**
  28215. * Gets a boolean indicating if specific vertex data is present
  28216. * @param kind defines the vertex data kind to use
  28217. * @returns true is data kind is present
  28218. */
  28219. isVerticesDataPresent(kind: string): boolean;
  28220. /**
  28221. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28222. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28223. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28224. * @returns a BoundingInfo
  28225. */
  28226. getBoundingInfo(): BoundingInfo;
  28227. /**
  28228. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28229. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28230. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28231. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28232. * @returns the current mesh
  28233. */
  28234. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28235. /**
  28236. * Overwrite the current bounding info
  28237. * @param boundingInfo defines the new bounding info
  28238. * @returns the current mesh
  28239. */
  28240. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28241. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28242. get useBones(): boolean;
  28243. /** @hidden */
  28244. _preActivate(): void;
  28245. /** @hidden */
  28246. _preActivateForIntermediateRendering(renderId: number): void;
  28247. /** @hidden */
  28248. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28249. /** @hidden */
  28250. _postActivate(): void;
  28251. /** @hidden */
  28252. _freeze(): void;
  28253. /** @hidden */
  28254. _unFreeze(): void;
  28255. /**
  28256. * Gets the current world matrix
  28257. * @returns a Matrix
  28258. */
  28259. getWorldMatrix(): Matrix;
  28260. /** @hidden */
  28261. _getWorldMatrixDeterminant(): number;
  28262. /**
  28263. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28264. */
  28265. get isAnInstance(): boolean;
  28266. /**
  28267. * Gets a boolean indicating if this mesh has instances
  28268. */
  28269. get hasInstances(): boolean;
  28270. /**
  28271. * Perform relative position change from the point of view of behind the front of the mesh.
  28272. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28273. * Supports definition of mesh facing forward or backward
  28274. * @param amountRight defines the distance on the right axis
  28275. * @param amountUp defines the distance on the up axis
  28276. * @param amountForward defines the distance on the forward axis
  28277. * @returns the current mesh
  28278. */
  28279. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28280. /**
  28281. * Calculate relative position change from the point of view of behind the front of the mesh.
  28282. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28283. * Supports definition of mesh facing forward or backward
  28284. * @param amountRight defines the distance on the right axis
  28285. * @param amountUp defines the distance on the up axis
  28286. * @param amountForward defines the distance on the forward axis
  28287. * @returns the new displacement vector
  28288. */
  28289. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28290. /**
  28291. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28292. * Supports definition of mesh facing forward or backward
  28293. * @param flipBack defines the flip
  28294. * @param twirlClockwise defines the twirl
  28295. * @param tiltRight defines the tilt
  28296. * @returns the current mesh
  28297. */
  28298. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28299. /**
  28300. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28301. * Supports definition of mesh facing forward or backward.
  28302. * @param flipBack defines the flip
  28303. * @param twirlClockwise defines the twirl
  28304. * @param tiltRight defines the tilt
  28305. * @returns the new rotation vector
  28306. */
  28307. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28308. /**
  28309. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28310. * This means the mesh underlying bounding box and sphere are recomputed.
  28311. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28312. * @returns the current mesh
  28313. */
  28314. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28315. /** @hidden */
  28316. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28317. /** @hidden */
  28318. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28319. /** @hidden */
  28320. _updateBoundingInfo(): AbstractMesh;
  28321. /** @hidden */
  28322. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28323. /** @hidden */
  28324. protected _afterComputeWorldMatrix(): void;
  28325. /** @hidden */
  28326. get _effectiveMesh(): AbstractMesh;
  28327. /**
  28328. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28329. * A mesh is in the frustum if its bounding box intersects the frustum
  28330. * @param frustumPlanes defines the frustum to test
  28331. * @returns true if the mesh is in the frustum planes
  28332. */
  28333. isInFrustum(frustumPlanes: Plane[]): boolean;
  28334. /**
  28335. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28336. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28337. * @param frustumPlanes defines the frustum to test
  28338. * @returns true if the mesh is completely in the frustum planes
  28339. */
  28340. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28341. /**
  28342. * True if the mesh intersects another mesh or a SolidParticle object
  28343. * @param mesh defines a target mesh or SolidParticle to test
  28344. * @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)
  28345. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28346. * @returns true if there is an intersection
  28347. */
  28348. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28349. /**
  28350. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28351. * @param point defines the point to test
  28352. * @returns true if there is an intersection
  28353. */
  28354. intersectsPoint(point: Vector3): boolean;
  28355. /**
  28356. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28357. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28358. */
  28359. get checkCollisions(): boolean;
  28360. set checkCollisions(collisionEnabled: boolean);
  28361. /**
  28362. * Gets Collider object used to compute collisions (not physics)
  28363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28364. */
  28365. get collider(): Nullable<Collider>;
  28366. /**
  28367. * Move the mesh using collision engine
  28368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28369. * @param displacement defines the requested displacement vector
  28370. * @returns the current mesh
  28371. */
  28372. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28373. private _onCollisionPositionChange;
  28374. /** @hidden */
  28375. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28376. /** @hidden */
  28377. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28378. /** @hidden */
  28379. _checkCollision(collider: Collider): AbstractMesh;
  28380. /** @hidden */
  28381. _generatePointsArray(): boolean;
  28382. /**
  28383. * Checks if the passed Ray intersects with the mesh
  28384. * @param ray defines the ray to use
  28385. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28386. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28387. * @returns the picking info
  28388. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28389. */
  28390. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28391. /**
  28392. * Clones the current mesh
  28393. * @param name defines the mesh name
  28394. * @param newParent defines the new mesh parent
  28395. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28396. * @returns the new mesh
  28397. */
  28398. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28399. /**
  28400. * Disposes all the submeshes of the current meshnp
  28401. * @returns the current mesh
  28402. */
  28403. releaseSubMeshes(): AbstractMesh;
  28404. /**
  28405. * Releases resources associated with this abstract mesh.
  28406. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28407. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28408. */
  28409. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28410. /**
  28411. * Adds the passed mesh as a child to the current mesh
  28412. * @param mesh defines the child mesh
  28413. * @returns the current mesh
  28414. */
  28415. addChild(mesh: AbstractMesh): AbstractMesh;
  28416. /**
  28417. * Removes the passed mesh from the current mesh children list
  28418. * @param mesh defines the child mesh
  28419. * @returns the current mesh
  28420. */
  28421. removeChild(mesh: AbstractMesh): AbstractMesh;
  28422. /** @hidden */
  28423. private _initFacetData;
  28424. /**
  28425. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28426. * This method can be called within the render loop.
  28427. * 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
  28428. * @returns the current mesh
  28429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28430. */
  28431. updateFacetData(): AbstractMesh;
  28432. /**
  28433. * Returns the facetLocalNormals array.
  28434. * The normals are expressed in the mesh local spac
  28435. * @returns an array of Vector3
  28436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28437. */
  28438. getFacetLocalNormals(): Vector3[];
  28439. /**
  28440. * Returns the facetLocalPositions array.
  28441. * The facet positions are expressed in the mesh local space
  28442. * @returns an array of Vector3
  28443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28444. */
  28445. getFacetLocalPositions(): Vector3[];
  28446. /**
  28447. * Returns the facetLocalPartioning array
  28448. * @returns an array of array of numbers
  28449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28450. */
  28451. getFacetLocalPartitioning(): number[][];
  28452. /**
  28453. * Returns the i-th facet position in the world system.
  28454. * This method allocates a new Vector3 per call
  28455. * @param i defines the facet index
  28456. * @returns a new Vector3
  28457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28458. */
  28459. getFacetPosition(i: number): Vector3;
  28460. /**
  28461. * Sets the reference Vector3 with the i-th facet position in the world system
  28462. * @param i defines the facet index
  28463. * @param ref defines the target vector
  28464. * @returns the current mesh
  28465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28466. */
  28467. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28468. /**
  28469. * Returns the i-th facet normal in the world system.
  28470. * This method allocates a new Vector3 per call
  28471. * @param i defines the facet index
  28472. * @returns a new Vector3
  28473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28474. */
  28475. getFacetNormal(i: number): Vector3;
  28476. /**
  28477. * Sets the reference Vector3 with the i-th facet normal in the world system
  28478. * @param i defines the facet index
  28479. * @param ref defines the target vector
  28480. * @returns the current mesh
  28481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28482. */
  28483. getFacetNormalToRef(i: number, ref: Vector3): this;
  28484. /**
  28485. * 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)
  28486. * @param x defines x coordinate
  28487. * @param y defines y coordinate
  28488. * @param z defines z coordinate
  28489. * @returns the array of facet indexes
  28490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28491. */
  28492. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28493. /**
  28494. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28495. * @param projected sets as the (x,y,z) world projection on the facet
  28496. * @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
  28497. * @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
  28498. * @param x defines x coordinate
  28499. * @param y defines y coordinate
  28500. * @param z defines z coordinate
  28501. * @returns the face index if found (or null instead)
  28502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28503. */
  28504. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28505. /**
  28506. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28507. * @param projected sets as the (x,y,z) local projection on the facet
  28508. * @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
  28509. * @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
  28510. * @param x defines x coordinate
  28511. * @param y defines y coordinate
  28512. * @param z defines z coordinate
  28513. * @returns the face index if found (or null instead)
  28514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28515. */
  28516. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28517. /**
  28518. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28519. * @returns the parameters
  28520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28521. */
  28522. getFacetDataParameters(): any;
  28523. /**
  28524. * Disables the feature FacetData and frees the related memory
  28525. * @returns the current mesh
  28526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28527. */
  28528. disableFacetData(): AbstractMesh;
  28529. /**
  28530. * Updates the AbstractMesh indices array
  28531. * @param indices defines the data source
  28532. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28533. * @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)
  28534. * @returns the current mesh
  28535. */
  28536. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28537. /**
  28538. * Creates new normals data for the mesh
  28539. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28540. * @returns the current mesh
  28541. */
  28542. createNormals(updatable: boolean): AbstractMesh;
  28543. /**
  28544. * Align the mesh with a normal
  28545. * @param normal defines the normal to use
  28546. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28547. * @returns the current mesh
  28548. */
  28549. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28550. /** @hidden */
  28551. _checkOcclusionQuery(): boolean;
  28552. /**
  28553. * Disables the mesh edge rendering mode
  28554. * @returns the currentAbstractMesh
  28555. */
  28556. disableEdgesRendering(): AbstractMesh;
  28557. /**
  28558. * Enables the edge rendering mode on the mesh.
  28559. * This mode makes the mesh edges visible
  28560. * @param epsilon defines the maximal distance between two angles to detect a face
  28561. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28562. * @returns the currentAbstractMesh
  28563. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28564. */
  28565. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28566. }
  28567. }
  28568. declare module BABYLON {
  28569. /**
  28570. * Interface used to define ActionEvent
  28571. */
  28572. export interface IActionEvent {
  28573. /** The mesh or sprite that triggered the action */
  28574. source: any;
  28575. /** The X mouse cursor position at the time of the event */
  28576. pointerX: number;
  28577. /** The Y mouse cursor position at the time of the event */
  28578. pointerY: number;
  28579. /** The mesh that is currently pointed at (can be null) */
  28580. meshUnderPointer: Nullable<AbstractMesh>;
  28581. /** the original (browser) event that triggered the ActionEvent */
  28582. sourceEvent?: any;
  28583. /** additional data for the event */
  28584. additionalData?: any;
  28585. }
  28586. /**
  28587. * ActionEvent is the event being sent when an action is triggered.
  28588. */
  28589. export class ActionEvent implements IActionEvent {
  28590. /** The mesh or sprite that triggered the action */
  28591. source: any;
  28592. /** The X mouse cursor position at the time of the event */
  28593. pointerX: number;
  28594. /** The Y mouse cursor position at the time of the event */
  28595. pointerY: number;
  28596. /** The mesh that is currently pointed at (can be null) */
  28597. meshUnderPointer: Nullable<AbstractMesh>;
  28598. /** the original (browser) event that triggered the ActionEvent */
  28599. sourceEvent?: any;
  28600. /** additional data for the event */
  28601. additionalData?: any;
  28602. /**
  28603. * Creates a new ActionEvent
  28604. * @param source The mesh or sprite that triggered the action
  28605. * @param pointerX The X mouse cursor position at the time of the event
  28606. * @param pointerY The Y mouse cursor position at the time of the event
  28607. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28608. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28609. * @param additionalData additional data for the event
  28610. */
  28611. constructor(
  28612. /** The mesh or sprite that triggered the action */
  28613. source: any,
  28614. /** The X mouse cursor position at the time of the event */
  28615. pointerX: number,
  28616. /** The Y mouse cursor position at the time of the event */
  28617. pointerY: number,
  28618. /** The mesh that is currently pointed at (can be null) */
  28619. meshUnderPointer: Nullable<AbstractMesh>,
  28620. /** the original (browser) event that triggered the ActionEvent */
  28621. sourceEvent?: any,
  28622. /** additional data for the event */
  28623. additionalData?: any);
  28624. /**
  28625. * Helper function to auto-create an ActionEvent from a source mesh.
  28626. * @param source The source mesh that triggered the event
  28627. * @param evt The original (browser) event
  28628. * @param additionalData additional data for the event
  28629. * @returns the new ActionEvent
  28630. */
  28631. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28632. /**
  28633. * Helper function to auto-create an ActionEvent from a source sprite
  28634. * @param source The source sprite that triggered the event
  28635. * @param scene Scene associated with the sprite
  28636. * @param evt The original (browser) event
  28637. * @param additionalData additional data for the event
  28638. * @returns the new ActionEvent
  28639. */
  28640. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28641. /**
  28642. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28643. * @param scene the scene where the event occurred
  28644. * @param evt The original (browser) event
  28645. * @returns the new ActionEvent
  28646. */
  28647. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28648. /**
  28649. * Helper function to auto-create an ActionEvent from a primitive
  28650. * @param prim defines the target primitive
  28651. * @param pointerPos defines the pointer position
  28652. * @param evt The original (browser) event
  28653. * @param additionalData additional data for the event
  28654. * @returns the new ActionEvent
  28655. */
  28656. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28657. }
  28658. }
  28659. declare module BABYLON {
  28660. /**
  28661. * Abstract class used to decouple action Manager from scene and meshes.
  28662. * Do not instantiate.
  28663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28664. */
  28665. export abstract class AbstractActionManager implements IDisposable {
  28666. /** Gets the list of active triggers */
  28667. static Triggers: {
  28668. [key: string]: number;
  28669. };
  28670. /** Gets the cursor to use when hovering items */
  28671. hoverCursor: string;
  28672. /** Gets the list of actions */
  28673. actions: IAction[];
  28674. /**
  28675. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28676. */
  28677. isRecursive: boolean;
  28678. /**
  28679. * Releases all associated resources
  28680. */
  28681. abstract dispose(): void;
  28682. /**
  28683. * Does this action manager has pointer triggers
  28684. */
  28685. abstract get hasPointerTriggers(): boolean;
  28686. /**
  28687. * Does this action manager has pick triggers
  28688. */
  28689. abstract get hasPickTriggers(): boolean;
  28690. /**
  28691. * Process a specific trigger
  28692. * @param trigger defines the trigger to process
  28693. * @param evt defines the event details to be processed
  28694. */
  28695. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28696. /**
  28697. * Does this action manager handles actions of any of the given triggers
  28698. * @param triggers defines the triggers to be tested
  28699. * @return a boolean indicating whether one (or more) of the triggers is handled
  28700. */
  28701. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28702. /**
  28703. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28704. * speed.
  28705. * @param triggerA defines the trigger to be tested
  28706. * @param triggerB defines the trigger to be tested
  28707. * @return a boolean indicating whether one (or more) of the triggers is handled
  28708. */
  28709. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28710. /**
  28711. * Does this action manager handles actions of a given trigger
  28712. * @param trigger defines the trigger to be tested
  28713. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28714. * @return whether the trigger is handled
  28715. */
  28716. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28717. /**
  28718. * Serialize this manager to a JSON object
  28719. * @param name defines the property name to store this manager
  28720. * @returns a JSON representation of this manager
  28721. */
  28722. abstract serialize(name: string): any;
  28723. /**
  28724. * Registers an action to this action manager
  28725. * @param action defines the action to be registered
  28726. * @return the action amended (prepared) after registration
  28727. */
  28728. abstract registerAction(action: IAction): Nullable<IAction>;
  28729. /**
  28730. * Unregisters an action to this action manager
  28731. * @param action defines the action to be unregistered
  28732. * @return a boolean indicating whether the action has been unregistered
  28733. */
  28734. abstract unregisterAction(action: IAction): Boolean;
  28735. /**
  28736. * Does exist one action manager with at least one trigger
  28737. **/
  28738. static get HasTriggers(): boolean;
  28739. /**
  28740. * Does exist one action manager with at least one pick trigger
  28741. **/
  28742. static get HasPickTriggers(): boolean;
  28743. /**
  28744. * Does exist one action manager that handles actions of a given trigger
  28745. * @param trigger defines the trigger to be tested
  28746. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28747. **/
  28748. static HasSpecificTrigger(trigger: number): boolean;
  28749. }
  28750. }
  28751. declare module BABYLON {
  28752. /**
  28753. * Defines how a node can be built from a string name.
  28754. */
  28755. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28756. /**
  28757. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28758. */
  28759. export class Node implements IBehaviorAware<Node> {
  28760. /** @hidden */
  28761. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28762. private static _NodeConstructors;
  28763. /**
  28764. * Add a new node constructor
  28765. * @param type defines the type name of the node to construct
  28766. * @param constructorFunc defines the constructor function
  28767. */
  28768. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28769. /**
  28770. * Returns a node constructor based on type name
  28771. * @param type defines the type name
  28772. * @param name defines the new node name
  28773. * @param scene defines the hosting scene
  28774. * @param options defines optional options to transmit to constructors
  28775. * @returns the new constructor or null
  28776. */
  28777. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28778. /**
  28779. * Gets or sets the name of the node
  28780. */
  28781. name: string;
  28782. /**
  28783. * Gets or sets the id of the node
  28784. */
  28785. id: string;
  28786. /**
  28787. * Gets or sets the unique id of the node
  28788. */
  28789. uniqueId: number;
  28790. /**
  28791. * Gets or sets a string used to store user defined state for the node
  28792. */
  28793. state: string;
  28794. /**
  28795. * Gets or sets an object used to store user defined information for the node
  28796. */
  28797. metadata: any;
  28798. /**
  28799. * For internal use only. Please do not use.
  28800. */
  28801. reservedDataStore: any;
  28802. /**
  28803. * List of inspectable custom properties (used by the Inspector)
  28804. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28805. */
  28806. inspectableCustomProperties: IInspectable[];
  28807. private _doNotSerialize;
  28808. /**
  28809. * Gets or sets a boolean used to define if the node must be serialized
  28810. */
  28811. get doNotSerialize(): boolean;
  28812. set doNotSerialize(value: boolean);
  28813. /** @hidden */
  28814. _isDisposed: boolean;
  28815. /**
  28816. * Gets a list of Animations associated with the node
  28817. */
  28818. animations: Animation[];
  28819. protected _ranges: {
  28820. [name: string]: Nullable<AnimationRange>;
  28821. };
  28822. /**
  28823. * Callback raised when the node is ready to be used
  28824. */
  28825. onReady: Nullable<(node: Node) => void>;
  28826. private _isEnabled;
  28827. private _isParentEnabled;
  28828. private _isReady;
  28829. /** @hidden */
  28830. _currentRenderId: number;
  28831. private _parentUpdateId;
  28832. /** @hidden */
  28833. _childUpdateId: number;
  28834. /** @hidden */
  28835. _waitingParentId: Nullable<string>;
  28836. /** @hidden */
  28837. _scene: Scene;
  28838. /** @hidden */
  28839. _cache: any;
  28840. private _parentNode;
  28841. private _children;
  28842. /** @hidden */
  28843. _worldMatrix: Matrix;
  28844. /** @hidden */
  28845. _worldMatrixDeterminant: number;
  28846. /** @hidden */
  28847. _worldMatrixDeterminantIsDirty: boolean;
  28848. /** @hidden */
  28849. private _sceneRootNodesIndex;
  28850. /**
  28851. * Gets a boolean indicating if the node has been disposed
  28852. * @returns true if the node was disposed
  28853. */
  28854. isDisposed(): boolean;
  28855. /**
  28856. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28857. * @see https://doc.babylonjs.com/how_to/parenting
  28858. */
  28859. set parent(parent: Nullable<Node>);
  28860. get parent(): Nullable<Node>;
  28861. /** @hidden */
  28862. _addToSceneRootNodes(): void;
  28863. /** @hidden */
  28864. _removeFromSceneRootNodes(): void;
  28865. private _animationPropertiesOverride;
  28866. /**
  28867. * Gets or sets the animation properties override
  28868. */
  28869. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28870. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28871. /**
  28872. * Gets a string idenfifying the name of the class
  28873. * @returns "Node" string
  28874. */
  28875. getClassName(): string;
  28876. /** @hidden */
  28877. readonly _isNode: boolean;
  28878. /**
  28879. * An event triggered when the mesh is disposed
  28880. */
  28881. onDisposeObservable: Observable<Node>;
  28882. private _onDisposeObserver;
  28883. /**
  28884. * Sets a callback that will be raised when the node will be disposed
  28885. */
  28886. set onDispose(callback: () => void);
  28887. /**
  28888. * Creates a new Node
  28889. * @param name the name and id to be given to this node
  28890. * @param scene the scene this node will be added to
  28891. */
  28892. constructor(name: string, scene?: Nullable<Scene>);
  28893. /**
  28894. * Gets the scene of the node
  28895. * @returns a scene
  28896. */
  28897. getScene(): Scene;
  28898. /**
  28899. * Gets the engine of the node
  28900. * @returns a Engine
  28901. */
  28902. getEngine(): Engine;
  28903. private _behaviors;
  28904. /**
  28905. * Attach a behavior to the node
  28906. * @see http://doc.babylonjs.com/features/behaviour
  28907. * @param behavior defines the behavior to attach
  28908. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28909. * @returns the current Node
  28910. */
  28911. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28912. /**
  28913. * Remove an attached behavior
  28914. * @see http://doc.babylonjs.com/features/behaviour
  28915. * @param behavior defines the behavior to attach
  28916. * @returns the current Node
  28917. */
  28918. removeBehavior(behavior: Behavior<Node>): Node;
  28919. /**
  28920. * Gets the list of attached behaviors
  28921. * @see http://doc.babylonjs.com/features/behaviour
  28922. */
  28923. get behaviors(): Behavior<Node>[];
  28924. /**
  28925. * Gets an attached behavior by name
  28926. * @param name defines the name of the behavior to look for
  28927. * @see http://doc.babylonjs.com/features/behaviour
  28928. * @returns null if behavior was not found else the requested behavior
  28929. */
  28930. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28931. /**
  28932. * Returns the latest update of the World matrix
  28933. * @returns a Matrix
  28934. */
  28935. getWorldMatrix(): Matrix;
  28936. /** @hidden */
  28937. _getWorldMatrixDeterminant(): number;
  28938. /**
  28939. * Returns directly the latest state of the mesh World matrix.
  28940. * A Matrix is returned.
  28941. */
  28942. get worldMatrixFromCache(): Matrix;
  28943. /** @hidden */
  28944. _initCache(): void;
  28945. /** @hidden */
  28946. updateCache(force?: boolean): void;
  28947. /** @hidden */
  28948. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28949. /** @hidden */
  28950. _updateCache(ignoreParentClass?: boolean): void;
  28951. /** @hidden */
  28952. _isSynchronized(): boolean;
  28953. /** @hidden */
  28954. _markSyncedWithParent(): void;
  28955. /** @hidden */
  28956. isSynchronizedWithParent(): boolean;
  28957. /** @hidden */
  28958. isSynchronized(): boolean;
  28959. /**
  28960. * Is this node ready to be used/rendered
  28961. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28962. * @return true if the node is ready
  28963. */
  28964. isReady(completeCheck?: boolean): boolean;
  28965. /**
  28966. * Is this node enabled?
  28967. * 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
  28968. * @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
  28969. * @return whether this node (and its parent) is enabled
  28970. */
  28971. isEnabled(checkAncestors?: boolean): boolean;
  28972. /** @hidden */
  28973. protected _syncParentEnabledState(): void;
  28974. /**
  28975. * Set the enabled state of this node
  28976. * @param value defines the new enabled state
  28977. */
  28978. setEnabled(value: boolean): void;
  28979. /**
  28980. * Is this node a descendant of the given node?
  28981. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28982. * @param ancestor defines the parent node to inspect
  28983. * @returns a boolean indicating if this node is a descendant of the given node
  28984. */
  28985. isDescendantOf(ancestor: Node): boolean;
  28986. /** @hidden */
  28987. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28988. /**
  28989. * Will return all nodes that have this node as ascendant
  28990. * @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
  28991. * @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
  28992. * @return all children nodes of all types
  28993. */
  28994. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28995. /**
  28996. * Get all child-meshes of this node
  28997. * @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)
  28998. * @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
  28999. * @returns an array of AbstractMesh
  29000. */
  29001. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29002. /**
  29003. * Get all direct children of this node
  29004. * @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
  29005. * @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)
  29006. * @returns an array of Node
  29007. */
  29008. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29009. /** @hidden */
  29010. _setReady(state: boolean): void;
  29011. /**
  29012. * Get an animation by name
  29013. * @param name defines the name of the animation to look for
  29014. * @returns null if not found else the requested animation
  29015. */
  29016. getAnimationByName(name: string): Nullable<Animation>;
  29017. /**
  29018. * Creates an animation range for this node
  29019. * @param name defines the name of the range
  29020. * @param from defines the starting key
  29021. * @param to defines the end key
  29022. */
  29023. createAnimationRange(name: string, from: number, to: number): void;
  29024. /**
  29025. * Delete a specific animation range
  29026. * @param name defines the name of the range to delete
  29027. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29028. */
  29029. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29030. /**
  29031. * Get an animation range by name
  29032. * @param name defines the name of the animation range to look for
  29033. * @returns null if not found else the requested animation range
  29034. */
  29035. getAnimationRange(name: string): Nullable<AnimationRange>;
  29036. /**
  29037. * Gets the list of all animation ranges defined on this node
  29038. * @returns an array
  29039. */
  29040. getAnimationRanges(): Nullable<AnimationRange>[];
  29041. /**
  29042. * Will start the animation sequence
  29043. * @param name defines the range frames for animation sequence
  29044. * @param loop defines if the animation should loop (false by default)
  29045. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29046. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29047. * @returns the object created for this animation. If range does not exist, it will return null
  29048. */
  29049. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29050. /**
  29051. * Serialize animation ranges into a JSON compatible object
  29052. * @returns serialization object
  29053. */
  29054. serializeAnimationRanges(): any;
  29055. /**
  29056. * Computes the world matrix of the node
  29057. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29058. * @returns the world matrix
  29059. */
  29060. computeWorldMatrix(force?: boolean): Matrix;
  29061. /**
  29062. * Releases resources associated with this node.
  29063. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29064. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29065. */
  29066. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29067. /**
  29068. * Parse animation range data from a serialization object and store them into a given node
  29069. * @param node defines where to store the animation ranges
  29070. * @param parsedNode defines the serialization object to read data from
  29071. * @param scene defines the hosting scene
  29072. */
  29073. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29074. /**
  29075. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29076. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29077. * @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
  29078. * @returns the new bounding vectors
  29079. */
  29080. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29081. min: Vector3;
  29082. max: Vector3;
  29083. };
  29084. }
  29085. }
  29086. declare module BABYLON {
  29087. /**
  29088. * @hidden
  29089. */
  29090. export class _IAnimationState {
  29091. key: number;
  29092. repeatCount: number;
  29093. workValue?: any;
  29094. loopMode?: number;
  29095. offsetValue?: any;
  29096. highLimitValue?: any;
  29097. }
  29098. /**
  29099. * Class used to store any kind of animation
  29100. */
  29101. export class Animation {
  29102. /**Name of the animation */
  29103. name: string;
  29104. /**Property to animate */
  29105. targetProperty: string;
  29106. /**The frames per second of the animation */
  29107. framePerSecond: number;
  29108. /**The data type of the animation */
  29109. dataType: number;
  29110. /**The loop mode of the animation */
  29111. loopMode?: number | undefined;
  29112. /**Specifies if blending should be enabled */
  29113. enableBlending?: boolean | undefined;
  29114. /**
  29115. * Use matrix interpolation instead of using direct key value when animating matrices
  29116. */
  29117. static AllowMatricesInterpolation: boolean;
  29118. /**
  29119. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29120. */
  29121. static AllowMatrixDecomposeForInterpolation: boolean;
  29122. /**
  29123. * Stores the key frames of the animation
  29124. */
  29125. private _keys;
  29126. /**
  29127. * Stores the easing function of the animation
  29128. */
  29129. private _easingFunction;
  29130. /**
  29131. * @hidden Internal use only
  29132. */
  29133. _runtimeAnimations: RuntimeAnimation[];
  29134. /**
  29135. * The set of event that will be linked to this animation
  29136. */
  29137. private _events;
  29138. /**
  29139. * Stores an array of target property paths
  29140. */
  29141. targetPropertyPath: string[];
  29142. /**
  29143. * Stores the blending speed of the animation
  29144. */
  29145. blendingSpeed: number;
  29146. /**
  29147. * Stores the animation ranges for the animation
  29148. */
  29149. private _ranges;
  29150. /**
  29151. * @hidden Internal use
  29152. */
  29153. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29154. /**
  29155. * Sets up an animation
  29156. * @param property The property to animate
  29157. * @param animationType The animation type to apply
  29158. * @param framePerSecond The frames per second of the animation
  29159. * @param easingFunction The easing function used in the animation
  29160. * @returns The created animation
  29161. */
  29162. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29163. /**
  29164. * Create and start an animation on a node
  29165. * @param name defines the name of the global animation that will be run on all nodes
  29166. * @param node defines the root node where the animation will take place
  29167. * @param targetProperty defines property to animate
  29168. * @param framePerSecond defines the number of frame per second yo use
  29169. * @param totalFrame defines the number of frames in total
  29170. * @param from defines the initial value
  29171. * @param to defines the final value
  29172. * @param loopMode defines which loop mode you want to use (off by default)
  29173. * @param easingFunction defines the easing function to use (linear by default)
  29174. * @param onAnimationEnd defines the callback to call when animation end
  29175. * @returns the animatable created for this animation
  29176. */
  29177. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29178. /**
  29179. * Create and start an animation on a node and its descendants
  29180. * @param name defines the name of the global animation that will be run on all nodes
  29181. * @param node defines the root node where the animation will take place
  29182. * @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
  29183. * @param targetProperty defines property to animate
  29184. * @param framePerSecond defines the number of frame per second to use
  29185. * @param totalFrame defines the number of frames in total
  29186. * @param from defines the initial value
  29187. * @param to defines the final value
  29188. * @param loopMode defines which loop mode you want to use (off by default)
  29189. * @param easingFunction defines the easing function to use (linear by default)
  29190. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29191. * @returns the list of animatables created for all nodes
  29192. * @example https://www.babylonjs-playground.com/#MH0VLI
  29193. */
  29194. 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[]>;
  29195. /**
  29196. * Creates a new animation, merges it with the existing animations and starts it
  29197. * @param name Name of the animation
  29198. * @param node Node which contains the scene that begins the animations
  29199. * @param targetProperty Specifies which property to animate
  29200. * @param framePerSecond The frames per second of the animation
  29201. * @param totalFrame The total number of frames
  29202. * @param from The frame at the beginning of the animation
  29203. * @param to The frame at the end of the animation
  29204. * @param loopMode Specifies the loop mode of the animation
  29205. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29206. * @param onAnimationEnd Callback to run once the animation is complete
  29207. * @returns Nullable animation
  29208. */
  29209. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29210. /**
  29211. * Transition property of an host to the target Value
  29212. * @param property The property to transition
  29213. * @param targetValue The target Value of the property
  29214. * @param host The object where the property to animate belongs
  29215. * @param scene Scene used to run the animation
  29216. * @param frameRate Framerate (in frame/s) to use
  29217. * @param transition The transition type we want to use
  29218. * @param duration The duration of the animation, in milliseconds
  29219. * @param onAnimationEnd Callback trigger at the end of the animation
  29220. * @returns Nullable animation
  29221. */
  29222. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29223. /**
  29224. * Return the array of runtime animations currently using this animation
  29225. */
  29226. get runtimeAnimations(): RuntimeAnimation[];
  29227. /**
  29228. * Specifies if any of the runtime animations are currently running
  29229. */
  29230. get hasRunningRuntimeAnimations(): boolean;
  29231. /**
  29232. * Initializes the animation
  29233. * @param name Name of the animation
  29234. * @param targetProperty Property to animate
  29235. * @param framePerSecond The frames per second of the animation
  29236. * @param dataType The data type of the animation
  29237. * @param loopMode The loop mode of the animation
  29238. * @param enableBlending Specifies if blending should be enabled
  29239. */
  29240. constructor(
  29241. /**Name of the animation */
  29242. name: string,
  29243. /**Property to animate */
  29244. targetProperty: string,
  29245. /**The frames per second of the animation */
  29246. framePerSecond: number,
  29247. /**The data type of the animation */
  29248. dataType: number,
  29249. /**The loop mode of the animation */
  29250. loopMode?: number | undefined,
  29251. /**Specifies if blending should be enabled */
  29252. enableBlending?: boolean | undefined);
  29253. /**
  29254. * Converts the animation to a string
  29255. * @param fullDetails support for multiple levels of logging within scene loading
  29256. * @returns String form of the animation
  29257. */
  29258. toString(fullDetails?: boolean): string;
  29259. /**
  29260. * Add an event to this animation
  29261. * @param event Event to add
  29262. */
  29263. addEvent(event: AnimationEvent): void;
  29264. /**
  29265. * Remove all events found at the given frame
  29266. * @param frame The frame to remove events from
  29267. */
  29268. removeEvents(frame: number): void;
  29269. /**
  29270. * Retrieves all the events from the animation
  29271. * @returns Events from the animation
  29272. */
  29273. getEvents(): AnimationEvent[];
  29274. /**
  29275. * Creates an animation range
  29276. * @param name Name of the animation range
  29277. * @param from Starting frame of the animation range
  29278. * @param to Ending frame of the animation
  29279. */
  29280. createRange(name: string, from: number, to: number): void;
  29281. /**
  29282. * Deletes an animation range by name
  29283. * @param name Name of the animation range to delete
  29284. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29285. */
  29286. deleteRange(name: string, deleteFrames?: boolean): void;
  29287. /**
  29288. * Gets the animation range by name, or null if not defined
  29289. * @param name Name of the animation range
  29290. * @returns Nullable animation range
  29291. */
  29292. getRange(name: string): Nullable<AnimationRange>;
  29293. /**
  29294. * Gets the key frames from the animation
  29295. * @returns The key frames of the animation
  29296. */
  29297. getKeys(): Array<IAnimationKey>;
  29298. /**
  29299. * Gets the highest frame rate of the animation
  29300. * @returns Highest frame rate of the animation
  29301. */
  29302. getHighestFrame(): number;
  29303. /**
  29304. * Gets the easing function of the animation
  29305. * @returns Easing function of the animation
  29306. */
  29307. getEasingFunction(): IEasingFunction;
  29308. /**
  29309. * Sets the easing function of the animation
  29310. * @param easingFunction A custom mathematical formula for animation
  29311. */
  29312. setEasingFunction(easingFunction: EasingFunction): void;
  29313. /**
  29314. * Interpolates a scalar linearly
  29315. * @param startValue Start value of the animation curve
  29316. * @param endValue End value of the animation curve
  29317. * @param gradient Scalar amount to interpolate
  29318. * @returns Interpolated scalar value
  29319. */
  29320. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29321. /**
  29322. * Interpolates a scalar cubically
  29323. * @param startValue Start value of the animation curve
  29324. * @param outTangent End tangent of the animation
  29325. * @param endValue End value of the animation curve
  29326. * @param inTangent Start tangent of the animation curve
  29327. * @param gradient Scalar amount to interpolate
  29328. * @returns Interpolated scalar value
  29329. */
  29330. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29331. /**
  29332. * Interpolates a quaternion using a spherical linear interpolation
  29333. * @param startValue Start value of the animation curve
  29334. * @param endValue End value of the animation curve
  29335. * @param gradient Scalar amount to interpolate
  29336. * @returns Interpolated quaternion value
  29337. */
  29338. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29339. /**
  29340. * Interpolates a quaternion cubically
  29341. * @param startValue Start value of the animation curve
  29342. * @param outTangent End tangent of the animation curve
  29343. * @param endValue End value of the animation curve
  29344. * @param inTangent Start tangent of the animation curve
  29345. * @param gradient Scalar amount to interpolate
  29346. * @returns Interpolated quaternion value
  29347. */
  29348. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29349. /**
  29350. * Interpolates a Vector3 linearl
  29351. * @param startValue Start value of the animation curve
  29352. * @param endValue End value of the animation curve
  29353. * @param gradient Scalar amount to interpolate
  29354. * @returns Interpolated scalar value
  29355. */
  29356. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29357. /**
  29358. * Interpolates a Vector3 cubically
  29359. * @param startValue Start value of the animation curve
  29360. * @param outTangent End tangent of the animation
  29361. * @param endValue End value of the animation curve
  29362. * @param inTangent Start tangent of the animation curve
  29363. * @param gradient Scalar amount to interpolate
  29364. * @returns InterpolatedVector3 value
  29365. */
  29366. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29367. /**
  29368. * Interpolates a Vector2 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 Vector2 value
  29373. */
  29374. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29375. /**
  29376. * Interpolates a Vector2 cubically
  29377. * @param startValue Start value of the animation curve
  29378. * @param outTangent End tangent of the animation
  29379. * @param endValue End value of the animation curve
  29380. * @param inTangent Start tangent of the animation curve
  29381. * @param gradient Scalar amount to interpolate
  29382. * @returns Interpolated Vector2 value
  29383. */
  29384. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29385. /**
  29386. * Interpolates a size linearly
  29387. * @param startValue Start value of the animation curve
  29388. * @param endValue End value of the animation curve
  29389. * @param gradient Scalar amount to interpolate
  29390. * @returns Interpolated Size value
  29391. */
  29392. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29393. /**
  29394. * Interpolates a Color3 linearly
  29395. * @param startValue Start value of the animation curve
  29396. * @param endValue End value of the animation curve
  29397. * @param gradient Scalar amount to interpolate
  29398. * @returns Interpolated Color3 value
  29399. */
  29400. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29401. /**
  29402. * Interpolates a Color4 linearly
  29403. * @param startValue Start value of the animation curve
  29404. * @param endValue End value of the animation curve
  29405. * @param gradient Scalar amount to interpolate
  29406. * @returns Interpolated Color3 value
  29407. */
  29408. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29409. /**
  29410. * @hidden Internal use only
  29411. */
  29412. _getKeyValue(value: any): any;
  29413. /**
  29414. * @hidden Internal use only
  29415. */
  29416. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29417. /**
  29418. * Defines the function to use to interpolate matrices
  29419. * @param startValue defines the start matrix
  29420. * @param endValue defines the end matrix
  29421. * @param gradient defines the gradient between both matrices
  29422. * @param result defines an optional target matrix where to store the interpolation
  29423. * @returns the interpolated matrix
  29424. */
  29425. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29426. /**
  29427. * Makes a copy of the animation
  29428. * @returns Cloned animation
  29429. */
  29430. clone(): Animation;
  29431. /**
  29432. * Sets the key frames of the animation
  29433. * @param values The animation key frames to set
  29434. */
  29435. setKeys(values: Array<IAnimationKey>): void;
  29436. /**
  29437. * Serializes the animation to an object
  29438. * @returns Serialized object
  29439. */
  29440. serialize(): any;
  29441. /**
  29442. * Float animation type
  29443. */
  29444. static readonly ANIMATIONTYPE_FLOAT: number;
  29445. /**
  29446. * Vector3 animation type
  29447. */
  29448. static readonly ANIMATIONTYPE_VECTOR3: number;
  29449. /**
  29450. * Quaternion animation type
  29451. */
  29452. static readonly ANIMATIONTYPE_QUATERNION: number;
  29453. /**
  29454. * Matrix animation type
  29455. */
  29456. static readonly ANIMATIONTYPE_MATRIX: number;
  29457. /**
  29458. * Color3 animation type
  29459. */
  29460. static readonly ANIMATIONTYPE_COLOR3: number;
  29461. /**
  29462. * Color3 animation type
  29463. */
  29464. static readonly ANIMATIONTYPE_COLOR4: number;
  29465. /**
  29466. * Vector2 animation type
  29467. */
  29468. static readonly ANIMATIONTYPE_VECTOR2: number;
  29469. /**
  29470. * Size animation type
  29471. */
  29472. static readonly ANIMATIONTYPE_SIZE: number;
  29473. /**
  29474. * Relative Loop Mode
  29475. */
  29476. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29477. /**
  29478. * Cycle Loop Mode
  29479. */
  29480. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29481. /**
  29482. * Constant Loop Mode
  29483. */
  29484. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29485. /** @hidden */
  29486. static _UniversalLerp(left: any, right: any, amount: number): any;
  29487. /**
  29488. * Parses an animation object and creates an animation
  29489. * @param parsedAnimation Parsed animation object
  29490. * @returns Animation object
  29491. */
  29492. static Parse(parsedAnimation: any): Animation;
  29493. /**
  29494. * Appends the serialized animations from the source animations
  29495. * @param source Source containing the animations
  29496. * @param destination Target to store the animations
  29497. */
  29498. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29499. }
  29500. }
  29501. declare module BABYLON {
  29502. /**
  29503. * Interface containing an array of animations
  29504. */
  29505. export interface IAnimatable {
  29506. /**
  29507. * Array of animations
  29508. */
  29509. animations: Nullable<Array<Animation>>;
  29510. }
  29511. }
  29512. declare module BABYLON {
  29513. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29514. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29515. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29516. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29517. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29518. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29519. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29520. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29521. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29522. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29523. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29524. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29525. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29526. /**
  29527. * Decorator used to define property that can be serialized as reference to a camera
  29528. * @param sourceName defines the name of the property to decorate
  29529. */
  29530. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29531. /**
  29532. * Class used to help serialization objects
  29533. */
  29534. export class SerializationHelper {
  29535. /** @hidden */
  29536. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29537. /** @hidden */
  29538. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29539. /** @hidden */
  29540. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29541. /** @hidden */
  29542. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29543. /**
  29544. * Appends the serialized animations from the source animations
  29545. * @param source Source containing the animations
  29546. * @param destination Target to store the animations
  29547. */
  29548. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29549. /**
  29550. * Static function used to serialized a specific entity
  29551. * @param entity defines the entity to serialize
  29552. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29553. * @returns a JSON compatible object representing the serialization of the entity
  29554. */
  29555. static Serialize<T>(entity: T, serializationObject?: any): any;
  29556. /**
  29557. * Creates a new entity from a serialization data object
  29558. * @param creationFunction defines a function used to instanciated the new entity
  29559. * @param source defines the source serialization data
  29560. * @param scene defines the hosting scene
  29561. * @param rootUrl defines the root url for resources
  29562. * @returns a new entity
  29563. */
  29564. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29565. /**
  29566. * Clones an object
  29567. * @param creationFunction defines the function used to instanciate the new object
  29568. * @param source defines the source object
  29569. * @returns the cloned object
  29570. */
  29571. static Clone<T>(creationFunction: () => T, source: T): T;
  29572. /**
  29573. * Instanciates a new object based on a source one (some data will be shared between both object)
  29574. * @param creationFunction defines the function used to instanciate the new object
  29575. * @param source defines the source object
  29576. * @returns the new object
  29577. */
  29578. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29579. }
  29580. }
  29581. declare module BABYLON {
  29582. /**
  29583. * Class used to manipulate GUIDs
  29584. */
  29585. export class GUID {
  29586. /**
  29587. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29588. * Be aware Math.random() could cause collisions, but:
  29589. * "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"
  29590. * @returns a pseudo random id
  29591. */
  29592. static RandomId(): string;
  29593. }
  29594. }
  29595. declare module BABYLON {
  29596. /**
  29597. * Base class of all the textures in babylon.
  29598. * It groups all the common properties the materials, post process, lights... might need
  29599. * in order to make a correct use of the texture.
  29600. */
  29601. export class BaseTexture implements IAnimatable {
  29602. /**
  29603. * Default anisotropic filtering level for the application.
  29604. * It is set to 4 as a good tradeoff between perf and quality.
  29605. */
  29606. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29607. /**
  29608. * Gets or sets the unique id of the texture
  29609. */
  29610. uniqueId: number;
  29611. /**
  29612. * Define the name of the texture.
  29613. */
  29614. name: string;
  29615. /**
  29616. * Gets or sets an object used to store user defined information.
  29617. */
  29618. metadata: any;
  29619. /**
  29620. * For internal use only. Please do not use.
  29621. */
  29622. reservedDataStore: any;
  29623. private _hasAlpha;
  29624. /**
  29625. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29626. */
  29627. set hasAlpha(value: boolean);
  29628. get hasAlpha(): boolean;
  29629. /**
  29630. * Defines if the alpha value should be determined via the rgb values.
  29631. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29632. */
  29633. getAlphaFromRGB: boolean;
  29634. /**
  29635. * Intensity or strength of the texture.
  29636. * It is commonly used by materials to fine tune the intensity of the texture
  29637. */
  29638. level: number;
  29639. /**
  29640. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29641. * This is part of the texture as textures usually maps to one uv set.
  29642. */
  29643. coordinatesIndex: number;
  29644. private _coordinatesMode;
  29645. /**
  29646. * How a texture is mapped.
  29647. *
  29648. * | Value | Type | Description |
  29649. * | ----- | ----------------------------------- | ----------- |
  29650. * | 0 | EXPLICIT_MODE | |
  29651. * | 1 | SPHERICAL_MODE | |
  29652. * | 2 | PLANAR_MODE | |
  29653. * | 3 | CUBIC_MODE | |
  29654. * | 4 | PROJECTION_MODE | |
  29655. * | 5 | SKYBOX_MODE | |
  29656. * | 6 | INVCUBIC_MODE | |
  29657. * | 7 | EQUIRECTANGULAR_MODE | |
  29658. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29659. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29660. */
  29661. set coordinatesMode(value: number);
  29662. get coordinatesMode(): number;
  29663. /**
  29664. * | Value | Type | Description |
  29665. * | ----- | ------------------ | ----------- |
  29666. * | 0 | CLAMP_ADDRESSMODE | |
  29667. * | 1 | WRAP_ADDRESSMODE | |
  29668. * | 2 | MIRROR_ADDRESSMODE | |
  29669. */
  29670. wrapU: number;
  29671. /**
  29672. * | Value | Type | Description |
  29673. * | ----- | ------------------ | ----------- |
  29674. * | 0 | CLAMP_ADDRESSMODE | |
  29675. * | 1 | WRAP_ADDRESSMODE | |
  29676. * | 2 | MIRROR_ADDRESSMODE | |
  29677. */
  29678. wrapV: number;
  29679. /**
  29680. * | Value | Type | Description |
  29681. * | ----- | ------------------ | ----------- |
  29682. * | 0 | CLAMP_ADDRESSMODE | |
  29683. * | 1 | WRAP_ADDRESSMODE | |
  29684. * | 2 | MIRROR_ADDRESSMODE | |
  29685. */
  29686. wrapR: number;
  29687. /**
  29688. * With compliant hardware and browser (supporting anisotropic filtering)
  29689. * this defines the level of anisotropic filtering in the texture.
  29690. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29691. */
  29692. anisotropicFilteringLevel: number;
  29693. /**
  29694. * Define if the texture is a cube texture or if false a 2d texture.
  29695. */
  29696. get isCube(): boolean;
  29697. set isCube(value: boolean);
  29698. /**
  29699. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29700. */
  29701. get is3D(): boolean;
  29702. set is3D(value: boolean);
  29703. /**
  29704. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29705. */
  29706. get is2DArray(): boolean;
  29707. set is2DArray(value: boolean);
  29708. /**
  29709. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29710. * HDR texture are usually stored in linear space.
  29711. * This only impacts the PBR and Background materials
  29712. */
  29713. gammaSpace: boolean;
  29714. /**
  29715. * Gets or sets whether or not the texture contains RGBD data.
  29716. */
  29717. get isRGBD(): boolean;
  29718. set isRGBD(value: boolean);
  29719. /**
  29720. * Is Z inverted in the texture (useful in a cube texture).
  29721. */
  29722. invertZ: boolean;
  29723. /**
  29724. * Are mip maps generated for this texture or not.
  29725. */
  29726. get noMipmap(): boolean;
  29727. /**
  29728. * @hidden
  29729. */
  29730. lodLevelInAlpha: boolean;
  29731. /**
  29732. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29733. */
  29734. get lodGenerationOffset(): number;
  29735. set lodGenerationOffset(value: number);
  29736. /**
  29737. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29738. */
  29739. get lodGenerationScale(): number;
  29740. set lodGenerationScale(value: number);
  29741. /**
  29742. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29743. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29744. * average roughness values.
  29745. */
  29746. get linearSpecularLOD(): boolean;
  29747. set linearSpecularLOD(value: boolean);
  29748. /**
  29749. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29750. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29751. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29752. */
  29753. get irradianceTexture(): Nullable<BaseTexture>;
  29754. set irradianceTexture(value: Nullable<BaseTexture>);
  29755. /**
  29756. * Define if the texture is a render target.
  29757. */
  29758. isRenderTarget: boolean;
  29759. /**
  29760. * Define the unique id of the texture in the scene.
  29761. */
  29762. get uid(): string;
  29763. /**
  29764. * Return a string representation of the texture.
  29765. * @returns the texture as a string
  29766. */
  29767. toString(): string;
  29768. /**
  29769. * Get the class name of the texture.
  29770. * @returns "BaseTexture"
  29771. */
  29772. getClassName(): string;
  29773. /**
  29774. * Define the list of animation attached to the texture.
  29775. */
  29776. animations: Animation[];
  29777. /**
  29778. * An event triggered when the texture is disposed.
  29779. */
  29780. onDisposeObservable: Observable<BaseTexture>;
  29781. private _onDisposeObserver;
  29782. /**
  29783. * Callback triggered when the texture has been disposed.
  29784. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29785. */
  29786. set onDispose(callback: () => void);
  29787. /**
  29788. * Define the current state of the loading sequence when in delayed load mode.
  29789. */
  29790. delayLoadState: number;
  29791. private _scene;
  29792. /** @hidden */
  29793. _texture: Nullable<InternalTexture>;
  29794. private _uid;
  29795. /**
  29796. * Define if the texture is preventinga material to render or not.
  29797. * If not and the texture is not ready, the engine will use a default black texture instead.
  29798. */
  29799. get isBlocking(): boolean;
  29800. /**
  29801. * Instantiates a new BaseTexture.
  29802. * Base class of all the textures in babylon.
  29803. * It groups all the common properties the materials, post process, lights... might need
  29804. * in order to make a correct use of the texture.
  29805. * @param scene Define the scene the texture blongs to
  29806. */
  29807. constructor(scene: Nullable<Scene>);
  29808. /**
  29809. * Get the scene the texture belongs to.
  29810. * @returns the scene or null if undefined
  29811. */
  29812. getScene(): Nullable<Scene>;
  29813. /**
  29814. * Get the texture transform matrix used to offset tile the texture for istance.
  29815. * @returns the transformation matrix
  29816. */
  29817. getTextureMatrix(): Matrix;
  29818. /**
  29819. * Get the texture reflection matrix used to rotate/transform the reflection.
  29820. * @returns the reflection matrix
  29821. */
  29822. getReflectionTextureMatrix(): Matrix;
  29823. /**
  29824. * Get the underlying lower level texture from Babylon.
  29825. * @returns the insternal texture
  29826. */
  29827. getInternalTexture(): Nullable<InternalTexture>;
  29828. /**
  29829. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29830. * @returns true if ready or not blocking
  29831. */
  29832. isReadyOrNotBlocking(): boolean;
  29833. /**
  29834. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29835. * @returns true if fully ready
  29836. */
  29837. isReady(): boolean;
  29838. private _cachedSize;
  29839. /**
  29840. * Get the size of the texture.
  29841. * @returns the texture size.
  29842. */
  29843. getSize(): ISize;
  29844. /**
  29845. * Get the base size of the texture.
  29846. * It can be different from the size if the texture has been resized for POT for instance
  29847. * @returns the base size
  29848. */
  29849. getBaseSize(): ISize;
  29850. /**
  29851. * Update the sampling mode of the texture.
  29852. * Default is Trilinear mode.
  29853. *
  29854. * | Value | Type | Description |
  29855. * | ----- | ------------------ | ----------- |
  29856. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29857. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29858. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29859. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29860. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29861. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29862. * | 7 | NEAREST_LINEAR | |
  29863. * | 8 | NEAREST_NEAREST | |
  29864. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29865. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29866. * | 11 | LINEAR_LINEAR | |
  29867. * | 12 | LINEAR_NEAREST | |
  29868. *
  29869. * > _mag_: magnification filter (close to the viewer)
  29870. * > _min_: minification filter (far from the viewer)
  29871. * > _mip_: filter used between mip map levels
  29872. *@param samplingMode Define the new sampling mode of the texture
  29873. */
  29874. updateSamplingMode(samplingMode: number): void;
  29875. /**
  29876. * Scales the texture if is `canRescale()`
  29877. * @param ratio the resize factor we want to use to rescale
  29878. */
  29879. scale(ratio: number): void;
  29880. /**
  29881. * Get if the texture can rescale.
  29882. */
  29883. get canRescale(): boolean;
  29884. /** @hidden */
  29885. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29886. /** @hidden */
  29887. _rebuild(): void;
  29888. /**
  29889. * Triggers the load sequence in delayed load mode.
  29890. */
  29891. delayLoad(): void;
  29892. /**
  29893. * Clones the texture.
  29894. * @returns the cloned texture
  29895. */
  29896. clone(): Nullable<BaseTexture>;
  29897. /**
  29898. * Get the texture underlying type (INT, FLOAT...)
  29899. */
  29900. get textureType(): number;
  29901. /**
  29902. * Get the texture underlying format (RGB, RGBA...)
  29903. */
  29904. get textureFormat(): number;
  29905. /**
  29906. * Indicates that textures need to be re-calculated for all materials
  29907. */
  29908. protected _markAllSubMeshesAsTexturesDirty(): void;
  29909. /**
  29910. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29911. * This will returns an RGBA array buffer containing either in values (0-255) or
  29912. * float values (0-1) depending of the underlying buffer type.
  29913. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29914. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29915. * @param buffer defines a user defined buffer to fill with data (can be null)
  29916. * @returns The Array buffer containing the pixels data.
  29917. */
  29918. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29919. /**
  29920. * Release and destroy the underlying lower level texture aka internalTexture.
  29921. */
  29922. releaseInternalTexture(): void;
  29923. /** @hidden */
  29924. get _lodTextureHigh(): Nullable<BaseTexture>;
  29925. /** @hidden */
  29926. get _lodTextureMid(): Nullable<BaseTexture>;
  29927. /** @hidden */
  29928. get _lodTextureLow(): Nullable<BaseTexture>;
  29929. /**
  29930. * Dispose the texture and release its associated resources.
  29931. */
  29932. dispose(): void;
  29933. /**
  29934. * Serialize the texture into a JSON representation that can be parsed later on.
  29935. * @returns the JSON representation of the texture
  29936. */
  29937. serialize(): any;
  29938. /**
  29939. * Helper function to be called back once a list of texture contains only ready textures.
  29940. * @param textures Define the list of textures to wait for
  29941. * @param callback Define the callback triggered once the entire list will be ready
  29942. */
  29943. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29944. }
  29945. }
  29946. declare module BABYLON {
  29947. /**
  29948. * Options to be used when creating an effect.
  29949. */
  29950. export interface IEffectCreationOptions {
  29951. /**
  29952. * Atrributes that will be used in the shader.
  29953. */
  29954. attributes: string[];
  29955. /**
  29956. * Uniform varible names that will be set in the shader.
  29957. */
  29958. uniformsNames: string[];
  29959. /**
  29960. * Uniform buffer variable names that will be set in the shader.
  29961. */
  29962. uniformBuffersNames: string[];
  29963. /**
  29964. * Sampler texture variable names that will be set in the shader.
  29965. */
  29966. samplers: string[];
  29967. /**
  29968. * Define statements that will be set in the shader.
  29969. */
  29970. defines: any;
  29971. /**
  29972. * Possible fallbacks for this effect to improve performance when needed.
  29973. */
  29974. fallbacks: Nullable<IEffectFallbacks>;
  29975. /**
  29976. * Callback that will be called when the shader is compiled.
  29977. */
  29978. onCompiled: Nullable<(effect: Effect) => void>;
  29979. /**
  29980. * Callback that will be called if an error occurs during shader compilation.
  29981. */
  29982. onError: Nullable<(effect: Effect, errors: string) => void>;
  29983. /**
  29984. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29985. */
  29986. indexParameters?: any;
  29987. /**
  29988. * Max number of lights that can be used in the shader.
  29989. */
  29990. maxSimultaneousLights?: number;
  29991. /**
  29992. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29993. */
  29994. transformFeedbackVaryings?: Nullable<string[]>;
  29995. }
  29996. /**
  29997. * Effect containing vertex and fragment shader that can be executed on an object.
  29998. */
  29999. export class Effect implements IDisposable {
  30000. /**
  30001. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30002. */
  30003. static ShadersRepository: string;
  30004. /**
  30005. * Name of the effect.
  30006. */
  30007. name: any;
  30008. /**
  30009. * String container all the define statements that should be set on the shader.
  30010. */
  30011. defines: string;
  30012. /**
  30013. * Callback that will be called when the shader is compiled.
  30014. */
  30015. onCompiled: Nullable<(effect: Effect) => void>;
  30016. /**
  30017. * Callback that will be called if an error occurs during shader compilation.
  30018. */
  30019. onError: Nullable<(effect: Effect, errors: string) => void>;
  30020. /**
  30021. * Callback that will be called when effect is bound.
  30022. */
  30023. onBind: Nullable<(effect: Effect) => void>;
  30024. /**
  30025. * Unique ID of the effect.
  30026. */
  30027. uniqueId: number;
  30028. /**
  30029. * Observable that will be called when the shader is compiled.
  30030. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30031. */
  30032. onCompileObservable: Observable<Effect>;
  30033. /**
  30034. * Observable that will be called if an error occurs during shader compilation.
  30035. */
  30036. onErrorObservable: Observable<Effect>;
  30037. /** @hidden */
  30038. _onBindObservable: Nullable<Observable<Effect>>;
  30039. /**
  30040. * @hidden
  30041. * Specifies if the effect was previously ready
  30042. */
  30043. _wasPreviouslyReady: boolean;
  30044. /**
  30045. * Observable that will be called when effect is bound.
  30046. */
  30047. get onBindObservable(): Observable<Effect>;
  30048. /** @hidden */
  30049. _bonesComputationForcedToCPU: boolean;
  30050. private static _uniqueIdSeed;
  30051. private _engine;
  30052. private _uniformBuffersNames;
  30053. private _uniformsNames;
  30054. private _samplerList;
  30055. private _samplers;
  30056. private _isReady;
  30057. private _compilationError;
  30058. private _allFallbacksProcessed;
  30059. private _attributesNames;
  30060. private _attributes;
  30061. private _attributeLocationByName;
  30062. private _uniforms;
  30063. /**
  30064. * Key for the effect.
  30065. * @hidden
  30066. */
  30067. _key: string;
  30068. private _indexParameters;
  30069. private _fallbacks;
  30070. private _vertexSourceCode;
  30071. private _fragmentSourceCode;
  30072. private _vertexSourceCodeOverride;
  30073. private _fragmentSourceCodeOverride;
  30074. private _transformFeedbackVaryings;
  30075. /**
  30076. * Compiled shader to webGL program.
  30077. * @hidden
  30078. */
  30079. _pipelineContext: Nullable<IPipelineContext>;
  30080. private _valueCache;
  30081. private static _baseCache;
  30082. /**
  30083. * Instantiates an effect.
  30084. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30085. * @param baseName Name of the effect.
  30086. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30087. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30088. * @param samplers List of sampler variables that will be passed to the shader.
  30089. * @param engine Engine to be used to render the effect
  30090. * @param defines Define statements to be added to the shader.
  30091. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30092. * @param onCompiled Callback that will be called when the shader is compiled.
  30093. * @param onError Callback that will be called if an error occurs during shader compilation.
  30094. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30095. */
  30096. 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);
  30097. private _useFinalCode;
  30098. /**
  30099. * Unique key for this effect
  30100. */
  30101. get key(): string;
  30102. /**
  30103. * If the effect has been compiled and prepared.
  30104. * @returns if the effect is compiled and prepared.
  30105. */
  30106. isReady(): boolean;
  30107. private _isReadyInternal;
  30108. /**
  30109. * The engine the effect was initialized with.
  30110. * @returns the engine.
  30111. */
  30112. getEngine(): Engine;
  30113. /**
  30114. * The pipeline context for this effect
  30115. * @returns the associated pipeline context
  30116. */
  30117. getPipelineContext(): Nullable<IPipelineContext>;
  30118. /**
  30119. * The set of names of attribute variables for the shader.
  30120. * @returns An array of attribute names.
  30121. */
  30122. getAttributesNames(): string[];
  30123. /**
  30124. * Returns the attribute at the given index.
  30125. * @param index The index of the attribute.
  30126. * @returns The location of the attribute.
  30127. */
  30128. getAttributeLocation(index: number): number;
  30129. /**
  30130. * Returns the attribute based on the name of the variable.
  30131. * @param name of the attribute to look up.
  30132. * @returns the attribute location.
  30133. */
  30134. getAttributeLocationByName(name: string): number;
  30135. /**
  30136. * The number of attributes.
  30137. * @returns the numnber of attributes.
  30138. */
  30139. getAttributesCount(): number;
  30140. /**
  30141. * Gets the index of a uniform variable.
  30142. * @param uniformName of the uniform to look up.
  30143. * @returns the index.
  30144. */
  30145. getUniformIndex(uniformName: string): number;
  30146. /**
  30147. * Returns the attribute based on the name of the variable.
  30148. * @param uniformName of the uniform to look up.
  30149. * @returns the location of the uniform.
  30150. */
  30151. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30152. /**
  30153. * Returns an array of sampler variable names
  30154. * @returns The array of sampler variable neames.
  30155. */
  30156. getSamplers(): string[];
  30157. /**
  30158. * The error from the last compilation.
  30159. * @returns the error string.
  30160. */
  30161. getCompilationError(): string;
  30162. /**
  30163. * Gets a boolean indicating that all fallbacks were used during compilation
  30164. * @returns true if all fallbacks were used
  30165. */
  30166. allFallbacksProcessed(): boolean;
  30167. /**
  30168. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30169. * @param func The callback to be used.
  30170. */
  30171. executeWhenCompiled(func: (effect: Effect) => void): void;
  30172. private _checkIsReady;
  30173. private _loadShader;
  30174. /**
  30175. * Recompiles the webGL program
  30176. * @param vertexSourceCode The source code for the vertex shader.
  30177. * @param fragmentSourceCode The source code for the fragment shader.
  30178. * @param onCompiled Callback called when completed.
  30179. * @param onError Callback called on error.
  30180. * @hidden
  30181. */
  30182. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30183. /**
  30184. * Prepares the effect
  30185. * @hidden
  30186. */
  30187. _prepareEffect(): void;
  30188. private _processCompilationErrors;
  30189. /**
  30190. * Checks if the effect is supported. (Must be called after compilation)
  30191. */
  30192. get isSupported(): boolean;
  30193. /**
  30194. * Binds a texture to the engine to be used as output of the shader.
  30195. * @param channel Name of the output variable.
  30196. * @param texture Texture to bind.
  30197. * @hidden
  30198. */
  30199. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30200. /**
  30201. * Sets a texture on the engine to be used in the shader.
  30202. * @param channel Name of the sampler variable.
  30203. * @param texture Texture to set.
  30204. */
  30205. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30206. /**
  30207. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30208. * @param channel Name of the sampler variable.
  30209. * @param texture Texture to set.
  30210. */
  30211. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30212. /**
  30213. * Sets an array of textures on the engine to be used in the shader.
  30214. * @param channel Name of the variable.
  30215. * @param textures Textures to set.
  30216. */
  30217. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30218. /**
  30219. * 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)
  30220. * @param channel Name of the sampler variable.
  30221. * @param postProcess Post process to get the input texture from.
  30222. */
  30223. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30224. /**
  30225. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30226. * 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)
  30227. * @param channel Name of the sampler variable.
  30228. * @param postProcess Post process to get the output texture from.
  30229. */
  30230. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30231. /** @hidden */
  30232. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30233. /** @hidden */
  30234. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30235. /** @hidden */
  30236. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30237. /** @hidden */
  30238. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30239. /**
  30240. * Binds a buffer to a uniform.
  30241. * @param buffer Buffer to bind.
  30242. * @param name Name of the uniform variable to bind to.
  30243. */
  30244. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30245. /**
  30246. * Binds block to a uniform.
  30247. * @param blockName Name of the block to bind.
  30248. * @param index Index to bind.
  30249. */
  30250. bindUniformBlock(blockName: string, index: number): void;
  30251. /**
  30252. * Sets an interger value on a uniform variable.
  30253. * @param uniformName Name of the variable.
  30254. * @param value Value to be set.
  30255. * @returns this effect.
  30256. */
  30257. setInt(uniformName: string, value: number): Effect;
  30258. /**
  30259. * Sets an int array on a uniform variable.
  30260. * @param uniformName Name of the variable.
  30261. * @param array array to be set.
  30262. * @returns this effect.
  30263. */
  30264. setIntArray(uniformName: string, array: Int32Array): Effect;
  30265. /**
  30266. * 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)
  30267. * @param uniformName Name of the variable.
  30268. * @param array array to be set.
  30269. * @returns this effect.
  30270. */
  30271. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30272. /**
  30273. * 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)
  30274. * @param uniformName Name of the variable.
  30275. * @param array array to be set.
  30276. * @returns this effect.
  30277. */
  30278. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30279. /**
  30280. * 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)
  30281. * @param uniformName Name of the variable.
  30282. * @param array array to be set.
  30283. * @returns this effect.
  30284. */
  30285. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30286. /**
  30287. * Sets an float array on a uniform variable.
  30288. * @param uniformName Name of the variable.
  30289. * @param array array to be set.
  30290. * @returns this effect.
  30291. */
  30292. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30293. /**
  30294. * 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)
  30295. * @param uniformName Name of the variable.
  30296. * @param array array to be set.
  30297. * @returns this effect.
  30298. */
  30299. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30300. /**
  30301. * 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)
  30302. * @param uniformName Name of the variable.
  30303. * @param array array to be set.
  30304. * @returns this effect.
  30305. */
  30306. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30307. /**
  30308. * 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)
  30309. * @param uniformName Name of the variable.
  30310. * @param array array to be set.
  30311. * @returns this effect.
  30312. */
  30313. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30314. /**
  30315. * Sets an array on a uniform variable.
  30316. * @param uniformName Name of the variable.
  30317. * @param array array to be set.
  30318. * @returns this effect.
  30319. */
  30320. setArray(uniformName: string, array: number[]): Effect;
  30321. /**
  30322. * 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)
  30323. * @param uniformName Name of the variable.
  30324. * @param array array to be set.
  30325. * @returns this effect.
  30326. */
  30327. setArray2(uniformName: string, array: number[]): Effect;
  30328. /**
  30329. * 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)
  30330. * @param uniformName Name of the variable.
  30331. * @param array array to be set.
  30332. * @returns this effect.
  30333. */
  30334. setArray3(uniformName: string, array: number[]): Effect;
  30335. /**
  30336. * 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)
  30337. * @param uniformName Name of the variable.
  30338. * @param array array to be set.
  30339. * @returns this effect.
  30340. */
  30341. setArray4(uniformName: string, array: number[]): Effect;
  30342. /**
  30343. * Sets matrices on a uniform variable.
  30344. * @param uniformName Name of the variable.
  30345. * @param matrices matrices to be set.
  30346. * @returns this effect.
  30347. */
  30348. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30349. /**
  30350. * Sets matrix on a uniform variable.
  30351. * @param uniformName Name of the variable.
  30352. * @param matrix matrix to be set.
  30353. * @returns this effect.
  30354. */
  30355. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30356. /**
  30357. * 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)
  30358. * @param uniformName Name of the variable.
  30359. * @param matrix matrix to be set.
  30360. * @returns this effect.
  30361. */
  30362. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30363. /**
  30364. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30365. * @param uniformName Name of the variable.
  30366. * @param matrix matrix to be set.
  30367. * @returns this effect.
  30368. */
  30369. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30370. /**
  30371. * Sets a float on a uniform variable.
  30372. * @param uniformName Name of the variable.
  30373. * @param value value to be set.
  30374. * @returns this effect.
  30375. */
  30376. setFloat(uniformName: string, value: number): Effect;
  30377. /**
  30378. * Sets a boolean on a uniform variable.
  30379. * @param uniformName Name of the variable.
  30380. * @param bool value to be set.
  30381. * @returns this effect.
  30382. */
  30383. setBool(uniformName: string, bool: boolean): Effect;
  30384. /**
  30385. * Sets a Vector2 on a uniform variable.
  30386. * @param uniformName Name of the variable.
  30387. * @param vector2 vector2 to be set.
  30388. * @returns this effect.
  30389. */
  30390. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30391. /**
  30392. * Sets a float2 on a uniform variable.
  30393. * @param uniformName Name of the variable.
  30394. * @param x First float in float2.
  30395. * @param y Second float in float2.
  30396. * @returns this effect.
  30397. */
  30398. setFloat2(uniformName: string, x: number, y: number): Effect;
  30399. /**
  30400. * Sets a Vector3 on a uniform variable.
  30401. * @param uniformName Name of the variable.
  30402. * @param vector3 Value to be set.
  30403. * @returns this effect.
  30404. */
  30405. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30406. /**
  30407. * Sets a float3 on a uniform variable.
  30408. * @param uniformName Name of the variable.
  30409. * @param x First float in float3.
  30410. * @param y Second float in float3.
  30411. * @param z Third float in float3.
  30412. * @returns this effect.
  30413. */
  30414. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30415. /**
  30416. * Sets a Vector4 on a uniform variable.
  30417. * @param uniformName Name of the variable.
  30418. * @param vector4 Value to be set.
  30419. * @returns this effect.
  30420. */
  30421. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30422. /**
  30423. * Sets a float4 on a uniform variable.
  30424. * @param uniformName Name of the variable.
  30425. * @param x First float in float4.
  30426. * @param y Second float in float4.
  30427. * @param z Third float in float4.
  30428. * @param w Fourth float in float4.
  30429. * @returns this effect.
  30430. */
  30431. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30432. /**
  30433. * Sets a Color3 on a uniform variable.
  30434. * @param uniformName Name of the variable.
  30435. * @param color3 Value to be set.
  30436. * @returns this effect.
  30437. */
  30438. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30439. /**
  30440. * Sets a Color4 on a uniform variable.
  30441. * @param uniformName Name of the variable.
  30442. * @param color3 Value to be set.
  30443. * @param alpha Alpha value to be set.
  30444. * @returns this effect.
  30445. */
  30446. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30447. /**
  30448. * Sets a Color4 on a uniform variable
  30449. * @param uniformName defines the name of the variable
  30450. * @param color4 defines the value to be set
  30451. * @returns this effect.
  30452. */
  30453. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30454. /** Release all associated resources */
  30455. dispose(): void;
  30456. /**
  30457. * This function will add a new shader to the shader store
  30458. * @param name the name of the shader
  30459. * @param pixelShader optional pixel shader content
  30460. * @param vertexShader optional vertex shader content
  30461. */
  30462. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30463. /**
  30464. * Store of each shader (The can be looked up using effect.key)
  30465. */
  30466. static ShadersStore: {
  30467. [key: string]: string;
  30468. };
  30469. /**
  30470. * Store of each included file for a shader (The can be looked up using effect.key)
  30471. */
  30472. static IncludesShadersStore: {
  30473. [key: string]: string;
  30474. };
  30475. /**
  30476. * Resets the cache of effects.
  30477. */
  30478. static ResetCache(): void;
  30479. }
  30480. }
  30481. declare module BABYLON {
  30482. /**
  30483. * Interface used to describe the capabilities of the engine relatively to the current browser
  30484. */
  30485. export interface EngineCapabilities {
  30486. /** Maximum textures units per fragment shader */
  30487. maxTexturesImageUnits: number;
  30488. /** Maximum texture units per vertex shader */
  30489. maxVertexTextureImageUnits: number;
  30490. /** Maximum textures units in the entire pipeline */
  30491. maxCombinedTexturesImageUnits: number;
  30492. /** Maximum texture size */
  30493. maxTextureSize: number;
  30494. /** Maximum texture samples */
  30495. maxSamples?: number;
  30496. /** Maximum cube texture size */
  30497. maxCubemapTextureSize: number;
  30498. /** Maximum render texture size */
  30499. maxRenderTextureSize: number;
  30500. /** Maximum number of vertex attributes */
  30501. maxVertexAttribs: number;
  30502. /** Maximum number of varyings */
  30503. maxVaryingVectors: number;
  30504. /** Maximum number of uniforms per vertex shader */
  30505. maxVertexUniformVectors: number;
  30506. /** Maximum number of uniforms per fragment shader */
  30507. maxFragmentUniformVectors: number;
  30508. /** Defines if standard derivates (dx/dy) are supported */
  30509. standardDerivatives: boolean;
  30510. /** Defines if s3tc texture compression is supported */
  30511. s3tc?: WEBGL_compressed_texture_s3tc;
  30512. /** Defines if pvrtc texture compression is supported */
  30513. pvrtc: any;
  30514. /** Defines if etc1 texture compression is supported */
  30515. etc1: any;
  30516. /** Defines if etc2 texture compression is supported */
  30517. etc2: any;
  30518. /** Defines if astc texture compression is supported */
  30519. astc: any;
  30520. /** Defines if float textures are supported */
  30521. textureFloat: boolean;
  30522. /** Defines if vertex array objects are supported */
  30523. vertexArrayObject: boolean;
  30524. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30525. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30526. /** Gets the maximum level of anisotropy supported */
  30527. maxAnisotropy: number;
  30528. /** Defines if instancing is supported */
  30529. instancedArrays: boolean;
  30530. /** Defines if 32 bits indices are supported */
  30531. uintIndices: boolean;
  30532. /** Defines if high precision shaders are supported */
  30533. highPrecisionShaderSupported: boolean;
  30534. /** Defines if depth reading in the fragment shader is supported */
  30535. fragmentDepthSupported: boolean;
  30536. /** Defines if float texture linear filtering is supported*/
  30537. textureFloatLinearFiltering: boolean;
  30538. /** Defines if rendering to float textures is supported */
  30539. textureFloatRender: boolean;
  30540. /** Defines if half float textures are supported*/
  30541. textureHalfFloat: boolean;
  30542. /** Defines if half float texture linear filtering is supported*/
  30543. textureHalfFloatLinearFiltering: boolean;
  30544. /** Defines if rendering to half float textures is supported */
  30545. textureHalfFloatRender: boolean;
  30546. /** Defines if textureLOD shader command is supported */
  30547. textureLOD: boolean;
  30548. /** Defines if draw buffers extension is supported */
  30549. drawBuffersExtension: boolean;
  30550. /** Defines if depth textures are supported */
  30551. depthTextureExtension: boolean;
  30552. /** Defines if float color buffer are supported */
  30553. colorBufferFloat: boolean;
  30554. /** Gets disjoint timer query extension (null if not supported) */
  30555. timerQuery?: EXT_disjoint_timer_query;
  30556. /** Defines if timestamp can be used with timer query */
  30557. canUseTimestampForTimerQuery: boolean;
  30558. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30559. multiview?: any;
  30560. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30561. oculusMultiview?: any;
  30562. /** Function used to let the system compiles shaders in background */
  30563. parallelShaderCompile?: {
  30564. COMPLETION_STATUS_KHR: number;
  30565. };
  30566. /** Max number of texture samples for MSAA */
  30567. maxMSAASamples: number;
  30568. /** Defines if the blend min max extension is supported */
  30569. blendMinMax: boolean;
  30570. }
  30571. }
  30572. declare module BABYLON {
  30573. /**
  30574. * @hidden
  30575. **/
  30576. export class DepthCullingState {
  30577. private _isDepthTestDirty;
  30578. private _isDepthMaskDirty;
  30579. private _isDepthFuncDirty;
  30580. private _isCullFaceDirty;
  30581. private _isCullDirty;
  30582. private _isZOffsetDirty;
  30583. private _isFrontFaceDirty;
  30584. private _depthTest;
  30585. private _depthMask;
  30586. private _depthFunc;
  30587. private _cull;
  30588. private _cullFace;
  30589. private _zOffset;
  30590. private _frontFace;
  30591. /**
  30592. * Initializes the state.
  30593. */
  30594. constructor();
  30595. get isDirty(): boolean;
  30596. get zOffset(): number;
  30597. set zOffset(value: number);
  30598. get cullFace(): Nullable<number>;
  30599. set cullFace(value: Nullable<number>);
  30600. get cull(): Nullable<boolean>;
  30601. set cull(value: Nullable<boolean>);
  30602. get depthFunc(): Nullable<number>;
  30603. set depthFunc(value: Nullable<number>);
  30604. get depthMask(): boolean;
  30605. set depthMask(value: boolean);
  30606. get depthTest(): boolean;
  30607. set depthTest(value: boolean);
  30608. get frontFace(): Nullable<number>;
  30609. set frontFace(value: Nullable<number>);
  30610. reset(): void;
  30611. apply(gl: WebGLRenderingContext): void;
  30612. }
  30613. }
  30614. declare module BABYLON {
  30615. /**
  30616. * @hidden
  30617. **/
  30618. export class StencilState {
  30619. /** 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 */
  30620. static readonly ALWAYS: number;
  30621. /** Passed to stencilOperation to specify that stencil value must be kept */
  30622. static readonly KEEP: number;
  30623. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30624. static readonly REPLACE: number;
  30625. private _isStencilTestDirty;
  30626. private _isStencilMaskDirty;
  30627. private _isStencilFuncDirty;
  30628. private _isStencilOpDirty;
  30629. private _stencilTest;
  30630. private _stencilMask;
  30631. private _stencilFunc;
  30632. private _stencilFuncRef;
  30633. private _stencilFuncMask;
  30634. private _stencilOpStencilFail;
  30635. private _stencilOpDepthFail;
  30636. private _stencilOpStencilDepthPass;
  30637. get isDirty(): boolean;
  30638. get stencilFunc(): number;
  30639. set stencilFunc(value: number);
  30640. get stencilFuncRef(): number;
  30641. set stencilFuncRef(value: number);
  30642. get stencilFuncMask(): number;
  30643. set stencilFuncMask(value: number);
  30644. get stencilOpStencilFail(): number;
  30645. set stencilOpStencilFail(value: number);
  30646. get stencilOpDepthFail(): number;
  30647. set stencilOpDepthFail(value: number);
  30648. get stencilOpStencilDepthPass(): number;
  30649. set stencilOpStencilDepthPass(value: number);
  30650. get stencilMask(): number;
  30651. set stencilMask(value: number);
  30652. get stencilTest(): boolean;
  30653. set stencilTest(value: boolean);
  30654. constructor();
  30655. reset(): void;
  30656. apply(gl: WebGLRenderingContext): void;
  30657. }
  30658. }
  30659. declare module BABYLON {
  30660. /**
  30661. * @hidden
  30662. **/
  30663. export class AlphaState {
  30664. private _isAlphaBlendDirty;
  30665. private _isBlendFunctionParametersDirty;
  30666. private _isBlendEquationParametersDirty;
  30667. private _isBlendConstantsDirty;
  30668. private _alphaBlend;
  30669. private _blendFunctionParameters;
  30670. private _blendEquationParameters;
  30671. private _blendConstants;
  30672. /**
  30673. * Initializes the state.
  30674. */
  30675. constructor();
  30676. get isDirty(): boolean;
  30677. get alphaBlend(): boolean;
  30678. set alphaBlend(value: boolean);
  30679. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30680. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30681. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30682. reset(): void;
  30683. apply(gl: WebGLRenderingContext): void;
  30684. }
  30685. }
  30686. declare module BABYLON {
  30687. /** @hidden */
  30688. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30689. attributeProcessor(attribute: string): string;
  30690. varyingProcessor(varying: string, isFragment: boolean): string;
  30691. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30692. }
  30693. }
  30694. declare module BABYLON {
  30695. /**
  30696. * Interface for attribute information associated with buffer instanciation
  30697. */
  30698. export interface InstancingAttributeInfo {
  30699. /**
  30700. * Name of the GLSL attribute
  30701. * if attribute index is not specified, this is used to retrieve the index from the effect
  30702. */
  30703. attributeName: string;
  30704. /**
  30705. * Index/offset of the attribute in the vertex shader
  30706. * if not specified, this will be computes from the name.
  30707. */
  30708. index?: number;
  30709. /**
  30710. * size of the attribute, 1, 2, 3 or 4
  30711. */
  30712. attributeSize: number;
  30713. /**
  30714. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30715. */
  30716. offset: number;
  30717. /**
  30718. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30719. * default to 1
  30720. */
  30721. divisor?: number;
  30722. /**
  30723. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30724. * default is FLOAT
  30725. */
  30726. attributeType?: number;
  30727. /**
  30728. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30729. */
  30730. normalized?: boolean;
  30731. }
  30732. }
  30733. declare module BABYLON {
  30734. interface ThinEngine {
  30735. /**
  30736. * Update a video texture
  30737. * @param texture defines the texture to update
  30738. * @param video defines the video element to use
  30739. * @param invertY defines if data must be stored with Y axis inverted
  30740. */
  30741. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30742. }
  30743. }
  30744. declare module BABYLON {
  30745. /**
  30746. * Settings for finer control over video usage
  30747. */
  30748. export interface VideoTextureSettings {
  30749. /**
  30750. * Applies `autoplay` to video, if specified
  30751. */
  30752. autoPlay?: boolean;
  30753. /**
  30754. * Applies `loop` to video, if specified
  30755. */
  30756. loop?: boolean;
  30757. /**
  30758. * Automatically updates internal texture from video at every frame in the render loop
  30759. */
  30760. autoUpdateTexture: boolean;
  30761. /**
  30762. * Image src displayed during the video loading or until the user interacts with the video.
  30763. */
  30764. poster?: string;
  30765. }
  30766. /**
  30767. * If you want to display a video in your scene, this is the special texture for that.
  30768. * This special texture works similar to other textures, with the exception of a few parameters.
  30769. * @see https://doc.babylonjs.com/how_to/video_texture
  30770. */
  30771. export class VideoTexture extends Texture {
  30772. /**
  30773. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30774. */
  30775. readonly autoUpdateTexture: boolean;
  30776. /**
  30777. * The video instance used by the texture internally
  30778. */
  30779. readonly video: HTMLVideoElement;
  30780. private _onUserActionRequestedObservable;
  30781. /**
  30782. * Event triggerd when a dom action is required by the user to play the video.
  30783. * This happens due to recent changes in browser policies preventing video to auto start.
  30784. */
  30785. get onUserActionRequestedObservable(): Observable<Texture>;
  30786. private _generateMipMaps;
  30787. private _engine;
  30788. private _stillImageCaptured;
  30789. private _displayingPosterTexture;
  30790. private _settings;
  30791. private _createInternalTextureOnEvent;
  30792. private _frameId;
  30793. private _currentSrc;
  30794. /**
  30795. * Creates a video texture.
  30796. * If you want to display a video in your scene, this is the special texture for that.
  30797. * This special texture works similar to other textures, with the exception of a few parameters.
  30798. * @see https://doc.babylonjs.com/how_to/video_texture
  30799. * @param name optional name, will detect from video source, if not defined
  30800. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30801. * @param scene is obviously the current scene.
  30802. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30803. * @param invertY is false by default but can be used to invert video on Y axis
  30804. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30805. * @param settings allows finer control over video usage
  30806. */
  30807. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30808. private _getName;
  30809. private _getVideo;
  30810. private _createInternalTexture;
  30811. private reset;
  30812. /**
  30813. * @hidden Internal method to initiate `update`.
  30814. */
  30815. _rebuild(): void;
  30816. /**
  30817. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30818. */
  30819. update(): void;
  30820. /**
  30821. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30822. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30823. */
  30824. updateTexture(isVisible: boolean): void;
  30825. protected _updateInternalTexture: () => void;
  30826. /**
  30827. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30828. * @param url New url.
  30829. */
  30830. updateURL(url: string): void;
  30831. /**
  30832. * Clones the texture.
  30833. * @returns the cloned texture
  30834. */
  30835. clone(): VideoTexture;
  30836. /**
  30837. * Dispose the texture and release its associated resources.
  30838. */
  30839. dispose(): void;
  30840. /**
  30841. * Creates a video texture straight from a stream.
  30842. * @param scene Define the scene the texture should be created in
  30843. * @param stream Define the stream the texture should be created from
  30844. * @returns The created video texture as a promise
  30845. */
  30846. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30847. /**
  30848. * Creates a video texture straight from your WebCam video feed.
  30849. * @param scene Define the scene the texture should be created in
  30850. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30851. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30852. * @returns The created video texture as a promise
  30853. */
  30854. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30855. minWidth: number;
  30856. maxWidth: number;
  30857. minHeight: number;
  30858. maxHeight: number;
  30859. deviceId: string;
  30860. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30861. /**
  30862. * Creates a video texture straight from your WebCam video feed.
  30863. * @param scene Define the scene the texture should be created in
  30864. * @param onReady Define a callback to triggered once the texture will be ready
  30865. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30866. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30867. */
  30868. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30869. minWidth: number;
  30870. maxWidth: number;
  30871. minHeight: number;
  30872. maxHeight: number;
  30873. deviceId: string;
  30874. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30875. }
  30876. }
  30877. declare module BABYLON {
  30878. /**
  30879. * Defines the interface used by objects working like Scene
  30880. * @hidden
  30881. */
  30882. export interface ISceneLike {
  30883. _addPendingData(data: any): void;
  30884. _removePendingData(data: any): void;
  30885. offlineProvider: IOfflineProvider;
  30886. }
  30887. /** Interface defining initialization parameters for Engine class */
  30888. export interface EngineOptions extends WebGLContextAttributes {
  30889. /**
  30890. * Defines if the engine should no exceed a specified device ratio
  30891. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30892. */
  30893. limitDeviceRatio?: number;
  30894. /**
  30895. * Defines if webvr should be enabled automatically
  30896. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30897. */
  30898. autoEnableWebVR?: boolean;
  30899. /**
  30900. * Defines if webgl2 should be turned off even if supported
  30901. * @see http://doc.babylonjs.com/features/webgl2
  30902. */
  30903. disableWebGL2Support?: boolean;
  30904. /**
  30905. * Defines if webaudio should be initialized as well
  30906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30907. */
  30908. audioEngine?: boolean;
  30909. /**
  30910. * Defines if animations should run using a deterministic lock step
  30911. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30912. */
  30913. deterministicLockstep?: boolean;
  30914. /** Defines the maximum steps to use with deterministic lock step mode */
  30915. lockstepMaxSteps?: number;
  30916. /** Defines the seconds between each deterministic lock step */
  30917. timeStep?: number;
  30918. /**
  30919. * Defines that engine should ignore context lost events
  30920. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30921. */
  30922. doNotHandleContextLost?: boolean;
  30923. /**
  30924. * Defines that engine should ignore modifying touch action attribute and style
  30925. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30926. */
  30927. doNotHandleTouchAction?: boolean;
  30928. /**
  30929. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30930. */
  30931. useHighPrecisionFloats?: boolean;
  30932. }
  30933. /**
  30934. * The base engine class (root of all engines)
  30935. */
  30936. export class ThinEngine {
  30937. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30938. static ExceptionList: ({
  30939. key: string;
  30940. capture: string;
  30941. captureConstraint: number;
  30942. targets: string[];
  30943. } | {
  30944. key: string;
  30945. capture: null;
  30946. captureConstraint: null;
  30947. targets: string[];
  30948. })[];
  30949. /** @hidden */
  30950. static _TextureLoaders: IInternalTextureLoader[];
  30951. /**
  30952. * Returns the current npm package of the sdk
  30953. */
  30954. static get NpmPackage(): string;
  30955. /**
  30956. * Returns the current version of the framework
  30957. */
  30958. static get Version(): string;
  30959. /**
  30960. * Returns a string describing the current engine
  30961. */
  30962. get description(): string;
  30963. /**
  30964. * Gets or sets the epsilon value used by collision engine
  30965. */
  30966. static CollisionsEpsilon: number;
  30967. /**
  30968. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30969. */
  30970. static get ShadersRepository(): string;
  30971. static set ShadersRepository(value: string);
  30972. /** @hidden */
  30973. _shaderProcessor: IShaderProcessor;
  30974. /**
  30975. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30976. */
  30977. forcePOTTextures: boolean;
  30978. /**
  30979. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30980. */
  30981. isFullscreen: boolean;
  30982. /**
  30983. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30984. */
  30985. cullBackFaces: boolean;
  30986. /**
  30987. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30988. */
  30989. renderEvenInBackground: boolean;
  30990. /**
  30991. * Gets or sets a boolean indicating that cache can be kept between frames
  30992. */
  30993. preventCacheWipeBetweenFrames: boolean;
  30994. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30995. validateShaderPrograms: boolean;
  30996. /**
  30997. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30998. * This can provide greater z depth for distant objects.
  30999. */
  31000. useReverseDepthBuffer: boolean;
  31001. /**
  31002. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31003. */
  31004. disableUniformBuffers: boolean;
  31005. /** @hidden */
  31006. _uniformBuffers: UniformBuffer[];
  31007. /**
  31008. * Gets a boolean indicating that the engine supports uniform buffers
  31009. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31010. */
  31011. get supportsUniformBuffers(): boolean;
  31012. /** @hidden */
  31013. _gl: WebGLRenderingContext;
  31014. /** @hidden */
  31015. _webGLVersion: number;
  31016. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31017. protected _windowIsBackground: boolean;
  31018. protected _creationOptions: EngineOptions;
  31019. protected _highPrecisionShadersAllowed: boolean;
  31020. /** @hidden */
  31021. get _shouldUseHighPrecisionShader(): boolean;
  31022. /**
  31023. * Gets a boolean indicating that only power of 2 textures are supported
  31024. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31025. */
  31026. get needPOTTextures(): boolean;
  31027. /** @hidden */
  31028. _badOS: boolean;
  31029. /** @hidden */
  31030. _badDesktopOS: boolean;
  31031. private _hardwareScalingLevel;
  31032. /** @hidden */
  31033. _caps: EngineCapabilities;
  31034. private _isStencilEnable;
  31035. private _glVersion;
  31036. private _glRenderer;
  31037. private _glVendor;
  31038. /** @hidden */
  31039. _videoTextureSupported: boolean;
  31040. protected _renderingQueueLaunched: boolean;
  31041. protected _activeRenderLoops: (() => void)[];
  31042. /**
  31043. * Observable signaled when a context lost event is raised
  31044. */
  31045. onContextLostObservable: Observable<ThinEngine>;
  31046. /**
  31047. * Observable signaled when a context restored event is raised
  31048. */
  31049. onContextRestoredObservable: Observable<ThinEngine>;
  31050. private _onContextLost;
  31051. private _onContextRestored;
  31052. protected _contextWasLost: boolean;
  31053. /** @hidden */
  31054. _doNotHandleContextLost: boolean;
  31055. /**
  31056. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31058. */
  31059. get doNotHandleContextLost(): boolean;
  31060. set doNotHandleContextLost(value: boolean);
  31061. /**
  31062. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31063. */
  31064. disableVertexArrayObjects: boolean;
  31065. /** @hidden */
  31066. protected _colorWrite: boolean;
  31067. /** @hidden */
  31068. protected _colorWriteChanged: boolean;
  31069. /** @hidden */
  31070. protected _depthCullingState: DepthCullingState;
  31071. /** @hidden */
  31072. protected _stencilState: StencilState;
  31073. /** @hidden */
  31074. _alphaState: AlphaState;
  31075. /** @hidden */
  31076. _alphaMode: number;
  31077. /** @hidden */
  31078. _alphaEquation: number;
  31079. /** @hidden */
  31080. _internalTexturesCache: InternalTexture[];
  31081. /** @hidden */
  31082. protected _activeChannel: number;
  31083. private _currentTextureChannel;
  31084. /** @hidden */
  31085. protected _boundTexturesCache: {
  31086. [key: string]: Nullable<InternalTexture>;
  31087. };
  31088. /** @hidden */
  31089. protected _currentEffect: Nullable<Effect>;
  31090. /** @hidden */
  31091. protected _currentProgram: Nullable<WebGLProgram>;
  31092. private _compiledEffects;
  31093. private _vertexAttribArraysEnabled;
  31094. /** @hidden */
  31095. protected _cachedViewport: Nullable<IViewportLike>;
  31096. private _cachedVertexArrayObject;
  31097. /** @hidden */
  31098. protected _cachedVertexBuffers: any;
  31099. /** @hidden */
  31100. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31101. /** @hidden */
  31102. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31103. /** @hidden */
  31104. _currentRenderTarget: Nullable<InternalTexture>;
  31105. private _uintIndicesCurrentlySet;
  31106. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31107. /** @hidden */
  31108. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31109. private _currentBufferPointers;
  31110. private _currentInstanceLocations;
  31111. private _currentInstanceBuffers;
  31112. private _textureUnits;
  31113. /** @hidden */
  31114. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31115. /** @hidden */
  31116. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31117. /** @hidden */
  31118. _boundRenderFunction: any;
  31119. private _vaoRecordInProgress;
  31120. private _mustWipeVertexAttributes;
  31121. private _emptyTexture;
  31122. private _emptyCubeTexture;
  31123. private _emptyTexture3D;
  31124. private _emptyTexture2DArray;
  31125. /** @hidden */
  31126. _frameHandler: number;
  31127. private _nextFreeTextureSlots;
  31128. private _maxSimultaneousTextures;
  31129. private _activeRequests;
  31130. protected _texturesSupported: string[];
  31131. /** @hidden */
  31132. _textureFormatInUse: Nullable<string>;
  31133. protected get _supportsHardwareTextureRescaling(): boolean;
  31134. private _framebufferDimensionsObject;
  31135. /**
  31136. * sets the object from which width and height will be taken from when getting render width and height
  31137. * Will fallback to the gl object
  31138. * @param dimensions the framebuffer width and height that will be used.
  31139. */
  31140. set framebufferDimensionsObject(dimensions: Nullable<{
  31141. framebufferWidth: number;
  31142. framebufferHeight: number;
  31143. }>);
  31144. /**
  31145. * Gets the list of texture formats supported
  31146. */
  31147. get texturesSupported(): Array<string>;
  31148. /**
  31149. * Gets the list of texture formats in use
  31150. */
  31151. get textureFormatInUse(): Nullable<string>;
  31152. /**
  31153. * Gets the current viewport
  31154. */
  31155. get currentViewport(): Nullable<IViewportLike>;
  31156. /**
  31157. * Gets the default empty texture
  31158. */
  31159. get emptyTexture(): InternalTexture;
  31160. /**
  31161. * Gets the default empty 3D texture
  31162. */
  31163. get emptyTexture3D(): InternalTexture;
  31164. /**
  31165. * Gets the default empty 2D array texture
  31166. */
  31167. get emptyTexture2DArray(): InternalTexture;
  31168. /**
  31169. * Gets the default empty cube texture
  31170. */
  31171. get emptyCubeTexture(): InternalTexture;
  31172. /**
  31173. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31174. */
  31175. readonly premultipliedAlpha: boolean;
  31176. /**
  31177. * Observable event triggered before each texture is initialized
  31178. */
  31179. onBeforeTextureInitObservable: Observable<Texture>;
  31180. /**
  31181. * Creates a new engine
  31182. * @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
  31183. * @param antialias defines enable antialiasing (default: false)
  31184. * @param options defines further options to be sent to the getContext() function
  31185. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31186. */
  31187. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31188. private _rebuildInternalTextures;
  31189. private _rebuildEffects;
  31190. /**
  31191. * Gets a boolean indicating if all created effects are ready
  31192. * @returns true if all effects are ready
  31193. */
  31194. areAllEffectsReady(): boolean;
  31195. protected _rebuildBuffers(): void;
  31196. private _initGLContext;
  31197. /**
  31198. * Gets version of the current webGL context
  31199. */
  31200. get webGLVersion(): number;
  31201. /**
  31202. * Gets a string idenfifying the name of the class
  31203. * @returns "Engine" string
  31204. */
  31205. getClassName(): string;
  31206. /**
  31207. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31208. */
  31209. get isStencilEnable(): boolean;
  31210. /** @hidden */
  31211. _prepareWorkingCanvas(): void;
  31212. /**
  31213. * Reset the texture cache to empty state
  31214. */
  31215. resetTextureCache(): void;
  31216. /**
  31217. * Gets an object containing information about the current webGL context
  31218. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31219. */
  31220. getGlInfo(): {
  31221. vendor: string;
  31222. renderer: string;
  31223. version: string;
  31224. };
  31225. /**
  31226. * Defines the hardware scaling level.
  31227. * By default the hardware scaling level is computed from the window device ratio.
  31228. * 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.
  31229. * @param level defines the level to use
  31230. */
  31231. setHardwareScalingLevel(level: number): void;
  31232. /**
  31233. * Gets the current hardware scaling level.
  31234. * By default the hardware scaling level is computed from the window device ratio.
  31235. * 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.
  31236. * @returns a number indicating the current hardware scaling level
  31237. */
  31238. getHardwareScalingLevel(): number;
  31239. /**
  31240. * Gets the list of loaded textures
  31241. * @returns an array containing all loaded textures
  31242. */
  31243. getLoadedTexturesCache(): InternalTexture[];
  31244. /**
  31245. * Gets the object containing all engine capabilities
  31246. * @returns the EngineCapabilities object
  31247. */
  31248. getCaps(): EngineCapabilities;
  31249. /**
  31250. * stop executing a render loop function and remove it from the execution array
  31251. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31252. */
  31253. stopRenderLoop(renderFunction?: () => void): void;
  31254. /** @hidden */
  31255. _renderLoop(): void;
  31256. /**
  31257. * Gets the HTML canvas attached with the current webGL context
  31258. * @returns a HTML canvas
  31259. */
  31260. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31261. /**
  31262. * Gets host window
  31263. * @returns the host window object
  31264. */
  31265. getHostWindow(): Nullable<Window>;
  31266. /**
  31267. * Gets the current render width
  31268. * @param useScreen defines if screen size must be used (or the current render target if any)
  31269. * @returns a number defining the current render width
  31270. */
  31271. getRenderWidth(useScreen?: boolean): number;
  31272. /**
  31273. * Gets the current render height
  31274. * @param useScreen defines if screen size must be used (or the current render target if any)
  31275. * @returns a number defining the current render height
  31276. */
  31277. getRenderHeight(useScreen?: boolean): number;
  31278. /**
  31279. * Can be used to override the current requestAnimationFrame requester.
  31280. * @hidden
  31281. */
  31282. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31283. /**
  31284. * Register and execute a render loop. The engine can have more than one render function
  31285. * @param renderFunction defines the function to continuously execute
  31286. */
  31287. runRenderLoop(renderFunction: () => void): void;
  31288. /**
  31289. * Clear the current render buffer or the current render target (if any is set up)
  31290. * @param color defines the color to use
  31291. * @param backBuffer defines if the back buffer must be cleared
  31292. * @param depth defines if the depth buffer must be cleared
  31293. * @param stencil defines if the stencil buffer must be cleared
  31294. */
  31295. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31296. private _viewportCached;
  31297. /** @hidden */
  31298. _viewport(x: number, y: number, width: number, height: number): void;
  31299. /**
  31300. * Set the WebGL's viewport
  31301. * @param viewport defines the viewport element to be used
  31302. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31303. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31304. */
  31305. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31306. /**
  31307. * Begin a new frame
  31308. */
  31309. beginFrame(): void;
  31310. /**
  31311. * Enf the current frame
  31312. */
  31313. endFrame(): void;
  31314. /**
  31315. * Resize the view according to the canvas' size
  31316. */
  31317. resize(): void;
  31318. /**
  31319. * Force a specific size of the canvas
  31320. * @param width defines the new canvas' width
  31321. * @param height defines the new canvas' height
  31322. */
  31323. setSize(width: number, height: number): void;
  31324. /**
  31325. * Binds the frame buffer to the specified texture.
  31326. * @param texture The texture to render to or null for the default canvas
  31327. * @param faceIndex The face of the texture to render to in case of cube texture
  31328. * @param requiredWidth The width of the target to render to
  31329. * @param requiredHeight The height of the target to render to
  31330. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31331. * @param lodLevel defines the lod level to bind to the frame buffer
  31332. * @param layer defines the 2d array index to bind to frame buffer to
  31333. */
  31334. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31335. /** @hidden */
  31336. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31337. /**
  31338. * Unbind the current render target texture from the webGL context
  31339. * @param texture defines the render target texture to unbind
  31340. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31341. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31342. */
  31343. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31344. /**
  31345. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31346. */
  31347. flushFramebuffer(): void;
  31348. /**
  31349. * Unbind the current render target and bind the default framebuffer
  31350. */
  31351. restoreDefaultFramebuffer(): void;
  31352. /** @hidden */
  31353. protected _resetVertexBufferBinding(): void;
  31354. /**
  31355. * Creates a vertex buffer
  31356. * @param data the data for the vertex buffer
  31357. * @returns the new WebGL static buffer
  31358. */
  31359. createVertexBuffer(data: DataArray): DataBuffer;
  31360. private _createVertexBuffer;
  31361. /**
  31362. * Creates a dynamic vertex buffer
  31363. * @param data the data for the dynamic vertex buffer
  31364. * @returns the new WebGL dynamic buffer
  31365. */
  31366. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31367. protected _resetIndexBufferBinding(): void;
  31368. /**
  31369. * Creates a new index buffer
  31370. * @param indices defines the content of the index buffer
  31371. * @param updatable defines if the index buffer must be updatable
  31372. * @returns a new webGL buffer
  31373. */
  31374. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31375. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31376. /**
  31377. * Bind a webGL buffer to the webGL context
  31378. * @param buffer defines the buffer to bind
  31379. */
  31380. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31381. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31382. private bindBuffer;
  31383. /**
  31384. * update the bound buffer with the given data
  31385. * @param data defines the data to update
  31386. */
  31387. updateArrayBuffer(data: Float32Array): void;
  31388. private _vertexAttribPointer;
  31389. /** @hidden */
  31390. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31391. private _bindVertexBuffersAttributes;
  31392. /**
  31393. * Records a vertex array object
  31394. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31395. * @param vertexBuffers defines the list of vertex buffers to store
  31396. * @param indexBuffer defines the index buffer to store
  31397. * @param effect defines the effect to store
  31398. * @returns the new vertex array object
  31399. */
  31400. recordVertexArrayObject(vertexBuffers: {
  31401. [key: string]: VertexBuffer;
  31402. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31403. /**
  31404. * Bind a specific vertex array object
  31405. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31406. * @param vertexArrayObject defines the vertex array object to bind
  31407. * @param indexBuffer defines the index buffer to bind
  31408. */
  31409. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31410. /**
  31411. * Bind webGl buffers directly to the webGL context
  31412. * @param vertexBuffer defines the vertex buffer to bind
  31413. * @param indexBuffer defines the index buffer to bind
  31414. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31415. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31416. * @param effect defines the effect associated with the vertex buffer
  31417. */
  31418. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31419. private _unbindVertexArrayObject;
  31420. /**
  31421. * Bind a list of vertex buffers to the webGL context
  31422. * @param vertexBuffers defines the list of vertex buffers to bind
  31423. * @param indexBuffer defines the index buffer to bind
  31424. * @param effect defines the effect associated with the vertex buffers
  31425. */
  31426. bindBuffers(vertexBuffers: {
  31427. [key: string]: Nullable<VertexBuffer>;
  31428. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31429. /**
  31430. * Unbind all instance attributes
  31431. */
  31432. unbindInstanceAttributes(): void;
  31433. /**
  31434. * Release and free the memory of a vertex array object
  31435. * @param vao defines the vertex array object to delete
  31436. */
  31437. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31438. /** @hidden */
  31439. _releaseBuffer(buffer: DataBuffer): boolean;
  31440. protected _deleteBuffer(buffer: DataBuffer): void;
  31441. /**
  31442. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31443. * @param instancesBuffer defines the webGL buffer to update and bind
  31444. * @param data defines the data to store in the buffer
  31445. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31446. */
  31447. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31448. /**
  31449. * Bind the content of a webGL buffer used with instantiation
  31450. * @param instancesBuffer defines the webGL buffer to bind
  31451. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31452. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31453. */
  31454. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31455. /**
  31456. * Disable the instance attribute corresponding to the name in parameter
  31457. * @param name defines the name of the attribute to disable
  31458. */
  31459. disableInstanceAttributeByName(name: string): void;
  31460. /**
  31461. * Disable the instance attribute corresponding to the location in parameter
  31462. * @param attributeLocation defines the attribute location of the attribute to disable
  31463. */
  31464. disableInstanceAttribute(attributeLocation: number): void;
  31465. /**
  31466. * Disable the attribute corresponding to the location in parameter
  31467. * @param attributeLocation defines the attribute location of the attribute to disable
  31468. */
  31469. disableAttributeByIndex(attributeLocation: number): void;
  31470. /**
  31471. * Send a draw order
  31472. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31473. * @param indexStart defines the starting index
  31474. * @param indexCount defines the number of index to draw
  31475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31476. */
  31477. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31478. /**
  31479. * Draw a list of points
  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. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31485. /**
  31486. * Draw a list of unindexed primitives
  31487. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31488. * @param verticesStart defines the index of first vertex to draw
  31489. * @param verticesCount defines the count of vertices to draw
  31490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31491. */
  31492. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31493. /**
  31494. * Draw a list of indexed primitives
  31495. * @param fillMode defines the primitive to use
  31496. * @param indexStart defines the starting index
  31497. * @param indexCount defines the number of index to draw
  31498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31499. */
  31500. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31501. /**
  31502. * Draw a list of unindexed primitives
  31503. * @param fillMode defines the primitive to use
  31504. * @param verticesStart defines the index of first vertex to draw
  31505. * @param verticesCount defines the count of vertices to draw
  31506. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31507. */
  31508. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31509. private _drawMode;
  31510. /** @hidden */
  31511. protected _reportDrawCall(): void;
  31512. /** @hidden */
  31513. _releaseEffect(effect: Effect): void;
  31514. /** @hidden */
  31515. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31516. /**
  31517. * Create a new effect (used to store vertex/fragment shaders)
  31518. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31519. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31520. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31521. * @param samplers defines an array of string used to represent textures
  31522. * @param defines defines the string containing the defines to use to compile the shaders
  31523. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31524. * @param onCompiled defines a function to call when the effect creation is successful
  31525. * @param onError defines a function to call when the effect creation has failed
  31526. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31527. * @returns the new Effect
  31528. */
  31529. 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;
  31530. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31531. private _compileShader;
  31532. private _compileRawShader;
  31533. /**
  31534. * Directly creates a webGL program
  31535. * @param pipelineContext defines the pipeline context to attach to
  31536. * @param vertexCode defines the vertex shader code to use
  31537. * @param fragmentCode defines the fragment shader code to use
  31538. * @param context defines the webGL context to use (if not set, the current one will be used)
  31539. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31540. * @returns the new webGL program
  31541. */
  31542. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31543. /**
  31544. * Creates a webGL program
  31545. * @param pipelineContext defines the pipeline context to attach to
  31546. * @param vertexCode defines the vertex shader code to use
  31547. * @param fragmentCode defines the fragment shader code to use
  31548. * @param defines defines the string containing the defines to use to compile the shaders
  31549. * @param context defines the webGL context to use (if not set, the current one will be used)
  31550. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31551. * @returns the new webGL program
  31552. */
  31553. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31554. /**
  31555. * Creates a new pipeline context
  31556. * @returns the new pipeline
  31557. */
  31558. createPipelineContext(): IPipelineContext;
  31559. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31560. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31561. /** @hidden */
  31562. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31563. /** @hidden */
  31564. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31565. /** @hidden */
  31566. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31567. /**
  31568. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31569. * @param pipelineContext defines the pipeline context to use
  31570. * @param uniformsNames defines the list of uniform names
  31571. * @returns an array of webGL uniform locations
  31572. */
  31573. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31574. /**
  31575. * Gets the lsit of active attributes for a given webGL program
  31576. * @param pipelineContext defines the pipeline context to use
  31577. * @param attributesNames defines the list of attribute names to get
  31578. * @returns an array of indices indicating the offset of each attribute
  31579. */
  31580. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31581. /**
  31582. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31583. * @param effect defines the effect to activate
  31584. */
  31585. enableEffect(effect: Nullable<Effect>): void;
  31586. /**
  31587. * Set the value of an uniform to a number (int)
  31588. * @param uniform defines the webGL uniform location where to store the value
  31589. * @param value defines the int number to store
  31590. */
  31591. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31592. /**
  31593. * Set the value of an uniform to an array of int32
  31594. * @param uniform defines the webGL uniform location where to store the value
  31595. * @param array defines the array of int32 to store
  31596. */
  31597. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31598. /**
  31599. * Set the value of an uniform to an array of int32 (stored as vec2)
  31600. * @param uniform defines the webGL uniform location where to store the value
  31601. * @param array defines the array of int32 to store
  31602. */
  31603. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31604. /**
  31605. * Set the value of an uniform to an array of int32 (stored as vec3)
  31606. * @param uniform defines the webGL uniform location where to store the value
  31607. * @param array defines the array of int32 to store
  31608. */
  31609. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31610. /**
  31611. * Set the value of an uniform to an array of int32 (stored as vec4)
  31612. * @param uniform defines the webGL uniform location where to store the value
  31613. * @param array defines the array of int32 to store
  31614. */
  31615. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31616. /**
  31617. * Set the value of an uniform to an array of number
  31618. * @param uniform defines the webGL uniform location where to store the value
  31619. * @param array defines the array of number to store
  31620. */
  31621. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31622. /**
  31623. * Set the value of an uniform to an array of number (stored as vec2)
  31624. * @param uniform defines the webGL uniform location where to store the value
  31625. * @param array defines the array of number to store
  31626. */
  31627. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31628. /**
  31629. * Set the value of an uniform to an array of number (stored as vec3)
  31630. * @param uniform defines the webGL uniform location where to store the value
  31631. * @param array defines the array of number to store
  31632. */
  31633. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31634. /**
  31635. * Set the value of an uniform to an array of number (stored as vec4)
  31636. * @param uniform defines the webGL uniform location where to store the value
  31637. * @param array defines the array of number to store
  31638. */
  31639. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31640. /**
  31641. * Set the value of an uniform to an array of float32 (stored as matrices)
  31642. * @param uniform defines the webGL uniform location where to store the value
  31643. * @param matrices defines the array of float32 to store
  31644. */
  31645. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31646. /**
  31647. * Set the value of an uniform to a matrix (3x3)
  31648. * @param uniform defines the webGL uniform location where to store the value
  31649. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31650. */
  31651. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31652. /**
  31653. * Set the value of an uniform to a matrix (2x2)
  31654. * @param uniform defines the webGL uniform location where to store the value
  31655. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31656. */
  31657. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31658. /**
  31659. * Set the value of an uniform to a number (float)
  31660. * @param uniform defines the webGL uniform location where to store the value
  31661. * @param value defines the float number to store
  31662. */
  31663. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31664. /**
  31665. * Set the value of an uniform to a vec2
  31666. * @param uniform defines the webGL uniform location where to store the value
  31667. * @param x defines the 1st component of the value
  31668. * @param y defines the 2nd component of the value
  31669. */
  31670. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31671. /**
  31672. * Set the value of an uniform to a vec3
  31673. * @param uniform defines the webGL uniform location where to store the value
  31674. * @param x defines the 1st component of the value
  31675. * @param y defines the 2nd component of the value
  31676. * @param z defines the 3rd component of the value
  31677. */
  31678. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31679. /**
  31680. * Set the value of an uniform to a vec4
  31681. * @param uniform defines the webGL uniform location where to store the value
  31682. * @param x defines the 1st component of the value
  31683. * @param y defines the 2nd component of the value
  31684. * @param z defines the 3rd component of the value
  31685. * @param w defines the 4th component of the value
  31686. */
  31687. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31688. /**
  31689. * Apply all cached states (depth, culling, stencil and alpha)
  31690. */
  31691. applyStates(): void;
  31692. /**
  31693. * Enable or disable color writing
  31694. * @param enable defines the state to set
  31695. */
  31696. setColorWrite(enable: boolean): void;
  31697. /**
  31698. * Gets a boolean indicating if color writing is enabled
  31699. * @returns the current color writing state
  31700. */
  31701. getColorWrite(): boolean;
  31702. /**
  31703. * Gets the depth culling state manager
  31704. */
  31705. get depthCullingState(): DepthCullingState;
  31706. /**
  31707. * Gets the alpha state manager
  31708. */
  31709. get alphaState(): AlphaState;
  31710. /**
  31711. * Gets the stencil state manager
  31712. */
  31713. get stencilState(): StencilState;
  31714. /**
  31715. * Clears the list of texture accessible through engine.
  31716. * This can help preventing texture load conflict due to name collision.
  31717. */
  31718. clearInternalTexturesCache(): void;
  31719. /**
  31720. * Force the entire cache to be cleared
  31721. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31722. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31723. */
  31724. wipeCaches(bruteForce?: boolean): void;
  31725. /** @hidden */
  31726. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31727. min: number;
  31728. mag: number;
  31729. };
  31730. /** @hidden */
  31731. _createTexture(): WebGLTexture;
  31732. /**
  31733. * Usually called from Texture.ts.
  31734. * Passed information to create a WebGLTexture
  31735. * @param urlArg defines a value which contains one of the following:
  31736. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31737. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31738. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31739. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31740. * @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)
  31741. * @param scene needed for loading to the correct scene
  31742. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31743. * @param onLoad optional callback to be called upon successful completion
  31744. * @param onError optional callback to be called upon failure
  31745. * @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
  31746. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31747. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31748. * @param forcedExtension defines the extension to use to pick the right loader
  31749. * @param mimeType defines an optional mime type
  31750. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31751. */
  31752. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  31753. /**
  31754. * Loads an image as an HTMLImageElement.
  31755. * @param input url string, ArrayBuffer, or Blob to load
  31756. * @param onLoad callback called when the image successfully loads
  31757. * @param onError callback called when the image fails to load
  31758. * @param offlineProvider offline provider for caching
  31759. * @param mimeType optional mime type
  31760. * @returns the HTMLImageElement of the loaded image
  31761. * @hidden
  31762. */
  31763. 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>;
  31764. /**
  31765. * @hidden
  31766. */
  31767. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31768. /**
  31769. * Creates a raw texture
  31770. * @param data defines the data to store in the texture
  31771. * @param width defines the width of the texture
  31772. * @param height defines the height of the texture
  31773. * @param format defines the format of the data
  31774. * @param generateMipMaps defines if the engine should generate the mip levels
  31775. * @param invertY defines if data must be stored with Y axis inverted
  31776. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31777. * @param compression defines the compression used (null by default)
  31778. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31779. * @returns the raw texture inside an InternalTexture
  31780. */
  31781. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31782. /**
  31783. * Creates a new raw cube texture
  31784. * @param data defines the array of data to use to create each face
  31785. * @param size defines the size of the textures
  31786. * @param format defines the format of the data
  31787. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31788. * @param generateMipMaps defines if the engine should generate the mip levels
  31789. * @param invertY defines if data must be stored with Y axis inverted
  31790. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31791. * @param compression defines the compression used (null by default)
  31792. * @returns the cube texture as an InternalTexture
  31793. */
  31794. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31795. /**
  31796. * Creates a new raw 3D texture
  31797. * @param data defines the data used to create the texture
  31798. * @param width defines the width of the texture
  31799. * @param height defines the height of the texture
  31800. * @param depth defines the depth of the texture
  31801. * @param format defines the format of the texture
  31802. * @param generateMipMaps defines if the engine must generate mip levels
  31803. * @param invertY defines if data must be stored with Y axis inverted
  31804. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31805. * @param compression defines the compressed used (can be null)
  31806. * @param textureType defines the compressed used (can be null)
  31807. * @returns a new raw 3D texture (stored in an InternalTexture)
  31808. */
  31809. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31810. /**
  31811. * Creates a new raw 2D array texture
  31812. * @param data defines the data used to create the texture
  31813. * @param width defines the width of the texture
  31814. * @param height defines the height of the texture
  31815. * @param depth defines the number of layers of the texture
  31816. * @param format defines the format of the texture
  31817. * @param generateMipMaps defines if the engine must generate mip levels
  31818. * @param invertY defines if data must be stored with Y axis inverted
  31819. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31820. * @param compression defines the compressed used (can be null)
  31821. * @param textureType defines the compressed used (can be null)
  31822. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31823. */
  31824. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31825. private _unpackFlipYCached;
  31826. /**
  31827. * In case you are sharing the context with other applications, it might
  31828. * be interested to not cache the unpack flip y state to ensure a consistent
  31829. * value would be set.
  31830. */
  31831. enableUnpackFlipYCached: boolean;
  31832. /** @hidden */
  31833. _unpackFlipY(value: boolean): void;
  31834. /** @hidden */
  31835. _getUnpackAlignement(): number;
  31836. private _getTextureTarget;
  31837. /**
  31838. * Update the sampling mode of a given texture
  31839. * @param samplingMode defines the required sampling mode
  31840. * @param texture defines the texture to update
  31841. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31842. */
  31843. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31844. /**
  31845. * Update the sampling mode of a given texture
  31846. * @param texture defines the texture to update
  31847. * @param wrapU defines the texture wrap mode of the u coordinates
  31848. * @param wrapV defines the texture wrap mode of the v coordinates
  31849. * @param wrapR defines the texture wrap mode of the r coordinates
  31850. */
  31851. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31852. /** @hidden */
  31853. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31854. width: number;
  31855. height: number;
  31856. layers?: number;
  31857. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31858. /** @hidden */
  31859. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31860. /** @hidden */
  31861. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31862. /**
  31863. * Update a portion of an internal texture
  31864. * @param texture defines the texture to update
  31865. * @param imageData defines the data to store into the texture
  31866. * @param xOffset defines the x coordinates of the update rectangle
  31867. * @param yOffset defines the y coordinates of the update rectangle
  31868. * @param width defines the width of the update rectangle
  31869. * @param height defines the height of the update rectangle
  31870. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31871. * @param lod defines the lod level to update (0 by default)
  31872. */
  31873. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31874. /** @hidden */
  31875. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31876. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31877. private _prepareWebGLTexture;
  31878. /** @hidden */
  31879. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31880. private _getDepthStencilBuffer;
  31881. /** @hidden */
  31882. _releaseFramebufferObjects(texture: InternalTexture): void;
  31883. /** @hidden */
  31884. _releaseTexture(texture: InternalTexture): void;
  31885. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31886. protected _setProgram(program: WebGLProgram): void;
  31887. protected _boundUniforms: {
  31888. [key: number]: WebGLUniformLocation;
  31889. };
  31890. /**
  31891. * Binds an effect to the webGL context
  31892. * @param effect defines the effect to bind
  31893. */
  31894. bindSamplers(effect: Effect): void;
  31895. private _activateCurrentTexture;
  31896. /** @hidden */
  31897. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31898. /** @hidden */
  31899. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31900. /**
  31901. * Unbind all textures from the webGL context
  31902. */
  31903. unbindAllTextures(): void;
  31904. /**
  31905. * Sets a texture to the according uniform.
  31906. * @param channel The texture channel
  31907. * @param uniform The uniform to set
  31908. * @param texture The texture to apply
  31909. */
  31910. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31911. private _bindSamplerUniformToChannel;
  31912. private _getTextureWrapMode;
  31913. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31914. /**
  31915. * Sets an array of texture to the webGL context
  31916. * @param channel defines the channel where the texture array must be set
  31917. * @param uniform defines the associated uniform location
  31918. * @param textures defines the array of textures to bind
  31919. */
  31920. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31921. /** @hidden */
  31922. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31923. private _setTextureParameterFloat;
  31924. private _setTextureParameterInteger;
  31925. /**
  31926. * Unbind all vertex attributes from the webGL context
  31927. */
  31928. unbindAllAttributes(): void;
  31929. /**
  31930. * 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
  31931. */
  31932. releaseEffects(): void;
  31933. /**
  31934. * Dispose and release all associated resources
  31935. */
  31936. dispose(): void;
  31937. /**
  31938. * Attach a new callback raised when context lost event is fired
  31939. * @param callback defines the callback to call
  31940. */
  31941. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31942. /**
  31943. * Attach a new callback raised when context restored event is fired
  31944. * @param callback defines the callback to call
  31945. */
  31946. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31947. /**
  31948. * Get the current error code of the webGL context
  31949. * @returns the error code
  31950. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31951. */
  31952. getError(): number;
  31953. private _canRenderToFloatFramebuffer;
  31954. private _canRenderToHalfFloatFramebuffer;
  31955. private _canRenderToFramebuffer;
  31956. /** @hidden */
  31957. _getWebGLTextureType(type: number): number;
  31958. /** @hidden */
  31959. _getInternalFormat(format: number): number;
  31960. /** @hidden */
  31961. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31962. /** @hidden */
  31963. _getRGBAMultiSampleBufferFormat(type: number): number;
  31964. /** @hidden */
  31965. _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;
  31966. /**
  31967. * Loads a file from a url
  31968. * @param url url to load
  31969. * @param onSuccess callback called when the file successfully loads
  31970. * @param onProgress callback called while file is loading (if the server supports this mode)
  31971. * @param offlineProvider defines the offline provider for caching
  31972. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31973. * @param onError callback called when the file fails to load
  31974. * @returns a file request object
  31975. * @hidden
  31976. */
  31977. 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;
  31978. /**
  31979. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31980. * @param x defines the x coordinate of the rectangle where pixels must be read
  31981. * @param y defines the y coordinate of the rectangle where pixels must be read
  31982. * @param width defines the width of the rectangle where pixels must be read
  31983. * @param height defines the height of the rectangle where pixels must be read
  31984. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31985. * @returns a Uint8Array containing RGBA colors
  31986. */
  31987. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31988. private static _isSupported;
  31989. /**
  31990. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31991. * @returns true if the engine can be created
  31992. * @ignorenaming
  31993. */
  31994. static isSupported(): boolean;
  31995. /**
  31996. * Find the next highest power of two.
  31997. * @param x Number to start search from.
  31998. * @return Next highest power of two.
  31999. */
  32000. static CeilingPOT(x: number): number;
  32001. /**
  32002. * Find the next lowest power of two.
  32003. * @param x Number to start search from.
  32004. * @return Next lowest power of two.
  32005. */
  32006. static FloorPOT(x: number): number;
  32007. /**
  32008. * Find the nearest power of two.
  32009. * @param x Number to start search from.
  32010. * @return Next nearest power of two.
  32011. */
  32012. static NearestPOT(x: number): number;
  32013. /**
  32014. * Get the closest exponent of two
  32015. * @param value defines the value to approximate
  32016. * @param max defines the maximum value to return
  32017. * @param mode defines how to define the closest value
  32018. * @returns closest exponent of two of the given value
  32019. */
  32020. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32021. /**
  32022. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32023. * @param func - the function to be called
  32024. * @param requester - the object that will request the next frame. Falls back to window.
  32025. * @returns frame number
  32026. */
  32027. static QueueNewFrame(func: () => void, requester?: any): number;
  32028. /**
  32029. * Gets host document
  32030. * @returns the host document object
  32031. */
  32032. getHostDocument(): Nullable<Document>;
  32033. }
  32034. }
  32035. declare module BABYLON {
  32036. /**
  32037. * Class representing spherical harmonics coefficients to the 3rd degree
  32038. */
  32039. export class SphericalHarmonics {
  32040. /**
  32041. * Defines whether or not the harmonics have been prescaled for rendering.
  32042. */
  32043. preScaled: boolean;
  32044. /**
  32045. * The l0,0 coefficients of the spherical harmonics
  32046. */
  32047. l00: Vector3;
  32048. /**
  32049. * The l1,-1 coefficients of the spherical harmonics
  32050. */
  32051. l1_1: Vector3;
  32052. /**
  32053. * The l1,0 coefficients of the spherical harmonics
  32054. */
  32055. l10: Vector3;
  32056. /**
  32057. * The l1,1 coefficients of the spherical harmonics
  32058. */
  32059. l11: Vector3;
  32060. /**
  32061. * The l2,-2 coefficients of the spherical harmonics
  32062. */
  32063. l2_2: Vector3;
  32064. /**
  32065. * The l2,-1 coefficients of the spherical harmonics
  32066. */
  32067. l2_1: Vector3;
  32068. /**
  32069. * The l2,0 coefficients of the spherical harmonics
  32070. */
  32071. l20: Vector3;
  32072. /**
  32073. * The l2,1 coefficients of the spherical harmonics
  32074. */
  32075. l21: Vector3;
  32076. /**
  32077. * The l2,2 coefficients of the spherical harmonics
  32078. */
  32079. l22: Vector3;
  32080. /**
  32081. * Adds a light to the spherical harmonics
  32082. * @param direction the direction of the light
  32083. * @param color the color of the light
  32084. * @param deltaSolidAngle the delta solid angle of the light
  32085. */
  32086. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32087. /**
  32088. * Scales the spherical harmonics by the given amount
  32089. * @param scale the amount to scale
  32090. */
  32091. scaleInPlace(scale: number): void;
  32092. /**
  32093. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32094. *
  32095. * ```
  32096. * E_lm = A_l * L_lm
  32097. * ```
  32098. *
  32099. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32100. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32101. * the scaling factors are given in equation 9.
  32102. */
  32103. convertIncidentRadianceToIrradiance(): void;
  32104. /**
  32105. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32106. *
  32107. * ```
  32108. * L = (1/pi) * E * rho
  32109. * ```
  32110. *
  32111. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32112. */
  32113. convertIrradianceToLambertianRadiance(): void;
  32114. /**
  32115. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32116. * required operations at run time.
  32117. *
  32118. * This is simply done by scaling back the SH with Ylm constants parameter.
  32119. * The trigonometric part being applied by the shader at run time.
  32120. */
  32121. preScaleForRendering(): void;
  32122. /**
  32123. * Constructs a spherical harmonics from an array.
  32124. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32125. * @returns the spherical harmonics
  32126. */
  32127. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32128. /**
  32129. * Gets the spherical harmonics from polynomial
  32130. * @param polynomial the spherical polynomial
  32131. * @returns the spherical harmonics
  32132. */
  32133. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32134. }
  32135. /**
  32136. * Class representing spherical polynomial coefficients to the 3rd degree
  32137. */
  32138. export class SphericalPolynomial {
  32139. private _harmonics;
  32140. /**
  32141. * The spherical harmonics used to create the polynomials.
  32142. */
  32143. get preScaledHarmonics(): SphericalHarmonics;
  32144. /**
  32145. * The x coefficients of the spherical polynomial
  32146. */
  32147. x: Vector3;
  32148. /**
  32149. * The y coefficients of the spherical polynomial
  32150. */
  32151. y: Vector3;
  32152. /**
  32153. * The z coefficients of the spherical polynomial
  32154. */
  32155. z: Vector3;
  32156. /**
  32157. * The xx coefficients of the spherical polynomial
  32158. */
  32159. xx: Vector3;
  32160. /**
  32161. * The yy coefficients of the spherical polynomial
  32162. */
  32163. yy: Vector3;
  32164. /**
  32165. * The zz coefficients of the spherical polynomial
  32166. */
  32167. zz: Vector3;
  32168. /**
  32169. * The xy coefficients of the spherical polynomial
  32170. */
  32171. xy: Vector3;
  32172. /**
  32173. * The yz coefficients of the spherical polynomial
  32174. */
  32175. yz: Vector3;
  32176. /**
  32177. * The zx coefficients of the spherical polynomial
  32178. */
  32179. zx: Vector3;
  32180. /**
  32181. * Adds an ambient color to the spherical polynomial
  32182. * @param color the color to add
  32183. */
  32184. addAmbient(color: Color3): void;
  32185. /**
  32186. * Scales the spherical polynomial by the given amount
  32187. * @param scale the amount to scale
  32188. */
  32189. scaleInPlace(scale: number): void;
  32190. /**
  32191. * Gets the spherical polynomial from harmonics
  32192. * @param harmonics the spherical harmonics
  32193. * @returns the spherical polynomial
  32194. */
  32195. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32196. /**
  32197. * Constructs a spherical polynomial from an array.
  32198. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32199. * @returns the spherical polynomial
  32200. */
  32201. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32202. }
  32203. }
  32204. declare module BABYLON {
  32205. /**
  32206. * Defines the source of the internal texture
  32207. */
  32208. export enum InternalTextureSource {
  32209. /**
  32210. * The source of the texture data is unknown
  32211. */
  32212. Unknown = 0,
  32213. /**
  32214. * Texture data comes from an URL
  32215. */
  32216. Url = 1,
  32217. /**
  32218. * Texture data is only used for temporary storage
  32219. */
  32220. Temp = 2,
  32221. /**
  32222. * Texture data comes from raw data (ArrayBuffer)
  32223. */
  32224. Raw = 3,
  32225. /**
  32226. * Texture content is dynamic (video or dynamic texture)
  32227. */
  32228. Dynamic = 4,
  32229. /**
  32230. * Texture content is generated by rendering to it
  32231. */
  32232. RenderTarget = 5,
  32233. /**
  32234. * Texture content is part of a multi render target process
  32235. */
  32236. MultiRenderTarget = 6,
  32237. /**
  32238. * Texture data comes from a cube data file
  32239. */
  32240. Cube = 7,
  32241. /**
  32242. * Texture data comes from a raw cube data
  32243. */
  32244. CubeRaw = 8,
  32245. /**
  32246. * Texture data come from a prefiltered cube data file
  32247. */
  32248. CubePrefiltered = 9,
  32249. /**
  32250. * Texture content is raw 3D data
  32251. */
  32252. Raw3D = 10,
  32253. /**
  32254. * Texture content is raw 2D array data
  32255. */
  32256. Raw2DArray = 11,
  32257. /**
  32258. * Texture content is a depth texture
  32259. */
  32260. Depth = 12,
  32261. /**
  32262. * Texture data comes from a raw cube data encoded with RGBD
  32263. */
  32264. CubeRawRGBD = 13
  32265. }
  32266. /**
  32267. * Class used to store data associated with WebGL texture data for the engine
  32268. * This class should not be used directly
  32269. */
  32270. export class InternalTexture {
  32271. /** @hidden */
  32272. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32273. /**
  32274. * Defines if the texture is ready
  32275. */
  32276. isReady: boolean;
  32277. /**
  32278. * Defines if the texture is a cube texture
  32279. */
  32280. isCube: boolean;
  32281. /**
  32282. * Defines if the texture contains 3D data
  32283. */
  32284. is3D: boolean;
  32285. /**
  32286. * Defines if the texture contains 2D array data
  32287. */
  32288. is2DArray: boolean;
  32289. /**
  32290. * Defines if the texture contains multiview data
  32291. */
  32292. isMultiview: boolean;
  32293. /**
  32294. * Gets the URL used to load this texture
  32295. */
  32296. url: string;
  32297. /**
  32298. * Gets the sampling mode of the texture
  32299. */
  32300. samplingMode: number;
  32301. /**
  32302. * Gets a boolean indicating if the texture needs mipmaps generation
  32303. */
  32304. generateMipMaps: boolean;
  32305. /**
  32306. * Gets the number of samples used by the texture (WebGL2+ only)
  32307. */
  32308. samples: number;
  32309. /**
  32310. * Gets the type of the texture (int, float...)
  32311. */
  32312. type: number;
  32313. /**
  32314. * Gets the format of the texture (RGB, RGBA...)
  32315. */
  32316. format: number;
  32317. /**
  32318. * Observable called when the texture is loaded
  32319. */
  32320. onLoadedObservable: Observable<InternalTexture>;
  32321. /**
  32322. * Gets the width of the texture
  32323. */
  32324. width: number;
  32325. /**
  32326. * Gets the height of the texture
  32327. */
  32328. height: number;
  32329. /**
  32330. * Gets the depth of the texture
  32331. */
  32332. depth: number;
  32333. /**
  32334. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32335. */
  32336. baseWidth: number;
  32337. /**
  32338. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32339. */
  32340. baseHeight: number;
  32341. /**
  32342. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32343. */
  32344. baseDepth: number;
  32345. /**
  32346. * Gets a boolean indicating if the texture is inverted on Y axis
  32347. */
  32348. invertY: boolean;
  32349. /** @hidden */
  32350. _invertVScale: boolean;
  32351. /** @hidden */
  32352. _associatedChannel: number;
  32353. /** @hidden */
  32354. _source: InternalTextureSource;
  32355. /** @hidden */
  32356. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32357. /** @hidden */
  32358. _bufferView: Nullable<ArrayBufferView>;
  32359. /** @hidden */
  32360. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32361. /** @hidden */
  32362. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32363. /** @hidden */
  32364. _size: number;
  32365. /** @hidden */
  32366. _extension: string;
  32367. /** @hidden */
  32368. _files: Nullable<string[]>;
  32369. /** @hidden */
  32370. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32371. /** @hidden */
  32372. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32373. /** @hidden */
  32374. _framebuffer: Nullable<WebGLFramebuffer>;
  32375. /** @hidden */
  32376. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32377. /** @hidden */
  32378. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32379. /** @hidden */
  32380. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32381. /** @hidden */
  32382. _attachments: Nullable<number[]>;
  32383. /** @hidden */
  32384. _cachedCoordinatesMode: Nullable<number>;
  32385. /** @hidden */
  32386. _cachedWrapU: Nullable<number>;
  32387. /** @hidden */
  32388. _cachedWrapV: Nullable<number>;
  32389. /** @hidden */
  32390. _cachedWrapR: Nullable<number>;
  32391. /** @hidden */
  32392. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32393. /** @hidden */
  32394. _isDisabled: boolean;
  32395. /** @hidden */
  32396. _compression: Nullable<string>;
  32397. /** @hidden */
  32398. _generateStencilBuffer: boolean;
  32399. /** @hidden */
  32400. _generateDepthBuffer: boolean;
  32401. /** @hidden */
  32402. _comparisonFunction: number;
  32403. /** @hidden */
  32404. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32405. /** @hidden */
  32406. _lodGenerationScale: number;
  32407. /** @hidden */
  32408. _lodGenerationOffset: number;
  32409. /** @hidden */
  32410. _depthStencilTexture: Nullable<InternalTexture>;
  32411. /** @hidden */
  32412. _colorTextureArray: Nullable<WebGLTexture>;
  32413. /** @hidden */
  32414. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32415. /** @hidden */
  32416. _lodTextureHigh: Nullable<BaseTexture>;
  32417. /** @hidden */
  32418. _lodTextureMid: Nullable<BaseTexture>;
  32419. /** @hidden */
  32420. _lodTextureLow: Nullable<BaseTexture>;
  32421. /** @hidden */
  32422. _isRGBD: boolean;
  32423. /** @hidden */
  32424. _linearSpecularLOD: boolean;
  32425. /** @hidden */
  32426. _irradianceTexture: Nullable<BaseTexture>;
  32427. /** @hidden */
  32428. _webGLTexture: Nullable<WebGLTexture>;
  32429. /** @hidden */
  32430. _references: number;
  32431. private _engine;
  32432. /**
  32433. * Gets the Engine the texture belongs to.
  32434. * @returns The babylon engine
  32435. */
  32436. getEngine(): ThinEngine;
  32437. /**
  32438. * Gets the data source type of the texture
  32439. */
  32440. get source(): InternalTextureSource;
  32441. /**
  32442. * Creates a new InternalTexture
  32443. * @param engine defines the engine to use
  32444. * @param source defines the type of data that will be used
  32445. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32446. */
  32447. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32448. /**
  32449. * Increments the number of references (ie. the number of Texture that point to it)
  32450. */
  32451. incrementReferences(): void;
  32452. /**
  32453. * Change the size of the texture (not the size of the content)
  32454. * @param width defines the new width
  32455. * @param height defines the new height
  32456. * @param depth defines the new depth (1 by default)
  32457. */
  32458. updateSize(width: int, height: int, depth?: int): void;
  32459. /** @hidden */
  32460. _rebuild(): void;
  32461. /** @hidden */
  32462. _swapAndDie(target: InternalTexture): void;
  32463. /**
  32464. * Dispose the current allocated resources
  32465. */
  32466. dispose(): void;
  32467. }
  32468. }
  32469. declare module BABYLON {
  32470. /**
  32471. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32473. */
  32474. export class Analyser {
  32475. /**
  32476. * Gets or sets the smoothing
  32477. * @ignorenaming
  32478. */
  32479. SMOOTHING: number;
  32480. /**
  32481. * Gets or sets the FFT table size
  32482. * @ignorenaming
  32483. */
  32484. FFT_SIZE: number;
  32485. /**
  32486. * Gets or sets the bar graph amplitude
  32487. * @ignorenaming
  32488. */
  32489. BARGRAPHAMPLITUDE: number;
  32490. /**
  32491. * Gets or sets the position of the debug canvas
  32492. * @ignorenaming
  32493. */
  32494. DEBUGCANVASPOS: {
  32495. x: number;
  32496. y: number;
  32497. };
  32498. /**
  32499. * Gets or sets the debug canvas size
  32500. * @ignorenaming
  32501. */
  32502. DEBUGCANVASSIZE: {
  32503. width: number;
  32504. height: number;
  32505. };
  32506. private _byteFreqs;
  32507. private _byteTime;
  32508. private _floatFreqs;
  32509. private _webAudioAnalyser;
  32510. private _debugCanvas;
  32511. private _debugCanvasContext;
  32512. private _scene;
  32513. private _registerFunc;
  32514. private _audioEngine;
  32515. /**
  32516. * Creates a new analyser
  32517. * @param scene defines hosting scene
  32518. */
  32519. constructor(scene: Scene);
  32520. /**
  32521. * Get the number of data values you will have to play with for the visualization
  32522. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32523. * @returns a number
  32524. */
  32525. getFrequencyBinCount(): number;
  32526. /**
  32527. * Gets the current frequency data as a byte array
  32528. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32529. * @returns a Uint8Array
  32530. */
  32531. getByteFrequencyData(): Uint8Array;
  32532. /**
  32533. * Gets the current waveform as a byte array
  32534. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32535. * @returns a Uint8Array
  32536. */
  32537. getByteTimeDomainData(): Uint8Array;
  32538. /**
  32539. * Gets the current frequency data as a float array
  32540. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32541. * @returns a Float32Array
  32542. */
  32543. getFloatFrequencyData(): Float32Array;
  32544. /**
  32545. * Renders the debug canvas
  32546. */
  32547. drawDebugCanvas(): void;
  32548. /**
  32549. * Stops rendering the debug canvas and removes it
  32550. */
  32551. stopDebugCanvas(): void;
  32552. /**
  32553. * Connects two audio nodes
  32554. * @param inputAudioNode defines first node to connect
  32555. * @param outputAudioNode defines second node to connect
  32556. */
  32557. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32558. /**
  32559. * Releases all associated resources
  32560. */
  32561. dispose(): void;
  32562. }
  32563. }
  32564. declare module BABYLON {
  32565. /**
  32566. * This represents an audio engine and it is responsible
  32567. * to play, synchronize and analyse sounds throughout the application.
  32568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32569. */
  32570. export interface IAudioEngine extends IDisposable {
  32571. /**
  32572. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32573. */
  32574. readonly canUseWebAudio: boolean;
  32575. /**
  32576. * Gets the current AudioContext if available.
  32577. */
  32578. readonly audioContext: Nullable<AudioContext>;
  32579. /**
  32580. * The master gain node defines the global audio volume of your audio engine.
  32581. */
  32582. readonly masterGain: GainNode;
  32583. /**
  32584. * Gets whether or not mp3 are supported by your browser.
  32585. */
  32586. readonly isMP3supported: boolean;
  32587. /**
  32588. * Gets whether or not ogg are supported by your browser.
  32589. */
  32590. readonly isOGGsupported: boolean;
  32591. /**
  32592. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32593. * @ignoreNaming
  32594. */
  32595. WarnedWebAudioUnsupported: boolean;
  32596. /**
  32597. * Defines if the audio engine relies on a custom unlocked button.
  32598. * In this case, the embedded button will not be displayed.
  32599. */
  32600. useCustomUnlockedButton: boolean;
  32601. /**
  32602. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32603. */
  32604. readonly unlocked: boolean;
  32605. /**
  32606. * Event raised when audio has been unlocked on the browser.
  32607. */
  32608. onAudioUnlockedObservable: Observable<AudioEngine>;
  32609. /**
  32610. * Event raised when audio has been locked on the browser.
  32611. */
  32612. onAudioLockedObservable: Observable<AudioEngine>;
  32613. /**
  32614. * Flags the audio engine in Locked state.
  32615. * This happens due to new browser policies preventing audio to autoplay.
  32616. */
  32617. lock(): void;
  32618. /**
  32619. * Unlocks the audio engine once a user action has been done on the dom.
  32620. * This is helpful to resume play once browser policies have been satisfied.
  32621. */
  32622. unlock(): void;
  32623. }
  32624. /**
  32625. * This represents the default audio engine used in babylon.
  32626. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32628. */
  32629. export class AudioEngine implements IAudioEngine {
  32630. private _audioContext;
  32631. private _audioContextInitialized;
  32632. private _muteButton;
  32633. private _hostElement;
  32634. /**
  32635. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32636. */
  32637. canUseWebAudio: boolean;
  32638. /**
  32639. * The master gain node defines the global audio volume of your audio engine.
  32640. */
  32641. masterGain: GainNode;
  32642. /**
  32643. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32644. * @ignoreNaming
  32645. */
  32646. WarnedWebAudioUnsupported: boolean;
  32647. /**
  32648. * Gets whether or not mp3 are supported by your browser.
  32649. */
  32650. isMP3supported: boolean;
  32651. /**
  32652. * Gets whether or not ogg are supported by your browser.
  32653. */
  32654. isOGGsupported: boolean;
  32655. /**
  32656. * Gets whether audio has been unlocked on the device.
  32657. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32658. * a user interaction has happened.
  32659. */
  32660. unlocked: boolean;
  32661. /**
  32662. * Defines if the audio engine relies on a custom unlocked button.
  32663. * In this case, the embedded button will not be displayed.
  32664. */
  32665. useCustomUnlockedButton: boolean;
  32666. /**
  32667. * Event raised when audio has been unlocked on the browser.
  32668. */
  32669. onAudioUnlockedObservable: Observable<AudioEngine>;
  32670. /**
  32671. * Event raised when audio has been locked on the browser.
  32672. */
  32673. onAudioLockedObservable: Observable<AudioEngine>;
  32674. /**
  32675. * Gets the current AudioContext if available.
  32676. */
  32677. get audioContext(): Nullable<AudioContext>;
  32678. private _connectedAnalyser;
  32679. /**
  32680. * Instantiates a new audio engine.
  32681. *
  32682. * There should be only one per page as some browsers restrict the number
  32683. * of audio contexts you can create.
  32684. * @param hostElement defines the host element where to display the mute icon if necessary
  32685. */
  32686. constructor(hostElement?: Nullable<HTMLElement>);
  32687. /**
  32688. * Flags the audio engine in Locked state.
  32689. * This happens due to new browser policies preventing audio to autoplay.
  32690. */
  32691. lock(): void;
  32692. /**
  32693. * Unlocks the audio engine once a user action has been done on the dom.
  32694. * This is helpful to resume play once browser policies have been satisfied.
  32695. */
  32696. unlock(): void;
  32697. private _resumeAudioContext;
  32698. private _initializeAudioContext;
  32699. private _tryToRun;
  32700. private _triggerRunningState;
  32701. private _triggerSuspendedState;
  32702. private _displayMuteButton;
  32703. private _moveButtonToTopLeft;
  32704. private _onResize;
  32705. private _hideMuteButton;
  32706. /**
  32707. * Destroy and release the resources associated with the audio ccontext.
  32708. */
  32709. dispose(): void;
  32710. /**
  32711. * Gets the global volume sets on the master gain.
  32712. * @returns the global volume if set or -1 otherwise
  32713. */
  32714. getGlobalVolume(): number;
  32715. /**
  32716. * Sets the global volume of your experience (sets on the master gain).
  32717. * @param newVolume Defines the new global volume of the application
  32718. */
  32719. setGlobalVolume(newVolume: number): void;
  32720. /**
  32721. * Connect the audio engine to an audio analyser allowing some amazing
  32722. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32724. * @param analyser The analyser to connect to the engine
  32725. */
  32726. connectToAnalyser(analyser: Analyser): void;
  32727. }
  32728. }
  32729. declare module BABYLON {
  32730. /**
  32731. * Interface used to present a loading screen while loading a scene
  32732. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32733. */
  32734. export interface ILoadingScreen {
  32735. /**
  32736. * Function called to display the loading screen
  32737. */
  32738. displayLoadingUI: () => void;
  32739. /**
  32740. * Function called to hide the loading screen
  32741. */
  32742. hideLoadingUI: () => void;
  32743. /**
  32744. * Gets or sets the color to use for the background
  32745. */
  32746. loadingUIBackgroundColor: string;
  32747. /**
  32748. * Gets or sets the text to display while loading
  32749. */
  32750. loadingUIText: string;
  32751. }
  32752. /**
  32753. * Class used for the default loading screen
  32754. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32755. */
  32756. export class DefaultLoadingScreen implements ILoadingScreen {
  32757. private _renderingCanvas;
  32758. private _loadingText;
  32759. private _loadingDivBackgroundColor;
  32760. private _loadingDiv;
  32761. private _loadingTextDiv;
  32762. /** Gets or sets the logo url to use for the default loading screen */
  32763. static DefaultLogoUrl: string;
  32764. /** Gets or sets the spinner url to use for the default loading screen */
  32765. static DefaultSpinnerUrl: string;
  32766. /**
  32767. * Creates a new default loading screen
  32768. * @param _renderingCanvas defines the canvas used to render the scene
  32769. * @param _loadingText defines the default text to display
  32770. * @param _loadingDivBackgroundColor defines the default background color
  32771. */
  32772. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32773. /**
  32774. * Function called to display the loading screen
  32775. */
  32776. displayLoadingUI(): void;
  32777. /**
  32778. * Function called to hide the loading screen
  32779. */
  32780. hideLoadingUI(): void;
  32781. /**
  32782. * Gets or sets the text to display while loading
  32783. */
  32784. set loadingUIText(text: string);
  32785. get loadingUIText(): string;
  32786. /**
  32787. * Gets or sets the color to use for the background
  32788. */
  32789. get loadingUIBackgroundColor(): string;
  32790. set loadingUIBackgroundColor(color: string);
  32791. private _resizeLoadingUI;
  32792. }
  32793. }
  32794. declare module BABYLON {
  32795. /**
  32796. * Interface for any object that can request an animation frame
  32797. */
  32798. export interface ICustomAnimationFrameRequester {
  32799. /**
  32800. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32801. */
  32802. renderFunction?: Function;
  32803. /**
  32804. * Called to request the next frame to render to
  32805. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32806. */
  32807. requestAnimationFrame: Function;
  32808. /**
  32809. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32810. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32811. */
  32812. requestID?: number;
  32813. }
  32814. }
  32815. declare module BABYLON {
  32816. /**
  32817. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32818. */
  32819. export class PerformanceMonitor {
  32820. private _enabled;
  32821. private _rollingFrameTime;
  32822. private _lastFrameTimeMs;
  32823. /**
  32824. * constructor
  32825. * @param frameSampleSize The number of samples required to saturate the sliding window
  32826. */
  32827. constructor(frameSampleSize?: number);
  32828. /**
  32829. * Samples current frame
  32830. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32831. */
  32832. sampleFrame(timeMs?: number): void;
  32833. /**
  32834. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32835. */
  32836. get averageFrameTime(): number;
  32837. /**
  32838. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32839. */
  32840. get averageFrameTimeVariance(): number;
  32841. /**
  32842. * Returns the frame time of the most recent frame
  32843. */
  32844. get instantaneousFrameTime(): number;
  32845. /**
  32846. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32847. */
  32848. get averageFPS(): number;
  32849. /**
  32850. * Returns the average framerate in frames per second using the most recent frame time
  32851. */
  32852. get instantaneousFPS(): number;
  32853. /**
  32854. * Returns true if enough samples have been taken to completely fill the sliding window
  32855. */
  32856. get isSaturated(): boolean;
  32857. /**
  32858. * Enables contributions to the sliding window sample set
  32859. */
  32860. enable(): void;
  32861. /**
  32862. * Disables contributions to the sliding window sample set
  32863. * Samples will not be interpolated over the disabled period
  32864. */
  32865. disable(): void;
  32866. /**
  32867. * Returns true if sampling is enabled
  32868. */
  32869. get isEnabled(): boolean;
  32870. /**
  32871. * Resets performance monitor
  32872. */
  32873. reset(): void;
  32874. }
  32875. /**
  32876. * RollingAverage
  32877. *
  32878. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32879. */
  32880. export class RollingAverage {
  32881. /**
  32882. * Current average
  32883. */
  32884. average: number;
  32885. /**
  32886. * Current variance
  32887. */
  32888. variance: number;
  32889. protected _samples: Array<number>;
  32890. protected _sampleCount: number;
  32891. protected _pos: number;
  32892. protected _m2: number;
  32893. /**
  32894. * constructor
  32895. * @param length The number of samples required to saturate the sliding window
  32896. */
  32897. constructor(length: number);
  32898. /**
  32899. * Adds a sample to the sample set
  32900. * @param v The sample value
  32901. */
  32902. add(v: number): void;
  32903. /**
  32904. * Returns previously added values or null if outside of history or outside the sliding window domain
  32905. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32906. * @return Value previously recorded with add() or null if outside of range
  32907. */
  32908. history(i: number): number;
  32909. /**
  32910. * Returns true if enough samples have been taken to completely fill the sliding window
  32911. * @return true if sample-set saturated
  32912. */
  32913. isSaturated(): boolean;
  32914. /**
  32915. * Resets the rolling average (equivalent to 0 samples taken so far)
  32916. */
  32917. reset(): void;
  32918. /**
  32919. * Wraps a value around the sample range boundaries
  32920. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32921. * @return Wrapped position in sample range
  32922. */
  32923. protected _wrapPosition(i: number): number;
  32924. }
  32925. }
  32926. declare module BABYLON {
  32927. /**
  32928. * This class is used to track a performance counter which is number based.
  32929. * The user has access to many properties which give statistics of different nature.
  32930. *
  32931. * The implementer can track two kinds of Performance Counter: time and count.
  32932. * 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.
  32933. * 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.
  32934. */
  32935. export class PerfCounter {
  32936. /**
  32937. * Gets or sets a global boolean to turn on and off all the counters
  32938. */
  32939. static Enabled: boolean;
  32940. /**
  32941. * Returns the smallest value ever
  32942. */
  32943. get min(): number;
  32944. /**
  32945. * Returns the biggest value ever
  32946. */
  32947. get max(): number;
  32948. /**
  32949. * Returns the average value since the performance counter is running
  32950. */
  32951. get average(): number;
  32952. /**
  32953. * Returns the average value of the last second the counter was monitored
  32954. */
  32955. get lastSecAverage(): number;
  32956. /**
  32957. * Returns the current value
  32958. */
  32959. get current(): number;
  32960. /**
  32961. * Gets the accumulated total
  32962. */
  32963. get total(): number;
  32964. /**
  32965. * Gets the total value count
  32966. */
  32967. get count(): number;
  32968. /**
  32969. * Creates a new counter
  32970. */
  32971. constructor();
  32972. /**
  32973. * Call this method to start monitoring a new frame.
  32974. * 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.
  32975. */
  32976. fetchNewFrame(): void;
  32977. /**
  32978. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32979. * @param newCount the count value to add to the monitored count
  32980. * @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.
  32981. */
  32982. addCount(newCount: number, fetchResult: boolean): void;
  32983. /**
  32984. * Start monitoring this performance counter
  32985. */
  32986. beginMonitoring(): void;
  32987. /**
  32988. * Compute the time lapsed since the previous beginMonitoring() call.
  32989. * @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
  32990. */
  32991. endMonitoring(newFrame?: boolean): void;
  32992. private _fetchResult;
  32993. private _startMonitoringTime;
  32994. private _min;
  32995. private _max;
  32996. private _average;
  32997. private _current;
  32998. private _totalValueCount;
  32999. private _totalAccumulated;
  33000. private _lastSecAverage;
  33001. private _lastSecAccumulated;
  33002. private _lastSecTime;
  33003. private _lastSecValueCount;
  33004. }
  33005. }
  33006. declare module BABYLON {
  33007. interface ThinEngine {
  33008. /**
  33009. * Sets alpha constants used by some alpha blending modes
  33010. * @param r defines the red component
  33011. * @param g defines the green component
  33012. * @param b defines the blue component
  33013. * @param a defines the alpha component
  33014. */
  33015. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33016. /**
  33017. * Sets the current alpha mode
  33018. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33019. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33020. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33021. */
  33022. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33023. /**
  33024. * Gets the current alpha mode
  33025. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33026. * @returns the current alpha mode
  33027. */
  33028. getAlphaMode(): number;
  33029. /**
  33030. * Sets the current alpha equation
  33031. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33032. */
  33033. setAlphaEquation(equation: number): void;
  33034. /**
  33035. * Gets the current alpha equation.
  33036. * @returns the current alpha equation
  33037. */
  33038. getAlphaEquation(): number;
  33039. }
  33040. }
  33041. declare module BABYLON {
  33042. /**
  33043. * Defines the interface used by display changed events
  33044. */
  33045. export interface IDisplayChangedEventArgs {
  33046. /** Gets the vrDisplay object (if any) */
  33047. vrDisplay: Nullable<any>;
  33048. /** Gets a boolean indicating if webVR is supported */
  33049. vrSupported: boolean;
  33050. }
  33051. /**
  33052. * Defines the interface used by objects containing a viewport (like a camera)
  33053. */
  33054. interface IViewportOwnerLike {
  33055. /**
  33056. * Gets or sets the viewport
  33057. */
  33058. viewport: IViewportLike;
  33059. }
  33060. /**
  33061. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33062. */
  33063. export class Engine extends ThinEngine {
  33064. /** Defines that alpha blending is disabled */
  33065. static readonly ALPHA_DISABLE: number;
  33066. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33067. static readonly ALPHA_ADD: number;
  33068. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33069. static readonly ALPHA_COMBINE: number;
  33070. /** Defines that alpha blending to DEST - SRC * DEST */
  33071. static readonly ALPHA_SUBTRACT: number;
  33072. /** Defines that alpha blending to SRC * DEST */
  33073. static readonly ALPHA_MULTIPLY: number;
  33074. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33075. static readonly ALPHA_MAXIMIZED: number;
  33076. /** Defines that alpha blending to SRC + DEST */
  33077. static readonly ALPHA_ONEONE: number;
  33078. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33079. static readonly ALPHA_PREMULTIPLIED: number;
  33080. /**
  33081. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33082. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33083. */
  33084. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33085. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33086. static readonly ALPHA_INTERPOLATE: number;
  33087. /**
  33088. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33089. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33090. */
  33091. static readonly ALPHA_SCREENMODE: number;
  33092. /** Defines that the ressource is not delayed*/
  33093. static readonly DELAYLOADSTATE_NONE: number;
  33094. /** Defines that the ressource was successfully delay loaded */
  33095. static readonly DELAYLOADSTATE_LOADED: number;
  33096. /** Defines that the ressource is currently delay loading */
  33097. static readonly DELAYLOADSTATE_LOADING: number;
  33098. /** Defines that the ressource is delayed and has not started loading */
  33099. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33100. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33101. static readonly NEVER: number;
  33102. /** 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 */
  33103. static readonly ALWAYS: number;
  33104. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33105. static readonly LESS: number;
  33106. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33107. static readonly EQUAL: number;
  33108. /** 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 */
  33109. static readonly LEQUAL: number;
  33110. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33111. static readonly GREATER: number;
  33112. /** 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 */
  33113. static readonly GEQUAL: number;
  33114. /** 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 */
  33115. static readonly NOTEQUAL: number;
  33116. /** Passed to stencilOperation to specify that stencil value must be kept */
  33117. static readonly KEEP: number;
  33118. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33119. static readonly REPLACE: number;
  33120. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33121. static readonly INCR: number;
  33122. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33123. static readonly DECR: number;
  33124. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33125. static readonly INVERT: number;
  33126. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33127. static readonly INCR_WRAP: number;
  33128. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33129. static readonly DECR_WRAP: number;
  33130. /** Texture is not repeating outside of 0..1 UVs */
  33131. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33132. /** Texture is repeating outside of 0..1 UVs */
  33133. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33134. /** Texture is repeating and mirrored */
  33135. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33136. /** ALPHA */
  33137. static readonly TEXTUREFORMAT_ALPHA: number;
  33138. /** LUMINANCE */
  33139. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33140. /** LUMINANCE_ALPHA */
  33141. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33142. /** RGB */
  33143. static readonly TEXTUREFORMAT_RGB: number;
  33144. /** RGBA */
  33145. static readonly TEXTUREFORMAT_RGBA: number;
  33146. /** RED */
  33147. static readonly TEXTUREFORMAT_RED: number;
  33148. /** RED (2nd reference) */
  33149. static readonly TEXTUREFORMAT_R: number;
  33150. /** RG */
  33151. static readonly TEXTUREFORMAT_RG: number;
  33152. /** RED_INTEGER */
  33153. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33154. /** RED_INTEGER (2nd reference) */
  33155. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33156. /** RG_INTEGER */
  33157. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33158. /** RGB_INTEGER */
  33159. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33160. /** RGBA_INTEGER */
  33161. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33162. /** UNSIGNED_BYTE */
  33163. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33164. /** UNSIGNED_BYTE (2nd reference) */
  33165. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33166. /** FLOAT */
  33167. static readonly TEXTURETYPE_FLOAT: number;
  33168. /** HALF_FLOAT */
  33169. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33170. /** BYTE */
  33171. static readonly TEXTURETYPE_BYTE: number;
  33172. /** SHORT */
  33173. static readonly TEXTURETYPE_SHORT: number;
  33174. /** UNSIGNED_SHORT */
  33175. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33176. /** INT */
  33177. static readonly TEXTURETYPE_INT: number;
  33178. /** UNSIGNED_INT */
  33179. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33180. /** UNSIGNED_SHORT_4_4_4_4 */
  33181. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33182. /** UNSIGNED_SHORT_5_5_5_1 */
  33183. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33184. /** UNSIGNED_SHORT_5_6_5 */
  33185. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33186. /** UNSIGNED_INT_2_10_10_10_REV */
  33187. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33188. /** UNSIGNED_INT_24_8 */
  33189. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33190. /** UNSIGNED_INT_10F_11F_11F_REV */
  33191. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33192. /** UNSIGNED_INT_5_9_9_9_REV */
  33193. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33194. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33195. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33196. /** nearest is mag = nearest and min = nearest and mip = linear */
  33197. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33198. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33199. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33200. /** Trilinear is mag = linear and min = linear and mip = linear */
  33201. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33202. /** nearest is mag = nearest and min = nearest and mip = linear */
  33203. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33204. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33205. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33206. /** Trilinear is mag = linear and min = linear and mip = linear */
  33207. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33208. /** mag = nearest and min = nearest and mip = nearest */
  33209. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33210. /** mag = nearest and min = linear and mip = nearest */
  33211. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33212. /** mag = nearest and min = linear and mip = linear */
  33213. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33214. /** mag = nearest and min = linear and mip = none */
  33215. static readonly TEXTURE_NEAREST_LINEAR: number;
  33216. /** mag = nearest and min = nearest and mip = none */
  33217. static readonly TEXTURE_NEAREST_NEAREST: number;
  33218. /** mag = linear and min = nearest and mip = nearest */
  33219. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33220. /** mag = linear and min = nearest and mip = linear */
  33221. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33222. /** mag = linear and min = linear and mip = none */
  33223. static readonly TEXTURE_LINEAR_LINEAR: number;
  33224. /** mag = linear and min = nearest and mip = none */
  33225. static readonly TEXTURE_LINEAR_NEAREST: number;
  33226. /** Explicit coordinates mode */
  33227. static readonly TEXTURE_EXPLICIT_MODE: number;
  33228. /** Spherical coordinates mode */
  33229. static readonly TEXTURE_SPHERICAL_MODE: number;
  33230. /** Planar coordinates mode */
  33231. static readonly TEXTURE_PLANAR_MODE: number;
  33232. /** Cubic coordinates mode */
  33233. static readonly TEXTURE_CUBIC_MODE: number;
  33234. /** Projection coordinates mode */
  33235. static readonly TEXTURE_PROJECTION_MODE: number;
  33236. /** Skybox coordinates mode */
  33237. static readonly TEXTURE_SKYBOX_MODE: number;
  33238. /** Inverse Cubic coordinates mode */
  33239. static readonly TEXTURE_INVCUBIC_MODE: number;
  33240. /** Equirectangular coordinates mode */
  33241. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33242. /** Equirectangular Fixed coordinates mode */
  33243. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33244. /** Equirectangular Fixed Mirrored coordinates mode */
  33245. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33246. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33247. static readonly SCALEMODE_FLOOR: number;
  33248. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33249. static readonly SCALEMODE_NEAREST: number;
  33250. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33251. static readonly SCALEMODE_CEILING: number;
  33252. /**
  33253. * Returns the current npm package of the sdk
  33254. */
  33255. static get NpmPackage(): string;
  33256. /**
  33257. * Returns the current version of the framework
  33258. */
  33259. static get Version(): string;
  33260. /** Gets the list of created engines */
  33261. static get Instances(): Engine[];
  33262. /**
  33263. * Gets the latest created engine
  33264. */
  33265. static get LastCreatedEngine(): Nullable<Engine>;
  33266. /**
  33267. * Gets the latest created scene
  33268. */
  33269. static get LastCreatedScene(): Nullable<Scene>;
  33270. /**
  33271. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33272. * @param flag defines which part of the materials must be marked as dirty
  33273. * @param predicate defines a predicate used to filter which materials should be affected
  33274. */
  33275. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33276. /**
  33277. * Method called to create the default loading screen.
  33278. * This can be overriden in your own app.
  33279. * @param canvas The rendering canvas element
  33280. * @returns The loading screen
  33281. */
  33282. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33283. /**
  33284. * Method called to create the default rescale post process on each engine.
  33285. */
  33286. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33287. /**
  33288. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33289. **/
  33290. enableOfflineSupport: boolean;
  33291. /**
  33292. * 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)
  33293. **/
  33294. disableManifestCheck: boolean;
  33295. /**
  33296. * Gets the list of created scenes
  33297. */
  33298. scenes: Scene[];
  33299. /**
  33300. * Event raised when a new scene is created
  33301. */
  33302. onNewSceneAddedObservable: Observable<Scene>;
  33303. /**
  33304. * Gets the list of created postprocesses
  33305. */
  33306. postProcesses: PostProcess[];
  33307. /**
  33308. * Gets a boolean indicating if the pointer is currently locked
  33309. */
  33310. isPointerLock: boolean;
  33311. /**
  33312. * Observable event triggered each time the rendering canvas is resized
  33313. */
  33314. onResizeObservable: Observable<Engine>;
  33315. /**
  33316. * Observable event triggered each time the canvas loses focus
  33317. */
  33318. onCanvasBlurObservable: Observable<Engine>;
  33319. /**
  33320. * Observable event triggered each time the canvas gains focus
  33321. */
  33322. onCanvasFocusObservable: Observable<Engine>;
  33323. /**
  33324. * Observable event triggered each time the canvas receives pointerout event
  33325. */
  33326. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33327. /**
  33328. * Observable raised when the engine begins a new frame
  33329. */
  33330. onBeginFrameObservable: Observable<Engine>;
  33331. /**
  33332. * If set, will be used to request the next animation frame for the render loop
  33333. */
  33334. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33335. /**
  33336. * Observable raised when the engine ends the current frame
  33337. */
  33338. onEndFrameObservable: Observable<Engine>;
  33339. /**
  33340. * Observable raised when the engine is about to compile a shader
  33341. */
  33342. onBeforeShaderCompilationObservable: Observable<Engine>;
  33343. /**
  33344. * Observable raised when the engine has jsut compiled a shader
  33345. */
  33346. onAfterShaderCompilationObservable: Observable<Engine>;
  33347. /**
  33348. * Gets the audio engine
  33349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33350. * @ignorenaming
  33351. */
  33352. static audioEngine: IAudioEngine;
  33353. /**
  33354. * Default AudioEngine factory responsible of creating the Audio Engine.
  33355. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33356. */
  33357. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33358. /**
  33359. * Default offline support factory responsible of creating a tool used to store data locally.
  33360. * By default, this will create a Database object if the workload has been embedded.
  33361. */
  33362. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33363. private _loadingScreen;
  33364. private _pointerLockRequested;
  33365. private _dummyFramebuffer;
  33366. private _rescalePostProcess;
  33367. private _deterministicLockstep;
  33368. private _lockstepMaxSteps;
  33369. private _timeStep;
  33370. protected get _supportsHardwareTextureRescaling(): boolean;
  33371. private _fps;
  33372. private _deltaTime;
  33373. /** @hidden */
  33374. _drawCalls: PerfCounter;
  33375. /** 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 */
  33376. canvasTabIndex: number;
  33377. /**
  33378. * Turn this value on if you want to pause FPS computation when in background
  33379. */
  33380. disablePerformanceMonitorInBackground: boolean;
  33381. private _performanceMonitor;
  33382. /**
  33383. * Gets the performance monitor attached to this engine
  33384. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33385. */
  33386. get performanceMonitor(): PerformanceMonitor;
  33387. private _onFocus;
  33388. private _onBlur;
  33389. private _onCanvasPointerOut;
  33390. private _onCanvasBlur;
  33391. private _onCanvasFocus;
  33392. private _onFullscreenChange;
  33393. private _onPointerLockChange;
  33394. /**
  33395. * Gets the HTML element used to attach event listeners
  33396. * @returns a HTML element
  33397. */
  33398. getInputElement(): Nullable<HTMLElement>;
  33399. /**
  33400. * Creates a new engine
  33401. * @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
  33402. * @param antialias defines enable antialiasing (default: false)
  33403. * @param options defines further options to be sent to the getContext() function
  33404. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33405. */
  33406. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33407. /**
  33408. * Gets current aspect ratio
  33409. * @param viewportOwner defines the camera to use to get the aspect ratio
  33410. * @param useScreen defines if screen size must be used (or the current render target if any)
  33411. * @returns a number defining the aspect ratio
  33412. */
  33413. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33414. /**
  33415. * Gets current screen aspect ratio
  33416. * @returns a number defining the aspect ratio
  33417. */
  33418. getScreenAspectRatio(): number;
  33419. /**
  33420. * Gets the client rect of the HTML canvas attached with the current webGL context
  33421. * @returns a client rectanglee
  33422. */
  33423. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33424. /**
  33425. * Gets the client rect of the HTML element used for events
  33426. * @returns a client rectanglee
  33427. */
  33428. getInputElementClientRect(): Nullable<ClientRect>;
  33429. /**
  33430. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33431. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33432. * @returns true if engine is in deterministic lock step mode
  33433. */
  33434. isDeterministicLockStep(): boolean;
  33435. /**
  33436. * Gets the max steps when engine is running in deterministic lock step
  33437. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33438. * @returns the max steps
  33439. */
  33440. getLockstepMaxSteps(): number;
  33441. /**
  33442. * Returns the time in ms between steps when using deterministic lock step.
  33443. * @returns time step in (ms)
  33444. */
  33445. getTimeStep(): number;
  33446. /**
  33447. * Force the mipmap generation for the given render target texture
  33448. * @param texture defines the render target texture to use
  33449. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33450. */
  33451. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33452. /** States */
  33453. /**
  33454. * Set various states to the webGL context
  33455. * @param culling defines backface culling state
  33456. * @param zOffset defines the value to apply to zOffset (0 by default)
  33457. * @param force defines if states must be applied even if cache is up to date
  33458. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33459. */
  33460. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33461. /**
  33462. * Set the z offset to apply to current rendering
  33463. * @param value defines the offset to apply
  33464. */
  33465. setZOffset(value: number): void;
  33466. /**
  33467. * Gets the current value of the zOffset
  33468. * @returns the current zOffset state
  33469. */
  33470. getZOffset(): number;
  33471. /**
  33472. * Enable or disable depth buffering
  33473. * @param enable defines the state to set
  33474. */
  33475. setDepthBuffer(enable: boolean): void;
  33476. /**
  33477. * Gets a boolean indicating if depth writing is enabled
  33478. * @returns the current depth writing state
  33479. */
  33480. getDepthWrite(): boolean;
  33481. /**
  33482. * Enable or disable depth writing
  33483. * @param enable defines the state to set
  33484. */
  33485. setDepthWrite(enable: boolean): void;
  33486. /**
  33487. * Gets a boolean indicating if stencil buffer is enabled
  33488. * @returns the current stencil buffer state
  33489. */
  33490. getStencilBuffer(): boolean;
  33491. /**
  33492. * Enable or disable the stencil buffer
  33493. * @param enable defines if the stencil buffer must be enabled or disabled
  33494. */
  33495. setStencilBuffer(enable: boolean): void;
  33496. /**
  33497. * Gets the current stencil mask
  33498. * @returns a number defining the new stencil mask to use
  33499. */
  33500. getStencilMask(): number;
  33501. /**
  33502. * Sets the current stencil mask
  33503. * @param mask defines the new stencil mask to use
  33504. */
  33505. setStencilMask(mask: number): void;
  33506. /**
  33507. * Gets the current stencil function
  33508. * @returns a number defining the stencil function to use
  33509. */
  33510. getStencilFunction(): number;
  33511. /**
  33512. * Gets the current stencil reference value
  33513. * @returns a number defining the stencil reference value to use
  33514. */
  33515. getStencilFunctionReference(): number;
  33516. /**
  33517. * Gets the current stencil mask
  33518. * @returns a number defining the stencil mask to use
  33519. */
  33520. getStencilFunctionMask(): number;
  33521. /**
  33522. * Sets the current stencil function
  33523. * @param stencilFunc defines the new stencil function to use
  33524. */
  33525. setStencilFunction(stencilFunc: number): void;
  33526. /**
  33527. * Sets the current stencil reference
  33528. * @param reference defines the new stencil reference to use
  33529. */
  33530. setStencilFunctionReference(reference: number): void;
  33531. /**
  33532. * Sets the current stencil mask
  33533. * @param mask defines the new stencil mask to use
  33534. */
  33535. setStencilFunctionMask(mask: number): void;
  33536. /**
  33537. * Gets the current stencil operation when stencil fails
  33538. * @returns a number defining stencil operation to use when stencil fails
  33539. */
  33540. getStencilOperationFail(): number;
  33541. /**
  33542. * Gets the current stencil operation when depth fails
  33543. * @returns a number defining stencil operation to use when depth fails
  33544. */
  33545. getStencilOperationDepthFail(): number;
  33546. /**
  33547. * Gets the current stencil operation when stencil passes
  33548. * @returns a number defining stencil operation to use when stencil passes
  33549. */
  33550. getStencilOperationPass(): number;
  33551. /**
  33552. * Sets the stencil operation to use when stencil fails
  33553. * @param operation defines the stencil operation to use when stencil fails
  33554. */
  33555. setStencilOperationFail(operation: number): void;
  33556. /**
  33557. * Sets the stencil operation to use when depth fails
  33558. * @param operation defines the stencil operation to use when depth fails
  33559. */
  33560. setStencilOperationDepthFail(operation: number): void;
  33561. /**
  33562. * Sets the stencil operation to use when stencil passes
  33563. * @param operation defines the stencil operation to use when stencil passes
  33564. */
  33565. setStencilOperationPass(operation: number): void;
  33566. /**
  33567. * Sets a boolean indicating if the dithering state is enabled or disabled
  33568. * @param value defines the dithering state
  33569. */
  33570. setDitheringState(value: boolean): void;
  33571. /**
  33572. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33573. * @param value defines the rasterizer state
  33574. */
  33575. setRasterizerState(value: boolean): void;
  33576. /**
  33577. * Gets the current depth function
  33578. * @returns a number defining the depth function
  33579. */
  33580. getDepthFunction(): Nullable<number>;
  33581. /**
  33582. * Sets the current depth function
  33583. * @param depthFunc defines the function to use
  33584. */
  33585. setDepthFunction(depthFunc: number): void;
  33586. /**
  33587. * Sets the current depth function to GREATER
  33588. */
  33589. setDepthFunctionToGreater(): void;
  33590. /**
  33591. * Sets the current depth function to GEQUAL
  33592. */
  33593. setDepthFunctionToGreaterOrEqual(): void;
  33594. /**
  33595. * Sets the current depth function to LESS
  33596. */
  33597. setDepthFunctionToLess(): void;
  33598. /**
  33599. * Sets the current depth function to LEQUAL
  33600. */
  33601. setDepthFunctionToLessOrEqual(): void;
  33602. private _cachedStencilBuffer;
  33603. private _cachedStencilFunction;
  33604. private _cachedStencilMask;
  33605. private _cachedStencilOperationPass;
  33606. private _cachedStencilOperationFail;
  33607. private _cachedStencilOperationDepthFail;
  33608. private _cachedStencilReference;
  33609. /**
  33610. * Caches the the state of the stencil buffer
  33611. */
  33612. cacheStencilState(): void;
  33613. /**
  33614. * Restores the state of the stencil buffer
  33615. */
  33616. restoreStencilState(): void;
  33617. /**
  33618. * Directly set the WebGL Viewport
  33619. * @param x defines the x coordinate of the viewport (in screen space)
  33620. * @param y defines the y coordinate of the viewport (in screen space)
  33621. * @param width defines the width of the viewport (in screen space)
  33622. * @param height defines the height of the viewport (in screen space)
  33623. * @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
  33624. */
  33625. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33626. /**
  33627. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33628. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33629. * @param y defines the y-coordinate of the corner of the clear rectangle
  33630. * @param width defines the width of the clear rectangle
  33631. * @param height defines the height of the clear rectangle
  33632. * @param clearColor defines the clear color
  33633. */
  33634. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33635. /**
  33636. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33637. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33638. * @param y defines the y-coordinate of the corner of the clear rectangle
  33639. * @param width defines the width of the clear rectangle
  33640. * @param height defines the height of the clear rectangle
  33641. */
  33642. enableScissor(x: number, y: number, width: number, height: number): void;
  33643. /**
  33644. * Disable previously set scissor test rectangle
  33645. */
  33646. disableScissor(): void;
  33647. protected _reportDrawCall(): void;
  33648. /**
  33649. * Initializes a webVR display and starts listening to display change events
  33650. * The onVRDisplayChangedObservable will be notified upon these changes
  33651. * @returns The onVRDisplayChangedObservable
  33652. */
  33653. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33654. /** @hidden */
  33655. _prepareVRComponent(): void;
  33656. /** @hidden */
  33657. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33658. /** @hidden */
  33659. _submitVRFrame(): void;
  33660. /**
  33661. * Call this function to leave webVR mode
  33662. * Will do nothing if webVR is not supported or if there is no webVR device
  33663. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33664. */
  33665. disableVR(): void;
  33666. /**
  33667. * Gets a boolean indicating that the system is in VR mode and is presenting
  33668. * @returns true if VR mode is engaged
  33669. */
  33670. isVRPresenting(): boolean;
  33671. /** @hidden */
  33672. _requestVRFrame(): void;
  33673. /** @hidden */
  33674. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33675. /**
  33676. * Gets the source code of the vertex shader associated with a specific webGL program
  33677. * @param program defines the program to use
  33678. * @returns a string containing the source code of the vertex shader associated with the program
  33679. */
  33680. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33681. /**
  33682. * Gets the source code of the fragment shader associated with a specific webGL program
  33683. * @param program defines the program to use
  33684. * @returns a string containing the source code of the fragment shader associated with the program
  33685. */
  33686. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33687. /**
  33688. * Sets a depth stencil texture from a render target to the according uniform.
  33689. * @param channel The texture channel
  33690. * @param uniform The uniform to set
  33691. * @param texture The render target texture containing the depth stencil texture to apply
  33692. */
  33693. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33694. /**
  33695. * Sets a texture to the webGL context from a postprocess
  33696. * @param channel defines the channel to use
  33697. * @param postProcess defines the source postprocess
  33698. */
  33699. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33700. /**
  33701. * Binds the output of the passed in post process to the texture channel specified
  33702. * @param channel The channel the texture should be bound to
  33703. * @param postProcess The post process which's output should be bound
  33704. */
  33705. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33706. /** @hidden */
  33707. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33708. protected _rebuildBuffers(): void;
  33709. /** @hidden */
  33710. _renderFrame(): void;
  33711. _renderLoop(): void;
  33712. /** @hidden */
  33713. _renderViews(): boolean;
  33714. /**
  33715. * Toggle full screen mode
  33716. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33717. */
  33718. switchFullscreen(requestPointerLock: boolean): void;
  33719. /**
  33720. * Enters full screen mode
  33721. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33722. */
  33723. enterFullscreen(requestPointerLock: boolean): void;
  33724. /**
  33725. * Exits full screen mode
  33726. */
  33727. exitFullscreen(): void;
  33728. /**
  33729. * Enters Pointerlock mode
  33730. */
  33731. enterPointerlock(): void;
  33732. /**
  33733. * Exits Pointerlock mode
  33734. */
  33735. exitPointerlock(): void;
  33736. /**
  33737. * Begin a new frame
  33738. */
  33739. beginFrame(): void;
  33740. /**
  33741. * Enf the current frame
  33742. */
  33743. endFrame(): void;
  33744. resize(): void;
  33745. /**
  33746. * Force a specific size of the canvas
  33747. * @param width defines the new canvas' width
  33748. * @param height defines the new canvas' height
  33749. */
  33750. setSize(width: number, height: number): void;
  33751. /**
  33752. * Updates a dynamic vertex buffer.
  33753. * @param vertexBuffer the vertex buffer to update
  33754. * @param data the data used to update the vertex buffer
  33755. * @param byteOffset the byte offset of the data
  33756. * @param byteLength the byte length of the data
  33757. */
  33758. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33759. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33760. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33761. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33762. _releaseTexture(texture: InternalTexture): void;
  33763. /**
  33764. * @hidden
  33765. * Rescales a texture
  33766. * @param source input texutre
  33767. * @param destination destination texture
  33768. * @param scene scene to use to render the resize
  33769. * @param internalFormat format to use when resizing
  33770. * @param onComplete callback to be called when resize has completed
  33771. */
  33772. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33773. /**
  33774. * Gets the current framerate
  33775. * @returns a number representing the framerate
  33776. */
  33777. getFps(): number;
  33778. /**
  33779. * Gets the time spent between current and previous frame
  33780. * @returns a number representing the delta time in ms
  33781. */
  33782. getDeltaTime(): number;
  33783. private _measureFps;
  33784. /** @hidden */
  33785. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33786. /**
  33787. * Update a dynamic index buffer
  33788. * @param indexBuffer defines the target index buffer
  33789. * @param indices defines the data to update
  33790. * @param offset defines the offset in the target index buffer where update should start
  33791. */
  33792. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33793. /**
  33794. * Updates the sample count of a render target texture
  33795. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33796. * @param texture defines the texture to update
  33797. * @param samples defines the sample count to set
  33798. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33799. */
  33800. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33801. /**
  33802. * Updates a depth texture Comparison Mode and Function.
  33803. * If the comparison Function is equal to 0, the mode will be set to none.
  33804. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33805. * @param texture The texture to set the comparison function for
  33806. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33807. */
  33808. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33809. /**
  33810. * Creates a webGL buffer to use with instanciation
  33811. * @param capacity defines the size of the buffer
  33812. * @returns the webGL buffer
  33813. */
  33814. createInstancesBuffer(capacity: number): DataBuffer;
  33815. /**
  33816. * Delete a webGL buffer used with instanciation
  33817. * @param buffer defines the webGL buffer to delete
  33818. */
  33819. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33820. private _clientWaitAsync;
  33821. /** @hidden */
  33822. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  33823. /** @hidden */
  33824. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33825. dispose(): void;
  33826. private _disableTouchAction;
  33827. /**
  33828. * Display the loading screen
  33829. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33830. */
  33831. displayLoadingUI(): void;
  33832. /**
  33833. * Hide the loading screen
  33834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33835. */
  33836. hideLoadingUI(): void;
  33837. /**
  33838. * Gets the current loading screen object
  33839. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33840. */
  33841. get loadingScreen(): ILoadingScreen;
  33842. /**
  33843. * Sets the current loading screen object
  33844. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33845. */
  33846. set loadingScreen(loadingScreen: ILoadingScreen);
  33847. /**
  33848. * Sets the current loading screen text
  33849. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33850. */
  33851. set loadingUIText(text: string);
  33852. /**
  33853. * Sets the current loading screen background color
  33854. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33855. */
  33856. set loadingUIBackgroundColor(color: string);
  33857. /** Pointerlock and fullscreen */
  33858. /**
  33859. * Ask the browser to promote the current element to pointerlock mode
  33860. * @param element defines the DOM element to promote
  33861. */
  33862. static _RequestPointerlock(element: HTMLElement): void;
  33863. /**
  33864. * Asks the browser to exit pointerlock mode
  33865. */
  33866. static _ExitPointerlock(): void;
  33867. /**
  33868. * Ask the browser to promote the current element to fullscreen rendering mode
  33869. * @param element defines the DOM element to promote
  33870. */
  33871. static _RequestFullscreen(element: HTMLElement): void;
  33872. /**
  33873. * Asks the browser to exit fullscreen mode
  33874. */
  33875. static _ExitFullscreen(): void;
  33876. }
  33877. }
  33878. declare module BABYLON {
  33879. /**
  33880. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33881. * during the life time of the application.
  33882. */
  33883. export class EngineStore {
  33884. /** Gets the list of created engines */
  33885. static Instances: Engine[];
  33886. /** @hidden */
  33887. static _LastCreatedScene: Nullable<Scene>;
  33888. /**
  33889. * Gets the latest created engine
  33890. */
  33891. static get LastCreatedEngine(): Nullable<Engine>;
  33892. /**
  33893. * Gets the latest created scene
  33894. */
  33895. static get LastCreatedScene(): Nullable<Scene>;
  33896. /**
  33897. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33898. * @ignorenaming
  33899. */
  33900. static UseFallbackTexture: boolean;
  33901. /**
  33902. * Texture content used if a texture cannot loaded
  33903. * @ignorenaming
  33904. */
  33905. static FallbackTexture: string;
  33906. }
  33907. }
  33908. declare module BABYLON {
  33909. /**
  33910. * Helper class that provides a small promise polyfill
  33911. */
  33912. export class PromisePolyfill {
  33913. /**
  33914. * Static function used to check if the polyfill is required
  33915. * If this is the case then the function will inject the polyfill to window.Promise
  33916. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33917. */
  33918. static Apply(force?: boolean): void;
  33919. }
  33920. }
  33921. declare module BABYLON {
  33922. /**
  33923. * Interface for screenshot methods with describe argument called `size` as object with options
  33924. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33925. */
  33926. export interface IScreenshotSize {
  33927. /**
  33928. * number in pixels for canvas height
  33929. */
  33930. height?: number;
  33931. /**
  33932. * multiplier allowing render at a higher or lower resolution
  33933. * If value is defined then height and width will be ignored and taken from camera
  33934. */
  33935. precision?: number;
  33936. /**
  33937. * number in pixels for canvas width
  33938. */
  33939. width?: number;
  33940. }
  33941. }
  33942. declare module BABYLON {
  33943. interface IColor4Like {
  33944. r: float;
  33945. g: float;
  33946. b: float;
  33947. a: float;
  33948. }
  33949. /**
  33950. * Class containing a set of static utilities functions
  33951. */
  33952. export class Tools {
  33953. /**
  33954. * Gets or sets the base URL to use to load assets
  33955. */
  33956. static get BaseUrl(): string;
  33957. static set BaseUrl(value: string);
  33958. /**
  33959. * Enable/Disable Custom HTTP Request Headers globally.
  33960. * default = false
  33961. * @see CustomRequestHeaders
  33962. */
  33963. static UseCustomRequestHeaders: boolean;
  33964. /**
  33965. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33966. * i.e. when loading files, where the server/service expects an Authorization header
  33967. */
  33968. static CustomRequestHeaders: {
  33969. [key: string]: string;
  33970. };
  33971. /**
  33972. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33973. */
  33974. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33975. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33976. /**
  33977. * Default behaviour for cors in the application.
  33978. * It can be a string if the expected behavior is identical in the entire app.
  33979. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33980. */
  33981. static get CorsBehavior(): string | ((url: string | string[]) => string);
  33982. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  33983. /**
  33984. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33985. * @ignorenaming
  33986. */
  33987. static get UseFallbackTexture(): boolean;
  33988. static set UseFallbackTexture(value: boolean);
  33989. /**
  33990. * Use this object to register external classes like custom textures or material
  33991. * to allow the laoders to instantiate them
  33992. */
  33993. static get RegisteredExternalClasses(): {
  33994. [key: string]: Object;
  33995. };
  33996. static set RegisteredExternalClasses(classes: {
  33997. [key: string]: Object;
  33998. });
  33999. /**
  34000. * Texture content used if a texture cannot loaded
  34001. * @ignorenaming
  34002. */
  34003. static get fallbackTexture(): string;
  34004. static set fallbackTexture(value: string);
  34005. /**
  34006. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34007. * @param u defines the coordinate on X axis
  34008. * @param v defines the coordinate on Y axis
  34009. * @param width defines the width of the source data
  34010. * @param height defines the height of the source data
  34011. * @param pixels defines the source byte array
  34012. * @param color defines the output color
  34013. */
  34014. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34015. /**
  34016. * Interpolates between a and b via alpha
  34017. * @param a The lower value (returned when alpha = 0)
  34018. * @param b The upper value (returned when alpha = 1)
  34019. * @param alpha The interpolation-factor
  34020. * @return The mixed value
  34021. */
  34022. static Mix(a: number, b: number, alpha: number): number;
  34023. /**
  34024. * Tries to instantiate a new object from a given class name
  34025. * @param className defines the class name to instantiate
  34026. * @returns the new object or null if the system was not able to do the instantiation
  34027. */
  34028. static Instantiate(className: string): any;
  34029. /**
  34030. * Provides a slice function that will work even on IE
  34031. * @param data defines the array to slice
  34032. * @param start defines the start of the data (optional)
  34033. * @param end defines the end of the data (optional)
  34034. * @returns the new sliced array
  34035. */
  34036. static Slice<T>(data: T, start?: number, end?: number): T;
  34037. /**
  34038. * Polyfill for setImmediate
  34039. * @param action defines the action to execute after the current execution block
  34040. */
  34041. static SetImmediate(action: () => void): void;
  34042. /**
  34043. * Function indicating if a number is an exponent of 2
  34044. * @param value defines the value to test
  34045. * @returns true if the value is an exponent of 2
  34046. */
  34047. static IsExponentOfTwo(value: number): boolean;
  34048. private static _tmpFloatArray;
  34049. /**
  34050. * Returns the nearest 32-bit single precision float representation of a Number
  34051. * @param value A Number. If the parameter is of a different type, it will get converted
  34052. * to a number or to NaN if it cannot be converted
  34053. * @returns number
  34054. */
  34055. static FloatRound(value: number): number;
  34056. /**
  34057. * Extracts the filename from a path
  34058. * @param path defines the path to use
  34059. * @returns the filename
  34060. */
  34061. static GetFilename(path: string): string;
  34062. /**
  34063. * Extracts the "folder" part of a path (everything before the filename).
  34064. * @param uri The URI to extract the info from
  34065. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34066. * @returns The "folder" part of the path
  34067. */
  34068. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34069. /**
  34070. * Extracts text content from a DOM element hierarchy
  34071. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34072. */
  34073. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34074. /**
  34075. * Convert an angle in radians to degrees
  34076. * @param angle defines the angle to convert
  34077. * @returns the angle in degrees
  34078. */
  34079. static ToDegrees(angle: number): number;
  34080. /**
  34081. * Convert an angle in degrees to radians
  34082. * @param angle defines the angle to convert
  34083. * @returns the angle in radians
  34084. */
  34085. static ToRadians(angle: number): number;
  34086. /**
  34087. * Returns an array if obj is not an array
  34088. * @param obj defines the object to evaluate as an array
  34089. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34090. * @returns either obj directly if obj is an array or a new array containing obj
  34091. */
  34092. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34093. /**
  34094. * Gets the pointer prefix to use
  34095. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34096. */
  34097. static GetPointerPrefix(): string;
  34098. /**
  34099. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34100. * @param url define the url we are trying
  34101. * @param element define the dom element where to configure the cors policy
  34102. */
  34103. static SetCorsBehavior(url: string | string[], element: {
  34104. crossOrigin: string | null;
  34105. }): void;
  34106. /**
  34107. * Removes unwanted characters from an url
  34108. * @param url defines the url to clean
  34109. * @returns the cleaned url
  34110. */
  34111. static CleanUrl(url: string): string;
  34112. /**
  34113. * Gets or sets a function used to pre-process url before using them to load assets
  34114. */
  34115. static get PreprocessUrl(): (url: string) => string;
  34116. static set PreprocessUrl(processor: (url: string) => string);
  34117. /**
  34118. * Loads an image as an HTMLImageElement.
  34119. * @param input url string, ArrayBuffer, or Blob to load
  34120. * @param onLoad callback called when the image successfully loads
  34121. * @param onError callback called when the image fails to load
  34122. * @param offlineProvider offline provider for caching
  34123. * @param mimeType optional mime type
  34124. * @returns the HTMLImageElement of the loaded image
  34125. */
  34126. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34127. /**
  34128. * Loads a file from a url
  34129. * @param url url string, ArrayBuffer, or Blob to load
  34130. * @param onSuccess callback called when the file successfully loads
  34131. * @param onProgress callback called while file is loading (if the server supports this mode)
  34132. * @param offlineProvider defines the offline provider for caching
  34133. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34134. * @param onError callback called when the file fails to load
  34135. * @returns a file request object
  34136. */
  34137. 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;
  34138. /**
  34139. * Loads a file from a url
  34140. * @param url the file url to load
  34141. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34142. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34143. */
  34144. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34145. /**
  34146. * Load a script (identified by an url). When the url returns, the
  34147. * content of this file is added into a new script element, attached to the DOM (body element)
  34148. * @param scriptUrl defines the url of the script to laod
  34149. * @param onSuccess defines the callback called when the script is loaded
  34150. * @param onError defines the callback to call if an error occurs
  34151. * @param scriptId defines the id of the script element
  34152. */
  34153. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34154. /**
  34155. * Load an asynchronous script (identified by an url). When the url returns, the
  34156. * content of this file is added into a new script element, attached to the DOM (body element)
  34157. * @param scriptUrl defines the url of the script to laod
  34158. * @param scriptId defines the id of the script element
  34159. * @returns a promise request object
  34160. */
  34161. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34162. /**
  34163. * Loads a file from a blob
  34164. * @param fileToLoad defines the blob to use
  34165. * @param callback defines the callback to call when data is loaded
  34166. * @param progressCallback defines the callback to call during loading process
  34167. * @returns a file request object
  34168. */
  34169. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34170. /**
  34171. * Reads a file from a File object
  34172. * @param file defines the file to load
  34173. * @param onSuccess defines the callback to call when data is loaded
  34174. * @param onProgress defines the callback to call during loading process
  34175. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34176. * @param onError defines the callback to call when an error occurs
  34177. * @returns a file request object
  34178. */
  34179. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34180. /**
  34181. * Creates a data url from a given string content
  34182. * @param content defines the content to convert
  34183. * @returns the new data url link
  34184. */
  34185. static FileAsURL(content: string): string;
  34186. /**
  34187. * Format the given number to a specific decimal format
  34188. * @param value defines the number to format
  34189. * @param decimals defines the number of decimals to use
  34190. * @returns the formatted string
  34191. */
  34192. static Format(value: number, decimals?: number): string;
  34193. /**
  34194. * Tries to copy an object by duplicating every property
  34195. * @param source defines the source object
  34196. * @param destination defines the target object
  34197. * @param doNotCopyList defines a list of properties to avoid
  34198. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34199. */
  34200. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34201. /**
  34202. * Gets a boolean indicating if the given object has no own property
  34203. * @param obj defines the object to test
  34204. * @returns true if object has no own property
  34205. */
  34206. static IsEmpty(obj: any): boolean;
  34207. /**
  34208. * Function used to register events at window level
  34209. * @param windowElement defines the Window object to use
  34210. * @param events defines the events to register
  34211. */
  34212. static RegisterTopRootEvents(windowElement: Window, events: {
  34213. name: string;
  34214. handler: Nullable<(e: FocusEvent) => any>;
  34215. }[]): void;
  34216. /**
  34217. * Function used to unregister events from window level
  34218. * @param windowElement defines the Window object to use
  34219. * @param events defines the events to unregister
  34220. */
  34221. static UnregisterTopRootEvents(windowElement: Window, events: {
  34222. name: string;
  34223. handler: Nullable<(e: FocusEvent) => any>;
  34224. }[]): void;
  34225. /**
  34226. * @ignore
  34227. */
  34228. static _ScreenshotCanvas: HTMLCanvasElement;
  34229. /**
  34230. * Dumps the current bound framebuffer
  34231. * @param width defines the rendering width
  34232. * @param height defines the rendering height
  34233. * @param engine defines the hosting engine
  34234. * @param successCallback defines the callback triggered once the data are available
  34235. * @param mimeType defines the mime type of the result
  34236. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34237. */
  34238. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34239. /**
  34240. * Converts the canvas data to blob.
  34241. * This acts as a polyfill for browsers not supporting the to blob function.
  34242. * @param canvas Defines the canvas to extract the data from
  34243. * @param successCallback Defines the callback triggered once the data are available
  34244. * @param mimeType Defines the mime type of the result
  34245. */
  34246. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34247. /**
  34248. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34249. * @param successCallback defines the callback triggered once the data are available
  34250. * @param mimeType defines the mime type of the result
  34251. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34252. */
  34253. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34254. /**
  34255. * Downloads a blob in the browser
  34256. * @param blob defines the blob to download
  34257. * @param fileName defines the name of the downloaded file
  34258. */
  34259. static Download(blob: Blob, fileName: string): void;
  34260. /**
  34261. * Captures a screenshot of the current rendering
  34262. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34263. * @param engine defines the rendering engine
  34264. * @param camera defines the source camera
  34265. * @param size This parameter can be set to a single number or to an object with the
  34266. * following (optional) properties: precision, width, height. If a single number is passed,
  34267. * it will be used for both width and height. If an object is passed, the screenshot size
  34268. * will be derived from the parameters. The precision property is a multiplier allowing
  34269. * rendering at a higher or lower resolution
  34270. * @param successCallback defines the callback receives a single parameter which contains the
  34271. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34272. * src parameter of an <img> to display it
  34273. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34274. * Check your browser for supported MIME types
  34275. */
  34276. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34277. /**
  34278. * Captures a screenshot of the current rendering
  34279. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34280. * @param engine defines the rendering engine
  34281. * @param camera defines the source camera
  34282. * @param size This parameter can be set to a single number or to an object with the
  34283. * following (optional) properties: precision, width, height. If a single number is passed,
  34284. * it will be used for both width and height. If an object is passed, the screenshot size
  34285. * will be derived from the parameters. The precision property is a multiplier allowing
  34286. * rendering at a higher or lower resolution
  34287. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34288. * Check your browser for supported MIME types
  34289. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34290. * to the src parameter of an <img> to display it
  34291. */
  34292. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34293. /**
  34294. * Generates an image screenshot from the specified camera.
  34295. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34296. * @param engine The engine to use for rendering
  34297. * @param camera The camera to use for rendering
  34298. * @param size This parameter can be set to a single number or to an object with the
  34299. * following (optional) properties: precision, width, height. If a single number is passed,
  34300. * it will be used for both width and height. If an object is passed, the screenshot size
  34301. * will be derived from the parameters. The precision property is a multiplier allowing
  34302. * rendering at a higher or lower resolution
  34303. * @param successCallback The callback receives a single parameter which contains the
  34304. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34305. * src parameter of an <img> to display it
  34306. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34307. * Check your browser for supported MIME types
  34308. * @param samples Texture samples (default: 1)
  34309. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34310. * @param fileName A name for for the downloaded file.
  34311. */
  34312. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34313. /**
  34314. * Generates an image screenshot from the specified camera.
  34315. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34316. * @param engine The engine to use for rendering
  34317. * @param camera The camera to use for rendering
  34318. * @param size This parameter can be set to a single number or to an object with the
  34319. * following (optional) properties: precision, width, height. If a single number is passed,
  34320. * it will be used for both width and height. If an object is passed, the screenshot size
  34321. * will be derived from the parameters. The precision property is a multiplier allowing
  34322. * rendering at a higher or lower resolution
  34323. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34324. * Check your browser for supported MIME types
  34325. * @param samples Texture samples (default: 1)
  34326. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34327. * @param fileName A name for for the downloaded file.
  34328. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34329. * to the src parameter of an <img> to display it
  34330. */
  34331. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34332. /**
  34333. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34334. * Be aware Math.random() could cause collisions, but:
  34335. * "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"
  34336. * @returns a pseudo random id
  34337. */
  34338. static RandomId(): string;
  34339. /**
  34340. * Test if the given uri is a base64 string
  34341. * @param uri The uri to test
  34342. * @return True if the uri is a base64 string or false otherwise
  34343. */
  34344. static IsBase64(uri: string): boolean;
  34345. /**
  34346. * Decode the given base64 uri.
  34347. * @param uri The uri to decode
  34348. * @return The decoded base64 data.
  34349. */
  34350. static DecodeBase64(uri: string): ArrayBuffer;
  34351. /**
  34352. * Gets the absolute url.
  34353. * @param url the input url
  34354. * @return the absolute url
  34355. */
  34356. static GetAbsoluteUrl(url: string): string;
  34357. /**
  34358. * No log
  34359. */
  34360. static readonly NoneLogLevel: number;
  34361. /**
  34362. * Only message logs
  34363. */
  34364. static readonly MessageLogLevel: number;
  34365. /**
  34366. * Only warning logs
  34367. */
  34368. static readonly WarningLogLevel: number;
  34369. /**
  34370. * Only error logs
  34371. */
  34372. static readonly ErrorLogLevel: number;
  34373. /**
  34374. * All logs
  34375. */
  34376. static readonly AllLogLevel: number;
  34377. /**
  34378. * Gets a value indicating the number of loading errors
  34379. * @ignorenaming
  34380. */
  34381. static get errorsCount(): number;
  34382. /**
  34383. * Callback called when a new log is added
  34384. */
  34385. static OnNewCacheEntry: (entry: string) => void;
  34386. /**
  34387. * Log a message to the console
  34388. * @param message defines the message to log
  34389. */
  34390. static Log(message: string): void;
  34391. /**
  34392. * Write a warning message to the console
  34393. * @param message defines the message to log
  34394. */
  34395. static Warn(message: string): void;
  34396. /**
  34397. * Write an error message to the console
  34398. * @param message defines the message to log
  34399. */
  34400. static Error(message: string): void;
  34401. /**
  34402. * Gets current log cache (list of logs)
  34403. */
  34404. static get LogCache(): string;
  34405. /**
  34406. * Clears the log cache
  34407. */
  34408. static ClearLogCache(): void;
  34409. /**
  34410. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34411. */
  34412. static set LogLevels(level: number);
  34413. /**
  34414. * Checks if the window object exists
  34415. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34416. */
  34417. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34418. /**
  34419. * No performance log
  34420. */
  34421. static readonly PerformanceNoneLogLevel: number;
  34422. /**
  34423. * Use user marks to log performance
  34424. */
  34425. static readonly PerformanceUserMarkLogLevel: number;
  34426. /**
  34427. * Log performance to the console
  34428. */
  34429. static readonly PerformanceConsoleLogLevel: number;
  34430. private static _performance;
  34431. /**
  34432. * Sets the current performance log level
  34433. */
  34434. static set PerformanceLogLevel(level: number);
  34435. private static _StartPerformanceCounterDisabled;
  34436. private static _EndPerformanceCounterDisabled;
  34437. private static _StartUserMark;
  34438. private static _EndUserMark;
  34439. private static _StartPerformanceConsole;
  34440. private static _EndPerformanceConsole;
  34441. /**
  34442. * Starts a performance counter
  34443. */
  34444. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34445. /**
  34446. * Ends a specific performance coutner
  34447. */
  34448. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34449. /**
  34450. * Gets either window.performance.now() if supported or Date.now() else
  34451. */
  34452. static get Now(): number;
  34453. /**
  34454. * This method will return the name of the class used to create the instance of the given object.
  34455. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34456. * @param object the object to get the class name from
  34457. * @param isType defines if the object is actually a type
  34458. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34459. */
  34460. static GetClassName(object: any, isType?: boolean): string;
  34461. /**
  34462. * Gets the first element of an array satisfying a given predicate
  34463. * @param array defines the array to browse
  34464. * @param predicate defines the predicate to use
  34465. * @returns null if not found or the element
  34466. */
  34467. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34468. /**
  34469. * This method will return the name of the full name of the class, including its owning module (if any).
  34470. * 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).
  34471. * @param object the object to get the class name from
  34472. * @param isType defines if the object is actually a type
  34473. * @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.
  34474. * @ignorenaming
  34475. */
  34476. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34477. /**
  34478. * Returns a promise that resolves after the given amount of time.
  34479. * @param delay Number of milliseconds to delay
  34480. * @returns Promise that resolves after the given amount of time
  34481. */
  34482. static DelayAsync(delay: number): Promise<void>;
  34483. /**
  34484. * Utility function to detect if the current user agent is Safari
  34485. * @returns whether or not the current user agent is safari
  34486. */
  34487. static IsSafari(): boolean;
  34488. }
  34489. /**
  34490. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34491. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34492. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34493. * @param name The name of the class, case should be preserved
  34494. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34495. */
  34496. export function className(name: string, module?: string): (target: Object) => void;
  34497. /**
  34498. * An implementation of a loop for asynchronous functions.
  34499. */
  34500. export class AsyncLoop {
  34501. /**
  34502. * Defines the number of iterations for the loop
  34503. */
  34504. iterations: number;
  34505. /**
  34506. * Defines the current index of the loop.
  34507. */
  34508. index: number;
  34509. private _done;
  34510. private _fn;
  34511. private _successCallback;
  34512. /**
  34513. * Constructor.
  34514. * @param iterations the number of iterations.
  34515. * @param func the function to run each iteration
  34516. * @param successCallback the callback that will be called upon succesful execution
  34517. * @param offset starting offset.
  34518. */
  34519. constructor(
  34520. /**
  34521. * Defines the number of iterations for the loop
  34522. */
  34523. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34524. /**
  34525. * Execute the next iteration. Must be called after the last iteration was finished.
  34526. */
  34527. executeNext(): void;
  34528. /**
  34529. * Break the loop and run the success callback.
  34530. */
  34531. breakLoop(): void;
  34532. /**
  34533. * Create and run an async loop.
  34534. * @param iterations the number of iterations.
  34535. * @param fn the function to run each iteration
  34536. * @param successCallback the callback that will be called upon succesful execution
  34537. * @param offset starting offset.
  34538. * @returns the created async loop object
  34539. */
  34540. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34541. /**
  34542. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34543. * @param iterations total number of iterations
  34544. * @param syncedIterations number of synchronous iterations in each async iteration.
  34545. * @param fn the function to call each iteration.
  34546. * @param callback a success call back that will be called when iterating stops.
  34547. * @param breakFunction a break condition (optional)
  34548. * @param timeout timeout settings for the setTimeout function. default - 0.
  34549. * @returns the created async loop object
  34550. */
  34551. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34552. }
  34553. }
  34554. declare module BABYLON {
  34555. /**
  34556. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34557. * The underlying implementation relies on an associative array to ensure the best performances.
  34558. * The value can be anything including 'null' but except 'undefined'
  34559. */
  34560. export class StringDictionary<T> {
  34561. /**
  34562. * This will clear this dictionary and copy the content from the 'source' one.
  34563. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34564. * @param source the dictionary to take the content from and copy to this dictionary
  34565. */
  34566. copyFrom(source: StringDictionary<T>): void;
  34567. /**
  34568. * Get a value based from its key
  34569. * @param key the given key to get the matching value from
  34570. * @return the value if found, otherwise undefined is returned
  34571. */
  34572. get(key: string): T | undefined;
  34573. /**
  34574. * Get a value from its key or add it if it doesn't exist.
  34575. * This method will ensure you that a given key/data will be present in the dictionary.
  34576. * @param key the given key to get the matching value from
  34577. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34578. * The factory will only be invoked if there's no data for the given key.
  34579. * @return the value corresponding to the key.
  34580. */
  34581. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34582. /**
  34583. * Get a value from its key if present in the dictionary otherwise add it
  34584. * @param key the key to get the value from
  34585. * @param val if there's no such key/value pair in the dictionary add it with this value
  34586. * @return the value corresponding to the key
  34587. */
  34588. getOrAdd(key: string, val: T): T;
  34589. /**
  34590. * Check if there's a given key in the dictionary
  34591. * @param key the key to check for
  34592. * @return true if the key is present, false otherwise
  34593. */
  34594. contains(key: string): boolean;
  34595. /**
  34596. * Add a new key and its corresponding value
  34597. * @param key the key to add
  34598. * @param value the value corresponding to the key
  34599. * @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
  34600. */
  34601. add(key: string, value: T): boolean;
  34602. /**
  34603. * Update a specific value associated to a key
  34604. * @param key defines the key to use
  34605. * @param value defines the value to store
  34606. * @returns true if the value was updated (or false if the key was not found)
  34607. */
  34608. set(key: string, value: T): boolean;
  34609. /**
  34610. * Get the element of the given key and remove it from the dictionary
  34611. * @param key defines the key to search
  34612. * @returns the value associated with the key or null if not found
  34613. */
  34614. getAndRemove(key: string): Nullable<T>;
  34615. /**
  34616. * Remove a key/value from the dictionary.
  34617. * @param key the key to remove
  34618. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34619. */
  34620. remove(key: string): boolean;
  34621. /**
  34622. * Clear the whole content of the dictionary
  34623. */
  34624. clear(): void;
  34625. /**
  34626. * Gets the current count
  34627. */
  34628. get count(): number;
  34629. /**
  34630. * Execute a callback on each key/val of the dictionary.
  34631. * Note that you can remove any element in this dictionary in the callback implementation
  34632. * @param callback the callback to execute on a given key/value pair
  34633. */
  34634. forEach(callback: (key: string, val: T) => void): void;
  34635. /**
  34636. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34637. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34638. * Note that you can remove any element in this dictionary in the callback implementation
  34639. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34640. * @returns the first item
  34641. */
  34642. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34643. private _count;
  34644. private _data;
  34645. }
  34646. }
  34647. declare module BABYLON {
  34648. /** @hidden */
  34649. export interface ICollisionCoordinator {
  34650. createCollider(): Collider;
  34651. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34652. init(scene: Scene): void;
  34653. }
  34654. /** @hidden */
  34655. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34656. private _scene;
  34657. private _scaledPosition;
  34658. private _scaledVelocity;
  34659. private _finalPosition;
  34660. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34661. createCollider(): Collider;
  34662. init(scene: Scene): void;
  34663. private _collideWithWorld;
  34664. }
  34665. }
  34666. declare module BABYLON {
  34667. /**
  34668. * Class used to manage all inputs for the scene.
  34669. */
  34670. export class InputManager {
  34671. /** The distance in pixel that you have to move to prevent some events */
  34672. static DragMovementThreshold: number;
  34673. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34674. static LongPressDelay: number;
  34675. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34676. static DoubleClickDelay: number;
  34677. /** If you need to check double click without raising a single click at first click, enable this flag */
  34678. static ExclusiveDoubleClickMode: boolean;
  34679. private _wheelEventName;
  34680. private _onPointerMove;
  34681. private _onPointerDown;
  34682. private _onPointerUp;
  34683. private _initClickEvent;
  34684. private _initActionManager;
  34685. private _delayedSimpleClick;
  34686. private _delayedSimpleClickTimeout;
  34687. private _previousDelayedSimpleClickTimeout;
  34688. private _meshPickProceed;
  34689. private _previousButtonPressed;
  34690. private _currentPickResult;
  34691. private _previousPickResult;
  34692. private _totalPointersPressed;
  34693. private _doubleClickOccured;
  34694. private _pointerOverMesh;
  34695. private _pickedDownMesh;
  34696. private _pickedUpMesh;
  34697. private _pointerX;
  34698. private _pointerY;
  34699. private _unTranslatedPointerX;
  34700. private _unTranslatedPointerY;
  34701. private _startingPointerPosition;
  34702. private _previousStartingPointerPosition;
  34703. private _startingPointerTime;
  34704. private _previousStartingPointerTime;
  34705. private _pointerCaptures;
  34706. private _onKeyDown;
  34707. private _onKeyUp;
  34708. private _onCanvasFocusObserver;
  34709. private _onCanvasBlurObserver;
  34710. private _scene;
  34711. /**
  34712. * Creates a new InputManager
  34713. * @param scene defines the hosting scene
  34714. */
  34715. constructor(scene: Scene);
  34716. /**
  34717. * Gets the mesh that is currently under the pointer
  34718. */
  34719. get meshUnderPointer(): Nullable<AbstractMesh>;
  34720. /**
  34721. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34722. */
  34723. get unTranslatedPointer(): Vector2;
  34724. /**
  34725. * Gets or sets the current on-screen X position of the pointer
  34726. */
  34727. get pointerX(): number;
  34728. set pointerX(value: number);
  34729. /**
  34730. * Gets or sets the current on-screen Y position of the pointer
  34731. */
  34732. get pointerY(): number;
  34733. set pointerY(value: number);
  34734. private _updatePointerPosition;
  34735. private _processPointerMove;
  34736. private _setRayOnPointerInfo;
  34737. private _checkPrePointerObservable;
  34738. /**
  34739. * Use this method to simulate a pointer move on a mesh
  34740. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34741. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34742. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34743. */
  34744. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34745. /**
  34746. * Use this method to simulate a pointer down on a mesh
  34747. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34748. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34749. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34750. */
  34751. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34752. private _processPointerDown;
  34753. /** @hidden */
  34754. _isPointerSwiping(): boolean;
  34755. /**
  34756. * Use this method to simulate a pointer up on a mesh
  34757. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34758. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34759. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34760. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34761. */
  34762. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34763. private _processPointerUp;
  34764. /**
  34765. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34766. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34767. * @returns true if the pointer was captured
  34768. */
  34769. isPointerCaptured(pointerId?: number): boolean;
  34770. /**
  34771. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34772. * @param attachUp defines if you want to attach events to pointerup
  34773. * @param attachDown defines if you want to attach events to pointerdown
  34774. * @param attachMove defines if you want to attach events to pointermove
  34775. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34776. */
  34777. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34778. /**
  34779. * Detaches all event handlers
  34780. */
  34781. detachControl(): void;
  34782. /**
  34783. * Force the value of meshUnderPointer
  34784. * @param mesh defines the mesh to use
  34785. */
  34786. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34787. /**
  34788. * Gets the mesh under the pointer
  34789. * @returns a Mesh or null if no mesh is under the pointer
  34790. */
  34791. getPointerOverMesh(): Nullable<AbstractMesh>;
  34792. }
  34793. }
  34794. declare module BABYLON {
  34795. /**
  34796. * Helper class used to generate session unique ID
  34797. */
  34798. export class UniqueIdGenerator {
  34799. private static _UniqueIdCounter;
  34800. /**
  34801. * Gets an unique (relatively to the current scene) Id
  34802. */
  34803. static get UniqueId(): number;
  34804. }
  34805. }
  34806. declare module BABYLON {
  34807. /**
  34808. * This class defines the direct association between an animation and a target
  34809. */
  34810. export class TargetedAnimation {
  34811. /**
  34812. * Animation to perform
  34813. */
  34814. animation: Animation;
  34815. /**
  34816. * Target to animate
  34817. */
  34818. target: any;
  34819. /**
  34820. * Serialize the object
  34821. * @returns the JSON object representing the current entity
  34822. */
  34823. serialize(): any;
  34824. }
  34825. /**
  34826. * Use this class to create coordinated animations on multiple targets
  34827. */
  34828. export class AnimationGroup implements IDisposable {
  34829. /** The name of the animation group */
  34830. name: string;
  34831. private _scene;
  34832. private _targetedAnimations;
  34833. private _animatables;
  34834. private _from;
  34835. private _to;
  34836. private _isStarted;
  34837. private _isPaused;
  34838. private _speedRatio;
  34839. private _loopAnimation;
  34840. /**
  34841. * Gets or sets the unique id of the node
  34842. */
  34843. uniqueId: number;
  34844. /**
  34845. * This observable will notify when one animation have ended
  34846. */
  34847. onAnimationEndObservable: Observable<TargetedAnimation>;
  34848. /**
  34849. * Observer raised when one animation loops
  34850. */
  34851. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34852. /**
  34853. * Observer raised when all animations have looped
  34854. */
  34855. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34856. /**
  34857. * This observable will notify when all animations have ended.
  34858. */
  34859. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34860. /**
  34861. * This observable will notify when all animations have paused.
  34862. */
  34863. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34864. /**
  34865. * This observable will notify when all animations are playing.
  34866. */
  34867. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34868. /**
  34869. * Gets the first frame
  34870. */
  34871. get from(): number;
  34872. /**
  34873. * Gets the last frame
  34874. */
  34875. get to(): number;
  34876. /**
  34877. * Define if the animations are started
  34878. */
  34879. get isStarted(): boolean;
  34880. /**
  34881. * Gets a value indicating that the current group is playing
  34882. */
  34883. get isPlaying(): boolean;
  34884. /**
  34885. * Gets or sets the speed ratio to use for all animations
  34886. */
  34887. get speedRatio(): number;
  34888. /**
  34889. * Gets or sets the speed ratio to use for all animations
  34890. */
  34891. set speedRatio(value: number);
  34892. /**
  34893. * Gets or sets if all animations should loop or not
  34894. */
  34895. get loopAnimation(): boolean;
  34896. set loopAnimation(value: boolean);
  34897. /**
  34898. * Gets the targeted animations for this animation group
  34899. */
  34900. get targetedAnimations(): Array<TargetedAnimation>;
  34901. /**
  34902. * returning the list of animatables controlled by this animation group.
  34903. */
  34904. get animatables(): Array<Animatable>;
  34905. /**
  34906. * Instantiates a new Animation Group.
  34907. * This helps managing several animations at once.
  34908. * @see http://doc.babylonjs.com/how_to/group
  34909. * @param name Defines the name of the group
  34910. * @param scene Defines the scene the group belongs to
  34911. */
  34912. constructor(
  34913. /** The name of the animation group */
  34914. name: string, scene?: Nullable<Scene>);
  34915. /**
  34916. * Add an animation (with its target) in the group
  34917. * @param animation defines the animation we want to add
  34918. * @param target defines the target of the animation
  34919. * @returns the TargetedAnimation object
  34920. */
  34921. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34922. /**
  34923. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34924. * It can add constant keys at begin or end
  34925. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34926. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34927. * @returns the animation group
  34928. */
  34929. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34930. private _animationLoopCount;
  34931. private _animationLoopFlags;
  34932. private _processLoop;
  34933. /**
  34934. * Start all animations on given targets
  34935. * @param loop defines if animations must loop
  34936. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34937. * @param from defines the from key (optional)
  34938. * @param to defines the to key (optional)
  34939. * @returns the current animation group
  34940. */
  34941. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34942. /**
  34943. * Pause all animations
  34944. * @returns the animation group
  34945. */
  34946. pause(): AnimationGroup;
  34947. /**
  34948. * Play all animations to initial state
  34949. * This function will start() the animations if they were not started or will restart() them if they were paused
  34950. * @param loop defines if animations must loop
  34951. * @returns the animation group
  34952. */
  34953. play(loop?: boolean): AnimationGroup;
  34954. /**
  34955. * Reset all animations to initial state
  34956. * @returns the animation group
  34957. */
  34958. reset(): AnimationGroup;
  34959. /**
  34960. * Restart animations from key 0
  34961. * @returns the animation group
  34962. */
  34963. restart(): AnimationGroup;
  34964. /**
  34965. * Stop all animations
  34966. * @returns the animation group
  34967. */
  34968. stop(): AnimationGroup;
  34969. /**
  34970. * Set animation weight for all animatables
  34971. * @param weight defines the weight to use
  34972. * @return the animationGroup
  34973. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34974. */
  34975. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34976. /**
  34977. * Synchronize and normalize all animatables with a source animatable
  34978. * @param root defines the root animatable to synchronize with
  34979. * @return the animationGroup
  34980. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34981. */
  34982. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34983. /**
  34984. * Goes to a specific frame in this animation group
  34985. * @param frame the frame number to go to
  34986. * @return the animationGroup
  34987. */
  34988. goToFrame(frame: number): AnimationGroup;
  34989. /**
  34990. * Dispose all associated resources
  34991. */
  34992. dispose(): void;
  34993. private _checkAnimationGroupEnded;
  34994. /**
  34995. * Clone the current animation group and returns a copy
  34996. * @param newName defines the name of the new group
  34997. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34998. * @returns the new aniamtion group
  34999. */
  35000. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35001. /**
  35002. * Serializes the animationGroup to an object
  35003. * @returns Serialized object
  35004. */
  35005. serialize(): any;
  35006. /**
  35007. * Returns a new AnimationGroup object parsed from the source provided.
  35008. * @param parsedAnimationGroup defines the source
  35009. * @param scene defines the scene that will receive the animationGroup
  35010. * @returns a new AnimationGroup
  35011. */
  35012. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35013. /**
  35014. * Returns the string "AnimationGroup"
  35015. * @returns "AnimationGroup"
  35016. */
  35017. getClassName(): string;
  35018. /**
  35019. * Creates a detailled string about the object
  35020. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35021. * @returns a string representing the object
  35022. */
  35023. toString(fullDetails?: boolean): string;
  35024. }
  35025. }
  35026. declare module BABYLON {
  35027. /**
  35028. * Define an interface for all classes that will hold resources
  35029. */
  35030. export interface IDisposable {
  35031. /**
  35032. * Releases all held resources
  35033. */
  35034. dispose(): void;
  35035. }
  35036. /** Interface defining initialization parameters for Scene class */
  35037. export interface SceneOptions {
  35038. /**
  35039. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35040. * It will improve performance when the number of geometries becomes important.
  35041. */
  35042. useGeometryUniqueIdsMap?: boolean;
  35043. /**
  35044. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35045. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35046. */
  35047. useMaterialMeshMap?: boolean;
  35048. /**
  35049. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35050. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35051. */
  35052. useClonedMeshMap?: boolean;
  35053. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35054. virtual?: boolean;
  35055. }
  35056. /**
  35057. * Represents a scene to be rendered by the engine.
  35058. * @see http://doc.babylonjs.com/features/scene
  35059. */
  35060. export class Scene extends AbstractScene implements IAnimatable {
  35061. /** The fog is deactivated */
  35062. static readonly FOGMODE_NONE: number;
  35063. /** The fog density is following an exponential function */
  35064. static readonly FOGMODE_EXP: number;
  35065. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35066. static readonly FOGMODE_EXP2: number;
  35067. /** The fog density is following a linear function. */
  35068. static readonly FOGMODE_LINEAR: number;
  35069. /**
  35070. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35071. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35072. */
  35073. static MinDeltaTime: number;
  35074. /**
  35075. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35076. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35077. */
  35078. static MaxDeltaTime: number;
  35079. /**
  35080. * Factory used to create the default material.
  35081. * @param name The name of the material to create
  35082. * @param scene The scene to create the material for
  35083. * @returns The default material
  35084. */
  35085. static DefaultMaterialFactory(scene: Scene): Material;
  35086. /**
  35087. * Factory used to create the a collision coordinator.
  35088. * @returns The collision coordinator
  35089. */
  35090. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35091. /** @hidden */
  35092. _inputManager: InputManager;
  35093. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35094. cameraToUseForPointers: Nullable<Camera>;
  35095. /** @hidden */
  35096. readonly _isScene: boolean;
  35097. /** @hidden */
  35098. _blockEntityCollection: boolean;
  35099. /**
  35100. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35101. */
  35102. autoClear: boolean;
  35103. /**
  35104. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35105. */
  35106. autoClearDepthAndStencil: boolean;
  35107. /**
  35108. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35109. */
  35110. clearColor: Color4;
  35111. /**
  35112. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35113. */
  35114. ambientColor: Color3;
  35115. /**
  35116. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35117. * It should only be one of the following (if not the default embedded one):
  35118. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35119. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35120. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35121. * The material properties need to be setup according to the type of texture in use.
  35122. */
  35123. environmentBRDFTexture: BaseTexture;
  35124. /** @hidden */
  35125. protected _environmentTexture: Nullable<BaseTexture>;
  35126. /**
  35127. * Texture used in all pbr material as the reflection texture.
  35128. * As in the majority of the scene they are the same (exception for multi room and so on),
  35129. * this is easier to reference from here than from all the materials.
  35130. */
  35131. get environmentTexture(): Nullable<BaseTexture>;
  35132. /**
  35133. * Texture used in all pbr material as the reflection texture.
  35134. * As in the majority of the scene they are the same (exception for multi room and so on),
  35135. * this is easier to set here than in all the materials.
  35136. */
  35137. set environmentTexture(value: Nullable<BaseTexture>);
  35138. /** @hidden */
  35139. protected _environmentIntensity: number;
  35140. /**
  35141. * Intensity of the environment in all pbr material.
  35142. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35143. * As in the majority of the scene they are the same (exception for multi room and so on),
  35144. * this is easier to reference from here than from all the materials.
  35145. */
  35146. get environmentIntensity(): number;
  35147. /**
  35148. * Intensity of the environment in all pbr material.
  35149. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35150. * As in the majority of the scene they are the same (exception for multi room and so on),
  35151. * this is easier to set here than in all the materials.
  35152. */
  35153. set environmentIntensity(value: number);
  35154. /** @hidden */
  35155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35156. /**
  35157. * Default image processing configuration used either in the rendering
  35158. * Forward main pass or through the imageProcessingPostProcess if present.
  35159. * As in the majority of the scene they are the same (exception for multi camera),
  35160. * this is easier to reference from here than from all the materials and post process.
  35161. *
  35162. * No setter as we it is a shared configuration, you can set the values instead.
  35163. */
  35164. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35165. private _forceWireframe;
  35166. /**
  35167. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35168. */
  35169. set forceWireframe(value: boolean);
  35170. get forceWireframe(): boolean;
  35171. private _skipFrustumClipping;
  35172. /**
  35173. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35174. */
  35175. set skipFrustumClipping(value: boolean);
  35176. get skipFrustumClipping(): boolean;
  35177. private _forcePointsCloud;
  35178. /**
  35179. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35180. */
  35181. set forcePointsCloud(value: boolean);
  35182. get forcePointsCloud(): boolean;
  35183. /**
  35184. * Gets or sets the active clipplane 1
  35185. */
  35186. clipPlane: Nullable<Plane>;
  35187. /**
  35188. * Gets or sets the active clipplane 2
  35189. */
  35190. clipPlane2: Nullable<Plane>;
  35191. /**
  35192. * Gets or sets the active clipplane 3
  35193. */
  35194. clipPlane3: Nullable<Plane>;
  35195. /**
  35196. * Gets or sets the active clipplane 4
  35197. */
  35198. clipPlane4: Nullable<Plane>;
  35199. /**
  35200. * Gets or sets the active clipplane 5
  35201. */
  35202. clipPlane5: Nullable<Plane>;
  35203. /**
  35204. * Gets or sets the active clipplane 6
  35205. */
  35206. clipPlane6: Nullable<Plane>;
  35207. /**
  35208. * Gets or sets a boolean indicating if animations are enabled
  35209. */
  35210. animationsEnabled: boolean;
  35211. private _animationPropertiesOverride;
  35212. /**
  35213. * Gets or sets the animation properties override
  35214. */
  35215. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35216. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35217. /**
  35218. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35219. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35220. */
  35221. useConstantAnimationDeltaTime: boolean;
  35222. /**
  35223. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35224. * Please note that it requires to run a ray cast through the scene on every frame
  35225. */
  35226. constantlyUpdateMeshUnderPointer: boolean;
  35227. /**
  35228. * Defines the HTML cursor to use when hovering over interactive elements
  35229. */
  35230. hoverCursor: string;
  35231. /**
  35232. * Defines the HTML default cursor to use (empty by default)
  35233. */
  35234. defaultCursor: string;
  35235. /**
  35236. * Defines whether cursors are handled by the scene.
  35237. */
  35238. doNotHandleCursors: boolean;
  35239. /**
  35240. * This is used to call preventDefault() on pointer down
  35241. * in order to block unwanted artifacts like system double clicks
  35242. */
  35243. preventDefaultOnPointerDown: boolean;
  35244. /**
  35245. * This is used to call preventDefault() on pointer up
  35246. * in order to block unwanted artifacts like system double clicks
  35247. */
  35248. preventDefaultOnPointerUp: boolean;
  35249. /**
  35250. * Gets or sets user defined metadata
  35251. */
  35252. metadata: any;
  35253. /**
  35254. * For internal use only. Please do not use.
  35255. */
  35256. reservedDataStore: any;
  35257. /**
  35258. * Gets the name of the plugin used to load this scene (null by default)
  35259. */
  35260. loadingPluginName: string;
  35261. /**
  35262. * Use this array to add regular expressions used to disable offline support for specific urls
  35263. */
  35264. disableOfflineSupportExceptionRules: RegExp[];
  35265. /**
  35266. * An event triggered when the scene is disposed.
  35267. */
  35268. onDisposeObservable: Observable<Scene>;
  35269. private _onDisposeObserver;
  35270. /** Sets a function to be executed when this scene is disposed. */
  35271. set onDispose(callback: () => void);
  35272. /**
  35273. * An event triggered before rendering the scene (right after animations and physics)
  35274. */
  35275. onBeforeRenderObservable: Observable<Scene>;
  35276. private _onBeforeRenderObserver;
  35277. /** Sets a function to be executed before rendering this scene */
  35278. set beforeRender(callback: Nullable<() => void>);
  35279. /**
  35280. * An event triggered after rendering the scene
  35281. */
  35282. onAfterRenderObservable: Observable<Scene>;
  35283. /**
  35284. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35285. */
  35286. onAfterRenderCameraObservable: Observable<Camera>;
  35287. private _onAfterRenderObserver;
  35288. /** Sets a function to be executed after rendering this scene */
  35289. set afterRender(callback: Nullable<() => void>);
  35290. /**
  35291. * An event triggered before animating the scene
  35292. */
  35293. onBeforeAnimationsObservable: Observable<Scene>;
  35294. /**
  35295. * An event triggered after animations processing
  35296. */
  35297. onAfterAnimationsObservable: Observable<Scene>;
  35298. /**
  35299. * An event triggered before draw calls are ready to be sent
  35300. */
  35301. onBeforeDrawPhaseObservable: Observable<Scene>;
  35302. /**
  35303. * An event triggered after draw calls have been sent
  35304. */
  35305. onAfterDrawPhaseObservable: Observable<Scene>;
  35306. /**
  35307. * An event triggered when the scene is ready
  35308. */
  35309. onReadyObservable: Observable<Scene>;
  35310. /**
  35311. * An event triggered before rendering a camera
  35312. */
  35313. onBeforeCameraRenderObservable: Observable<Camera>;
  35314. private _onBeforeCameraRenderObserver;
  35315. /** Sets a function to be executed before rendering a camera*/
  35316. set beforeCameraRender(callback: () => void);
  35317. /**
  35318. * An event triggered after rendering a camera
  35319. */
  35320. onAfterCameraRenderObservable: Observable<Camera>;
  35321. private _onAfterCameraRenderObserver;
  35322. /** Sets a function to be executed after rendering a camera*/
  35323. set afterCameraRender(callback: () => void);
  35324. /**
  35325. * An event triggered when active meshes evaluation is about to start
  35326. */
  35327. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35328. /**
  35329. * An event triggered when active meshes evaluation is done
  35330. */
  35331. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35332. /**
  35333. * An event triggered when particles rendering is about to start
  35334. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35335. */
  35336. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35337. /**
  35338. * An event triggered when particles rendering is done
  35339. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35340. */
  35341. onAfterParticlesRenderingObservable: Observable<Scene>;
  35342. /**
  35343. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35344. */
  35345. onDataLoadedObservable: Observable<Scene>;
  35346. /**
  35347. * An event triggered when a camera is created
  35348. */
  35349. onNewCameraAddedObservable: Observable<Camera>;
  35350. /**
  35351. * An event triggered when a camera is removed
  35352. */
  35353. onCameraRemovedObservable: Observable<Camera>;
  35354. /**
  35355. * An event triggered when a light is created
  35356. */
  35357. onNewLightAddedObservable: Observable<Light>;
  35358. /**
  35359. * An event triggered when a light is removed
  35360. */
  35361. onLightRemovedObservable: Observable<Light>;
  35362. /**
  35363. * An event triggered when a geometry is created
  35364. */
  35365. onNewGeometryAddedObservable: Observable<Geometry>;
  35366. /**
  35367. * An event triggered when a geometry is removed
  35368. */
  35369. onGeometryRemovedObservable: Observable<Geometry>;
  35370. /**
  35371. * An event triggered when a transform node is created
  35372. */
  35373. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35374. /**
  35375. * An event triggered when a transform node is removed
  35376. */
  35377. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35378. /**
  35379. * An event triggered when a mesh is created
  35380. */
  35381. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35382. /**
  35383. * An event triggered when a mesh is removed
  35384. */
  35385. onMeshRemovedObservable: Observable<AbstractMesh>;
  35386. /**
  35387. * An event triggered when a skeleton is created
  35388. */
  35389. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35390. /**
  35391. * An event triggered when a skeleton is removed
  35392. */
  35393. onSkeletonRemovedObservable: Observable<Skeleton>;
  35394. /**
  35395. * An event triggered when a material is created
  35396. */
  35397. onNewMaterialAddedObservable: Observable<Material>;
  35398. /**
  35399. * An event triggered when a material is removed
  35400. */
  35401. onMaterialRemovedObservable: Observable<Material>;
  35402. /**
  35403. * An event triggered when a texture is created
  35404. */
  35405. onNewTextureAddedObservable: Observable<BaseTexture>;
  35406. /**
  35407. * An event triggered when a texture is removed
  35408. */
  35409. onTextureRemovedObservable: Observable<BaseTexture>;
  35410. /**
  35411. * An event triggered when render targets are about to be rendered
  35412. * Can happen multiple times per frame.
  35413. */
  35414. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35415. /**
  35416. * An event triggered when render targets were rendered.
  35417. * Can happen multiple times per frame.
  35418. */
  35419. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35420. /**
  35421. * An event triggered before calculating deterministic simulation step
  35422. */
  35423. onBeforeStepObservable: Observable<Scene>;
  35424. /**
  35425. * An event triggered after calculating deterministic simulation step
  35426. */
  35427. onAfterStepObservable: Observable<Scene>;
  35428. /**
  35429. * An event triggered when the activeCamera property is updated
  35430. */
  35431. onActiveCameraChanged: Observable<Scene>;
  35432. /**
  35433. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35434. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35435. * 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)
  35436. */
  35437. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35438. /**
  35439. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35440. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35441. * 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)
  35442. */
  35443. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35444. /**
  35445. * This Observable will when a mesh has been imported into the scene.
  35446. */
  35447. onMeshImportedObservable: Observable<AbstractMesh>;
  35448. /**
  35449. * This Observable will when an animation file has been imported into the scene.
  35450. */
  35451. onAnimationFileImportedObservable: Observable<Scene>;
  35452. /**
  35453. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35454. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35455. */
  35456. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35457. /** @hidden */
  35458. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35459. /**
  35460. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35461. */
  35462. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35463. /**
  35464. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35465. */
  35466. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35467. /**
  35468. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35469. */
  35470. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35471. /** Callback called when a pointer move is detected */
  35472. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35473. /** Callback called when a pointer down is detected */
  35474. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35475. /** Callback called when a pointer up is detected */
  35476. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35477. /** Callback called when a pointer pick is detected */
  35478. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35479. /**
  35480. * 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).
  35481. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35482. */
  35483. onPrePointerObservable: Observable<PointerInfoPre>;
  35484. /**
  35485. * Observable event triggered each time an input event is received from the rendering canvas
  35486. */
  35487. onPointerObservable: Observable<PointerInfo>;
  35488. /**
  35489. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35490. */
  35491. get unTranslatedPointer(): Vector2;
  35492. /**
  35493. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35494. */
  35495. static get DragMovementThreshold(): number;
  35496. static set DragMovementThreshold(value: number);
  35497. /**
  35498. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35499. */
  35500. static get LongPressDelay(): number;
  35501. static set LongPressDelay(value: number);
  35502. /**
  35503. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35504. */
  35505. static get DoubleClickDelay(): number;
  35506. static set DoubleClickDelay(value: number);
  35507. /** If you need to check double click without raising a single click at first click, enable this flag */
  35508. static get ExclusiveDoubleClickMode(): boolean;
  35509. static set ExclusiveDoubleClickMode(value: boolean);
  35510. /** @hidden */
  35511. _mirroredCameraPosition: Nullable<Vector3>;
  35512. /**
  35513. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35514. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35515. */
  35516. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35517. /**
  35518. * Observable event triggered each time an keyboard event is received from the hosting window
  35519. */
  35520. onKeyboardObservable: Observable<KeyboardInfo>;
  35521. private _useRightHandedSystem;
  35522. /**
  35523. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35524. */
  35525. set useRightHandedSystem(value: boolean);
  35526. get useRightHandedSystem(): boolean;
  35527. private _timeAccumulator;
  35528. private _currentStepId;
  35529. private _currentInternalStep;
  35530. /**
  35531. * Sets the step Id used by deterministic lock step
  35532. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35533. * @param newStepId defines the step Id
  35534. */
  35535. setStepId(newStepId: number): void;
  35536. /**
  35537. * Gets the step Id used by deterministic lock step
  35538. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35539. * @returns the step Id
  35540. */
  35541. getStepId(): number;
  35542. /**
  35543. * Gets the internal step used by deterministic lock step
  35544. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35545. * @returns the internal step
  35546. */
  35547. getInternalStep(): number;
  35548. private _fogEnabled;
  35549. /**
  35550. * Gets or sets a boolean indicating if fog is enabled on this scene
  35551. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35552. * (Default is true)
  35553. */
  35554. set fogEnabled(value: boolean);
  35555. get fogEnabled(): boolean;
  35556. private _fogMode;
  35557. /**
  35558. * Gets or sets the fog mode to use
  35559. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35560. * | mode | value |
  35561. * | --- | --- |
  35562. * | FOGMODE_NONE | 0 |
  35563. * | FOGMODE_EXP | 1 |
  35564. * | FOGMODE_EXP2 | 2 |
  35565. * | FOGMODE_LINEAR | 3 |
  35566. */
  35567. set fogMode(value: number);
  35568. get fogMode(): number;
  35569. /**
  35570. * Gets or sets the fog color to use
  35571. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35572. * (Default is Color3(0.2, 0.2, 0.3))
  35573. */
  35574. fogColor: Color3;
  35575. /**
  35576. * Gets or sets the fog density to use
  35577. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35578. * (Default is 0.1)
  35579. */
  35580. fogDensity: number;
  35581. /**
  35582. * Gets or sets the fog start distance to use
  35583. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35584. * (Default is 0)
  35585. */
  35586. fogStart: number;
  35587. /**
  35588. * Gets or sets the fog end distance to use
  35589. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35590. * (Default is 1000)
  35591. */
  35592. fogEnd: number;
  35593. private _shadowsEnabled;
  35594. /**
  35595. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35596. */
  35597. set shadowsEnabled(value: boolean);
  35598. get shadowsEnabled(): boolean;
  35599. private _lightsEnabled;
  35600. /**
  35601. * Gets or sets a boolean indicating if lights are enabled on this scene
  35602. */
  35603. set lightsEnabled(value: boolean);
  35604. get lightsEnabled(): boolean;
  35605. /** All of the active cameras added to this scene. */
  35606. activeCameras: Camera[];
  35607. /** @hidden */
  35608. _activeCamera: Nullable<Camera>;
  35609. /** Gets or sets the current active camera */
  35610. get activeCamera(): Nullable<Camera>;
  35611. set activeCamera(value: Nullable<Camera>);
  35612. private _defaultMaterial;
  35613. /** The default material used on meshes when no material is affected */
  35614. get defaultMaterial(): Material;
  35615. /** The default material used on meshes when no material is affected */
  35616. set defaultMaterial(value: Material);
  35617. private _texturesEnabled;
  35618. /**
  35619. * Gets or sets a boolean indicating if textures are enabled on this scene
  35620. */
  35621. set texturesEnabled(value: boolean);
  35622. get texturesEnabled(): boolean;
  35623. /**
  35624. * Gets or sets a boolean indicating if particles are enabled on this scene
  35625. */
  35626. particlesEnabled: boolean;
  35627. /**
  35628. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35629. */
  35630. spritesEnabled: boolean;
  35631. private _skeletonsEnabled;
  35632. /**
  35633. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35634. */
  35635. set skeletonsEnabled(value: boolean);
  35636. get skeletonsEnabled(): boolean;
  35637. /**
  35638. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35639. */
  35640. lensFlaresEnabled: boolean;
  35641. /**
  35642. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35644. */
  35645. collisionsEnabled: boolean;
  35646. private _collisionCoordinator;
  35647. /** @hidden */
  35648. get collisionCoordinator(): ICollisionCoordinator;
  35649. /**
  35650. * Defines the gravity applied to this scene (used only for collisions)
  35651. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35652. */
  35653. gravity: Vector3;
  35654. /**
  35655. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35656. */
  35657. postProcessesEnabled: boolean;
  35658. /**
  35659. * The list of postprocesses added to the scene
  35660. */
  35661. postProcesses: PostProcess[];
  35662. /**
  35663. * Gets the current postprocess manager
  35664. */
  35665. postProcessManager: PostProcessManager;
  35666. /**
  35667. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35668. */
  35669. renderTargetsEnabled: boolean;
  35670. /**
  35671. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35672. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35673. */
  35674. dumpNextRenderTargets: boolean;
  35675. /**
  35676. * The list of user defined render targets added to the scene
  35677. */
  35678. customRenderTargets: RenderTargetTexture[];
  35679. /**
  35680. * Defines if texture loading must be delayed
  35681. * If true, textures will only be loaded when they need to be rendered
  35682. */
  35683. useDelayedTextureLoading: boolean;
  35684. /**
  35685. * Gets the list of meshes imported to the scene through SceneLoader
  35686. */
  35687. importedMeshesFiles: String[];
  35688. /**
  35689. * Gets or sets a boolean indicating if probes are enabled on this scene
  35690. */
  35691. probesEnabled: boolean;
  35692. /**
  35693. * Gets or sets the current offline provider to use to store scene data
  35694. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35695. */
  35696. offlineProvider: IOfflineProvider;
  35697. /**
  35698. * Gets or sets the action manager associated with the scene
  35699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35700. */
  35701. actionManager: AbstractActionManager;
  35702. private _meshesForIntersections;
  35703. /**
  35704. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35705. */
  35706. proceduralTexturesEnabled: boolean;
  35707. private _engine;
  35708. private _totalVertices;
  35709. /** @hidden */
  35710. _activeIndices: PerfCounter;
  35711. /** @hidden */
  35712. _activeParticles: PerfCounter;
  35713. /** @hidden */
  35714. _activeBones: PerfCounter;
  35715. private _animationRatio;
  35716. /** @hidden */
  35717. _animationTimeLast: number;
  35718. /** @hidden */
  35719. _animationTime: number;
  35720. /**
  35721. * Gets or sets a general scale for animation speed
  35722. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35723. */
  35724. animationTimeScale: number;
  35725. /** @hidden */
  35726. _cachedMaterial: Nullable<Material>;
  35727. /** @hidden */
  35728. _cachedEffect: Nullable<Effect>;
  35729. /** @hidden */
  35730. _cachedVisibility: Nullable<number>;
  35731. private _renderId;
  35732. private _frameId;
  35733. private _executeWhenReadyTimeoutId;
  35734. private _intermediateRendering;
  35735. private _viewUpdateFlag;
  35736. private _projectionUpdateFlag;
  35737. /** @hidden */
  35738. _toBeDisposed: Nullable<IDisposable>[];
  35739. private _activeRequests;
  35740. /** @hidden */
  35741. _pendingData: any[];
  35742. private _isDisposed;
  35743. /**
  35744. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35745. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35746. */
  35747. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35748. private _activeMeshes;
  35749. private _processedMaterials;
  35750. private _renderTargets;
  35751. /** @hidden */
  35752. _activeParticleSystems: SmartArray<IParticleSystem>;
  35753. private _activeSkeletons;
  35754. private _softwareSkinnedMeshes;
  35755. private _renderingManager;
  35756. /** @hidden */
  35757. _activeAnimatables: Animatable[];
  35758. private _transformMatrix;
  35759. private _sceneUbo;
  35760. /** @hidden */
  35761. _viewMatrix: Matrix;
  35762. private _projectionMatrix;
  35763. /** @hidden */
  35764. _forcedViewPosition: Nullable<Vector3>;
  35765. /** @hidden */
  35766. _frustumPlanes: Plane[];
  35767. /**
  35768. * Gets the list of frustum planes (built from the active camera)
  35769. */
  35770. get frustumPlanes(): Plane[];
  35771. /**
  35772. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35773. * This is useful if there are more lights that the maximum simulteanous authorized
  35774. */
  35775. requireLightSorting: boolean;
  35776. /** @hidden */
  35777. readonly useMaterialMeshMap: boolean;
  35778. /** @hidden */
  35779. readonly useClonedMeshMap: boolean;
  35780. private _externalData;
  35781. private _uid;
  35782. /**
  35783. * @hidden
  35784. * Backing store of defined scene components.
  35785. */
  35786. _components: ISceneComponent[];
  35787. /**
  35788. * @hidden
  35789. * Backing store of defined scene components.
  35790. */
  35791. _serializableComponents: ISceneSerializableComponent[];
  35792. /**
  35793. * List of components to register on the next registration step.
  35794. */
  35795. private _transientComponents;
  35796. /**
  35797. * Registers the transient components if needed.
  35798. */
  35799. private _registerTransientComponents;
  35800. /**
  35801. * @hidden
  35802. * Add a component to the scene.
  35803. * Note that the ccomponent could be registered on th next frame if this is called after
  35804. * the register component stage.
  35805. * @param component Defines the component to add to the scene
  35806. */
  35807. _addComponent(component: ISceneComponent): void;
  35808. /**
  35809. * @hidden
  35810. * Gets a component from the scene.
  35811. * @param name defines the name of the component to retrieve
  35812. * @returns the component or null if not present
  35813. */
  35814. _getComponent(name: string): Nullable<ISceneComponent>;
  35815. /**
  35816. * @hidden
  35817. * Defines the actions happening before camera updates.
  35818. */
  35819. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35820. /**
  35821. * @hidden
  35822. * Defines the actions happening before clear the canvas.
  35823. */
  35824. _beforeClearStage: Stage<SimpleStageAction>;
  35825. /**
  35826. * @hidden
  35827. * Defines the actions when collecting render targets for the frame.
  35828. */
  35829. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35830. /**
  35831. * @hidden
  35832. * Defines the actions happening for one camera in the frame.
  35833. */
  35834. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35835. /**
  35836. * @hidden
  35837. * Defines the actions happening during the per mesh ready checks.
  35838. */
  35839. _isReadyForMeshStage: Stage<MeshStageAction>;
  35840. /**
  35841. * @hidden
  35842. * Defines the actions happening before evaluate active mesh checks.
  35843. */
  35844. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35845. /**
  35846. * @hidden
  35847. * Defines the actions happening during the evaluate sub mesh checks.
  35848. */
  35849. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35850. /**
  35851. * @hidden
  35852. * Defines the actions happening during the active mesh stage.
  35853. */
  35854. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35855. /**
  35856. * @hidden
  35857. * Defines the actions happening during the per camera render target step.
  35858. */
  35859. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35860. /**
  35861. * @hidden
  35862. * Defines the actions happening just before the active camera is drawing.
  35863. */
  35864. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35865. /**
  35866. * @hidden
  35867. * Defines the actions happening just before a render target is drawing.
  35868. */
  35869. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35870. /**
  35871. * @hidden
  35872. * Defines the actions happening just before a rendering group is drawing.
  35873. */
  35874. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35875. /**
  35876. * @hidden
  35877. * Defines the actions happening just before a mesh is drawing.
  35878. */
  35879. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35880. /**
  35881. * @hidden
  35882. * Defines the actions happening just after a mesh has been drawn.
  35883. */
  35884. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35885. /**
  35886. * @hidden
  35887. * Defines the actions happening just after a rendering group has been drawn.
  35888. */
  35889. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35890. /**
  35891. * @hidden
  35892. * Defines the actions happening just after the active camera has been drawn.
  35893. */
  35894. _afterCameraDrawStage: Stage<CameraStageAction>;
  35895. /**
  35896. * @hidden
  35897. * Defines the actions happening just after a render target has been drawn.
  35898. */
  35899. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35900. /**
  35901. * @hidden
  35902. * Defines the actions happening just after rendering all cameras and computing intersections.
  35903. */
  35904. _afterRenderStage: Stage<SimpleStageAction>;
  35905. /**
  35906. * @hidden
  35907. * Defines the actions happening when a pointer move event happens.
  35908. */
  35909. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35910. /**
  35911. * @hidden
  35912. * Defines the actions happening when a pointer down event happens.
  35913. */
  35914. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35915. /**
  35916. * @hidden
  35917. * Defines the actions happening when a pointer up event happens.
  35918. */
  35919. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35920. /**
  35921. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35922. */
  35923. private geometriesByUniqueId;
  35924. /**
  35925. * Creates a new Scene
  35926. * @param engine defines the engine to use to render this scene
  35927. * @param options defines the scene options
  35928. */
  35929. constructor(engine: Engine, options?: SceneOptions);
  35930. /**
  35931. * Gets a string idenfifying the name of the class
  35932. * @returns "Scene" string
  35933. */
  35934. getClassName(): string;
  35935. private _defaultMeshCandidates;
  35936. /**
  35937. * @hidden
  35938. */
  35939. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35940. private _defaultSubMeshCandidates;
  35941. /**
  35942. * @hidden
  35943. */
  35944. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35945. /**
  35946. * Sets the default candidate providers for the scene.
  35947. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35948. * and getCollidingSubMeshCandidates to their default function
  35949. */
  35950. setDefaultCandidateProviders(): void;
  35951. /**
  35952. * Gets the mesh that is currently under the pointer
  35953. */
  35954. get meshUnderPointer(): Nullable<AbstractMesh>;
  35955. /**
  35956. * Gets or sets the current on-screen X position of the pointer
  35957. */
  35958. get pointerX(): number;
  35959. set pointerX(value: number);
  35960. /**
  35961. * Gets or sets the current on-screen Y position of the pointer
  35962. */
  35963. get pointerY(): number;
  35964. set pointerY(value: number);
  35965. /**
  35966. * Gets the cached material (ie. the latest rendered one)
  35967. * @returns the cached material
  35968. */
  35969. getCachedMaterial(): Nullable<Material>;
  35970. /**
  35971. * Gets the cached effect (ie. the latest rendered one)
  35972. * @returns the cached effect
  35973. */
  35974. getCachedEffect(): Nullable<Effect>;
  35975. /**
  35976. * Gets the cached visibility state (ie. the latest rendered one)
  35977. * @returns the cached visibility state
  35978. */
  35979. getCachedVisibility(): Nullable<number>;
  35980. /**
  35981. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35982. * @param material defines the current material
  35983. * @param effect defines the current effect
  35984. * @param visibility defines the current visibility state
  35985. * @returns true if one parameter is not cached
  35986. */
  35987. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35988. /**
  35989. * Gets the engine associated with the scene
  35990. * @returns an Engine
  35991. */
  35992. getEngine(): Engine;
  35993. /**
  35994. * Gets the total number of vertices rendered per frame
  35995. * @returns the total number of vertices rendered per frame
  35996. */
  35997. getTotalVertices(): number;
  35998. /**
  35999. * Gets the performance counter for total vertices
  36000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36001. */
  36002. get totalVerticesPerfCounter(): PerfCounter;
  36003. /**
  36004. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36005. * @returns the total number of active indices rendered per frame
  36006. */
  36007. getActiveIndices(): number;
  36008. /**
  36009. * Gets the performance counter for active indices
  36010. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36011. */
  36012. get totalActiveIndicesPerfCounter(): PerfCounter;
  36013. /**
  36014. * Gets the total number of active particles rendered per frame
  36015. * @returns the total number of active particles rendered per frame
  36016. */
  36017. getActiveParticles(): number;
  36018. /**
  36019. * Gets the performance counter for active particles
  36020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36021. */
  36022. get activeParticlesPerfCounter(): PerfCounter;
  36023. /**
  36024. * Gets the total number of active bones rendered per frame
  36025. * @returns the total number of active bones rendered per frame
  36026. */
  36027. getActiveBones(): number;
  36028. /**
  36029. * Gets the performance counter for active bones
  36030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36031. */
  36032. get activeBonesPerfCounter(): PerfCounter;
  36033. /**
  36034. * Gets the array of active meshes
  36035. * @returns an array of AbstractMesh
  36036. */
  36037. getActiveMeshes(): SmartArray<AbstractMesh>;
  36038. /**
  36039. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36040. * @returns a number
  36041. */
  36042. getAnimationRatio(): number;
  36043. /**
  36044. * Gets an unique Id for the current render phase
  36045. * @returns a number
  36046. */
  36047. getRenderId(): number;
  36048. /**
  36049. * Gets an unique Id for the current frame
  36050. * @returns a number
  36051. */
  36052. getFrameId(): number;
  36053. /** Call this function if you want to manually increment the render Id*/
  36054. incrementRenderId(): void;
  36055. private _createUbo;
  36056. /**
  36057. * Use this method to simulate a pointer move on a mesh
  36058. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36059. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36060. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36061. * @returns the current scene
  36062. */
  36063. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36064. /**
  36065. * Use this method to simulate a pointer down on a mesh
  36066. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36067. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36068. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36069. * @returns the current scene
  36070. */
  36071. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36072. /**
  36073. * Use this method to simulate a pointer up on a mesh
  36074. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36075. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36076. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36077. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36078. * @returns the current scene
  36079. */
  36080. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36081. /**
  36082. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36083. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36084. * @returns true if the pointer was captured
  36085. */
  36086. isPointerCaptured(pointerId?: number): boolean;
  36087. /**
  36088. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36089. * @param attachUp defines if you want to attach events to pointerup
  36090. * @param attachDown defines if you want to attach events to pointerdown
  36091. * @param attachMove defines if you want to attach events to pointermove
  36092. */
  36093. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36094. /** Detaches all event handlers*/
  36095. detachControl(): void;
  36096. /**
  36097. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36098. * Delay loaded resources are not taking in account
  36099. * @return true if all required resources are ready
  36100. */
  36101. isReady(): boolean;
  36102. /** Resets all cached information relative to material (including effect and visibility) */
  36103. resetCachedMaterial(): void;
  36104. /**
  36105. * Registers a function to be called before every frame render
  36106. * @param func defines the function to register
  36107. */
  36108. registerBeforeRender(func: () => void): void;
  36109. /**
  36110. * Unregisters a function called before every frame render
  36111. * @param func defines the function to unregister
  36112. */
  36113. unregisterBeforeRender(func: () => void): void;
  36114. /**
  36115. * Registers a function to be called after every frame render
  36116. * @param func defines the function to register
  36117. */
  36118. registerAfterRender(func: () => void): void;
  36119. /**
  36120. * Unregisters a function called after every frame render
  36121. * @param func defines the function to unregister
  36122. */
  36123. unregisterAfterRender(func: () => void): void;
  36124. private _executeOnceBeforeRender;
  36125. /**
  36126. * The provided function will run before render once and will be disposed afterwards.
  36127. * A timeout delay can be provided so that the function will be executed in N ms.
  36128. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36129. * @param func The function to be executed.
  36130. * @param timeout optional delay in ms
  36131. */
  36132. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36133. /** @hidden */
  36134. _addPendingData(data: any): void;
  36135. /** @hidden */
  36136. _removePendingData(data: any): void;
  36137. /**
  36138. * Returns the number of items waiting to be loaded
  36139. * @returns the number of items waiting to be loaded
  36140. */
  36141. getWaitingItemsCount(): number;
  36142. /**
  36143. * Returns a boolean indicating if the scene is still loading data
  36144. */
  36145. get isLoading(): boolean;
  36146. /**
  36147. * Registers a function to be executed when the scene is ready
  36148. * @param {Function} func - the function to be executed
  36149. */
  36150. executeWhenReady(func: () => void): void;
  36151. /**
  36152. * Returns a promise that resolves when the scene is ready
  36153. * @returns A promise that resolves when the scene is ready
  36154. */
  36155. whenReadyAsync(): Promise<void>;
  36156. /** @hidden */
  36157. _checkIsReady(): void;
  36158. /**
  36159. * Gets all animatable attached to the scene
  36160. */
  36161. get animatables(): Animatable[];
  36162. /**
  36163. * Resets the last animation time frame.
  36164. * Useful to override when animations start running when loading a scene for the first time.
  36165. */
  36166. resetLastAnimationTimeFrame(): void;
  36167. /**
  36168. * Gets the current view matrix
  36169. * @returns a Matrix
  36170. */
  36171. getViewMatrix(): Matrix;
  36172. /**
  36173. * Gets the current projection matrix
  36174. * @returns a Matrix
  36175. */
  36176. getProjectionMatrix(): Matrix;
  36177. /**
  36178. * Gets the current transform matrix
  36179. * @returns a Matrix made of View * Projection
  36180. */
  36181. getTransformMatrix(): Matrix;
  36182. /**
  36183. * Sets the current transform matrix
  36184. * @param viewL defines the View matrix to use
  36185. * @param projectionL defines the Projection matrix to use
  36186. * @param viewR defines the right View matrix to use (if provided)
  36187. * @param projectionR defines the right Projection matrix to use (if provided)
  36188. */
  36189. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36190. /**
  36191. * Gets the uniform buffer used to store scene data
  36192. * @returns a UniformBuffer
  36193. */
  36194. getSceneUniformBuffer(): UniformBuffer;
  36195. /**
  36196. * Gets an unique (relatively to the current scene) Id
  36197. * @returns an unique number for the scene
  36198. */
  36199. getUniqueId(): number;
  36200. /**
  36201. * Add a mesh to the list of scene's meshes
  36202. * @param newMesh defines the mesh to add
  36203. * @param recursive if all child meshes should also be added to the scene
  36204. */
  36205. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36206. /**
  36207. * Remove a mesh for the list of scene's meshes
  36208. * @param toRemove defines the mesh to remove
  36209. * @param recursive if all child meshes should also be removed from the scene
  36210. * @returns the index where the mesh was in the mesh list
  36211. */
  36212. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36213. /**
  36214. * Add a transform node to the list of scene's transform nodes
  36215. * @param newTransformNode defines the transform node to add
  36216. */
  36217. addTransformNode(newTransformNode: TransformNode): void;
  36218. /**
  36219. * Remove a transform node for the list of scene's transform nodes
  36220. * @param toRemove defines the transform node to remove
  36221. * @returns the index where the transform node was in the transform node list
  36222. */
  36223. removeTransformNode(toRemove: TransformNode): number;
  36224. /**
  36225. * Remove a skeleton for the list of scene's skeletons
  36226. * @param toRemove defines the skeleton to remove
  36227. * @returns the index where the skeleton was in the skeleton list
  36228. */
  36229. removeSkeleton(toRemove: Skeleton): number;
  36230. /**
  36231. * Remove a morph target for the list of scene's morph targets
  36232. * @param toRemove defines the morph target to remove
  36233. * @returns the index where the morph target was in the morph target list
  36234. */
  36235. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36236. /**
  36237. * Remove a light for the list of scene's lights
  36238. * @param toRemove defines the light to remove
  36239. * @returns the index where the light was in the light list
  36240. */
  36241. removeLight(toRemove: Light): number;
  36242. /**
  36243. * Remove a camera for the list of scene's cameras
  36244. * @param toRemove defines the camera to remove
  36245. * @returns the index where the camera was in the camera list
  36246. */
  36247. removeCamera(toRemove: Camera): number;
  36248. /**
  36249. * Remove a particle system for the list of scene's particle systems
  36250. * @param toRemove defines the particle system to remove
  36251. * @returns the index where the particle system was in the particle system list
  36252. */
  36253. removeParticleSystem(toRemove: IParticleSystem): number;
  36254. /**
  36255. * Remove a animation for the list of scene's animations
  36256. * @param toRemove defines the animation to remove
  36257. * @returns the index where the animation was in the animation list
  36258. */
  36259. removeAnimation(toRemove: Animation): number;
  36260. /**
  36261. * Will stop the animation of the given target
  36262. * @param target - the target
  36263. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36264. * @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)
  36265. */
  36266. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36267. /**
  36268. * Removes the given animation group from this scene.
  36269. * @param toRemove The animation group to remove
  36270. * @returns The index of the removed animation group
  36271. */
  36272. removeAnimationGroup(toRemove: AnimationGroup): number;
  36273. /**
  36274. * Removes the given multi-material from this scene.
  36275. * @param toRemove The multi-material to remove
  36276. * @returns The index of the removed multi-material
  36277. */
  36278. removeMultiMaterial(toRemove: MultiMaterial): number;
  36279. /**
  36280. * Removes the given material from this scene.
  36281. * @param toRemove The material to remove
  36282. * @returns The index of the removed material
  36283. */
  36284. removeMaterial(toRemove: Material): number;
  36285. /**
  36286. * Removes the given action manager from this scene.
  36287. * @param toRemove The action manager to remove
  36288. * @returns The index of the removed action manager
  36289. */
  36290. removeActionManager(toRemove: AbstractActionManager): number;
  36291. /**
  36292. * Removes the given texture from this scene.
  36293. * @param toRemove The texture to remove
  36294. * @returns The index of the removed texture
  36295. */
  36296. removeTexture(toRemove: BaseTexture): number;
  36297. /**
  36298. * Adds the given light to this scene
  36299. * @param newLight The light to add
  36300. */
  36301. addLight(newLight: Light): void;
  36302. /**
  36303. * Sorts the list list based on light priorities
  36304. */
  36305. sortLightsByPriority(): void;
  36306. /**
  36307. * Adds the given camera to this scene
  36308. * @param newCamera The camera to add
  36309. */
  36310. addCamera(newCamera: Camera): void;
  36311. /**
  36312. * Adds the given skeleton to this scene
  36313. * @param newSkeleton The skeleton to add
  36314. */
  36315. addSkeleton(newSkeleton: Skeleton): void;
  36316. /**
  36317. * Adds the given particle system to this scene
  36318. * @param newParticleSystem The particle system to add
  36319. */
  36320. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36321. /**
  36322. * Adds the given animation to this scene
  36323. * @param newAnimation The animation to add
  36324. */
  36325. addAnimation(newAnimation: Animation): void;
  36326. /**
  36327. * Adds the given animation group to this scene.
  36328. * @param newAnimationGroup The animation group to add
  36329. */
  36330. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36331. /**
  36332. * Adds the given multi-material to this scene
  36333. * @param newMultiMaterial The multi-material to add
  36334. */
  36335. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36336. /**
  36337. * Adds the given material to this scene
  36338. * @param newMaterial The material to add
  36339. */
  36340. addMaterial(newMaterial: Material): void;
  36341. /**
  36342. * Adds the given morph target to this scene
  36343. * @param newMorphTargetManager The morph target to add
  36344. */
  36345. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36346. /**
  36347. * Adds the given geometry to this scene
  36348. * @param newGeometry The geometry to add
  36349. */
  36350. addGeometry(newGeometry: Geometry): void;
  36351. /**
  36352. * Adds the given action manager to this scene
  36353. * @param newActionManager The action manager to add
  36354. */
  36355. addActionManager(newActionManager: AbstractActionManager): void;
  36356. /**
  36357. * Adds the given texture to this scene.
  36358. * @param newTexture The texture to add
  36359. */
  36360. addTexture(newTexture: BaseTexture): void;
  36361. /**
  36362. * Switch active camera
  36363. * @param newCamera defines the new active camera
  36364. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36365. */
  36366. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36367. /**
  36368. * sets the active camera of the scene using its ID
  36369. * @param id defines the camera's ID
  36370. * @return the new active camera or null if none found.
  36371. */
  36372. setActiveCameraByID(id: string): Nullable<Camera>;
  36373. /**
  36374. * sets the active camera of the scene using its name
  36375. * @param name defines the camera's name
  36376. * @returns the new active camera or null if none found.
  36377. */
  36378. setActiveCameraByName(name: string): Nullable<Camera>;
  36379. /**
  36380. * get an animation group using its name
  36381. * @param name defines the material's name
  36382. * @return the animation group or null if none found.
  36383. */
  36384. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36385. /**
  36386. * Get a material using its unique id
  36387. * @param uniqueId defines the material's unique id
  36388. * @return the material or null if none found.
  36389. */
  36390. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36391. /**
  36392. * get a material using its id
  36393. * @param id defines the material's ID
  36394. * @return the material or null if none found.
  36395. */
  36396. getMaterialByID(id: string): Nullable<Material>;
  36397. /**
  36398. * Gets a the last added material using a given id
  36399. * @param id defines the material's ID
  36400. * @return the last material with the given id or null if none found.
  36401. */
  36402. getLastMaterialByID(id: string): Nullable<Material>;
  36403. /**
  36404. * Gets a material using its name
  36405. * @param name defines the material's name
  36406. * @return the material or null if none found.
  36407. */
  36408. getMaterialByName(name: string): Nullable<Material>;
  36409. /**
  36410. * Get a texture using its unique id
  36411. * @param uniqueId defines the texture's unique id
  36412. * @return the texture or null if none found.
  36413. */
  36414. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36415. /**
  36416. * Gets a camera using its id
  36417. * @param id defines the id to look for
  36418. * @returns the camera or null if not found
  36419. */
  36420. getCameraByID(id: string): Nullable<Camera>;
  36421. /**
  36422. * Gets a camera using its unique id
  36423. * @param uniqueId defines the unique id to look for
  36424. * @returns the camera or null if not found
  36425. */
  36426. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36427. /**
  36428. * Gets a camera using its name
  36429. * @param name defines the camera's name
  36430. * @return the camera or null if none found.
  36431. */
  36432. getCameraByName(name: string): Nullable<Camera>;
  36433. /**
  36434. * Gets a bone using its id
  36435. * @param id defines the bone's id
  36436. * @return the bone or null if not found
  36437. */
  36438. getBoneByID(id: string): Nullable<Bone>;
  36439. /**
  36440. * Gets a bone using its id
  36441. * @param name defines the bone's name
  36442. * @return the bone or null if not found
  36443. */
  36444. getBoneByName(name: string): Nullable<Bone>;
  36445. /**
  36446. * Gets a light node using its name
  36447. * @param name defines the the light's name
  36448. * @return the light or null if none found.
  36449. */
  36450. getLightByName(name: string): Nullable<Light>;
  36451. /**
  36452. * Gets a light node using its id
  36453. * @param id defines the light's id
  36454. * @return the light or null if none found.
  36455. */
  36456. getLightByID(id: string): Nullable<Light>;
  36457. /**
  36458. * Gets a light node using its scene-generated unique ID
  36459. * @param uniqueId defines the light's unique id
  36460. * @return the light or null if none found.
  36461. */
  36462. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36463. /**
  36464. * Gets a particle system by id
  36465. * @param id defines the particle system id
  36466. * @return the corresponding system or null if none found
  36467. */
  36468. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36469. /**
  36470. * Gets a geometry using its ID
  36471. * @param id defines the geometry's id
  36472. * @return the geometry or null if none found.
  36473. */
  36474. getGeometryByID(id: string): Nullable<Geometry>;
  36475. private _getGeometryByUniqueID;
  36476. /**
  36477. * Add a new geometry to this scene
  36478. * @param geometry defines the geometry to be added to the scene.
  36479. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36480. * @return a boolean defining if the geometry was added or not
  36481. */
  36482. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36483. /**
  36484. * Removes an existing geometry
  36485. * @param geometry defines the geometry to be removed from the scene
  36486. * @return a boolean defining if the geometry was removed or not
  36487. */
  36488. removeGeometry(geometry: Geometry): boolean;
  36489. /**
  36490. * Gets the list of geometries attached to the scene
  36491. * @returns an array of Geometry
  36492. */
  36493. getGeometries(): Geometry[];
  36494. /**
  36495. * Gets the first added mesh found of a given ID
  36496. * @param id defines the id to search for
  36497. * @return the mesh found or null if not found at all
  36498. */
  36499. getMeshByID(id: string): Nullable<AbstractMesh>;
  36500. /**
  36501. * Gets a list of meshes using their id
  36502. * @param id defines the id to search for
  36503. * @returns a list of meshes
  36504. */
  36505. getMeshesByID(id: string): Array<AbstractMesh>;
  36506. /**
  36507. * Gets the first added transform node found of a given ID
  36508. * @param id defines the id to search for
  36509. * @return the found transform node or null if not found at all.
  36510. */
  36511. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36512. /**
  36513. * Gets a transform node with its auto-generated unique id
  36514. * @param uniqueId efines the unique id to search for
  36515. * @return the found transform node or null if not found at all.
  36516. */
  36517. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36518. /**
  36519. * Gets a list of transform nodes using their id
  36520. * @param id defines the id to search for
  36521. * @returns a list of transform nodes
  36522. */
  36523. getTransformNodesByID(id: string): Array<TransformNode>;
  36524. /**
  36525. * Gets a mesh with its auto-generated unique id
  36526. * @param uniqueId defines the unique id to search for
  36527. * @return the found mesh or null if not found at all.
  36528. */
  36529. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36530. /**
  36531. * Gets a the last added mesh using a given id
  36532. * @param id defines the id to search for
  36533. * @return the found mesh or null if not found at all.
  36534. */
  36535. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36536. /**
  36537. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36538. * @param id defines the id to search for
  36539. * @return the found node or null if not found at all
  36540. */
  36541. getLastEntryByID(id: string): Nullable<Node>;
  36542. /**
  36543. * Gets a node (Mesh, Camera, Light) using a given id
  36544. * @param id defines the id to search for
  36545. * @return the found node or null if not found at all
  36546. */
  36547. getNodeByID(id: string): Nullable<Node>;
  36548. /**
  36549. * Gets a node (Mesh, Camera, Light) using a given name
  36550. * @param name defines the name to search for
  36551. * @return the found node or null if not found at all.
  36552. */
  36553. getNodeByName(name: string): Nullable<Node>;
  36554. /**
  36555. * Gets a mesh using a given name
  36556. * @param name defines the name to search for
  36557. * @return the found mesh or null if not found at all.
  36558. */
  36559. getMeshByName(name: string): Nullable<AbstractMesh>;
  36560. /**
  36561. * Gets a transform node using a given name
  36562. * @param name defines the name to search for
  36563. * @return the found transform node or null if not found at all.
  36564. */
  36565. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36566. /**
  36567. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36568. * @param id defines the id to search for
  36569. * @return the found skeleton or null if not found at all.
  36570. */
  36571. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36572. /**
  36573. * Gets a skeleton using a given auto generated unique id
  36574. * @param uniqueId defines the unique id to search for
  36575. * @return the found skeleton or null if not found at all.
  36576. */
  36577. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36578. /**
  36579. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36580. * @param id defines the id to search for
  36581. * @return the found skeleton or null if not found at all.
  36582. */
  36583. getSkeletonById(id: string): Nullable<Skeleton>;
  36584. /**
  36585. * Gets a skeleton using a given name
  36586. * @param name defines the name to search for
  36587. * @return the found skeleton or null if not found at all.
  36588. */
  36589. getSkeletonByName(name: string): Nullable<Skeleton>;
  36590. /**
  36591. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36592. * @param id defines the id to search for
  36593. * @return the found morph target manager or null if not found at all.
  36594. */
  36595. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36596. /**
  36597. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36598. * @param id defines the id to search for
  36599. * @return the found morph target or null if not found at all.
  36600. */
  36601. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36602. /**
  36603. * Gets a boolean indicating if the given mesh is active
  36604. * @param mesh defines the mesh to look for
  36605. * @returns true if the mesh is in the active list
  36606. */
  36607. isActiveMesh(mesh: AbstractMesh): boolean;
  36608. /**
  36609. * Return a unique id as a string which can serve as an identifier for the scene
  36610. */
  36611. get uid(): string;
  36612. /**
  36613. * Add an externaly attached data from its key.
  36614. * This method call will fail and return false, if such key already exists.
  36615. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36616. * @param key the unique key that identifies the data
  36617. * @param data the data object to associate to the key for this Engine instance
  36618. * @return true if no such key were already present and the data was added successfully, false otherwise
  36619. */
  36620. addExternalData<T>(key: string, data: T): boolean;
  36621. /**
  36622. * Get an externaly attached data from its key
  36623. * @param key the unique key that identifies the data
  36624. * @return the associated data, if present (can be null), or undefined if not present
  36625. */
  36626. getExternalData<T>(key: string): Nullable<T>;
  36627. /**
  36628. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36629. * @param key the unique key that identifies the data
  36630. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36631. * @return the associated data, can be null if the factory returned null.
  36632. */
  36633. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36634. /**
  36635. * Remove an externaly attached data from the Engine instance
  36636. * @param key the unique key that identifies the data
  36637. * @return true if the data was successfully removed, false if it doesn't exist
  36638. */
  36639. removeExternalData(key: string): boolean;
  36640. private _evaluateSubMesh;
  36641. /**
  36642. * Clear the processed materials smart array preventing retention point in material dispose.
  36643. */
  36644. freeProcessedMaterials(): void;
  36645. private _preventFreeActiveMeshesAndRenderingGroups;
  36646. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36647. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36648. * when disposing several meshes in a row or a hierarchy of meshes.
  36649. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36650. */
  36651. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36652. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36653. /**
  36654. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36655. */
  36656. freeActiveMeshes(): void;
  36657. /**
  36658. * Clear the info related to rendering groups preventing retention points during dispose.
  36659. */
  36660. freeRenderingGroups(): void;
  36661. /** @hidden */
  36662. _isInIntermediateRendering(): boolean;
  36663. /**
  36664. * Lambda returning the list of potentially active meshes.
  36665. */
  36666. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36667. /**
  36668. * Lambda returning the list of potentially active sub meshes.
  36669. */
  36670. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36671. /**
  36672. * Lambda returning the list of potentially intersecting sub meshes.
  36673. */
  36674. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36675. /**
  36676. * Lambda returning the list of potentially colliding sub meshes.
  36677. */
  36678. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36679. private _activeMeshesFrozen;
  36680. private _skipEvaluateActiveMeshesCompletely;
  36681. /**
  36682. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36683. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36684. * @returns the current scene
  36685. */
  36686. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36687. /**
  36688. * Use this function to restart evaluating active meshes on every frame
  36689. * @returns the current scene
  36690. */
  36691. unfreezeActiveMeshes(): Scene;
  36692. private _evaluateActiveMeshes;
  36693. private _activeMesh;
  36694. /**
  36695. * Update the transform matrix to update from the current active camera
  36696. * @param force defines a boolean used to force the update even if cache is up to date
  36697. */
  36698. updateTransformMatrix(force?: boolean): void;
  36699. private _bindFrameBuffer;
  36700. /** @hidden */
  36701. _allowPostProcessClearColor: boolean;
  36702. /** @hidden */
  36703. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36704. private _processSubCameras;
  36705. private _checkIntersections;
  36706. /** @hidden */
  36707. _advancePhysicsEngineStep(step: number): void;
  36708. /**
  36709. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36710. */
  36711. getDeterministicFrameTime: () => number;
  36712. /** @hidden */
  36713. _animate(): void;
  36714. /** Execute all animations (for a frame) */
  36715. animate(): void;
  36716. /**
  36717. * Render the scene
  36718. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36719. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36720. */
  36721. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36722. /**
  36723. * Freeze all materials
  36724. * A frozen material will not be updatable but should be faster to render
  36725. */
  36726. freezeMaterials(): void;
  36727. /**
  36728. * Unfreeze all materials
  36729. * A frozen material will not be updatable but should be faster to render
  36730. */
  36731. unfreezeMaterials(): void;
  36732. /**
  36733. * Releases all held ressources
  36734. */
  36735. dispose(): void;
  36736. /**
  36737. * Gets if the scene is already disposed
  36738. */
  36739. get isDisposed(): boolean;
  36740. /**
  36741. * Call this function to reduce memory footprint of the scene.
  36742. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36743. */
  36744. clearCachedVertexData(): void;
  36745. /**
  36746. * This function will remove the local cached buffer data from texture.
  36747. * It will save memory but will prevent the texture from being rebuilt
  36748. */
  36749. cleanCachedTextureBuffer(): void;
  36750. /**
  36751. * Get the world extend vectors with an optional filter
  36752. *
  36753. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36754. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36755. */
  36756. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36757. min: Vector3;
  36758. max: Vector3;
  36759. };
  36760. /**
  36761. * Creates a ray that can be used to pick in the scene
  36762. * @param x defines the x coordinate of the origin (on-screen)
  36763. * @param y defines the y coordinate of the origin (on-screen)
  36764. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36765. * @param camera defines the camera to use for the picking
  36766. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36767. * @returns a Ray
  36768. */
  36769. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36770. /**
  36771. * Creates a ray that can be used to pick in the scene
  36772. * @param x defines the x coordinate of the origin (on-screen)
  36773. * @param y defines the y coordinate of the origin (on-screen)
  36774. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36775. * @param result defines the ray where to store the picking ray
  36776. * @param camera defines the camera to use for the picking
  36777. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36778. * @returns the current scene
  36779. */
  36780. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36781. /**
  36782. * Creates a ray that can be used to pick in the scene
  36783. * @param x defines the x coordinate of the origin (on-screen)
  36784. * @param y defines the y coordinate of the origin (on-screen)
  36785. * @param camera defines the camera to use for the picking
  36786. * @returns a Ray
  36787. */
  36788. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36789. /**
  36790. * Creates a ray that can be used to pick in the scene
  36791. * @param x defines the x coordinate of the origin (on-screen)
  36792. * @param y defines the y coordinate of the origin (on-screen)
  36793. * @param result defines the ray where to store the picking ray
  36794. * @param camera defines the camera to use for the picking
  36795. * @returns the current scene
  36796. */
  36797. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36798. /** Launch a ray to try to pick a mesh in the scene
  36799. * @param x position on screen
  36800. * @param y position on screen
  36801. * @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
  36802. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36803. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36804. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36805. * @returns a PickingInfo
  36806. */
  36807. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36808. /** Use the given ray to pick a mesh in the scene
  36809. * @param ray The ray to use to pick meshes
  36810. * @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
  36811. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36812. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36813. * @returns a PickingInfo
  36814. */
  36815. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36816. /**
  36817. * Launch a ray to try to pick a mesh in the scene
  36818. * @param x X position on screen
  36819. * @param y Y position on screen
  36820. * @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
  36821. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36822. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36823. * @returns an array of PickingInfo
  36824. */
  36825. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36826. /**
  36827. * Launch a ray to try to pick a mesh in the scene
  36828. * @param ray Ray to use
  36829. * @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
  36830. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36831. * @returns an array of PickingInfo
  36832. */
  36833. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36834. /**
  36835. * Force the value of meshUnderPointer
  36836. * @param mesh defines the mesh to use
  36837. */
  36838. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36839. /**
  36840. * Gets the mesh under the pointer
  36841. * @returns a Mesh or null if no mesh is under the pointer
  36842. */
  36843. getPointerOverMesh(): Nullable<AbstractMesh>;
  36844. /** @hidden */
  36845. _rebuildGeometries(): void;
  36846. /** @hidden */
  36847. _rebuildTextures(): void;
  36848. private _getByTags;
  36849. /**
  36850. * Get a list of meshes by tags
  36851. * @param tagsQuery defines the tags query to use
  36852. * @param forEach defines a predicate used to filter results
  36853. * @returns an array of Mesh
  36854. */
  36855. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36856. /**
  36857. * Get a list of cameras by tags
  36858. * @param tagsQuery defines the tags query to use
  36859. * @param forEach defines a predicate used to filter results
  36860. * @returns an array of Camera
  36861. */
  36862. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36863. /**
  36864. * Get a list of lights by tags
  36865. * @param tagsQuery defines the tags query to use
  36866. * @param forEach defines a predicate used to filter results
  36867. * @returns an array of Light
  36868. */
  36869. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36870. /**
  36871. * Get a list of materials by tags
  36872. * @param tagsQuery defines the tags query to use
  36873. * @param forEach defines a predicate used to filter results
  36874. * @returns an array of Material
  36875. */
  36876. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36877. /**
  36878. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36879. * This allowed control for front to back rendering or reversly depending of the special needs.
  36880. *
  36881. * @param renderingGroupId The rendering group id corresponding to its index
  36882. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36883. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36884. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36885. */
  36886. 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;
  36887. /**
  36888. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36889. *
  36890. * @param renderingGroupId The rendering group id corresponding to its index
  36891. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36892. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36893. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36894. */
  36895. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36896. /**
  36897. * Gets the current auto clear configuration for one rendering group of the rendering
  36898. * manager.
  36899. * @param index the rendering group index to get the information for
  36900. * @returns The auto clear setup for the requested rendering group
  36901. */
  36902. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36903. private _blockMaterialDirtyMechanism;
  36904. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36905. get blockMaterialDirtyMechanism(): boolean;
  36906. set blockMaterialDirtyMechanism(value: boolean);
  36907. /**
  36908. * Will flag all materials as dirty to trigger new shader compilation
  36909. * @param flag defines the flag used to specify which material part must be marked as dirty
  36910. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36911. */
  36912. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36913. /** @hidden */
  36914. _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;
  36915. /** @hidden */
  36916. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36917. /** @hidden */
  36918. _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;
  36919. /** @hidden */
  36920. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36921. /** @hidden */
  36922. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36923. /** @hidden */
  36924. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36925. }
  36926. }
  36927. declare module BABYLON {
  36928. /**
  36929. * Set of assets to keep when moving a scene into an asset container.
  36930. */
  36931. export class KeepAssets extends AbstractScene {
  36932. }
  36933. /**
  36934. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36935. */
  36936. export class InstantiatedEntries {
  36937. /**
  36938. * List of new root nodes (eg. nodes with no parent)
  36939. */
  36940. rootNodes: TransformNode[];
  36941. /**
  36942. * List of new skeletons
  36943. */
  36944. skeletons: Skeleton[];
  36945. /**
  36946. * List of new animation groups
  36947. */
  36948. animationGroups: AnimationGroup[];
  36949. }
  36950. /**
  36951. * Container with a set of assets that can be added or removed from a scene.
  36952. */
  36953. export class AssetContainer extends AbstractScene {
  36954. private _wasAddedToScene;
  36955. /**
  36956. * The scene the AssetContainer belongs to.
  36957. */
  36958. scene: Scene;
  36959. /**
  36960. * Instantiates an AssetContainer.
  36961. * @param scene The scene the AssetContainer belongs to.
  36962. */
  36963. constructor(scene: Scene);
  36964. /**
  36965. * Instantiate or clone all meshes and add the new ones to the scene.
  36966. * Skeletons and animation groups will all be cloned
  36967. * @param nameFunction defines an optional function used to get new names for clones
  36968. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36969. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36970. */
  36971. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36972. /**
  36973. * Adds all the assets from the container to the scene.
  36974. */
  36975. addAllToScene(): void;
  36976. /**
  36977. * Removes all the assets in the container from the scene
  36978. */
  36979. removeAllFromScene(): void;
  36980. /**
  36981. * Disposes all the assets in the container
  36982. */
  36983. dispose(): void;
  36984. private _moveAssets;
  36985. /**
  36986. * Removes all the assets contained in the scene and adds them to the container.
  36987. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36988. */
  36989. moveAllFromScene(keepAssets?: KeepAssets): void;
  36990. /**
  36991. * 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.
  36992. * @returns the root mesh
  36993. */
  36994. createRootMesh(): Mesh;
  36995. /**
  36996. * Merge animations from this asset container into a scene
  36997. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36998. * @param animatables set of animatables to retarget to a node from the scene
  36999. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37000. */
  37001. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37002. }
  37003. }
  37004. declare module BABYLON {
  37005. /**
  37006. * Defines how the parser contract is defined.
  37007. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37008. */
  37009. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37010. /**
  37011. * Defines how the individual parser contract is defined.
  37012. * These parser can parse an individual asset
  37013. */
  37014. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37015. /**
  37016. * Base class of the scene acting as a container for the different elements composing a scene.
  37017. * This class is dynamically extended by the different components of the scene increasing
  37018. * flexibility and reducing coupling
  37019. */
  37020. export abstract class AbstractScene {
  37021. /**
  37022. * Stores the list of available parsers in the application.
  37023. */
  37024. private static _BabylonFileParsers;
  37025. /**
  37026. * Stores the list of available individual parsers in the application.
  37027. */
  37028. private static _IndividualBabylonFileParsers;
  37029. /**
  37030. * Adds a parser in the list of available ones
  37031. * @param name Defines the name of the parser
  37032. * @param parser Defines the parser to add
  37033. */
  37034. static AddParser(name: string, parser: BabylonFileParser): void;
  37035. /**
  37036. * Gets a general parser from the list of avaialble ones
  37037. * @param name Defines the name of the parser
  37038. * @returns the requested parser or null
  37039. */
  37040. static GetParser(name: string): Nullable<BabylonFileParser>;
  37041. /**
  37042. * Adds n individual parser in the list of available ones
  37043. * @param name Defines the name of the parser
  37044. * @param parser Defines the parser to add
  37045. */
  37046. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37047. /**
  37048. * Gets an individual parser from the list of avaialble ones
  37049. * @param name Defines the name of the parser
  37050. * @returns the requested parser or null
  37051. */
  37052. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37053. /**
  37054. * Parser json data and populate both a scene and its associated container object
  37055. * @param jsonData Defines the data to parse
  37056. * @param scene Defines the scene to parse the data for
  37057. * @param container Defines the container attached to the parsing sequence
  37058. * @param rootUrl Defines the root url of the data
  37059. */
  37060. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37061. /**
  37062. * Gets the list of root nodes (ie. nodes with no parent)
  37063. */
  37064. rootNodes: Node[];
  37065. /** All of the cameras added to this scene
  37066. * @see http://doc.babylonjs.com/babylon101/cameras
  37067. */
  37068. cameras: Camera[];
  37069. /**
  37070. * All of the lights added to this scene
  37071. * @see http://doc.babylonjs.com/babylon101/lights
  37072. */
  37073. lights: Light[];
  37074. /**
  37075. * All of the (abstract) meshes added to this scene
  37076. */
  37077. meshes: AbstractMesh[];
  37078. /**
  37079. * The list of skeletons added to the scene
  37080. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37081. */
  37082. skeletons: Skeleton[];
  37083. /**
  37084. * All of the particle systems added to this scene
  37085. * @see http://doc.babylonjs.com/babylon101/particles
  37086. */
  37087. particleSystems: IParticleSystem[];
  37088. /**
  37089. * Gets a list of Animations associated with the scene
  37090. */
  37091. animations: Animation[];
  37092. /**
  37093. * All of the animation groups added to this scene
  37094. * @see http://doc.babylonjs.com/how_to/group
  37095. */
  37096. animationGroups: AnimationGroup[];
  37097. /**
  37098. * All of the multi-materials added to this scene
  37099. * @see http://doc.babylonjs.com/how_to/multi_materials
  37100. */
  37101. multiMaterials: MultiMaterial[];
  37102. /**
  37103. * All of the materials added to this scene
  37104. * In the context of a Scene, it is not supposed to be modified manually.
  37105. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37106. * Note also that the order of the Material within the array is not significant and might change.
  37107. * @see http://doc.babylonjs.com/babylon101/materials
  37108. */
  37109. materials: Material[];
  37110. /**
  37111. * The list of morph target managers added to the scene
  37112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37113. */
  37114. morphTargetManagers: MorphTargetManager[];
  37115. /**
  37116. * The list of geometries used in the scene.
  37117. */
  37118. geometries: Geometry[];
  37119. /**
  37120. * All of the tranform nodes added to this scene
  37121. * In the context of a Scene, it is not supposed to be modified manually.
  37122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37124. * @see http://doc.babylonjs.com/how_to/transformnode
  37125. */
  37126. transformNodes: TransformNode[];
  37127. /**
  37128. * ActionManagers available on the scene.
  37129. */
  37130. actionManagers: AbstractActionManager[];
  37131. /**
  37132. * Textures to keep.
  37133. */
  37134. textures: BaseTexture[];
  37135. /**
  37136. * Environment texture for the scene
  37137. */
  37138. environmentTexture: Nullable<BaseTexture>;
  37139. /**
  37140. * @returns all meshes, lights, cameras, transformNodes and bones
  37141. */
  37142. getNodes(): Array<Node>;
  37143. }
  37144. }
  37145. declare module BABYLON {
  37146. /**
  37147. * Interface used to define options for Sound class
  37148. */
  37149. export interface ISoundOptions {
  37150. /**
  37151. * Does the sound autoplay once loaded.
  37152. */
  37153. autoplay?: boolean;
  37154. /**
  37155. * Does the sound loop after it finishes playing once.
  37156. */
  37157. loop?: boolean;
  37158. /**
  37159. * Sound's volume
  37160. */
  37161. volume?: number;
  37162. /**
  37163. * Is it a spatial sound?
  37164. */
  37165. spatialSound?: boolean;
  37166. /**
  37167. * Maximum distance to hear that sound
  37168. */
  37169. maxDistance?: number;
  37170. /**
  37171. * Uses user defined attenuation function
  37172. */
  37173. useCustomAttenuation?: boolean;
  37174. /**
  37175. * Define the roll off factor of spatial sounds.
  37176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37177. */
  37178. rolloffFactor?: number;
  37179. /**
  37180. * Define the reference distance the sound should be heard perfectly.
  37181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37182. */
  37183. refDistance?: number;
  37184. /**
  37185. * Define the distance attenuation model the sound will follow.
  37186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37187. */
  37188. distanceModel?: string;
  37189. /**
  37190. * Defines the playback speed (1 by default)
  37191. */
  37192. playbackRate?: number;
  37193. /**
  37194. * Defines if the sound is from a streaming source
  37195. */
  37196. streaming?: boolean;
  37197. /**
  37198. * Defines an optional length (in seconds) inside the sound file
  37199. */
  37200. length?: number;
  37201. /**
  37202. * Defines an optional offset (in seconds) inside the sound file
  37203. */
  37204. offset?: number;
  37205. /**
  37206. * If true, URLs will not be required to state the audio file codec to use.
  37207. */
  37208. skipCodecCheck?: boolean;
  37209. }
  37210. /**
  37211. * Defines a sound that can be played in the application.
  37212. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37214. */
  37215. export class Sound {
  37216. /**
  37217. * The name of the sound in the scene.
  37218. */
  37219. name: string;
  37220. /**
  37221. * Does the sound autoplay once loaded.
  37222. */
  37223. autoplay: boolean;
  37224. /**
  37225. * Does the sound loop after it finishes playing once.
  37226. */
  37227. loop: boolean;
  37228. /**
  37229. * Does the sound use a custom attenuation curve to simulate the falloff
  37230. * happening when the source gets further away from the camera.
  37231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37232. */
  37233. useCustomAttenuation: boolean;
  37234. /**
  37235. * The sound track id this sound belongs to.
  37236. */
  37237. soundTrackId: number;
  37238. /**
  37239. * Is this sound currently played.
  37240. */
  37241. isPlaying: boolean;
  37242. /**
  37243. * Is this sound currently paused.
  37244. */
  37245. isPaused: boolean;
  37246. /**
  37247. * Does this sound enables spatial sound.
  37248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37249. */
  37250. spatialSound: boolean;
  37251. /**
  37252. * Define the reference distance the sound should be heard perfectly.
  37253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37254. */
  37255. refDistance: number;
  37256. /**
  37257. * Define the roll off factor of spatial sounds.
  37258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37259. */
  37260. rolloffFactor: number;
  37261. /**
  37262. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37264. */
  37265. maxDistance: number;
  37266. /**
  37267. * Define the distance attenuation model the sound will follow.
  37268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37269. */
  37270. distanceModel: string;
  37271. /**
  37272. * @hidden
  37273. * Back Compat
  37274. **/
  37275. onended: () => any;
  37276. /**
  37277. * Observable event when the current playing sound finishes.
  37278. */
  37279. onEndedObservable: Observable<Sound>;
  37280. private _panningModel;
  37281. private _playbackRate;
  37282. private _streaming;
  37283. private _startTime;
  37284. private _startOffset;
  37285. private _position;
  37286. /** @hidden */
  37287. _positionInEmitterSpace: boolean;
  37288. private _localDirection;
  37289. private _volume;
  37290. private _isReadyToPlay;
  37291. private _isDirectional;
  37292. private _readyToPlayCallback;
  37293. private _audioBuffer;
  37294. private _soundSource;
  37295. private _streamingSource;
  37296. private _soundPanner;
  37297. private _soundGain;
  37298. private _inputAudioNode;
  37299. private _outputAudioNode;
  37300. private _coneInnerAngle;
  37301. private _coneOuterAngle;
  37302. private _coneOuterGain;
  37303. private _scene;
  37304. private _connectedTransformNode;
  37305. private _customAttenuationFunction;
  37306. private _registerFunc;
  37307. private _isOutputConnected;
  37308. private _htmlAudioElement;
  37309. private _urlType;
  37310. private _length?;
  37311. private _offset?;
  37312. /** @hidden */
  37313. static _SceneComponentInitialization: (scene: Scene) => void;
  37314. /**
  37315. * Create a sound and attach it to a scene
  37316. * @param name Name of your sound
  37317. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37318. * @param scene defines the scene the sound belongs to
  37319. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37320. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37321. */
  37322. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37323. /**
  37324. * Release the sound and its associated resources
  37325. */
  37326. dispose(): void;
  37327. /**
  37328. * Gets if the sounds is ready to be played or not.
  37329. * @returns true if ready, otherwise false
  37330. */
  37331. isReady(): boolean;
  37332. private _soundLoaded;
  37333. /**
  37334. * Sets the data of the sound from an audiobuffer
  37335. * @param audioBuffer The audioBuffer containing the data
  37336. */
  37337. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37338. /**
  37339. * Updates the current sounds options such as maxdistance, loop...
  37340. * @param options A JSON object containing values named as the object properties
  37341. */
  37342. updateOptions(options: ISoundOptions): void;
  37343. private _createSpatialParameters;
  37344. private _updateSpatialParameters;
  37345. /**
  37346. * Switch the panning model to HRTF:
  37347. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37349. */
  37350. switchPanningModelToHRTF(): void;
  37351. /**
  37352. * Switch the panning model to Equal Power:
  37353. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37355. */
  37356. switchPanningModelToEqualPower(): void;
  37357. private _switchPanningModel;
  37358. /**
  37359. * Connect this sound to a sound track audio node like gain...
  37360. * @param soundTrackAudioNode the sound track audio node to connect to
  37361. */
  37362. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37363. /**
  37364. * Transform this sound into a directional source
  37365. * @param coneInnerAngle Size of the inner cone in degree
  37366. * @param coneOuterAngle Size of the outer cone in degree
  37367. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37368. */
  37369. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37370. /**
  37371. * Gets or sets the inner angle for the directional cone.
  37372. */
  37373. get directionalConeInnerAngle(): number;
  37374. /**
  37375. * Gets or sets the inner angle for the directional cone.
  37376. */
  37377. set directionalConeInnerAngle(value: number);
  37378. /**
  37379. * Gets or sets the outer angle for the directional cone.
  37380. */
  37381. get directionalConeOuterAngle(): number;
  37382. /**
  37383. * Gets or sets the outer angle for the directional cone.
  37384. */
  37385. set directionalConeOuterAngle(value: number);
  37386. /**
  37387. * Sets the position of the emitter if spatial sound is enabled
  37388. * @param newPosition Defines the new posisiton
  37389. */
  37390. setPosition(newPosition: Vector3): void;
  37391. /**
  37392. * Sets the local direction of the emitter if spatial sound is enabled
  37393. * @param newLocalDirection Defines the new local direction
  37394. */
  37395. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37396. private _updateDirection;
  37397. /** @hidden */
  37398. updateDistanceFromListener(): void;
  37399. /**
  37400. * Sets a new custom attenuation function for the sound.
  37401. * @param callback Defines the function used for the attenuation
  37402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37403. */
  37404. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37405. /**
  37406. * Play the sound
  37407. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37408. * @param offset (optional) Start the sound at a specific time in seconds
  37409. * @param length (optional) Sound duration (in seconds)
  37410. */
  37411. play(time?: number, offset?: number, length?: number): void;
  37412. private _onended;
  37413. /**
  37414. * Stop the sound
  37415. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37416. */
  37417. stop(time?: number): void;
  37418. /**
  37419. * Put the sound in pause
  37420. */
  37421. pause(): void;
  37422. /**
  37423. * Sets a dedicated volume for this sounds
  37424. * @param newVolume Define the new volume of the sound
  37425. * @param time Define time for gradual change to new volume
  37426. */
  37427. setVolume(newVolume: number, time?: number): void;
  37428. /**
  37429. * Set the sound play back rate
  37430. * @param newPlaybackRate Define the playback rate the sound should be played at
  37431. */
  37432. setPlaybackRate(newPlaybackRate: number): void;
  37433. /**
  37434. * Gets the volume of the sound.
  37435. * @returns the volume of the sound
  37436. */
  37437. getVolume(): number;
  37438. /**
  37439. * Attach the sound to a dedicated mesh
  37440. * @param transformNode The transform node to connect the sound with
  37441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37442. */
  37443. attachToMesh(transformNode: TransformNode): void;
  37444. /**
  37445. * Detach the sound from the previously attached mesh
  37446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37447. */
  37448. detachFromMesh(): void;
  37449. private _onRegisterAfterWorldMatrixUpdate;
  37450. /**
  37451. * Clone the current sound in the scene.
  37452. * @returns the new sound clone
  37453. */
  37454. clone(): Nullable<Sound>;
  37455. /**
  37456. * Gets the current underlying audio buffer containing the data
  37457. * @returns the audio buffer
  37458. */
  37459. getAudioBuffer(): Nullable<AudioBuffer>;
  37460. /**
  37461. * Serializes the Sound in a JSON representation
  37462. * @returns the JSON representation of the sound
  37463. */
  37464. serialize(): any;
  37465. /**
  37466. * Parse a JSON representation of a sound to innstantiate in a given scene
  37467. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37468. * @param scene Define the scene the new parsed sound should be created in
  37469. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37470. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37471. * @returns the newly parsed sound
  37472. */
  37473. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37474. }
  37475. }
  37476. declare module BABYLON {
  37477. /**
  37478. * This defines an action helpful to play a defined sound on a triggered action.
  37479. */
  37480. export class PlaySoundAction extends Action {
  37481. private _sound;
  37482. /**
  37483. * Instantiate the action
  37484. * @param triggerOptions defines the trigger options
  37485. * @param sound defines the sound to play
  37486. * @param condition defines the trigger related conditions
  37487. */
  37488. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37489. /** @hidden */
  37490. _prepare(): void;
  37491. /**
  37492. * Execute the action and play the sound.
  37493. */
  37494. execute(): void;
  37495. /**
  37496. * Serializes the actions and its related information.
  37497. * @param parent defines the object to serialize in
  37498. * @returns the serialized object
  37499. */
  37500. serialize(parent: any): any;
  37501. }
  37502. /**
  37503. * This defines an action helpful to stop a defined sound on a triggered action.
  37504. */
  37505. export class StopSoundAction extends Action {
  37506. private _sound;
  37507. /**
  37508. * Instantiate the action
  37509. * @param triggerOptions defines the trigger options
  37510. * @param sound defines the sound to stop
  37511. * @param condition defines the trigger related conditions
  37512. */
  37513. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37514. /** @hidden */
  37515. _prepare(): void;
  37516. /**
  37517. * Execute the action and stop the sound.
  37518. */
  37519. execute(): void;
  37520. /**
  37521. * Serializes the actions and its related information.
  37522. * @param parent defines the object to serialize in
  37523. * @returns the serialized object
  37524. */
  37525. serialize(parent: any): any;
  37526. }
  37527. }
  37528. declare module BABYLON {
  37529. /**
  37530. * This defines an action responsible to change the value of a property
  37531. * by interpolating between its current value and the newly set one once triggered.
  37532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37533. */
  37534. export class InterpolateValueAction extends Action {
  37535. /**
  37536. * Defines the path of the property where the value should be interpolated
  37537. */
  37538. propertyPath: string;
  37539. /**
  37540. * Defines the target value at the end of the interpolation.
  37541. */
  37542. value: any;
  37543. /**
  37544. * Defines the time it will take for the property to interpolate to the value.
  37545. */
  37546. duration: number;
  37547. /**
  37548. * Defines if the other scene animations should be stopped when the action has been triggered
  37549. */
  37550. stopOtherAnimations?: boolean;
  37551. /**
  37552. * Defines a callback raised once the interpolation animation has been done.
  37553. */
  37554. onInterpolationDone?: () => void;
  37555. /**
  37556. * Observable triggered once the interpolation animation has been done.
  37557. */
  37558. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37559. private _target;
  37560. private _effectiveTarget;
  37561. private _property;
  37562. /**
  37563. * Instantiate the action
  37564. * @param triggerOptions defines the trigger options
  37565. * @param target defines the object containing the value to interpolate
  37566. * @param propertyPath defines the path to the property in the target object
  37567. * @param value defines the target value at the end of the interpolation
  37568. * @param duration deines the time it will take for the property to interpolate to the value.
  37569. * @param condition defines the trigger related conditions
  37570. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37571. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37572. */
  37573. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37574. /** @hidden */
  37575. _prepare(): void;
  37576. /**
  37577. * Execute the action starts the value interpolation.
  37578. */
  37579. execute(): void;
  37580. /**
  37581. * Serializes the actions and its related information.
  37582. * @param parent defines the object to serialize in
  37583. * @returns the serialized object
  37584. */
  37585. serialize(parent: any): any;
  37586. }
  37587. }
  37588. declare module BABYLON {
  37589. /**
  37590. * Options allowed during the creation of a sound track.
  37591. */
  37592. export interface ISoundTrackOptions {
  37593. /**
  37594. * The volume the sound track should take during creation
  37595. */
  37596. volume?: number;
  37597. /**
  37598. * Define if the sound track is the main sound track of the scene
  37599. */
  37600. mainTrack?: boolean;
  37601. }
  37602. /**
  37603. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37604. * It will be also used in a future release to apply effects on a specific track.
  37605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37606. */
  37607. export class SoundTrack {
  37608. /**
  37609. * The unique identifier of the sound track in the scene.
  37610. */
  37611. id: number;
  37612. /**
  37613. * The list of sounds included in the sound track.
  37614. */
  37615. soundCollection: Array<Sound>;
  37616. private _outputAudioNode;
  37617. private _scene;
  37618. private _connectedAnalyser;
  37619. private _options;
  37620. private _isInitialized;
  37621. /**
  37622. * Creates a new sound track.
  37623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37624. * @param scene Define the scene the sound track belongs to
  37625. * @param options
  37626. */
  37627. constructor(scene: Scene, options?: ISoundTrackOptions);
  37628. private _initializeSoundTrackAudioGraph;
  37629. /**
  37630. * Release the sound track and its associated resources
  37631. */
  37632. dispose(): void;
  37633. /**
  37634. * Adds a sound to this sound track
  37635. * @param sound define the cound to add
  37636. * @ignoreNaming
  37637. */
  37638. AddSound(sound: Sound): void;
  37639. /**
  37640. * Removes a sound to this sound track
  37641. * @param sound define the cound to remove
  37642. * @ignoreNaming
  37643. */
  37644. RemoveSound(sound: Sound): void;
  37645. /**
  37646. * Set a global volume for the full sound track.
  37647. * @param newVolume Define the new volume of the sound track
  37648. */
  37649. setVolume(newVolume: number): void;
  37650. /**
  37651. * Switch the panning model to HRTF:
  37652. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37654. */
  37655. switchPanningModelToHRTF(): void;
  37656. /**
  37657. * Switch the panning model to Equal Power:
  37658. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37660. */
  37661. switchPanningModelToEqualPower(): void;
  37662. /**
  37663. * Connect the sound track to an audio analyser allowing some amazing
  37664. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37666. * @param analyser The analyser to connect to the engine
  37667. */
  37668. connectToAnalyser(analyser: Analyser): void;
  37669. }
  37670. }
  37671. declare module BABYLON {
  37672. interface AbstractScene {
  37673. /**
  37674. * The list of sounds used in the scene.
  37675. */
  37676. sounds: Nullable<Array<Sound>>;
  37677. }
  37678. interface Scene {
  37679. /**
  37680. * @hidden
  37681. * Backing field
  37682. */
  37683. _mainSoundTrack: SoundTrack;
  37684. /**
  37685. * The main sound track played by the scene.
  37686. * It cotains your primary collection of sounds.
  37687. */
  37688. mainSoundTrack: SoundTrack;
  37689. /**
  37690. * The list of sound tracks added to the scene
  37691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37692. */
  37693. soundTracks: Nullable<Array<SoundTrack>>;
  37694. /**
  37695. * Gets a sound using a given name
  37696. * @param name defines the name to search for
  37697. * @return the found sound or null if not found at all.
  37698. */
  37699. getSoundByName(name: string): Nullable<Sound>;
  37700. /**
  37701. * Gets or sets if audio support is enabled
  37702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37703. */
  37704. audioEnabled: boolean;
  37705. /**
  37706. * Gets or sets if audio will be output to headphones
  37707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37708. */
  37709. headphone: boolean;
  37710. /**
  37711. * Gets or sets custom audio listener position provider
  37712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37713. */
  37714. audioListenerPositionProvider: Nullable<() => Vector3>;
  37715. /**
  37716. * Gets or sets a refresh rate when using 3D audio positioning
  37717. */
  37718. audioPositioningRefreshRate: number;
  37719. }
  37720. /**
  37721. * Defines the sound scene component responsible to manage any sounds
  37722. * in a given scene.
  37723. */
  37724. export class AudioSceneComponent implements ISceneSerializableComponent {
  37725. /**
  37726. * The component name helpfull to identify the component in the list of scene components.
  37727. */
  37728. readonly name: string;
  37729. /**
  37730. * The scene the component belongs to.
  37731. */
  37732. scene: Scene;
  37733. private _audioEnabled;
  37734. /**
  37735. * Gets whether audio is enabled or not.
  37736. * Please use related enable/disable method to switch state.
  37737. */
  37738. get audioEnabled(): boolean;
  37739. private _headphone;
  37740. /**
  37741. * Gets whether audio is outputing to headphone or not.
  37742. * Please use the according Switch methods to change output.
  37743. */
  37744. get headphone(): boolean;
  37745. /**
  37746. * Gets or sets a refresh rate when using 3D audio positioning
  37747. */
  37748. audioPositioningRefreshRate: number;
  37749. private _audioListenerPositionProvider;
  37750. /**
  37751. * Gets the current audio listener position provider
  37752. */
  37753. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37754. /**
  37755. * Sets a custom listener position for all sounds in the scene
  37756. * By default, this is the position of the first active camera
  37757. */
  37758. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37759. /**
  37760. * Creates a new instance of the component for the given scene
  37761. * @param scene Defines the scene to register the component in
  37762. */
  37763. constructor(scene: Scene);
  37764. /**
  37765. * Registers the component in a given scene
  37766. */
  37767. register(): void;
  37768. /**
  37769. * Rebuilds the elements related to this component in case of
  37770. * context lost for instance.
  37771. */
  37772. rebuild(): void;
  37773. /**
  37774. * Serializes the component data to the specified json object
  37775. * @param serializationObject The object to serialize to
  37776. */
  37777. serialize(serializationObject: any): void;
  37778. /**
  37779. * Adds all the elements from the container to the scene
  37780. * @param container the container holding the elements
  37781. */
  37782. addFromContainer(container: AbstractScene): void;
  37783. /**
  37784. * Removes all the elements in the container from the scene
  37785. * @param container contains the elements to remove
  37786. * @param dispose if the removed element should be disposed (default: false)
  37787. */
  37788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37789. /**
  37790. * Disposes the component and the associated ressources.
  37791. */
  37792. dispose(): void;
  37793. /**
  37794. * Disables audio in the associated scene.
  37795. */
  37796. disableAudio(): void;
  37797. /**
  37798. * Enables audio in the associated scene.
  37799. */
  37800. enableAudio(): void;
  37801. /**
  37802. * Switch audio to headphone output.
  37803. */
  37804. switchAudioModeForHeadphones(): void;
  37805. /**
  37806. * Switch audio to normal speakers.
  37807. */
  37808. switchAudioModeForNormalSpeakers(): void;
  37809. private _cachedCameraDirection;
  37810. private _cachedCameraPosition;
  37811. private _lastCheck;
  37812. private _afterRender;
  37813. }
  37814. }
  37815. declare module BABYLON {
  37816. /**
  37817. * Wraps one or more Sound objects and selects one with random weight for playback.
  37818. */
  37819. export class WeightedSound {
  37820. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37821. loop: boolean;
  37822. private _coneInnerAngle;
  37823. private _coneOuterAngle;
  37824. private _volume;
  37825. /** A Sound is currently playing. */
  37826. isPlaying: boolean;
  37827. /** A Sound is currently paused. */
  37828. isPaused: boolean;
  37829. private _sounds;
  37830. private _weights;
  37831. private _currentIndex?;
  37832. /**
  37833. * Creates a new WeightedSound from the list of sounds given.
  37834. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37835. * @param sounds Array of Sounds that will be selected from.
  37836. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37837. */
  37838. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37839. /**
  37840. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37841. */
  37842. get directionalConeInnerAngle(): number;
  37843. /**
  37844. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37845. */
  37846. set directionalConeInnerAngle(value: number);
  37847. /**
  37848. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37849. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37850. */
  37851. get directionalConeOuterAngle(): number;
  37852. /**
  37853. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37854. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37855. */
  37856. set directionalConeOuterAngle(value: number);
  37857. /**
  37858. * Playback volume.
  37859. */
  37860. get volume(): number;
  37861. /**
  37862. * Playback volume.
  37863. */
  37864. set volume(value: number);
  37865. private _onended;
  37866. /**
  37867. * Suspend playback
  37868. */
  37869. pause(): void;
  37870. /**
  37871. * Stop playback
  37872. */
  37873. stop(): void;
  37874. /**
  37875. * Start playback.
  37876. * @param startOffset Position the clip head at a specific time in seconds.
  37877. */
  37878. play(startOffset?: number): void;
  37879. }
  37880. }
  37881. declare module BABYLON {
  37882. /**
  37883. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37884. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37885. */
  37886. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37887. /**
  37888. * Gets the name of the behavior.
  37889. */
  37890. get name(): string;
  37891. /**
  37892. * The easing function used by animations
  37893. */
  37894. static EasingFunction: BackEase;
  37895. /**
  37896. * The easing mode used by animations
  37897. */
  37898. static EasingMode: number;
  37899. /**
  37900. * The duration of the animation, in milliseconds
  37901. */
  37902. transitionDuration: number;
  37903. /**
  37904. * Length of the distance animated by the transition when lower radius is reached
  37905. */
  37906. lowerRadiusTransitionRange: number;
  37907. /**
  37908. * Length of the distance animated by the transition when upper radius is reached
  37909. */
  37910. upperRadiusTransitionRange: number;
  37911. private _autoTransitionRange;
  37912. /**
  37913. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37914. */
  37915. get autoTransitionRange(): boolean;
  37916. /**
  37917. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37918. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37919. */
  37920. set autoTransitionRange(value: boolean);
  37921. private _attachedCamera;
  37922. private _onAfterCheckInputsObserver;
  37923. private _onMeshTargetChangedObserver;
  37924. /**
  37925. * Initializes the behavior.
  37926. */
  37927. init(): void;
  37928. /**
  37929. * Attaches the behavior to its arc rotate camera.
  37930. * @param camera Defines the camera to attach the behavior to
  37931. */
  37932. attach(camera: ArcRotateCamera): void;
  37933. /**
  37934. * Detaches the behavior from its current arc rotate camera.
  37935. */
  37936. detach(): void;
  37937. private _radiusIsAnimating;
  37938. private _radiusBounceTransition;
  37939. private _animatables;
  37940. private _cachedWheelPrecision;
  37941. /**
  37942. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37943. * @param radiusLimit The limit to check against.
  37944. * @return Bool to indicate if at limit.
  37945. */
  37946. private _isRadiusAtLimit;
  37947. /**
  37948. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37949. * @param radiusDelta The delta by which to animate to. Can be negative.
  37950. */
  37951. private _applyBoundRadiusAnimation;
  37952. /**
  37953. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37954. */
  37955. protected _clearAnimationLocks(): void;
  37956. /**
  37957. * Stops and removes all animations that have been applied to the camera
  37958. */
  37959. stopAllAnimations(): void;
  37960. }
  37961. }
  37962. declare module BABYLON {
  37963. /**
  37964. * 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.
  37965. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37966. */
  37967. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37968. /**
  37969. * Gets the name of the behavior.
  37970. */
  37971. get name(): string;
  37972. private _mode;
  37973. private _radiusScale;
  37974. private _positionScale;
  37975. private _defaultElevation;
  37976. private _elevationReturnTime;
  37977. private _elevationReturnWaitTime;
  37978. private _zoomStopsAnimation;
  37979. private _framingTime;
  37980. /**
  37981. * The easing function used by animations
  37982. */
  37983. static EasingFunction: ExponentialEase;
  37984. /**
  37985. * The easing mode used by animations
  37986. */
  37987. static EasingMode: number;
  37988. /**
  37989. * Sets the current mode used by the behavior
  37990. */
  37991. set mode(mode: number);
  37992. /**
  37993. * Gets current mode used by the behavior.
  37994. */
  37995. get mode(): number;
  37996. /**
  37997. * Sets the scale applied to the radius (1 by default)
  37998. */
  37999. set radiusScale(radius: number);
  38000. /**
  38001. * Gets the scale applied to the radius
  38002. */
  38003. get radiusScale(): number;
  38004. /**
  38005. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38006. */
  38007. set positionScale(scale: number);
  38008. /**
  38009. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38010. */
  38011. get positionScale(): number;
  38012. /**
  38013. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38014. * behaviour is triggered, in radians.
  38015. */
  38016. set defaultElevation(elevation: number);
  38017. /**
  38018. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38019. * behaviour is triggered, in radians.
  38020. */
  38021. get defaultElevation(): number;
  38022. /**
  38023. * Sets the time (in milliseconds) taken to return to the default beta position.
  38024. * Negative value indicates camera should not return to default.
  38025. */
  38026. set elevationReturnTime(speed: number);
  38027. /**
  38028. * Gets the time (in milliseconds) taken to return to the default beta position.
  38029. * Negative value indicates camera should not return to default.
  38030. */
  38031. get elevationReturnTime(): number;
  38032. /**
  38033. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38034. */
  38035. set elevationReturnWaitTime(time: number);
  38036. /**
  38037. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38038. */
  38039. get elevationReturnWaitTime(): number;
  38040. /**
  38041. * Sets the flag that indicates if user zooming should stop animation.
  38042. */
  38043. set zoomStopsAnimation(flag: boolean);
  38044. /**
  38045. * Gets the flag that indicates if user zooming should stop animation.
  38046. */
  38047. get zoomStopsAnimation(): boolean;
  38048. /**
  38049. * Sets the transition time when framing the mesh, in milliseconds
  38050. */
  38051. set framingTime(time: number);
  38052. /**
  38053. * Gets the transition time when framing the mesh, in milliseconds
  38054. */
  38055. get framingTime(): number;
  38056. /**
  38057. * Define if the behavior should automatically change the configured
  38058. * camera limits and sensibilities.
  38059. */
  38060. autoCorrectCameraLimitsAndSensibility: boolean;
  38061. private _onPrePointerObservableObserver;
  38062. private _onAfterCheckInputsObserver;
  38063. private _onMeshTargetChangedObserver;
  38064. private _attachedCamera;
  38065. private _isPointerDown;
  38066. private _lastInteractionTime;
  38067. /**
  38068. * Initializes the behavior.
  38069. */
  38070. init(): void;
  38071. /**
  38072. * Attaches the behavior to its arc rotate camera.
  38073. * @param camera Defines the camera to attach the behavior to
  38074. */
  38075. attach(camera: ArcRotateCamera): void;
  38076. /**
  38077. * Detaches the behavior from its current arc rotate camera.
  38078. */
  38079. detach(): void;
  38080. private _animatables;
  38081. private _betaIsAnimating;
  38082. private _betaTransition;
  38083. private _radiusTransition;
  38084. private _vectorTransition;
  38085. /**
  38086. * Targets the given mesh and updates zoom level accordingly.
  38087. * @param mesh The mesh to target.
  38088. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38089. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38090. */
  38091. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38092. /**
  38093. * Targets the given mesh with its children and updates zoom level accordingly.
  38094. * @param mesh The mesh to target.
  38095. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38096. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38097. */
  38098. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38099. /**
  38100. * Targets the given meshes with their children and updates zoom level accordingly.
  38101. * @param meshes The mesh to target.
  38102. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38103. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38104. */
  38105. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38106. /**
  38107. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38108. * @param minimumWorld Determines the smaller position of the bounding box extend
  38109. * @param maximumWorld Determines the bigger position of the bounding box extend
  38110. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38111. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38112. */
  38113. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38114. /**
  38115. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38116. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38117. * frustum width.
  38118. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38119. * to fully enclose the mesh in the viewing frustum.
  38120. */
  38121. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38122. /**
  38123. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38124. * is automatically returned to its default position (expected to be above ground plane).
  38125. */
  38126. private _maintainCameraAboveGround;
  38127. /**
  38128. * Returns the frustum slope based on the canvas ratio and camera FOV
  38129. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38130. */
  38131. private _getFrustumSlope;
  38132. /**
  38133. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38134. */
  38135. private _clearAnimationLocks;
  38136. /**
  38137. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38138. */
  38139. private _applyUserInteraction;
  38140. /**
  38141. * Stops and removes all animations that have been applied to the camera
  38142. */
  38143. stopAllAnimations(): void;
  38144. /**
  38145. * Gets a value indicating if the user is moving the camera
  38146. */
  38147. get isUserIsMoving(): boolean;
  38148. /**
  38149. * The camera can move all the way towards the mesh.
  38150. */
  38151. static IgnoreBoundsSizeMode: number;
  38152. /**
  38153. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38154. */
  38155. static FitFrustumSidesMode: number;
  38156. }
  38157. }
  38158. declare module BABYLON {
  38159. /**
  38160. * Base class for Camera Pointer Inputs.
  38161. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38162. * for example usage.
  38163. */
  38164. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38165. /**
  38166. * Defines the camera the input is attached to.
  38167. */
  38168. abstract camera: Camera;
  38169. /**
  38170. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38171. */
  38172. protected _altKey: boolean;
  38173. protected _ctrlKey: boolean;
  38174. protected _metaKey: boolean;
  38175. protected _shiftKey: boolean;
  38176. /**
  38177. * Which mouse buttons were pressed at time of last mouse event.
  38178. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38179. */
  38180. protected _buttonsPressed: number;
  38181. /**
  38182. * Defines the buttons associated with the input to handle camera move.
  38183. */
  38184. buttons: number[];
  38185. /**
  38186. * Attach the input controls to a specific dom element to get the input from.
  38187. * @param element Defines the element the controls should be listened from
  38188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38189. */
  38190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38191. /**
  38192. * Detach the current controls from the specified dom element.
  38193. * @param element Defines the element to stop listening the inputs from
  38194. */
  38195. detachControl(element: Nullable<HTMLElement>): void;
  38196. /**
  38197. * Gets the class name of the current input.
  38198. * @returns the class name
  38199. */
  38200. getClassName(): string;
  38201. /**
  38202. * Get the friendly name associated with the input class.
  38203. * @returns the input friendly name
  38204. */
  38205. getSimpleName(): string;
  38206. /**
  38207. * Called on pointer POINTERDOUBLETAP event.
  38208. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38209. */
  38210. protected onDoubleTap(type: string): void;
  38211. /**
  38212. * Called on pointer POINTERMOVE event if only a single touch is active.
  38213. * Override this method to provide functionality.
  38214. */
  38215. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38216. /**
  38217. * Called on pointer POINTERMOVE event if multiple touches are active.
  38218. * Override this method to provide functionality.
  38219. */
  38220. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38221. /**
  38222. * Called on JS contextmenu event.
  38223. * Override this method to provide functionality.
  38224. */
  38225. protected onContextMenu(evt: PointerEvent): void;
  38226. /**
  38227. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38228. * press.
  38229. * Override this method to provide functionality.
  38230. */
  38231. protected onButtonDown(evt: PointerEvent): void;
  38232. /**
  38233. * Called each time a new POINTERUP event occurs. Ie, for each button
  38234. * release.
  38235. * Override this method to provide functionality.
  38236. */
  38237. protected onButtonUp(evt: PointerEvent): void;
  38238. /**
  38239. * Called when window becomes inactive.
  38240. * Override this method to provide functionality.
  38241. */
  38242. protected onLostFocus(): void;
  38243. private _pointerInput;
  38244. private _observer;
  38245. private _onLostFocus;
  38246. private pointA;
  38247. private pointB;
  38248. }
  38249. }
  38250. declare module BABYLON {
  38251. /**
  38252. * Manage the pointers inputs to control an arc rotate camera.
  38253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38254. */
  38255. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38256. /**
  38257. * Defines the camera the input is attached to.
  38258. */
  38259. camera: ArcRotateCamera;
  38260. /**
  38261. * Gets the class name of the current input.
  38262. * @returns the class name
  38263. */
  38264. getClassName(): string;
  38265. /**
  38266. * Defines the buttons associated with the input to handle camera move.
  38267. */
  38268. buttons: number[];
  38269. /**
  38270. * Defines the pointer angular sensibility along the X axis or how fast is
  38271. * the camera rotating.
  38272. */
  38273. angularSensibilityX: number;
  38274. /**
  38275. * Defines the pointer angular sensibility along the Y axis or how fast is
  38276. * the camera rotating.
  38277. */
  38278. angularSensibilityY: number;
  38279. /**
  38280. * Defines the pointer pinch precision or how fast is the camera zooming.
  38281. */
  38282. pinchPrecision: number;
  38283. /**
  38284. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38285. * from 0.
  38286. * It defines the percentage of current camera.radius to use as delta when
  38287. * pinch zoom is used.
  38288. */
  38289. pinchDeltaPercentage: number;
  38290. /**
  38291. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38292. * that any object in the plane at the camera's target point will scale
  38293. * perfectly with finger motion.
  38294. * Overrides pinchDeltaPercentage and pinchPrecision.
  38295. */
  38296. useNaturalPinchZoom: boolean;
  38297. /**
  38298. * Defines the pointer panning sensibility or how fast is the camera moving.
  38299. */
  38300. panningSensibility: number;
  38301. /**
  38302. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38303. */
  38304. multiTouchPanning: boolean;
  38305. /**
  38306. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38307. * zoom (pinch) through multitouch.
  38308. */
  38309. multiTouchPanAndZoom: boolean;
  38310. /**
  38311. * Revers pinch action direction.
  38312. */
  38313. pinchInwards: boolean;
  38314. private _isPanClick;
  38315. private _twoFingerActivityCount;
  38316. private _isPinching;
  38317. /**
  38318. * Called on pointer POINTERMOVE event if only a single touch is active.
  38319. */
  38320. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38321. /**
  38322. * Called on pointer POINTERDOUBLETAP event.
  38323. */
  38324. protected onDoubleTap(type: string): void;
  38325. /**
  38326. * Called on pointer POINTERMOVE event if multiple touches are active.
  38327. */
  38328. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38329. /**
  38330. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38331. * press.
  38332. */
  38333. protected onButtonDown(evt: PointerEvent): void;
  38334. /**
  38335. * Called each time a new POINTERUP event occurs. Ie, for each button
  38336. * release.
  38337. */
  38338. protected onButtonUp(evt: PointerEvent): void;
  38339. /**
  38340. * Called when window becomes inactive.
  38341. */
  38342. protected onLostFocus(): void;
  38343. }
  38344. }
  38345. declare module BABYLON {
  38346. /**
  38347. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38349. */
  38350. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38351. /**
  38352. * Defines the camera the input is attached to.
  38353. */
  38354. camera: ArcRotateCamera;
  38355. /**
  38356. * Defines the list of key codes associated with the up action (increase alpha)
  38357. */
  38358. keysUp: number[];
  38359. /**
  38360. * Defines the list of key codes associated with the down action (decrease alpha)
  38361. */
  38362. keysDown: number[];
  38363. /**
  38364. * Defines the list of key codes associated with the left action (increase beta)
  38365. */
  38366. keysLeft: number[];
  38367. /**
  38368. * Defines the list of key codes associated with the right action (decrease beta)
  38369. */
  38370. keysRight: number[];
  38371. /**
  38372. * Defines the list of key codes associated with the reset action.
  38373. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38374. */
  38375. keysReset: number[];
  38376. /**
  38377. * Defines the panning sensibility of the inputs.
  38378. * (How fast is the camera panning)
  38379. */
  38380. panningSensibility: number;
  38381. /**
  38382. * Defines the zooming sensibility of the inputs.
  38383. * (How fast is the camera zooming)
  38384. */
  38385. zoomingSensibility: number;
  38386. /**
  38387. * Defines whether maintaining the alt key down switch the movement mode from
  38388. * orientation to zoom.
  38389. */
  38390. useAltToZoom: boolean;
  38391. /**
  38392. * Rotation speed of the camera
  38393. */
  38394. angularSpeed: number;
  38395. private _keys;
  38396. private _ctrlPressed;
  38397. private _altPressed;
  38398. private _onCanvasBlurObserver;
  38399. private _onKeyboardObserver;
  38400. private _engine;
  38401. private _scene;
  38402. /**
  38403. * Attach the input controls to a specific dom element to get the input from.
  38404. * @param element Defines the element the controls should be listened from
  38405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38406. */
  38407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38408. /**
  38409. * Detach the current controls from the specified dom element.
  38410. * @param element Defines the element to stop listening the inputs from
  38411. */
  38412. detachControl(element: Nullable<HTMLElement>): void;
  38413. /**
  38414. * Update the current camera state depending on the inputs that have been used this frame.
  38415. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38416. */
  38417. checkInputs(): void;
  38418. /**
  38419. * Gets the class name of the current intput.
  38420. * @returns the class name
  38421. */
  38422. getClassName(): string;
  38423. /**
  38424. * Get the friendly name associated with the input class.
  38425. * @returns the input friendly name
  38426. */
  38427. getSimpleName(): string;
  38428. }
  38429. }
  38430. declare module BABYLON {
  38431. /**
  38432. * Manage the mouse wheel inputs to control an arc rotate camera.
  38433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38434. */
  38435. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38436. /**
  38437. * Defines the camera the input is attached to.
  38438. */
  38439. camera: ArcRotateCamera;
  38440. /**
  38441. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38442. */
  38443. wheelPrecision: number;
  38444. /**
  38445. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38446. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38447. */
  38448. wheelDeltaPercentage: number;
  38449. private _wheel;
  38450. private _observer;
  38451. private computeDeltaFromMouseWheelLegacyEvent;
  38452. /**
  38453. * Attach the input controls to a specific dom element to get the input from.
  38454. * @param element Defines the element the controls should be listened from
  38455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38456. */
  38457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38458. /**
  38459. * Detach the current controls from the specified dom element.
  38460. * @param element Defines the element to stop listening the inputs from
  38461. */
  38462. detachControl(element: Nullable<HTMLElement>): void;
  38463. /**
  38464. * Gets the class name of the current intput.
  38465. * @returns the class name
  38466. */
  38467. getClassName(): string;
  38468. /**
  38469. * Get the friendly name associated with the input class.
  38470. * @returns the input friendly name
  38471. */
  38472. getSimpleName(): string;
  38473. }
  38474. }
  38475. declare module BABYLON {
  38476. /**
  38477. * Default Inputs manager for the ArcRotateCamera.
  38478. * It groups all the default supported inputs for ease of use.
  38479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38480. */
  38481. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38482. /**
  38483. * Instantiates a new ArcRotateCameraInputsManager.
  38484. * @param camera Defines the camera the inputs belong to
  38485. */
  38486. constructor(camera: ArcRotateCamera);
  38487. /**
  38488. * Add mouse wheel input support to the input manager.
  38489. * @returns the current input manager
  38490. */
  38491. addMouseWheel(): ArcRotateCameraInputsManager;
  38492. /**
  38493. * Add pointers input support to the input manager.
  38494. * @returns the current input manager
  38495. */
  38496. addPointers(): ArcRotateCameraInputsManager;
  38497. /**
  38498. * Add keyboard input support to the input manager.
  38499. * @returns the current input manager
  38500. */
  38501. addKeyboard(): ArcRotateCameraInputsManager;
  38502. }
  38503. }
  38504. declare module BABYLON {
  38505. /**
  38506. * This represents an orbital type of camera.
  38507. *
  38508. * 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.
  38509. * 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.
  38510. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38511. */
  38512. export class ArcRotateCamera extends TargetCamera {
  38513. /**
  38514. * Defines the rotation angle of the camera along the longitudinal axis.
  38515. */
  38516. alpha: number;
  38517. /**
  38518. * Defines the rotation angle of the camera along the latitudinal axis.
  38519. */
  38520. beta: number;
  38521. /**
  38522. * Defines the radius of the camera from it s target point.
  38523. */
  38524. radius: number;
  38525. protected _target: Vector3;
  38526. protected _targetHost: Nullable<AbstractMesh>;
  38527. /**
  38528. * Defines the target point of the camera.
  38529. * The camera looks towards it form the radius distance.
  38530. */
  38531. get target(): Vector3;
  38532. set target(value: Vector3);
  38533. /**
  38534. * Define the current local position of the camera in the scene
  38535. */
  38536. get position(): Vector3;
  38537. set position(newPosition: Vector3);
  38538. protected _upVector: Vector3;
  38539. protected _upToYMatrix: Matrix;
  38540. protected _YToUpMatrix: Matrix;
  38541. /**
  38542. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38543. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38544. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38545. */
  38546. set upVector(vec: Vector3);
  38547. get upVector(): Vector3;
  38548. /**
  38549. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38550. */
  38551. setMatUp(): void;
  38552. /**
  38553. * Current inertia value on the longitudinal axis.
  38554. * The bigger this number the longer it will take for the camera to stop.
  38555. */
  38556. inertialAlphaOffset: number;
  38557. /**
  38558. * Current inertia value on the latitudinal axis.
  38559. * The bigger this number the longer it will take for the camera to stop.
  38560. */
  38561. inertialBetaOffset: number;
  38562. /**
  38563. * Current inertia value on the radius axis.
  38564. * The bigger this number the longer it will take for the camera to stop.
  38565. */
  38566. inertialRadiusOffset: number;
  38567. /**
  38568. * Minimum allowed angle on the longitudinal axis.
  38569. * This can help limiting how the Camera is able to move in the scene.
  38570. */
  38571. lowerAlphaLimit: Nullable<number>;
  38572. /**
  38573. * Maximum allowed angle on the longitudinal axis.
  38574. * This can help limiting how the Camera is able to move in the scene.
  38575. */
  38576. upperAlphaLimit: Nullable<number>;
  38577. /**
  38578. * Minimum allowed angle on the latitudinal axis.
  38579. * This can help limiting how the Camera is able to move in the scene.
  38580. */
  38581. lowerBetaLimit: number;
  38582. /**
  38583. * Maximum allowed angle on the latitudinal axis.
  38584. * This can help limiting how the Camera is able to move in the scene.
  38585. */
  38586. upperBetaLimit: number;
  38587. /**
  38588. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38589. * This can help limiting how the Camera is able to move in the scene.
  38590. */
  38591. lowerRadiusLimit: Nullable<number>;
  38592. /**
  38593. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38594. * This can help limiting how the Camera is able to move in the scene.
  38595. */
  38596. upperRadiusLimit: Nullable<number>;
  38597. /**
  38598. * Defines the current inertia value used during panning of the camera along the X axis.
  38599. */
  38600. inertialPanningX: number;
  38601. /**
  38602. * Defines the current inertia value used during panning of the camera along the Y axis.
  38603. */
  38604. inertialPanningY: number;
  38605. /**
  38606. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38607. * Basically if your fingers moves away from more than this distance you will be considered
  38608. * in pinch mode.
  38609. */
  38610. pinchToPanMaxDistance: number;
  38611. /**
  38612. * Defines the maximum distance the camera can pan.
  38613. * This could help keeping the cammera always in your scene.
  38614. */
  38615. panningDistanceLimit: Nullable<number>;
  38616. /**
  38617. * Defines the target of the camera before paning.
  38618. */
  38619. panningOriginTarget: Vector3;
  38620. /**
  38621. * Defines the value of the inertia used during panning.
  38622. * 0 would mean stop inertia and one would mean no decelleration at all.
  38623. */
  38624. panningInertia: number;
  38625. /**
  38626. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38627. */
  38628. get angularSensibilityX(): number;
  38629. set angularSensibilityX(value: number);
  38630. /**
  38631. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38632. */
  38633. get angularSensibilityY(): number;
  38634. set angularSensibilityY(value: number);
  38635. /**
  38636. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38637. */
  38638. get pinchPrecision(): number;
  38639. set pinchPrecision(value: number);
  38640. /**
  38641. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38642. * It will be used instead of pinchDeltaPrecision if different from 0.
  38643. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38644. */
  38645. get pinchDeltaPercentage(): number;
  38646. set pinchDeltaPercentage(value: number);
  38647. /**
  38648. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38649. * and pinch delta percentage.
  38650. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38651. * that any object in the plane at the camera's target point will scale
  38652. * perfectly with finger motion.
  38653. */
  38654. get useNaturalPinchZoom(): boolean;
  38655. set useNaturalPinchZoom(value: boolean);
  38656. /**
  38657. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38658. */
  38659. get panningSensibility(): number;
  38660. set panningSensibility(value: number);
  38661. /**
  38662. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38663. */
  38664. get keysUp(): number[];
  38665. set keysUp(value: number[]);
  38666. /**
  38667. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38668. */
  38669. get keysDown(): number[];
  38670. set keysDown(value: number[]);
  38671. /**
  38672. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38673. */
  38674. get keysLeft(): number[];
  38675. set keysLeft(value: number[]);
  38676. /**
  38677. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38678. */
  38679. get keysRight(): number[];
  38680. set keysRight(value: number[]);
  38681. /**
  38682. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38683. */
  38684. get wheelPrecision(): number;
  38685. set wheelPrecision(value: number);
  38686. /**
  38687. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38688. * It will be used instead of pinchDeltaPrecision if different from 0.
  38689. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38690. */
  38691. get wheelDeltaPercentage(): number;
  38692. set wheelDeltaPercentage(value: number);
  38693. /**
  38694. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38695. */
  38696. zoomOnFactor: number;
  38697. /**
  38698. * Defines a screen offset for the camera position.
  38699. */
  38700. targetScreenOffset: Vector2;
  38701. /**
  38702. * Allows the camera to be completely reversed.
  38703. * If false the camera can not arrive upside down.
  38704. */
  38705. allowUpsideDown: boolean;
  38706. /**
  38707. * Define if double tap/click is used to restore the previously saved state of the camera.
  38708. */
  38709. useInputToRestoreState: boolean;
  38710. /** @hidden */
  38711. _viewMatrix: Matrix;
  38712. /** @hidden */
  38713. _useCtrlForPanning: boolean;
  38714. /** @hidden */
  38715. _panningMouseButton: number;
  38716. /**
  38717. * Defines the input associated to the camera.
  38718. */
  38719. inputs: ArcRotateCameraInputsManager;
  38720. /** @hidden */
  38721. _reset: () => void;
  38722. /**
  38723. * Defines the allowed panning axis.
  38724. */
  38725. panningAxis: Vector3;
  38726. protected _localDirection: Vector3;
  38727. protected _transformedDirection: Vector3;
  38728. private _bouncingBehavior;
  38729. /**
  38730. * Gets the bouncing behavior of the camera if it has been enabled.
  38731. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38732. */
  38733. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38734. /**
  38735. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38737. */
  38738. get useBouncingBehavior(): boolean;
  38739. set useBouncingBehavior(value: boolean);
  38740. private _framingBehavior;
  38741. /**
  38742. * Gets the framing behavior of the camera if it has been enabled.
  38743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38744. */
  38745. get framingBehavior(): Nullable<FramingBehavior>;
  38746. /**
  38747. * Defines if the framing behavior of the camera is enabled on the camera.
  38748. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38749. */
  38750. get useFramingBehavior(): boolean;
  38751. set useFramingBehavior(value: boolean);
  38752. private _autoRotationBehavior;
  38753. /**
  38754. * Gets the auto rotation behavior of the camera if it has been enabled.
  38755. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38756. */
  38757. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38758. /**
  38759. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38760. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38761. */
  38762. get useAutoRotationBehavior(): boolean;
  38763. set useAutoRotationBehavior(value: boolean);
  38764. /**
  38765. * Observable triggered when the mesh target has been changed on the camera.
  38766. */
  38767. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38768. /**
  38769. * Event raised when the camera is colliding with a mesh.
  38770. */
  38771. onCollide: (collidedMesh: AbstractMesh) => void;
  38772. /**
  38773. * Defines whether the camera should check collision with the objects oh the scene.
  38774. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38775. */
  38776. checkCollisions: boolean;
  38777. /**
  38778. * Defines the collision radius of the camera.
  38779. * This simulates a sphere around the camera.
  38780. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38781. */
  38782. collisionRadius: Vector3;
  38783. protected _collider: Collider;
  38784. protected _previousPosition: Vector3;
  38785. protected _collisionVelocity: Vector3;
  38786. protected _newPosition: Vector3;
  38787. protected _previousAlpha: number;
  38788. protected _previousBeta: number;
  38789. protected _previousRadius: number;
  38790. protected _collisionTriggered: boolean;
  38791. protected _targetBoundingCenter: Nullable<Vector3>;
  38792. private _computationVector;
  38793. /**
  38794. * Instantiates a new ArcRotateCamera in a given scene
  38795. * @param name Defines the name of the camera
  38796. * @param alpha Defines the camera rotation along the logitudinal axis
  38797. * @param beta Defines the camera rotation along the latitudinal axis
  38798. * @param radius Defines the camera distance from its target
  38799. * @param target Defines the camera target
  38800. * @param scene Defines the scene the camera belongs to
  38801. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38802. */
  38803. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38804. /** @hidden */
  38805. _initCache(): void;
  38806. /** @hidden */
  38807. _updateCache(ignoreParentClass?: boolean): void;
  38808. protected _getTargetPosition(): Vector3;
  38809. private _storedAlpha;
  38810. private _storedBeta;
  38811. private _storedRadius;
  38812. private _storedTarget;
  38813. private _storedTargetScreenOffset;
  38814. /**
  38815. * Stores the current state of the camera (alpha, beta, radius and target)
  38816. * @returns the camera itself
  38817. */
  38818. storeState(): Camera;
  38819. /**
  38820. * @hidden
  38821. * Restored camera state. You must call storeState() first
  38822. */
  38823. _restoreStateValues(): boolean;
  38824. /** @hidden */
  38825. _isSynchronizedViewMatrix(): boolean;
  38826. /**
  38827. * Attached controls to the current camera.
  38828. * @param element Defines the element the controls should be listened from
  38829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38830. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38831. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38832. */
  38833. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38834. /**
  38835. * Detach the current controls from the camera.
  38836. * The camera will stop reacting to inputs.
  38837. * @param element Defines the element to stop listening the inputs from
  38838. */
  38839. detachControl(element: HTMLElement): void;
  38840. /** @hidden */
  38841. _checkInputs(): void;
  38842. protected _checkLimits(): void;
  38843. /**
  38844. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38845. */
  38846. rebuildAnglesAndRadius(): void;
  38847. /**
  38848. * Use a position to define the current camera related information like alpha, beta and radius
  38849. * @param position Defines the position to set the camera at
  38850. */
  38851. setPosition(position: Vector3): void;
  38852. /**
  38853. * Defines the target the camera should look at.
  38854. * This will automatically adapt alpha beta and radius to fit within the new target.
  38855. * @param target Defines the new target as a Vector or a mesh
  38856. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38857. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38858. */
  38859. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38860. /** @hidden */
  38861. _getViewMatrix(): Matrix;
  38862. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38863. /**
  38864. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38865. * @param meshes Defines the mesh to zoom on
  38866. * @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)
  38867. */
  38868. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38869. /**
  38870. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38871. * The target will be changed but the radius
  38872. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus 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. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38876. min: Vector3;
  38877. max: Vector3;
  38878. distance: number;
  38879. }, doNotUpdateMaxZ?: boolean): void;
  38880. /**
  38881. * @override
  38882. * Override Camera.createRigCamera
  38883. */
  38884. createRigCamera(name: string, cameraIndex: number): Camera;
  38885. /**
  38886. * @hidden
  38887. * @override
  38888. * Override Camera._updateRigCameras
  38889. */
  38890. _updateRigCameras(): void;
  38891. /**
  38892. * Destroy the camera and release the current resources hold by it.
  38893. */
  38894. dispose(): void;
  38895. /**
  38896. * Gets the current object class name.
  38897. * @return the class name
  38898. */
  38899. getClassName(): string;
  38900. }
  38901. }
  38902. declare module BABYLON {
  38903. /**
  38904. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38905. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38906. */
  38907. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38908. /**
  38909. * Gets the name of the behavior.
  38910. */
  38911. get name(): string;
  38912. private _zoomStopsAnimation;
  38913. private _idleRotationSpeed;
  38914. private _idleRotationWaitTime;
  38915. private _idleRotationSpinupTime;
  38916. /**
  38917. * Sets the flag that indicates if user zooming should stop animation.
  38918. */
  38919. set zoomStopsAnimation(flag: boolean);
  38920. /**
  38921. * Gets the flag that indicates if user zooming should stop animation.
  38922. */
  38923. get zoomStopsAnimation(): boolean;
  38924. /**
  38925. * Sets the default speed at which the camera rotates around the model.
  38926. */
  38927. set idleRotationSpeed(speed: number);
  38928. /**
  38929. * Gets the default speed at which the camera rotates around the model.
  38930. */
  38931. get idleRotationSpeed(): number;
  38932. /**
  38933. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38934. */
  38935. set idleRotationWaitTime(time: number);
  38936. /**
  38937. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38938. */
  38939. get idleRotationWaitTime(): number;
  38940. /**
  38941. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38942. */
  38943. set idleRotationSpinupTime(time: number);
  38944. /**
  38945. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38946. */
  38947. get idleRotationSpinupTime(): number;
  38948. /**
  38949. * Gets a value indicating if the camera is currently rotating because of this behavior
  38950. */
  38951. get rotationInProgress(): boolean;
  38952. private _onPrePointerObservableObserver;
  38953. private _onAfterCheckInputsObserver;
  38954. private _attachedCamera;
  38955. private _isPointerDown;
  38956. private _lastFrameTime;
  38957. private _lastInteractionTime;
  38958. private _cameraRotationSpeed;
  38959. /**
  38960. * Initializes the behavior.
  38961. */
  38962. init(): void;
  38963. /**
  38964. * Attaches the behavior to its arc rotate camera.
  38965. * @param camera Defines the camera to attach the behavior to
  38966. */
  38967. attach(camera: ArcRotateCamera): void;
  38968. /**
  38969. * Detaches the behavior from its current arc rotate camera.
  38970. */
  38971. detach(): void;
  38972. /**
  38973. * Returns true if user is scrolling.
  38974. * @return true if user is scrolling.
  38975. */
  38976. private _userIsZooming;
  38977. private _lastFrameRadius;
  38978. private _shouldAnimationStopForInteraction;
  38979. /**
  38980. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38981. */
  38982. private _applyUserInteraction;
  38983. private _userIsMoving;
  38984. }
  38985. }
  38986. declare module BABYLON {
  38987. /**
  38988. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38989. */
  38990. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38991. private ui;
  38992. /**
  38993. * The name of the behavior
  38994. */
  38995. name: string;
  38996. /**
  38997. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38998. */
  38999. distanceAwayFromFace: number;
  39000. /**
  39001. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39002. */
  39003. distanceAwayFromBottomOfFace: number;
  39004. private _faceVectors;
  39005. private _target;
  39006. private _scene;
  39007. private _onRenderObserver;
  39008. private _tmpMatrix;
  39009. private _tmpVector;
  39010. /**
  39011. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39012. * @param ui The transform node that should be attched to the mesh
  39013. */
  39014. constructor(ui: TransformNode);
  39015. /**
  39016. * Initializes the behavior
  39017. */
  39018. init(): void;
  39019. private _closestFace;
  39020. private _zeroVector;
  39021. private _lookAtTmpMatrix;
  39022. private _lookAtToRef;
  39023. /**
  39024. * Attaches the AttachToBoxBehavior to the passed in mesh
  39025. * @param target The mesh that the specified node will be attached to
  39026. */
  39027. attach(target: Mesh): void;
  39028. /**
  39029. * Detaches the behavior from the mesh
  39030. */
  39031. detach(): void;
  39032. }
  39033. }
  39034. declare module BABYLON {
  39035. /**
  39036. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39037. */
  39038. export class FadeInOutBehavior implements Behavior<Mesh> {
  39039. /**
  39040. * Time in milliseconds to delay before fading in (Default: 0)
  39041. */
  39042. delay: number;
  39043. /**
  39044. * Time in milliseconds for the mesh to fade in (Default: 300)
  39045. */
  39046. fadeInTime: number;
  39047. private _millisecondsPerFrame;
  39048. private _hovered;
  39049. private _hoverValue;
  39050. private _ownerNode;
  39051. /**
  39052. * Instatiates the FadeInOutBehavior
  39053. */
  39054. constructor();
  39055. /**
  39056. * The name of the behavior
  39057. */
  39058. get name(): string;
  39059. /**
  39060. * Initializes the behavior
  39061. */
  39062. init(): void;
  39063. /**
  39064. * Attaches the fade behavior on the passed in mesh
  39065. * @param ownerNode The mesh that will be faded in/out once attached
  39066. */
  39067. attach(ownerNode: Mesh): void;
  39068. /**
  39069. * Detaches the behavior from the mesh
  39070. */
  39071. detach(): void;
  39072. /**
  39073. * Triggers the mesh to begin fading in or out
  39074. * @param value if the object should fade in or out (true to fade in)
  39075. */
  39076. fadeIn(value: boolean): void;
  39077. private _update;
  39078. private _setAllVisibility;
  39079. }
  39080. }
  39081. declare module BABYLON {
  39082. /**
  39083. * Class containing a set of static utilities functions for managing Pivots
  39084. * @hidden
  39085. */
  39086. export class PivotTools {
  39087. private static _PivotCached;
  39088. private static _OldPivotPoint;
  39089. private static _PivotTranslation;
  39090. private static _PivotTmpVector;
  39091. /** @hidden */
  39092. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39093. /** @hidden */
  39094. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /**
  39099. * Class containing static functions to help procedurally build meshes
  39100. */
  39101. export class PlaneBuilder {
  39102. /**
  39103. * Creates a plane mesh
  39104. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39105. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39106. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39108. * * 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
  39109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39110. * @param name defines the name of the mesh
  39111. * @param options defines the options used to create the mesh
  39112. * @param scene defines the hosting scene
  39113. * @returns the plane mesh
  39114. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39115. */
  39116. static CreatePlane(name: string, options: {
  39117. size?: number;
  39118. width?: number;
  39119. height?: number;
  39120. sideOrientation?: number;
  39121. frontUVs?: Vector4;
  39122. backUVs?: Vector4;
  39123. updatable?: boolean;
  39124. sourcePlane?: Plane;
  39125. }, scene?: Nullable<Scene>): Mesh;
  39126. }
  39127. }
  39128. declare module BABYLON {
  39129. /**
  39130. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39131. */
  39132. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39133. private static _AnyMouseID;
  39134. /**
  39135. * Abstract mesh the behavior is set on
  39136. */
  39137. attachedNode: AbstractMesh;
  39138. private _dragPlane;
  39139. private _scene;
  39140. private _pointerObserver;
  39141. private _beforeRenderObserver;
  39142. private static _planeScene;
  39143. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39144. /**
  39145. * 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)
  39146. */
  39147. maxDragAngle: number;
  39148. /**
  39149. * @hidden
  39150. */
  39151. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39152. /**
  39153. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39154. */
  39155. currentDraggingPointerID: number;
  39156. /**
  39157. * The last position where the pointer hit the drag plane in world space
  39158. */
  39159. lastDragPosition: Vector3;
  39160. /**
  39161. * If the behavior is currently in a dragging state
  39162. */
  39163. dragging: boolean;
  39164. /**
  39165. * 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)
  39166. */
  39167. dragDeltaRatio: number;
  39168. /**
  39169. * If the drag plane orientation should be updated during the dragging (Default: true)
  39170. */
  39171. updateDragPlane: boolean;
  39172. private _debugMode;
  39173. private _moving;
  39174. /**
  39175. * Fires each time the attached mesh is dragged with the pointer
  39176. * * delta between last drag position and current drag position in world space
  39177. * * dragDistance along the drag axis
  39178. * * dragPlaneNormal normal of the current drag plane used during the drag
  39179. * * dragPlanePoint in world space where the drag intersects the drag plane
  39180. */
  39181. onDragObservable: Observable<{
  39182. delta: Vector3;
  39183. dragPlanePoint: Vector3;
  39184. dragPlaneNormal: Vector3;
  39185. dragDistance: number;
  39186. pointerId: number;
  39187. }>;
  39188. /**
  39189. * Fires each time a drag begins (eg. mouse down on mesh)
  39190. */
  39191. onDragStartObservable: Observable<{
  39192. dragPlanePoint: Vector3;
  39193. pointerId: number;
  39194. }>;
  39195. /**
  39196. * Fires each time a drag ends (eg. mouse release after drag)
  39197. */
  39198. onDragEndObservable: Observable<{
  39199. dragPlanePoint: Vector3;
  39200. pointerId: number;
  39201. }>;
  39202. /**
  39203. * If the attached mesh should be moved when dragged
  39204. */
  39205. moveAttached: boolean;
  39206. /**
  39207. * If the drag behavior will react to drag events (Default: true)
  39208. */
  39209. enabled: boolean;
  39210. /**
  39211. * If pointer events should start and release the drag (Default: true)
  39212. */
  39213. startAndReleaseDragOnPointerEvents: boolean;
  39214. /**
  39215. * If camera controls should be detached during the drag
  39216. */
  39217. detachCameraControls: boolean;
  39218. /**
  39219. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39220. */
  39221. useObjectOrientationForDragging: boolean;
  39222. private _options;
  39223. /**
  39224. * Gets the options used by the behavior
  39225. */
  39226. get options(): {
  39227. dragAxis?: Vector3;
  39228. dragPlaneNormal?: Vector3;
  39229. };
  39230. /**
  39231. * Sets the options used by the behavior
  39232. */
  39233. set options(options: {
  39234. dragAxis?: Vector3;
  39235. dragPlaneNormal?: Vector3;
  39236. });
  39237. /**
  39238. * Creates a pointer drag behavior that can be attached to a mesh
  39239. * @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)
  39240. */
  39241. constructor(options?: {
  39242. dragAxis?: Vector3;
  39243. dragPlaneNormal?: Vector3;
  39244. });
  39245. /**
  39246. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39247. */
  39248. validateDrag: (targetPosition: Vector3) => boolean;
  39249. /**
  39250. * The name of the behavior
  39251. */
  39252. get name(): string;
  39253. /**
  39254. * Initializes the behavior
  39255. */
  39256. init(): void;
  39257. private _tmpVector;
  39258. private _alternatePickedPoint;
  39259. private _worldDragAxis;
  39260. private _targetPosition;
  39261. private _attachedElement;
  39262. /**
  39263. * Attaches the drag behavior the passed in mesh
  39264. * @param ownerNode The mesh that will be dragged around once attached
  39265. * @param predicate Predicate to use for pick filtering
  39266. */
  39267. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39268. /**
  39269. * Force relase the drag action by code.
  39270. */
  39271. releaseDrag(): void;
  39272. private _startDragRay;
  39273. private _lastPointerRay;
  39274. /**
  39275. * Simulates the start of a pointer drag event on the behavior
  39276. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39277. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39278. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39279. */
  39280. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39281. private _startDrag;
  39282. private _dragDelta;
  39283. private _moveDrag;
  39284. private _pickWithRayOnDragPlane;
  39285. private _pointA;
  39286. private _pointB;
  39287. private _pointC;
  39288. private _lineA;
  39289. private _lineB;
  39290. private _localAxis;
  39291. private _lookAt;
  39292. private _updateDragPlanePosition;
  39293. /**
  39294. * Detaches the behavior from the mesh
  39295. */
  39296. detach(): void;
  39297. }
  39298. }
  39299. declare module BABYLON {
  39300. /**
  39301. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39302. */
  39303. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39304. private _dragBehaviorA;
  39305. private _dragBehaviorB;
  39306. private _startDistance;
  39307. private _initialScale;
  39308. private _targetScale;
  39309. private _ownerNode;
  39310. private _sceneRenderObserver;
  39311. /**
  39312. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39313. */
  39314. constructor();
  39315. /**
  39316. * The name of the behavior
  39317. */
  39318. get name(): string;
  39319. /**
  39320. * Initializes the behavior
  39321. */
  39322. init(): void;
  39323. private _getCurrentDistance;
  39324. /**
  39325. * Attaches the scale behavior the passed in mesh
  39326. * @param ownerNode The mesh that will be scaled around once attached
  39327. */
  39328. attach(ownerNode: Mesh): void;
  39329. /**
  39330. * Detaches the behavior from the mesh
  39331. */
  39332. detach(): void;
  39333. }
  39334. }
  39335. declare module BABYLON {
  39336. /**
  39337. * 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
  39338. */
  39339. export class SixDofDragBehavior implements Behavior<Mesh> {
  39340. private static _virtualScene;
  39341. private _ownerNode;
  39342. private _sceneRenderObserver;
  39343. private _scene;
  39344. private _targetPosition;
  39345. private _virtualOriginMesh;
  39346. private _virtualDragMesh;
  39347. private _pointerObserver;
  39348. private _moving;
  39349. private _startingOrientation;
  39350. /**
  39351. * 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)
  39352. */
  39353. private zDragFactor;
  39354. /**
  39355. * If the object should rotate to face the drag origin
  39356. */
  39357. rotateDraggedObject: boolean;
  39358. /**
  39359. * If the behavior is currently in a dragging state
  39360. */
  39361. dragging: boolean;
  39362. /**
  39363. * 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)
  39364. */
  39365. dragDeltaRatio: number;
  39366. /**
  39367. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39368. */
  39369. currentDraggingPointerID: number;
  39370. /**
  39371. * If camera controls should be detached during the drag
  39372. */
  39373. detachCameraControls: boolean;
  39374. /**
  39375. * Fires each time a drag starts
  39376. */
  39377. onDragStartObservable: Observable<{}>;
  39378. /**
  39379. * Fires each time a drag ends (eg. mouse release after drag)
  39380. */
  39381. onDragEndObservable: Observable<{}>;
  39382. /**
  39383. * 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
  39384. */
  39385. constructor();
  39386. /**
  39387. * The name of the behavior
  39388. */
  39389. get name(): string;
  39390. /**
  39391. * Initializes the behavior
  39392. */
  39393. init(): void;
  39394. /**
  39395. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39396. */
  39397. private get _pointerCamera();
  39398. /**
  39399. * Attaches the scale behavior the passed in mesh
  39400. * @param ownerNode The mesh that will be scaled around once attached
  39401. */
  39402. attach(ownerNode: Mesh): void;
  39403. /**
  39404. * Detaches the behavior from the mesh
  39405. */
  39406. detach(): void;
  39407. }
  39408. }
  39409. declare module BABYLON {
  39410. /**
  39411. * Class used to apply inverse kinematics to bones
  39412. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39413. */
  39414. export class BoneIKController {
  39415. private static _tmpVecs;
  39416. private static _tmpQuat;
  39417. private static _tmpMats;
  39418. /**
  39419. * Gets or sets the target mesh
  39420. */
  39421. targetMesh: AbstractMesh;
  39422. /** Gets or sets the mesh used as pole */
  39423. poleTargetMesh: AbstractMesh;
  39424. /**
  39425. * Gets or sets the bone used as pole
  39426. */
  39427. poleTargetBone: Nullable<Bone>;
  39428. /**
  39429. * Gets or sets the target position
  39430. */
  39431. targetPosition: Vector3;
  39432. /**
  39433. * Gets or sets the pole target position
  39434. */
  39435. poleTargetPosition: Vector3;
  39436. /**
  39437. * Gets or sets the pole target local offset
  39438. */
  39439. poleTargetLocalOffset: Vector3;
  39440. /**
  39441. * Gets or sets the pole angle
  39442. */
  39443. poleAngle: number;
  39444. /**
  39445. * Gets or sets the mesh associated with the controller
  39446. */
  39447. mesh: AbstractMesh;
  39448. /**
  39449. * 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)
  39450. */
  39451. slerpAmount: number;
  39452. private _bone1Quat;
  39453. private _bone1Mat;
  39454. private _bone2Ang;
  39455. private _bone1;
  39456. private _bone2;
  39457. private _bone1Length;
  39458. private _bone2Length;
  39459. private _maxAngle;
  39460. private _maxReach;
  39461. private _rightHandedSystem;
  39462. private _bendAxis;
  39463. private _slerping;
  39464. private _adjustRoll;
  39465. /**
  39466. * Gets or sets maximum allowed angle
  39467. */
  39468. get maxAngle(): number;
  39469. set maxAngle(value: number);
  39470. /**
  39471. * Creates a new BoneIKController
  39472. * @param mesh defines the mesh to control
  39473. * @param bone defines the bone to control
  39474. * @param options defines options to set up the controller
  39475. */
  39476. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39477. targetMesh?: AbstractMesh;
  39478. poleTargetMesh?: AbstractMesh;
  39479. poleTargetBone?: Bone;
  39480. poleTargetLocalOffset?: Vector3;
  39481. poleAngle?: number;
  39482. bendAxis?: Vector3;
  39483. maxAngle?: number;
  39484. slerpAmount?: number;
  39485. });
  39486. private _setMaxAngle;
  39487. /**
  39488. * Force the controller to update the bones
  39489. */
  39490. update(): void;
  39491. }
  39492. }
  39493. declare module BABYLON {
  39494. /**
  39495. * Class used to make a bone look toward a point in space
  39496. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39497. */
  39498. export class BoneLookController {
  39499. private static _tmpVecs;
  39500. private static _tmpQuat;
  39501. private static _tmpMats;
  39502. /**
  39503. * The target Vector3 that the bone will look at
  39504. */
  39505. target: Vector3;
  39506. /**
  39507. * The mesh that the bone is attached to
  39508. */
  39509. mesh: AbstractMesh;
  39510. /**
  39511. * The bone that will be looking to the target
  39512. */
  39513. bone: Bone;
  39514. /**
  39515. * The up axis of the coordinate system that is used when the bone is rotated
  39516. */
  39517. upAxis: Vector3;
  39518. /**
  39519. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39520. */
  39521. upAxisSpace: Space;
  39522. /**
  39523. * Used to make an adjustment to the yaw of the bone
  39524. */
  39525. adjustYaw: number;
  39526. /**
  39527. * Used to make an adjustment to the pitch of the bone
  39528. */
  39529. adjustPitch: number;
  39530. /**
  39531. * Used to make an adjustment to the roll of the bone
  39532. */
  39533. adjustRoll: number;
  39534. /**
  39535. * 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)
  39536. */
  39537. slerpAmount: number;
  39538. private _minYaw;
  39539. private _maxYaw;
  39540. private _minPitch;
  39541. private _maxPitch;
  39542. private _minYawSin;
  39543. private _minYawCos;
  39544. private _maxYawSin;
  39545. private _maxYawCos;
  39546. private _midYawConstraint;
  39547. private _minPitchTan;
  39548. private _maxPitchTan;
  39549. private _boneQuat;
  39550. private _slerping;
  39551. private _transformYawPitch;
  39552. private _transformYawPitchInv;
  39553. private _firstFrameSkipped;
  39554. private _yawRange;
  39555. private _fowardAxis;
  39556. /**
  39557. * Gets or sets the minimum yaw angle that the bone can look to
  39558. */
  39559. get minYaw(): number;
  39560. set minYaw(value: number);
  39561. /**
  39562. * Gets or sets the maximum yaw angle that the bone can look to
  39563. */
  39564. get maxYaw(): number;
  39565. set maxYaw(value: number);
  39566. /**
  39567. * Gets or sets the minimum pitch angle that the bone can look to
  39568. */
  39569. get minPitch(): number;
  39570. set minPitch(value: number);
  39571. /**
  39572. * Gets or sets the maximum pitch angle that the bone can look to
  39573. */
  39574. get maxPitch(): number;
  39575. set maxPitch(value: number);
  39576. /**
  39577. * Create a BoneLookController
  39578. * @param mesh the mesh that the bone belongs to
  39579. * @param bone the bone that will be looking to the target
  39580. * @param target the target Vector3 to look at
  39581. * @param options optional settings:
  39582. * * maxYaw: the maximum angle the bone will yaw to
  39583. * * minYaw: the minimum angle the bone will yaw to
  39584. * * maxPitch: the maximum angle the bone will pitch to
  39585. * * minPitch: the minimum angle the bone will yaw to
  39586. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39587. * * upAxis: the up axis of the coordinate system
  39588. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39589. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39590. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39591. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39592. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39593. * * adjustRoll: used to make an adjustment to the roll of the bone
  39594. **/
  39595. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39596. maxYaw?: number;
  39597. minYaw?: number;
  39598. maxPitch?: number;
  39599. minPitch?: number;
  39600. slerpAmount?: number;
  39601. upAxis?: Vector3;
  39602. upAxisSpace?: Space;
  39603. yawAxis?: Vector3;
  39604. pitchAxis?: Vector3;
  39605. adjustYaw?: number;
  39606. adjustPitch?: number;
  39607. adjustRoll?: number;
  39608. });
  39609. /**
  39610. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39611. */
  39612. update(): void;
  39613. private _getAngleDiff;
  39614. private _getAngleBetween;
  39615. private _isAngleBetween;
  39616. }
  39617. }
  39618. declare module BABYLON {
  39619. /**
  39620. * Manage the gamepad inputs to control an arc rotate camera.
  39621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39622. */
  39623. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39624. /**
  39625. * Defines the camera the input is attached to.
  39626. */
  39627. camera: ArcRotateCamera;
  39628. /**
  39629. * Defines the gamepad the input is gathering event from.
  39630. */
  39631. gamepad: Nullable<Gamepad>;
  39632. /**
  39633. * Defines the gamepad rotation sensiblity.
  39634. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39635. */
  39636. gamepadRotationSensibility: number;
  39637. /**
  39638. * Defines the gamepad move sensiblity.
  39639. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39640. */
  39641. gamepadMoveSensibility: number;
  39642. private _yAxisScale;
  39643. /**
  39644. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39645. */
  39646. get invertYAxis(): boolean;
  39647. set invertYAxis(value: boolean);
  39648. private _onGamepadConnectedObserver;
  39649. private _onGamepadDisconnectedObserver;
  39650. /**
  39651. * Attach the input controls to a specific dom element to get the input from.
  39652. * @param element Defines the element the controls should be listened from
  39653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39654. */
  39655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39656. /**
  39657. * Detach the current controls from the specified dom element.
  39658. * @param element Defines the element to stop listening the inputs from
  39659. */
  39660. detachControl(element: Nullable<HTMLElement>): void;
  39661. /**
  39662. * Update the current camera state depending on the inputs that have been used this frame.
  39663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39664. */
  39665. checkInputs(): void;
  39666. /**
  39667. * Gets the class name of the current intput.
  39668. * @returns the class name
  39669. */
  39670. getClassName(): string;
  39671. /**
  39672. * Get the friendly name associated with the input class.
  39673. * @returns the input friendly name
  39674. */
  39675. getSimpleName(): string;
  39676. }
  39677. }
  39678. declare module BABYLON {
  39679. interface ArcRotateCameraInputsManager {
  39680. /**
  39681. * Add orientation input support to the input manager.
  39682. * @returns the current input manager
  39683. */
  39684. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39685. }
  39686. /**
  39687. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39689. */
  39690. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39691. /**
  39692. * Defines the camera the input is attached to.
  39693. */
  39694. camera: ArcRotateCamera;
  39695. /**
  39696. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39697. */
  39698. alphaCorrection: number;
  39699. /**
  39700. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39701. */
  39702. gammaCorrection: number;
  39703. private _alpha;
  39704. private _gamma;
  39705. private _dirty;
  39706. private _deviceOrientationHandler;
  39707. /**
  39708. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39709. */
  39710. constructor();
  39711. /**
  39712. * Attach the input controls to a specific dom element to get the input from.
  39713. * @param element Defines the element the controls should be listened from
  39714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39715. */
  39716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39717. /** @hidden */
  39718. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39719. /**
  39720. * Update the current camera state depending on the inputs that have been used this frame.
  39721. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39722. */
  39723. checkInputs(): void;
  39724. /**
  39725. * Detach the current controls from the specified dom element.
  39726. * @param element Defines the element to stop listening the inputs from
  39727. */
  39728. detachControl(element: Nullable<HTMLElement>): void;
  39729. /**
  39730. * Gets the class name of the current intput.
  39731. * @returns the class name
  39732. */
  39733. getClassName(): string;
  39734. /**
  39735. * Get the friendly name associated with the input class.
  39736. * @returns the input friendly name
  39737. */
  39738. getSimpleName(): string;
  39739. }
  39740. }
  39741. declare module BABYLON {
  39742. /**
  39743. * Listen to mouse events to control the camera.
  39744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39745. */
  39746. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39747. /**
  39748. * Defines the camera the input is attached to.
  39749. */
  39750. camera: FlyCamera;
  39751. /**
  39752. * Defines if touch is enabled. (Default is true.)
  39753. */
  39754. touchEnabled: boolean;
  39755. /**
  39756. * Defines the buttons associated with the input to handle camera rotation.
  39757. */
  39758. buttons: number[];
  39759. /**
  39760. * Assign buttons for Yaw control.
  39761. */
  39762. buttonsYaw: number[];
  39763. /**
  39764. * Assign buttons for Pitch control.
  39765. */
  39766. buttonsPitch: number[];
  39767. /**
  39768. * Assign buttons for Roll control.
  39769. */
  39770. buttonsRoll: number[];
  39771. /**
  39772. * Detect if any button is being pressed while mouse is moved.
  39773. * -1 = Mouse locked.
  39774. * 0 = Left button.
  39775. * 1 = Middle Button.
  39776. * 2 = Right Button.
  39777. */
  39778. activeButton: number;
  39779. /**
  39780. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39781. * Higher values reduce its sensitivity.
  39782. */
  39783. angularSensibility: number;
  39784. private _mousemoveCallback;
  39785. private _observer;
  39786. private _rollObserver;
  39787. private previousPosition;
  39788. private noPreventDefault;
  39789. private element;
  39790. /**
  39791. * Listen to mouse events to control the camera.
  39792. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39794. */
  39795. constructor(touchEnabled?: boolean);
  39796. /**
  39797. * Attach the mouse control to the HTML DOM element.
  39798. * @param element Defines the element that listens to the input events.
  39799. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39800. */
  39801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39802. /**
  39803. * Detach the current controls from the specified dom element.
  39804. * @param element Defines the element to stop listening the inputs from
  39805. */
  39806. detachControl(element: Nullable<HTMLElement>): void;
  39807. /**
  39808. * Gets the class name of the current input.
  39809. * @returns the class name.
  39810. */
  39811. getClassName(): string;
  39812. /**
  39813. * Get the friendly name associated with the input class.
  39814. * @returns the input's friendly name.
  39815. */
  39816. getSimpleName(): string;
  39817. private _pointerInput;
  39818. private _onMouseMove;
  39819. /**
  39820. * Rotate camera by mouse offset.
  39821. */
  39822. private rotateCamera;
  39823. }
  39824. }
  39825. declare module BABYLON {
  39826. /**
  39827. * Default Inputs manager for the FlyCamera.
  39828. * It groups all the default supported inputs for ease of use.
  39829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39830. */
  39831. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39832. /**
  39833. * Instantiates a new FlyCameraInputsManager.
  39834. * @param camera Defines the camera the inputs belong to.
  39835. */
  39836. constructor(camera: FlyCamera);
  39837. /**
  39838. * Add keyboard input support to the input manager.
  39839. * @returns the new FlyCameraKeyboardMoveInput().
  39840. */
  39841. addKeyboard(): FlyCameraInputsManager;
  39842. /**
  39843. * Add mouse input support to the input manager.
  39844. * @param touchEnabled Enable touch screen support.
  39845. * @returns the new FlyCameraMouseInput().
  39846. */
  39847. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39848. }
  39849. }
  39850. declare module BABYLON {
  39851. /**
  39852. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39853. * such as in a 3D Space Shooter or a Flight Simulator.
  39854. */
  39855. export class FlyCamera extends TargetCamera {
  39856. /**
  39857. * Define the collision ellipsoid of the camera.
  39858. * This is helpful for simulating a camera body, like a player's body.
  39859. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39860. */
  39861. ellipsoid: Vector3;
  39862. /**
  39863. * Define an offset for the position of the ellipsoid around the camera.
  39864. * This can be helpful if the camera is attached away from the player's body center,
  39865. * such as at its head.
  39866. */
  39867. ellipsoidOffset: Vector3;
  39868. /**
  39869. * Enable or disable collisions of the camera with the rest of the scene objects.
  39870. */
  39871. checkCollisions: boolean;
  39872. /**
  39873. * Enable or disable gravity on the camera.
  39874. */
  39875. applyGravity: boolean;
  39876. /**
  39877. * Define the current direction the camera is moving to.
  39878. */
  39879. cameraDirection: Vector3;
  39880. /**
  39881. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39882. * This overrides and empties cameraRotation.
  39883. */
  39884. rotationQuaternion: Quaternion;
  39885. /**
  39886. * Track Roll to maintain the wanted Rolling when looking around.
  39887. */
  39888. _trackRoll: number;
  39889. /**
  39890. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39891. */
  39892. rollCorrect: number;
  39893. /**
  39894. * Mimic a banked turn, Rolling the camera when Yawing.
  39895. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39896. */
  39897. bankedTurn: boolean;
  39898. /**
  39899. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39900. */
  39901. bankedTurnLimit: number;
  39902. /**
  39903. * Value of 0 disables the banked Roll.
  39904. * Value of 1 is equal to the Yaw angle in radians.
  39905. */
  39906. bankedTurnMultiplier: number;
  39907. /**
  39908. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39909. */
  39910. inputs: FlyCameraInputsManager;
  39911. /**
  39912. * Gets the input sensibility for mouse input.
  39913. * Higher values reduce sensitivity.
  39914. */
  39915. get angularSensibility(): number;
  39916. /**
  39917. * Sets the input sensibility for a mouse input.
  39918. * Higher values reduce sensitivity.
  39919. */
  39920. set angularSensibility(value: number);
  39921. /**
  39922. * Get the keys for camera movement forward.
  39923. */
  39924. get keysForward(): number[];
  39925. /**
  39926. * Set the keys for camera movement forward.
  39927. */
  39928. set keysForward(value: number[]);
  39929. /**
  39930. * Get the keys for camera movement backward.
  39931. */
  39932. get keysBackward(): number[];
  39933. set keysBackward(value: number[]);
  39934. /**
  39935. * Get the keys for camera movement up.
  39936. */
  39937. get keysUp(): number[];
  39938. /**
  39939. * Set the keys for camera movement up.
  39940. */
  39941. set keysUp(value: number[]);
  39942. /**
  39943. * Get the keys for camera movement down.
  39944. */
  39945. get keysDown(): number[];
  39946. /**
  39947. * Set the keys for camera movement down.
  39948. */
  39949. set keysDown(value: number[]);
  39950. /**
  39951. * Get the keys for camera movement left.
  39952. */
  39953. get keysLeft(): number[];
  39954. /**
  39955. * Set the keys for camera movement left.
  39956. */
  39957. set keysLeft(value: number[]);
  39958. /**
  39959. * Set the keys for camera movement right.
  39960. */
  39961. get keysRight(): number[];
  39962. /**
  39963. * Set the keys for camera movement right.
  39964. */
  39965. set keysRight(value: number[]);
  39966. /**
  39967. * Event raised when the camera collides with a mesh in the scene.
  39968. */
  39969. onCollide: (collidedMesh: AbstractMesh) => void;
  39970. private _collider;
  39971. private _needMoveForGravity;
  39972. private _oldPosition;
  39973. private _diffPosition;
  39974. private _newPosition;
  39975. /** @hidden */
  39976. _localDirection: Vector3;
  39977. /** @hidden */
  39978. _transformedDirection: Vector3;
  39979. /**
  39980. * Instantiates a FlyCamera.
  39981. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39982. * such as in a 3D Space Shooter or a Flight Simulator.
  39983. * @param name Define the name of the camera in the scene.
  39984. * @param position Define the starting position of the camera in the scene.
  39985. * @param scene Define the scene the camera belongs to.
  39986. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39987. */
  39988. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39989. /**
  39990. * Attach a control to the HTML DOM element.
  39991. * @param element Defines the element that listens to the input events.
  39992. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39993. */
  39994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39995. /**
  39996. * Detach a control from the HTML DOM element.
  39997. * The camera will stop reacting to that input.
  39998. * @param element Defines the element that listens to the input events.
  39999. */
  40000. detachControl(element: HTMLElement): void;
  40001. private _collisionMask;
  40002. /**
  40003. * Get the mask that the camera ignores in collision events.
  40004. */
  40005. get collisionMask(): number;
  40006. /**
  40007. * Set the mask that the camera ignores in collision events.
  40008. */
  40009. set collisionMask(mask: number);
  40010. /** @hidden */
  40011. _collideWithWorld(displacement: Vector3): void;
  40012. /** @hidden */
  40013. private _onCollisionPositionChange;
  40014. /** @hidden */
  40015. _checkInputs(): void;
  40016. /** @hidden */
  40017. _decideIfNeedsToMove(): boolean;
  40018. /** @hidden */
  40019. _updatePosition(): void;
  40020. /**
  40021. * Restore the Roll to its target value at the rate specified.
  40022. * @param rate - Higher means slower restoring.
  40023. * @hidden
  40024. */
  40025. restoreRoll(rate: number): void;
  40026. /**
  40027. * Destroy the camera and release the current resources held by it.
  40028. */
  40029. dispose(): void;
  40030. /**
  40031. * Get the current object class name.
  40032. * @returns the class name.
  40033. */
  40034. getClassName(): string;
  40035. }
  40036. }
  40037. declare module BABYLON {
  40038. /**
  40039. * Listen to keyboard events to control the camera.
  40040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40041. */
  40042. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40043. /**
  40044. * Defines the camera the input is attached to.
  40045. */
  40046. camera: FlyCamera;
  40047. /**
  40048. * The list of keyboard keys used to control the forward move of the camera.
  40049. */
  40050. keysForward: number[];
  40051. /**
  40052. * The list of keyboard keys used to control the backward move of the camera.
  40053. */
  40054. keysBackward: number[];
  40055. /**
  40056. * The list of keyboard keys used to control the forward move of the camera.
  40057. */
  40058. keysUp: number[];
  40059. /**
  40060. * The list of keyboard keys used to control the backward move of the camera.
  40061. */
  40062. keysDown: number[];
  40063. /**
  40064. * The list of keyboard keys used to control the right strafe move of the camera.
  40065. */
  40066. keysRight: number[];
  40067. /**
  40068. * The list of keyboard keys used to control the left strafe move of the camera.
  40069. */
  40070. keysLeft: number[];
  40071. private _keys;
  40072. private _onCanvasBlurObserver;
  40073. private _onKeyboardObserver;
  40074. private _engine;
  40075. private _scene;
  40076. /**
  40077. * Attach the input controls to a specific dom element to get the input from.
  40078. * @param element Defines the element the controls should be listened from
  40079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40080. */
  40081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40082. /**
  40083. * Detach the current controls from the specified dom element.
  40084. * @param element Defines the element to stop listening the inputs from
  40085. */
  40086. detachControl(element: Nullable<HTMLElement>): void;
  40087. /**
  40088. * Gets the class name of the current intput.
  40089. * @returns the class name
  40090. */
  40091. getClassName(): string;
  40092. /** @hidden */
  40093. _onLostFocus(e: FocusEvent): void;
  40094. /**
  40095. * Get the friendly name associated with the input class.
  40096. * @returns the input friendly name
  40097. */
  40098. getSimpleName(): string;
  40099. /**
  40100. * Update the current camera state depending on the inputs that have been used this frame.
  40101. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40102. */
  40103. checkInputs(): void;
  40104. }
  40105. }
  40106. declare module BABYLON {
  40107. /**
  40108. * Manage the mouse wheel inputs to control a follow camera.
  40109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40110. */
  40111. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40112. /**
  40113. * Defines the camera the input is attached to.
  40114. */
  40115. camera: FollowCamera;
  40116. /**
  40117. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40118. */
  40119. axisControlRadius: boolean;
  40120. /**
  40121. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40122. */
  40123. axisControlHeight: boolean;
  40124. /**
  40125. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40126. */
  40127. axisControlRotation: boolean;
  40128. /**
  40129. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40130. * relation to mouseWheel events.
  40131. */
  40132. wheelPrecision: number;
  40133. /**
  40134. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40135. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40136. */
  40137. wheelDeltaPercentage: number;
  40138. private _wheel;
  40139. private _observer;
  40140. /**
  40141. * Attach the input controls to a specific dom element to get the input from.
  40142. * @param element Defines the element the controls should be listened from
  40143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40144. */
  40145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40146. /**
  40147. * Detach the current controls from the specified dom element.
  40148. * @param element Defines the element to stop listening the inputs from
  40149. */
  40150. detachControl(element: Nullable<HTMLElement>): void;
  40151. /**
  40152. * Gets the class name of the current intput.
  40153. * @returns the class name
  40154. */
  40155. getClassName(): string;
  40156. /**
  40157. * Get the friendly name associated with the input class.
  40158. * @returns the input friendly name
  40159. */
  40160. getSimpleName(): string;
  40161. }
  40162. }
  40163. declare module BABYLON {
  40164. /**
  40165. * Manage the pointers inputs to control an follow camera.
  40166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40167. */
  40168. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40169. /**
  40170. * Defines the camera the input is attached to.
  40171. */
  40172. camera: FollowCamera;
  40173. /**
  40174. * Gets the class name of the current input.
  40175. * @returns the class name
  40176. */
  40177. getClassName(): string;
  40178. /**
  40179. * Defines the pointer angular sensibility along the X axis or how fast is
  40180. * the camera rotating.
  40181. * A negative number will reverse the axis direction.
  40182. */
  40183. angularSensibilityX: number;
  40184. /**
  40185. * Defines the pointer angular sensibility along the Y axis or how fast is
  40186. * the camera rotating.
  40187. * A negative number will reverse the axis direction.
  40188. */
  40189. angularSensibilityY: number;
  40190. /**
  40191. * Defines the pointer pinch precision or how fast is the camera zooming.
  40192. * A negative number will reverse the axis direction.
  40193. */
  40194. pinchPrecision: number;
  40195. /**
  40196. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40197. * from 0.
  40198. * It defines the percentage of current camera.radius to use as delta when
  40199. * pinch zoom is used.
  40200. */
  40201. pinchDeltaPercentage: number;
  40202. /**
  40203. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40204. */
  40205. axisXControlRadius: boolean;
  40206. /**
  40207. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40208. */
  40209. axisXControlHeight: boolean;
  40210. /**
  40211. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40212. */
  40213. axisXControlRotation: boolean;
  40214. /**
  40215. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40216. */
  40217. axisYControlRadius: boolean;
  40218. /**
  40219. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40220. */
  40221. axisYControlHeight: boolean;
  40222. /**
  40223. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40224. */
  40225. axisYControlRotation: boolean;
  40226. /**
  40227. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40228. */
  40229. axisPinchControlRadius: boolean;
  40230. /**
  40231. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40232. */
  40233. axisPinchControlHeight: boolean;
  40234. /**
  40235. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40236. */
  40237. axisPinchControlRotation: boolean;
  40238. /**
  40239. * Log error messages if basic misconfiguration has occurred.
  40240. */
  40241. warningEnable: boolean;
  40242. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40243. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40244. private _warningCounter;
  40245. private _warning;
  40246. }
  40247. }
  40248. declare module BABYLON {
  40249. /**
  40250. * Default Inputs manager for the FollowCamera.
  40251. * It groups all the default supported inputs for ease of use.
  40252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40253. */
  40254. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40255. /**
  40256. * Instantiates a new FollowCameraInputsManager.
  40257. * @param camera Defines the camera the inputs belong to
  40258. */
  40259. constructor(camera: FollowCamera);
  40260. /**
  40261. * Add keyboard input support to the input manager.
  40262. * @returns the current input manager
  40263. */
  40264. addKeyboard(): FollowCameraInputsManager;
  40265. /**
  40266. * Add mouse wheel input support to the input manager.
  40267. * @returns the current input manager
  40268. */
  40269. addMouseWheel(): FollowCameraInputsManager;
  40270. /**
  40271. * Add pointers input support to the input manager.
  40272. * @returns the current input manager
  40273. */
  40274. addPointers(): FollowCameraInputsManager;
  40275. /**
  40276. * Add orientation input support to the input manager.
  40277. * @returns the current input manager
  40278. */
  40279. addVRDeviceOrientation(): FollowCameraInputsManager;
  40280. }
  40281. }
  40282. declare module BABYLON {
  40283. /**
  40284. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40285. * an arc rotate version arcFollowCamera are available.
  40286. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40287. */
  40288. export class FollowCamera extends TargetCamera {
  40289. /**
  40290. * Distance the follow camera should follow an object at
  40291. */
  40292. radius: number;
  40293. /**
  40294. * Minimum allowed distance of the camera to the axis of rotation
  40295. * (The camera can not get closer).
  40296. * This can help limiting how the Camera is able to move in the scene.
  40297. */
  40298. lowerRadiusLimit: Nullable<number>;
  40299. /**
  40300. * Maximum allowed distance of the camera to the axis of rotation
  40301. * (The camera can not get further).
  40302. * This can help limiting how the Camera is able to move in the scene.
  40303. */
  40304. upperRadiusLimit: Nullable<number>;
  40305. /**
  40306. * Define a rotation offset between the camera and the object it follows
  40307. */
  40308. rotationOffset: number;
  40309. /**
  40310. * Minimum allowed angle to camera position relative to target object.
  40311. * This can help limiting how the Camera is able to move in the scene.
  40312. */
  40313. lowerRotationOffsetLimit: Nullable<number>;
  40314. /**
  40315. * Maximum allowed angle to camera position relative to target object.
  40316. * This can help limiting how the Camera is able to move in the scene.
  40317. */
  40318. upperRotationOffsetLimit: Nullable<number>;
  40319. /**
  40320. * Define a height offset between the camera and the object it follows.
  40321. * It can help following an object from the top (like a car chaing a plane)
  40322. */
  40323. heightOffset: number;
  40324. /**
  40325. * Minimum allowed height of camera position relative to target object.
  40326. * This can help limiting how the Camera is able to move in the scene.
  40327. */
  40328. lowerHeightOffsetLimit: Nullable<number>;
  40329. /**
  40330. * Maximum allowed height of camera position relative to target object.
  40331. * This can help limiting how the Camera is able to move in the scene.
  40332. */
  40333. upperHeightOffsetLimit: Nullable<number>;
  40334. /**
  40335. * Define how fast the camera can accelerate to follow it s target.
  40336. */
  40337. cameraAcceleration: number;
  40338. /**
  40339. * Define the speed limit of the camera following an object.
  40340. */
  40341. maxCameraSpeed: number;
  40342. /**
  40343. * Define the target of the camera.
  40344. */
  40345. lockedTarget: Nullable<AbstractMesh>;
  40346. /**
  40347. * Defines the input associated with the camera.
  40348. */
  40349. inputs: FollowCameraInputsManager;
  40350. /**
  40351. * Instantiates the follow camera.
  40352. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40353. * @param name Define the name of the camera in the scene
  40354. * @param position Define the position of the camera
  40355. * @param scene Define the scene the camera belong to
  40356. * @param lockedTarget Define the target of the camera
  40357. */
  40358. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40359. private _follow;
  40360. /**
  40361. * Attached controls to the current camera.
  40362. * @param element Defines the element the controls should be listened from
  40363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40364. */
  40365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40366. /**
  40367. * Detach the current controls from the camera.
  40368. * The camera will stop reacting to inputs.
  40369. * @param element Defines the element to stop listening the inputs from
  40370. */
  40371. detachControl(element: HTMLElement): void;
  40372. /** @hidden */
  40373. _checkInputs(): void;
  40374. private _checkLimits;
  40375. /**
  40376. * Gets the camera class name.
  40377. * @returns the class name
  40378. */
  40379. getClassName(): string;
  40380. }
  40381. /**
  40382. * Arc Rotate version of the follow camera.
  40383. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40384. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40385. */
  40386. export class ArcFollowCamera extends TargetCamera {
  40387. /** The longitudinal angle of the camera */
  40388. alpha: number;
  40389. /** The latitudinal angle of the camera */
  40390. beta: number;
  40391. /** The radius of the camera from its target */
  40392. radius: number;
  40393. /** Define the camera target (the messh it should follow) */
  40394. target: Nullable<AbstractMesh>;
  40395. private _cartesianCoordinates;
  40396. /**
  40397. * Instantiates a new ArcFollowCamera
  40398. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40399. * @param name Define the name of the camera
  40400. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40401. * @param beta Define the rotation angle of the camera around the elevation axis
  40402. * @param radius Define the radius of the camera from its target point
  40403. * @param target Define the target of the camera
  40404. * @param scene Define the scene the camera belongs to
  40405. */
  40406. constructor(name: string,
  40407. /** The longitudinal angle of the camera */
  40408. alpha: number,
  40409. /** The latitudinal angle of the camera */
  40410. beta: number,
  40411. /** The radius of the camera from its target */
  40412. radius: number,
  40413. /** Define the camera target (the messh it should follow) */
  40414. target: Nullable<AbstractMesh>, scene: Scene);
  40415. private _follow;
  40416. /** @hidden */
  40417. _checkInputs(): void;
  40418. /**
  40419. * Returns the class name of the object.
  40420. * It is mostly used internally for serialization purposes.
  40421. */
  40422. getClassName(): string;
  40423. }
  40424. }
  40425. declare module BABYLON {
  40426. /**
  40427. * Manage the keyboard inputs to control the movement of a follow camera.
  40428. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40429. */
  40430. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40431. /**
  40432. * Defines the camera the input is attached to.
  40433. */
  40434. camera: FollowCamera;
  40435. /**
  40436. * Defines the list of key codes associated with the up action (increase heightOffset)
  40437. */
  40438. keysHeightOffsetIncr: number[];
  40439. /**
  40440. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40441. */
  40442. keysHeightOffsetDecr: number[];
  40443. /**
  40444. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40445. */
  40446. keysHeightOffsetModifierAlt: boolean;
  40447. /**
  40448. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40449. */
  40450. keysHeightOffsetModifierCtrl: boolean;
  40451. /**
  40452. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40453. */
  40454. keysHeightOffsetModifierShift: boolean;
  40455. /**
  40456. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40457. */
  40458. keysRotationOffsetIncr: number[];
  40459. /**
  40460. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40461. */
  40462. keysRotationOffsetDecr: number[];
  40463. /**
  40464. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40465. */
  40466. keysRotationOffsetModifierAlt: boolean;
  40467. /**
  40468. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40469. */
  40470. keysRotationOffsetModifierCtrl: boolean;
  40471. /**
  40472. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40473. */
  40474. keysRotationOffsetModifierShift: boolean;
  40475. /**
  40476. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40477. */
  40478. keysRadiusIncr: number[];
  40479. /**
  40480. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40481. */
  40482. keysRadiusDecr: number[];
  40483. /**
  40484. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40485. */
  40486. keysRadiusModifierAlt: boolean;
  40487. /**
  40488. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40489. */
  40490. keysRadiusModifierCtrl: boolean;
  40491. /**
  40492. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40493. */
  40494. keysRadiusModifierShift: boolean;
  40495. /**
  40496. * Defines the rate of change of heightOffset.
  40497. */
  40498. heightSensibility: number;
  40499. /**
  40500. * Defines the rate of change of rotationOffset.
  40501. */
  40502. rotationSensibility: number;
  40503. /**
  40504. * Defines the rate of change of radius.
  40505. */
  40506. radiusSensibility: number;
  40507. private _keys;
  40508. private _ctrlPressed;
  40509. private _altPressed;
  40510. private _shiftPressed;
  40511. private _onCanvasBlurObserver;
  40512. private _onKeyboardObserver;
  40513. private _engine;
  40514. private _scene;
  40515. /**
  40516. * Attach the input controls to a specific dom element to get the input from.
  40517. * @param element Defines the element the controls should be listened from
  40518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40519. */
  40520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40521. /**
  40522. * Detach the current controls from the specified dom element.
  40523. * @param element Defines the element to stop listening the inputs from
  40524. */
  40525. detachControl(element: Nullable<HTMLElement>): void;
  40526. /**
  40527. * Update the current camera state depending on the inputs that have been used this frame.
  40528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40529. */
  40530. checkInputs(): void;
  40531. /**
  40532. * Gets the class name of the current input.
  40533. * @returns the class name
  40534. */
  40535. getClassName(): string;
  40536. /**
  40537. * Get the friendly name associated with the input class.
  40538. * @returns the input friendly name
  40539. */
  40540. getSimpleName(): string;
  40541. /**
  40542. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40543. * allow modification of the heightOffset value.
  40544. */
  40545. private _modifierHeightOffset;
  40546. /**
  40547. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40548. * allow modification of the rotationOffset value.
  40549. */
  40550. private _modifierRotationOffset;
  40551. /**
  40552. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40553. * allow modification of the radius value.
  40554. */
  40555. private _modifierRadius;
  40556. }
  40557. }
  40558. declare module BABYLON {
  40559. interface FreeCameraInputsManager {
  40560. /**
  40561. * @hidden
  40562. */
  40563. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40564. /**
  40565. * Add orientation input support to the input manager.
  40566. * @returns the current input manager
  40567. */
  40568. addDeviceOrientation(): FreeCameraInputsManager;
  40569. }
  40570. /**
  40571. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40572. * Screen rotation is taken into account.
  40573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40574. */
  40575. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40576. private _camera;
  40577. private _screenOrientationAngle;
  40578. private _constantTranform;
  40579. private _screenQuaternion;
  40580. private _alpha;
  40581. private _beta;
  40582. private _gamma;
  40583. /**
  40584. * Can be used to detect if a device orientation sensor is available on a device
  40585. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40586. * @returns a promise that will resolve on orientation change
  40587. */
  40588. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40589. /**
  40590. * @hidden
  40591. */
  40592. _onDeviceOrientationChangedObservable: Observable<void>;
  40593. /**
  40594. * Instantiates a new input
  40595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40596. */
  40597. constructor();
  40598. /**
  40599. * Define the camera controlled by the input.
  40600. */
  40601. get camera(): FreeCamera;
  40602. set camera(camera: FreeCamera);
  40603. /**
  40604. * Attach the input controls to a specific dom element to get the input from.
  40605. * @param element Defines the element the controls should be listened from
  40606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40607. */
  40608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40609. private _orientationChanged;
  40610. private _deviceOrientation;
  40611. /**
  40612. * Detach the current controls from the specified dom element.
  40613. * @param element Defines the element to stop listening the inputs from
  40614. */
  40615. detachControl(element: Nullable<HTMLElement>): void;
  40616. /**
  40617. * Update the current camera state depending on the inputs that have been used this frame.
  40618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40619. */
  40620. checkInputs(): void;
  40621. /**
  40622. * Gets the class name of the current intput.
  40623. * @returns the class name
  40624. */
  40625. getClassName(): string;
  40626. /**
  40627. * Get the friendly name associated with the input class.
  40628. * @returns the input friendly name
  40629. */
  40630. getSimpleName(): string;
  40631. }
  40632. }
  40633. declare module BABYLON {
  40634. /**
  40635. * Manage the gamepad inputs to control a free camera.
  40636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40637. */
  40638. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40639. /**
  40640. * Define the camera the input is attached to.
  40641. */
  40642. camera: FreeCamera;
  40643. /**
  40644. * Define the Gamepad controlling the input
  40645. */
  40646. gamepad: Nullable<Gamepad>;
  40647. /**
  40648. * Defines the gamepad rotation sensiblity.
  40649. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40650. */
  40651. gamepadAngularSensibility: number;
  40652. /**
  40653. * Defines the gamepad move sensiblity.
  40654. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40655. */
  40656. gamepadMoveSensibility: number;
  40657. private _yAxisScale;
  40658. /**
  40659. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40660. */
  40661. get invertYAxis(): boolean;
  40662. set invertYAxis(value: boolean);
  40663. private _onGamepadConnectedObserver;
  40664. private _onGamepadDisconnectedObserver;
  40665. private _cameraTransform;
  40666. private _deltaTransform;
  40667. private _vector3;
  40668. private _vector2;
  40669. /**
  40670. * Attach the input controls to a specific dom element to get the input from.
  40671. * @param element Defines the element the controls should be listened from
  40672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40673. */
  40674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40675. /**
  40676. * Detach the current controls from the specified dom element.
  40677. * @param element Defines the element to stop listening the inputs from
  40678. */
  40679. detachControl(element: Nullable<HTMLElement>): void;
  40680. /**
  40681. * Update the current camera state depending on the inputs that have been used this frame.
  40682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40683. */
  40684. checkInputs(): void;
  40685. /**
  40686. * Gets the class name of the current intput.
  40687. * @returns the class name
  40688. */
  40689. getClassName(): string;
  40690. /**
  40691. * Get the friendly name associated with the input class.
  40692. * @returns the input friendly name
  40693. */
  40694. getSimpleName(): string;
  40695. }
  40696. }
  40697. declare module BABYLON {
  40698. /**
  40699. * Defines the potential axis of a Joystick
  40700. */
  40701. export enum JoystickAxis {
  40702. /** X axis */
  40703. X = 0,
  40704. /** Y axis */
  40705. Y = 1,
  40706. /** Z axis */
  40707. Z = 2
  40708. }
  40709. /**
  40710. * Class used to define virtual joystick (used in touch mode)
  40711. */
  40712. export class VirtualJoystick {
  40713. /**
  40714. * Gets or sets a boolean indicating that left and right values must be inverted
  40715. */
  40716. reverseLeftRight: boolean;
  40717. /**
  40718. * Gets or sets a boolean indicating that up and down values must be inverted
  40719. */
  40720. reverseUpDown: boolean;
  40721. /**
  40722. * Gets the offset value for the position (ie. the change of the position value)
  40723. */
  40724. deltaPosition: Vector3;
  40725. /**
  40726. * Gets a boolean indicating if the virtual joystick was pressed
  40727. */
  40728. pressed: boolean;
  40729. /**
  40730. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40731. */
  40732. static Canvas: Nullable<HTMLCanvasElement>;
  40733. private static _globalJoystickIndex;
  40734. private static vjCanvasContext;
  40735. private static vjCanvasWidth;
  40736. private static vjCanvasHeight;
  40737. private static halfWidth;
  40738. private _action;
  40739. private _axisTargetedByLeftAndRight;
  40740. private _axisTargetedByUpAndDown;
  40741. private _joystickSensibility;
  40742. private _inversedSensibility;
  40743. private _joystickPointerID;
  40744. private _joystickColor;
  40745. private _joystickPointerPos;
  40746. private _joystickPreviousPointerPos;
  40747. private _joystickPointerStartPos;
  40748. private _deltaJoystickVector;
  40749. private _leftJoystick;
  40750. private _touches;
  40751. private _onPointerDownHandlerRef;
  40752. private _onPointerMoveHandlerRef;
  40753. private _onPointerUpHandlerRef;
  40754. private _onResize;
  40755. /**
  40756. * Creates a new virtual joystick
  40757. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40758. */
  40759. constructor(leftJoystick?: boolean);
  40760. /**
  40761. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40762. * @param newJoystickSensibility defines the new sensibility
  40763. */
  40764. setJoystickSensibility(newJoystickSensibility: number): void;
  40765. private _onPointerDown;
  40766. private _onPointerMove;
  40767. private _onPointerUp;
  40768. /**
  40769. * Change the color of the virtual joystick
  40770. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40771. */
  40772. setJoystickColor(newColor: string): void;
  40773. /**
  40774. * Defines a callback to call when the joystick is touched
  40775. * @param action defines the callback
  40776. */
  40777. setActionOnTouch(action: () => any): void;
  40778. /**
  40779. * Defines which axis you'd like to control for left & right
  40780. * @param axis defines the axis to use
  40781. */
  40782. setAxisForLeftRight(axis: JoystickAxis): void;
  40783. /**
  40784. * Defines which axis you'd like to control for up & down
  40785. * @param axis defines the axis to use
  40786. */
  40787. setAxisForUpDown(axis: JoystickAxis): void;
  40788. private _drawVirtualJoystick;
  40789. /**
  40790. * Release internal HTML canvas
  40791. */
  40792. releaseCanvas(): void;
  40793. }
  40794. }
  40795. declare module BABYLON {
  40796. interface FreeCameraInputsManager {
  40797. /**
  40798. * Add virtual joystick input support to the input manager.
  40799. * @returns the current input manager
  40800. */
  40801. addVirtualJoystick(): FreeCameraInputsManager;
  40802. }
  40803. /**
  40804. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40806. */
  40807. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40808. /**
  40809. * Defines the camera the input is attached to.
  40810. */
  40811. camera: FreeCamera;
  40812. private _leftjoystick;
  40813. private _rightjoystick;
  40814. /**
  40815. * Gets the left stick of the virtual joystick.
  40816. * @returns The virtual Joystick
  40817. */
  40818. getLeftJoystick(): VirtualJoystick;
  40819. /**
  40820. * Gets the right stick of the virtual joystick.
  40821. * @returns The virtual Joystick
  40822. */
  40823. getRightJoystick(): VirtualJoystick;
  40824. /**
  40825. * Update the current camera state depending on the inputs that have been used this frame.
  40826. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40827. */
  40828. checkInputs(): void;
  40829. /**
  40830. * Attach the input controls to a specific dom element to get the input from.
  40831. * @param element Defines the element the controls should be listened from
  40832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40833. */
  40834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40835. /**
  40836. * Detach the current controls from the specified dom element.
  40837. * @param element Defines the element to stop listening the inputs from
  40838. */
  40839. detachControl(element: Nullable<HTMLElement>): void;
  40840. /**
  40841. * Gets the class name of the current intput.
  40842. * @returns the class name
  40843. */
  40844. getClassName(): string;
  40845. /**
  40846. * Get the friendly name associated with the input class.
  40847. * @returns the input friendly name
  40848. */
  40849. getSimpleName(): string;
  40850. }
  40851. }
  40852. declare module BABYLON {
  40853. /**
  40854. * This represents a FPS type of camera controlled by touch.
  40855. * This is like a universal camera minus the Gamepad controls.
  40856. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40857. */
  40858. export class TouchCamera extends FreeCamera {
  40859. /**
  40860. * Defines the touch sensibility for rotation.
  40861. * The higher the faster.
  40862. */
  40863. get touchAngularSensibility(): number;
  40864. set touchAngularSensibility(value: number);
  40865. /**
  40866. * Defines the touch sensibility for move.
  40867. * The higher the faster.
  40868. */
  40869. get touchMoveSensibility(): number;
  40870. set touchMoveSensibility(value: number);
  40871. /**
  40872. * Instantiates a new touch camera.
  40873. * This represents a FPS type of camera controlled by touch.
  40874. * This is like a universal camera minus the Gamepad controls.
  40875. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40876. * @param name Define the name of the camera in the scene
  40877. * @param position Define the start position of the camera in the scene
  40878. * @param scene Define the scene the camera belongs to
  40879. */
  40880. constructor(name: string, position: Vector3, scene: Scene);
  40881. /**
  40882. * Gets the current object class name.
  40883. * @return the class name
  40884. */
  40885. getClassName(): string;
  40886. /** @hidden */
  40887. _setupInputs(): void;
  40888. }
  40889. }
  40890. declare module BABYLON {
  40891. /**
  40892. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40893. * being tilted forward or back and left or right.
  40894. */
  40895. export class DeviceOrientationCamera extends FreeCamera {
  40896. private _initialQuaternion;
  40897. private _quaternionCache;
  40898. private _tmpDragQuaternion;
  40899. private _disablePointerInputWhenUsingDeviceOrientation;
  40900. /**
  40901. * Creates a new device orientation camera
  40902. * @param name The name of the camera
  40903. * @param position The start position camera
  40904. * @param scene The scene the camera belongs to
  40905. */
  40906. constructor(name: string, position: Vector3, scene: Scene);
  40907. /**
  40908. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40909. */
  40910. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40911. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40912. private _dragFactor;
  40913. /**
  40914. * Enabled turning on the y axis when the orientation sensor is active
  40915. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40916. */
  40917. enableHorizontalDragging(dragFactor?: number): void;
  40918. /**
  40919. * Gets the current instance class name ("DeviceOrientationCamera").
  40920. * This helps avoiding instanceof at run time.
  40921. * @returns the class name
  40922. */
  40923. getClassName(): string;
  40924. /**
  40925. * @hidden
  40926. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40927. */
  40928. _checkInputs(): void;
  40929. /**
  40930. * Reset the camera to its default orientation on the specified axis only.
  40931. * @param axis The axis to reset
  40932. */
  40933. resetToCurrentRotation(axis?: Axis): void;
  40934. }
  40935. }
  40936. declare module BABYLON {
  40937. /**
  40938. * Defines supported buttons for XBox360 compatible gamepads
  40939. */
  40940. export enum Xbox360Button {
  40941. /** A */
  40942. A = 0,
  40943. /** B */
  40944. B = 1,
  40945. /** X */
  40946. X = 2,
  40947. /** Y */
  40948. Y = 3,
  40949. /** Left button */
  40950. LB = 4,
  40951. /** Right button */
  40952. RB = 5,
  40953. /** Back */
  40954. Back = 8,
  40955. /** Start */
  40956. Start = 9,
  40957. /** Left stick */
  40958. LeftStick = 10,
  40959. /** Right stick */
  40960. RightStick = 11
  40961. }
  40962. /** Defines values for XBox360 DPad */
  40963. export enum Xbox360Dpad {
  40964. /** Up */
  40965. Up = 12,
  40966. /** Down */
  40967. Down = 13,
  40968. /** Left */
  40969. Left = 14,
  40970. /** Right */
  40971. Right = 15
  40972. }
  40973. /**
  40974. * Defines a XBox360 gamepad
  40975. */
  40976. export class Xbox360Pad extends Gamepad {
  40977. private _leftTrigger;
  40978. private _rightTrigger;
  40979. private _onlefttriggerchanged;
  40980. private _onrighttriggerchanged;
  40981. private _onbuttondown;
  40982. private _onbuttonup;
  40983. private _ondpaddown;
  40984. private _ondpadup;
  40985. /** Observable raised when a button is pressed */
  40986. onButtonDownObservable: Observable<Xbox360Button>;
  40987. /** Observable raised when a button is released */
  40988. onButtonUpObservable: Observable<Xbox360Button>;
  40989. /** Observable raised when a pad is pressed */
  40990. onPadDownObservable: Observable<Xbox360Dpad>;
  40991. /** Observable raised when a pad is released */
  40992. onPadUpObservable: Observable<Xbox360Dpad>;
  40993. private _buttonA;
  40994. private _buttonB;
  40995. private _buttonX;
  40996. private _buttonY;
  40997. private _buttonBack;
  40998. private _buttonStart;
  40999. private _buttonLB;
  41000. private _buttonRB;
  41001. private _buttonLeftStick;
  41002. private _buttonRightStick;
  41003. private _dPadUp;
  41004. private _dPadDown;
  41005. private _dPadLeft;
  41006. private _dPadRight;
  41007. private _isXboxOnePad;
  41008. /**
  41009. * Creates a new XBox360 gamepad object
  41010. * @param id defines the id of this gamepad
  41011. * @param index defines its index
  41012. * @param gamepad defines the internal HTML gamepad object
  41013. * @param xboxOne defines if it is a XBox One gamepad
  41014. */
  41015. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41016. /**
  41017. * Defines the callback to call when left trigger is pressed
  41018. * @param callback defines the callback to use
  41019. */
  41020. onlefttriggerchanged(callback: (value: number) => void): void;
  41021. /**
  41022. * Defines the callback to call when right trigger is pressed
  41023. * @param callback defines the callback to use
  41024. */
  41025. onrighttriggerchanged(callback: (value: number) => void): void;
  41026. /**
  41027. * Gets the left trigger value
  41028. */
  41029. get leftTrigger(): number;
  41030. /**
  41031. * Sets the left trigger value
  41032. */
  41033. set leftTrigger(newValue: number);
  41034. /**
  41035. * Gets the right trigger value
  41036. */
  41037. get rightTrigger(): number;
  41038. /**
  41039. * Sets the right trigger value
  41040. */
  41041. set rightTrigger(newValue: number);
  41042. /**
  41043. * Defines the callback to call when a button is pressed
  41044. * @param callback defines the callback to use
  41045. */
  41046. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41047. /**
  41048. * Defines the callback to call when a button is released
  41049. * @param callback defines the callback to use
  41050. */
  41051. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41052. /**
  41053. * Defines the callback to call when a pad is pressed
  41054. * @param callback defines the callback to use
  41055. */
  41056. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41057. /**
  41058. * Defines the callback to call when a pad is released
  41059. * @param callback defines the callback to use
  41060. */
  41061. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41062. private _setButtonValue;
  41063. private _setDPadValue;
  41064. /**
  41065. * Gets the value of the `A` button
  41066. */
  41067. get buttonA(): number;
  41068. /**
  41069. * Sets the value of the `A` button
  41070. */
  41071. set buttonA(value: number);
  41072. /**
  41073. * Gets the value of the `B` button
  41074. */
  41075. get buttonB(): number;
  41076. /**
  41077. * Sets the value of the `B` button
  41078. */
  41079. set buttonB(value: number);
  41080. /**
  41081. * Gets the value of the `X` button
  41082. */
  41083. get buttonX(): number;
  41084. /**
  41085. * Sets the value of the `X` button
  41086. */
  41087. set buttonX(value: number);
  41088. /**
  41089. * Gets the value of the `Y` button
  41090. */
  41091. get buttonY(): number;
  41092. /**
  41093. * Sets the value of the `Y` button
  41094. */
  41095. set buttonY(value: number);
  41096. /**
  41097. * Gets the value of the `Start` button
  41098. */
  41099. get buttonStart(): number;
  41100. /**
  41101. * Sets the value of the `Start` button
  41102. */
  41103. set buttonStart(value: number);
  41104. /**
  41105. * Gets the value of the `Back` button
  41106. */
  41107. get buttonBack(): number;
  41108. /**
  41109. * Sets the value of the `Back` button
  41110. */
  41111. set buttonBack(value: number);
  41112. /**
  41113. * Gets the value of the `Left` button
  41114. */
  41115. get buttonLB(): number;
  41116. /**
  41117. * Sets the value of the `Left` button
  41118. */
  41119. set buttonLB(value: number);
  41120. /**
  41121. * Gets the value of the `Right` button
  41122. */
  41123. get buttonRB(): number;
  41124. /**
  41125. * Sets the value of the `Right` button
  41126. */
  41127. set buttonRB(value: number);
  41128. /**
  41129. * Gets the value of the Left joystick
  41130. */
  41131. get buttonLeftStick(): number;
  41132. /**
  41133. * Sets the value of the Left joystick
  41134. */
  41135. set buttonLeftStick(value: number);
  41136. /**
  41137. * Gets the value of the Right joystick
  41138. */
  41139. get buttonRightStick(): number;
  41140. /**
  41141. * Sets the value of the Right joystick
  41142. */
  41143. set buttonRightStick(value: number);
  41144. /**
  41145. * Gets the value of D-pad up
  41146. */
  41147. get dPadUp(): number;
  41148. /**
  41149. * Sets the value of D-pad up
  41150. */
  41151. set dPadUp(value: number);
  41152. /**
  41153. * Gets the value of D-pad down
  41154. */
  41155. get dPadDown(): number;
  41156. /**
  41157. * Sets the value of D-pad down
  41158. */
  41159. set dPadDown(value: number);
  41160. /**
  41161. * Gets the value of D-pad left
  41162. */
  41163. get dPadLeft(): number;
  41164. /**
  41165. * Sets the value of D-pad left
  41166. */
  41167. set dPadLeft(value: number);
  41168. /**
  41169. * Gets the value of D-pad right
  41170. */
  41171. get dPadRight(): number;
  41172. /**
  41173. * Sets the value of D-pad right
  41174. */
  41175. set dPadRight(value: number);
  41176. /**
  41177. * Force the gamepad to synchronize with device values
  41178. */
  41179. update(): void;
  41180. /**
  41181. * Disposes the gamepad
  41182. */
  41183. dispose(): void;
  41184. }
  41185. }
  41186. declare module BABYLON {
  41187. /**
  41188. * Defines supported buttons for DualShock compatible gamepads
  41189. */
  41190. export enum DualShockButton {
  41191. /** Cross */
  41192. Cross = 0,
  41193. /** Circle */
  41194. Circle = 1,
  41195. /** Square */
  41196. Square = 2,
  41197. /** Triangle */
  41198. Triangle = 3,
  41199. /** L1 */
  41200. L1 = 4,
  41201. /** R1 */
  41202. R1 = 5,
  41203. /** Share */
  41204. Share = 8,
  41205. /** Options */
  41206. Options = 9,
  41207. /** Left stick */
  41208. LeftStick = 10,
  41209. /** Right stick */
  41210. RightStick = 11
  41211. }
  41212. /** Defines values for DualShock DPad */
  41213. export enum DualShockDpad {
  41214. /** Up */
  41215. Up = 12,
  41216. /** Down */
  41217. Down = 13,
  41218. /** Left */
  41219. Left = 14,
  41220. /** Right */
  41221. Right = 15
  41222. }
  41223. /**
  41224. * Defines a DualShock gamepad
  41225. */
  41226. export class DualShockPad extends Gamepad {
  41227. private _leftTrigger;
  41228. private _rightTrigger;
  41229. private _onlefttriggerchanged;
  41230. private _onrighttriggerchanged;
  41231. private _onbuttondown;
  41232. private _onbuttonup;
  41233. private _ondpaddown;
  41234. private _ondpadup;
  41235. /** Observable raised when a button is pressed */
  41236. onButtonDownObservable: Observable<DualShockButton>;
  41237. /** Observable raised when a button is released */
  41238. onButtonUpObservable: Observable<DualShockButton>;
  41239. /** Observable raised when a pad is pressed */
  41240. onPadDownObservable: Observable<DualShockDpad>;
  41241. /** Observable raised when a pad is released */
  41242. onPadUpObservable: Observable<DualShockDpad>;
  41243. private _buttonCross;
  41244. private _buttonCircle;
  41245. private _buttonSquare;
  41246. private _buttonTriangle;
  41247. private _buttonShare;
  41248. private _buttonOptions;
  41249. private _buttonL1;
  41250. private _buttonR1;
  41251. private _buttonLeftStick;
  41252. private _buttonRightStick;
  41253. private _dPadUp;
  41254. private _dPadDown;
  41255. private _dPadLeft;
  41256. private _dPadRight;
  41257. /**
  41258. * Creates a new DualShock gamepad object
  41259. * @param id defines the id of this gamepad
  41260. * @param index defines its index
  41261. * @param gamepad defines the internal HTML gamepad object
  41262. */
  41263. constructor(id: string, index: number, gamepad: any);
  41264. /**
  41265. * Defines the callback to call when left trigger is pressed
  41266. * @param callback defines the callback to use
  41267. */
  41268. onlefttriggerchanged(callback: (value: number) => void): void;
  41269. /**
  41270. * Defines the callback to call when right trigger is pressed
  41271. * @param callback defines the callback to use
  41272. */
  41273. onrighttriggerchanged(callback: (value: number) => void): void;
  41274. /**
  41275. * Gets the left trigger value
  41276. */
  41277. get leftTrigger(): number;
  41278. /**
  41279. * Sets the left trigger value
  41280. */
  41281. set leftTrigger(newValue: number);
  41282. /**
  41283. * Gets the right trigger value
  41284. */
  41285. get rightTrigger(): number;
  41286. /**
  41287. * Sets the right trigger value
  41288. */
  41289. set rightTrigger(newValue: number);
  41290. /**
  41291. * Defines the callback to call when a button is pressed
  41292. * @param callback defines the callback to use
  41293. */
  41294. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41295. /**
  41296. * Defines the callback to call when a button is released
  41297. * @param callback defines the callback to use
  41298. */
  41299. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41300. /**
  41301. * Defines the callback to call when a pad is pressed
  41302. * @param callback defines the callback to use
  41303. */
  41304. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41305. /**
  41306. * Defines the callback to call when a pad is released
  41307. * @param callback defines the callback to use
  41308. */
  41309. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41310. private _setButtonValue;
  41311. private _setDPadValue;
  41312. /**
  41313. * Gets the value of the `Cross` button
  41314. */
  41315. get buttonCross(): number;
  41316. /**
  41317. * Sets the value of the `Cross` button
  41318. */
  41319. set buttonCross(value: number);
  41320. /**
  41321. * Gets the value of the `Circle` button
  41322. */
  41323. get buttonCircle(): number;
  41324. /**
  41325. * Sets the value of the `Circle` button
  41326. */
  41327. set buttonCircle(value: number);
  41328. /**
  41329. * Gets the value of the `Square` button
  41330. */
  41331. get buttonSquare(): number;
  41332. /**
  41333. * Sets the value of the `Square` button
  41334. */
  41335. set buttonSquare(value: number);
  41336. /**
  41337. * Gets the value of the `Triangle` button
  41338. */
  41339. get buttonTriangle(): number;
  41340. /**
  41341. * Sets the value of the `Triangle` button
  41342. */
  41343. set buttonTriangle(value: number);
  41344. /**
  41345. * Gets the value of the `Options` button
  41346. */
  41347. get buttonOptions(): number;
  41348. /**
  41349. * Sets the value of the `Options` button
  41350. */
  41351. set buttonOptions(value: number);
  41352. /**
  41353. * Gets the value of the `Share` button
  41354. */
  41355. get buttonShare(): number;
  41356. /**
  41357. * Sets the value of the `Share` button
  41358. */
  41359. set buttonShare(value: number);
  41360. /**
  41361. * Gets the value of the `L1` button
  41362. */
  41363. get buttonL1(): number;
  41364. /**
  41365. * Sets the value of the `L1` button
  41366. */
  41367. set buttonL1(value: number);
  41368. /**
  41369. * Gets the value of the `R1` button
  41370. */
  41371. get buttonR1(): number;
  41372. /**
  41373. * Sets the value of the `R1` button
  41374. */
  41375. set buttonR1(value: number);
  41376. /**
  41377. * Gets the value of the Left joystick
  41378. */
  41379. get buttonLeftStick(): number;
  41380. /**
  41381. * Sets the value of the Left joystick
  41382. */
  41383. set buttonLeftStick(value: number);
  41384. /**
  41385. * Gets the value of the Right joystick
  41386. */
  41387. get buttonRightStick(): number;
  41388. /**
  41389. * Sets the value of the Right joystick
  41390. */
  41391. set buttonRightStick(value: number);
  41392. /**
  41393. * Gets the value of D-pad up
  41394. */
  41395. get dPadUp(): number;
  41396. /**
  41397. * Sets the value of D-pad up
  41398. */
  41399. set dPadUp(value: number);
  41400. /**
  41401. * Gets the value of D-pad down
  41402. */
  41403. get dPadDown(): number;
  41404. /**
  41405. * Sets the value of D-pad down
  41406. */
  41407. set dPadDown(value: number);
  41408. /**
  41409. * Gets the value of D-pad left
  41410. */
  41411. get dPadLeft(): number;
  41412. /**
  41413. * Sets the value of D-pad left
  41414. */
  41415. set dPadLeft(value: number);
  41416. /**
  41417. * Gets the value of D-pad right
  41418. */
  41419. get dPadRight(): number;
  41420. /**
  41421. * Sets the value of D-pad right
  41422. */
  41423. set dPadRight(value: number);
  41424. /**
  41425. * Force the gamepad to synchronize with device values
  41426. */
  41427. update(): void;
  41428. /**
  41429. * Disposes the gamepad
  41430. */
  41431. dispose(): void;
  41432. }
  41433. }
  41434. declare module BABYLON {
  41435. /**
  41436. * Manager for handling gamepads
  41437. */
  41438. export class GamepadManager {
  41439. private _scene?;
  41440. private _babylonGamepads;
  41441. private _oneGamepadConnected;
  41442. /** @hidden */
  41443. _isMonitoring: boolean;
  41444. private _gamepadEventSupported;
  41445. private _gamepadSupport?;
  41446. /**
  41447. * observable to be triggered when the gamepad controller has been connected
  41448. */
  41449. onGamepadConnectedObservable: Observable<Gamepad>;
  41450. /**
  41451. * observable to be triggered when the gamepad controller has been disconnected
  41452. */
  41453. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41454. private _onGamepadConnectedEvent;
  41455. private _onGamepadDisconnectedEvent;
  41456. /**
  41457. * Initializes the gamepad manager
  41458. * @param _scene BabylonJS scene
  41459. */
  41460. constructor(_scene?: Scene | undefined);
  41461. /**
  41462. * The gamepads in the game pad manager
  41463. */
  41464. get gamepads(): Gamepad[];
  41465. /**
  41466. * Get the gamepad controllers based on type
  41467. * @param type The type of gamepad controller
  41468. * @returns Nullable gamepad
  41469. */
  41470. getGamepadByType(type?: number): Nullable<Gamepad>;
  41471. /**
  41472. * Disposes the gamepad manager
  41473. */
  41474. dispose(): void;
  41475. private _addNewGamepad;
  41476. private _startMonitoringGamepads;
  41477. private _stopMonitoringGamepads;
  41478. /** @hidden */
  41479. _checkGamepadsStatus(): void;
  41480. private _updateGamepadObjects;
  41481. }
  41482. }
  41483. declare module BABYLON {
  41484. interface Scene {
  41485. /** @hidden */
  41486. _gamepadManager: Nullable<GamepadManager>;
  41487. /**
  41488. * Gets the gamepad manager associated with the scene
  41489. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41490. */
  41491. gamepadManager: GamepadManager;
  41492. }
  41493. /**
  41494. * Interface representing a free camera inputs manager
  41495. */
  41496. interface FreeCameraInputsManager {
  41497. /**
  41498. * Adds gamepad input support to the FreeCameraInputsManager.
  41499. * @returns the FreeCameraInputsManager
  41500. */
  41501. addGamepad(): FreeCameraInputsManager;
  41502. }
  41503. /**
  41504. * Interface representing an arc rotate camera inputs manager
  41505. */
  41506. interface ArcRotateCameraInputsManager {
  41507. /**
  41508. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41509. * @returns the camera inputs manager
  41510. */
  41511. addGamepad(): ArcRotateCameraInputsManager;
  41512. }
  41513. /**
  41514. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41515. */
  41516. export class GamepadSystemSceneComponent implements ISceneComponent {
  41517. /**
  41518. * The component name helpfull to identify the component in the list of scene components.
  41519. */
  41520. readonly name: string;
  41521. /**
  41522. * The scene the component belongs to.
  41523. */
  41524. scene: Scene;
  41525. /**
  41526. * Creates a new instance of the component for the given scene
  41527. * @param scene Defines the scene to register the component in
  41528. */
  41529. constructor(scene: Scene);
  41530. /**
  41531. * Registers the component in a given scene
  41532. */
  41533. register(): void;
  41534. /**
  41535. * Rebuilds the elements related to this component in case of
  41536. * context lost for instance.
  41537. */
  41538. rebuild(): void;
  41539. /**
  41540. * Disposes the component and the associated ressources
  41541. */
  41542. dispose(): void;
  41543. private _beforeCameraUpdate;
  41544. }
  41545. }
  41546. declare module BABYLON {
  41547. /**
  41548. * 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,
  41549. * which still works and will still be found in many Playgrounds.
  41550. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41551. */
  41552. export class UniversalCamera extends TouchCamera {
  41553. /**
  41554. * Defines the gamepad rotation sensiblity.
  41555. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41556. */
  41557. get gamepadAngularSensibility(): number;
  41558. set gamepadAngularSensibility(value: number);
  41559. /**
  41560. * Defines the gamepad move sensiblity.
  41561. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41562. */
  41563. get gamepadMoveSensibility(): number;
  41564. set gamepadMoveSensibility(value: number);
  41565. /**
  41566. * 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,
  41567. * which still works and will still be found in many Playgrounds.
  41568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41569. * @param name Define the name of the camera in the scene
  41570. * @param position Define the start position of the camera in the scene
  41571. * @param scene Define the scene the camera belongs to
  41572. */
  41573. constructor(name: string, position: Vector3, scene: Scene);
  41574. /**
  41575. * Gets the current object class name.
  41576. * @return the class name
  41577. */
  41578. getClassName(): string;
  41579. }
  41580. }
  41581. declare module BABYLON {
  41582. /**
  41583. * This represents a FPS type of camera. This is only here for back compat purpose.
  41584. * Please use the UniversalCamera instead as both are identical.
  41585. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41586. */
  41587. export class GamepadCamera extends UniversalCamera {
  41588. /**
  41589. * Instantiates a new Gamepad Camera
  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. * @param name Define the name of the camera in the scene
  41594. * @param position Define the start position of the camera in the scene
  41595. * @param scene Define the scene the camera belongs to
  41596. */
  41597. constructor(name: string, position: Vector3, scene: Scene);
  41598. /**
  41599. * Gets the current object class name.
  41600. * @return the class name
  41601. */
  41602. getClassName(): string;
  41603. }
  41604. }
  41605. declare module BABYLON {
  41606. /** @hidden */
  41607. export var passPixelShader: {
  41608. name: string;
  41609. shader: string;
  41610. };
  41611. }
  41612. declare module BABYLON {
  41613. /** @hidden */
  41614. export var passCubePixelShader: {
  41615. name: string;
  41616. shader: string;
  41617. };
  41618. }
  41619. declare module BABYLON {
  41620. /**
  41621. * PassPostProcess which produces an output the same as it's input
  41622. */
  41623. export class PassPostProcess extends PostProcess {
  41624. /**
  41625. * Creates the PassPostProcess
  41626. * @param name The name of the effect.
  41627. * @param options The required width/height ratio to downsize to before computing the render pass.
  41628. * @param camera The camera to apply the render pass to.
  41629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41630. * @param engine The engine which the post process will be applied. (default: current engine)
  41631. * @param reusable If the post process can be reused on the same frame. (default: false)
  41632. * @param textureType The type of texture to be used when performing the post processing.
  41633. * @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)
  41634. */
  41635. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41636. }
  41637. /**
  41638. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41639. */
  41640. export class PassCubePostProcess extends PostProcess {
  41641. private _face;
  41642. /**
  41643. * Gets or sets the cube face to display.
  41644. * * 0 is +X
  41645. * * 1 is -X
  41646. * * 2 is +Y
  41647. * * 3 is -Y
  41648. * * 4 is +Z
  41649. * * 5 is -Z
  41650. */
  41651. get face(): number;
  41652. set face(value: number);
  41653. /**
  41654. * Creates the PassCubePostProcess
  41655. * @param name The name of the effect.
  41656. * @param options The required width/height ratio to downsize to before computing the render pass.
  41657. * @param camera The camera to apply the render pass to.
  41658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41659. * @param engine The engine which the post process will be applied. (default: current engine)
  41660. * @param reusable If the post process can be reused on the same frame. (default: false)
  41661. * @param textureType The type of texture to be used when performing the post processing.
  41662. * @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)
  41663. */
  41664. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41665. }
  41666. }
  41667. declare module BABYLON {
  41668. /** @hidden */
  41669. export var anaglyphPixelShader: {
  41670. name: string;
  41671. shader: string;
  41672. };
  41673. }
  41674. declare module BABYLON {
  41675. /**
  41676. * Postprocess used to generate anaglyphic rendering
  41677. */
  41678. export class AnaglyphPostProcess extends PostProcess {
  41679. private _passedProcess;
  41680. /**
  41681. * Creates a new AnaglyphPostProcess
  41682. * @param name defines postprocess name
  41683. * @param options defines creation options or target ratio scale
  41684. * @param rigCameras defines cameras using this postprocess
  41685. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41686. * @param engine defines hosting engine
  41687. * @param reusable defines if the postprocess will be reused multiple times per frame
  41688. */
  41689. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41690. }
  41691. }
  41692. declare module BABYLON {
  41693. /**
  41694. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41695. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41696. */
  41697. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41698. /**
  41699. * Creates a new AnaglyphArcRotateCamera
  41700. * @param name defines camera name
  41701. * @param alpha defines alpha angle (in radians)
  41702. * @param beta defines beta angle (in radians)
  41703. * @param radius defines radius
  41704. * @param target defines camera target
  41705. * @param interaxialDistance defines distance between each color axis
  41706. * @param scene defines the hosting scene
  41707. */
  41708. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41709. /**
  41710. * Gets camera class name
  41711. * @returns AnaglyphArcRotateCamera
  41712. */
  41713. getClassName(): string;
  41714. }
  41715. }
  41716. declare module BABYLON {
  41717. /**
  41718. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41719. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41720. */
  41721. export class AnaglyphFreeCamera extends FreeCamera {
  41722. /**
  41723. * Creates a new AnaglyphFreeCamera
  41724. * @param name defines camera name
  41725. * @param position defines initial position
  41726. * @param interaxialDistance defines distance between each color axis
  41727. * @param scene defines the hosting scene
  41728. */
  41729. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41730. /**
  41731. * Gets camera class name
  41732. * @returns AnaglyphFreeCamera
  41733. */
  41734. getClassName(): string;
  41735. }
  41736. }
  41737. declare module BABYLON {
  41738. /**
  41739. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41740. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41741. */
  41742. export class AnaglyphGamepadCamera extends GamepadCamera {
  41743. /**
  41744. * Creates a new AnaglyphGamepadCamera
  41745. * @param name defines camera name
  41746. * @param position defines initial position
  41747. * @param interaxialDistance defines distance between each color axis
  41748. * @param scene defines the hosting scene
  41749. */
  41750. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41751. /**
  41752. * Gets camera class name
  41753. * @returns AnaglyphGamepadCamera
  41754. */
  41755. getClassName(): string;
  41756. }
  41757. }
  41758. declare module BABYLON {
  41759. /**
  41760. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41761. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41762. */
  41763. export class AnaglyphUniversalCamera extends UniversalCamera {
  41764. /**
  41765. * Creates a new AnaglyphUniversalCamera
  41766. * @param name defines camera name
  41767. * @param position defines initial position
  41768. * @param interaxialDistance defines distance between each color axis
  41769. * @param scene defines the hosting scene
  41770. */
  41771. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41772. /**
  41773. * Gets camera class name
  41774. * @returns AnaglyphUniversalCamera
  41775. */
  41776. getClassName(): string;
  41777. }
  41778. }
  41779. declare module BABYLON {
  41780. /** @hidden */
  41781. export var stereoscopicInterlacePixelShader: {
  41782. name: string;
  41783. shader: string;
  41784. };
  41785. }
  41786. declare module BABYLON {
  41787. /**
  41788. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41789. */
  41790. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41791. private _stepSize;
  41792. private _passedProcess;
  41793. /**
  41794. * Initializes a StereoscopicInterlacePostProcessI
  41795. * @param name The name of the effect.
  41796. * @param rigCameras The rig cameras to be appled to the post process
  41797. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41798. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41800. * @param engine The engine which the post process will be applied. (default: current engine)
  41801. * @param reusable If the post process can be reused on the same frame. (default: false)
  41802. */
  41803. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41804. }
  41805. /**
  41806. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41807. */
  41808. export class StereoscopicInterlacePostProcess extends PostProcess {
  41809. private _stepSize;
  41810. private _passedProcess;
  41811. /**
  41812. * Initializes a StereoscopicInterlacePostProcess
  41813. * @param name The name of the effect.
  41814. * @param rigCameras The rig cameras to be appled to the post process
  41815. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41817. * @param engine The engine which the post process will be applied. (default: current engine)
  41818. * @param reusable If the post process can be reused on the same frame. (default: false)
  41819. */
  41820. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41821. }
  41822. }
  41823. declare module BABYLON {
  41824. /**
  41825. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41826. * @see http://doc.babylonjs.com/features/cameras
  41827. */
  41828. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41829. /**
  41830. * Creates a new StereoscopicArcRotateCamera
  41831. * @param name defines camera name
  41832. * @param alpha defines alpha angle (in radians)
  41833. * @param beta defines beta angle (in radians)
  41834. * @param radius defines radius
  41835. * @param target defines camera target
  41836. * @param interaxialDistance defines distance between each color axis
  41837. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41838. * @param scene defines the hosting scene
  41839. */
  41840. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41841. /**
  41842. * Gets camera class name
  41843. * @returns StereoscopicArcRotateCamera
  41844. */
  41845. getClassName(): string;
  41846. }
  41847. }
  41848. declare module BABYLON {
  41849. /**
  41850. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41851. * @see http://doc.babylonjs.com/features/cameras
  41852. */
  41853. export class StereoscopicFreeCamera extends FreeCamera {
  41854. /**
  41855. * Creates a new StereoscopicFreeCamera
  41856. * @param name defines camera name
  41857. * @param position defines initial position
  41858. * @param interaxialDistance defines distance between each color axis
  41859. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41860. * @param scene defines the hosting scene
  41861. */
  41862. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41863. /**
  41864. * Gets camera class name
  41865. * @returns StereoscopicFreeCamera
  41866. */
  41867. getClassName(): string;
  41868. }
  41869. }
  41870. declare module BABYLON {
  41871. /**
  41872. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41873. * @see http://doc.babylonjs.com/features/cameras
  41874. */
  41875. export class StereoscopicGamepadCamera extends GamepadCamera {
  41876. /**
  41877. * Creates a new StereoscopicGamepadCamera
  41878. * @param name defines camera name
  41879. * @param position defines initial position
  41880. * @param interaxialDistance defines distance between each color axis
  41881. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41882. * @param scene defines the hosting scene
  41883. */
  41884. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41885. /**
  41886. * Gets camera class name
  41887. * @returns StereoscopicGamepadCamera
  41888. */
  41889. getClassName(): string;
  41890. }
  41891. }
  41892. declare module BABYLON {
  41893. /**
  41894. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41895. * @see http://doc.babylonjs.com/features/cameras
  41896. */
  41897. export class StereoscopicUniversalCamera extends UniversalCamera {
  41898. /**
  41899. * Creates a new StereoscopicUniversalCamera
  41900. * @param name defines camera name
  41901. * @param position defines initial position
  41902. * @param interaxialDistance defines distance between each color axis
  41903. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41904. * @param scene defines the hosting scene
  41905. */
  41906. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41907. /**
  41908. * Gets camera class name
  41909. * @returns StereoscopicUniversalCamera
  41910. */
  41911. getClassName(): string;
  41912. }
  41913. }
  41914. declare module BABYLON {
  41915. /**
  41916. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41917. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41918. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41919. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41920. */
  41921. export class VirtualJoysticksCamera extends FreeCamera {
  41922. /**
  41923. * Intantiates a VirtualJoysticksCamera. 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. * @param name Define the name of the camera in the scene
  41928. * @param position Define the start position of the camera in the scene
  41929. * @param scene Define the scene the camera belongs to
  41930. */
  41931. constructor(name: string, position: Vector3, scene: Scene);
  41932. /**
  41933. * Gets the current object class name.
  41934. * @return the class name
  41935. */
  41936. getClassName(): string;
  41937. }
  41938. }
  41939. declare module BABYLON {
  41940. /**
  41941. * This represents all the required metrics to create a VR camera.
  41942. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41943. */
  41944. export class VRCameraMetrics {
  41945. /**
  41946. * Define the horizontal resolution off the screen.
  41947. */
  41948. hResolution: number;
  41949. /**
  41950. * Define the vertical resolution off the screen.
  41951. */
  41952. vResolution: number;
  41953. /**
  41954. * Define the horizontal screen size.
  41955. */
  41956. hScreenSize: number;
  41957. /**
  41958. * Define the vertical screen size.
  41959. */
  41960. vScreenSize: number;
  41961. /**
  41962. * Define the vertical screen center position.
  41963. */
  41964. vScreenCenter: number;
  41965. /**
  41966. * Define the distance of the eyes to the screen.
  41967. */
  41968. eyeToScreenDistance: number;
  41969. /**
  41970. * Define the distance between both lenses
  41971. */
  41972. lensSeparationDistance: number;
  41973. /**
  41974. * Define the distance between both viewer's eyes.
  41975. */
  41976. interpupillaryDistance: number;
  41977. /**
  41978. * Define the distortion factor of the VR postprocess.
  41979. * Please, touch with care.
  41980. */
  41981. distortionK: number[];
  41982. /**
  41983. * Define the chromatic aberration correction factors for the VR post process.
  41984. */
  41985. chromaAbCorrection: number[];
  41986. /**
  41987. * Define the scale factor of the post process.
  41988. * The smaller the better but the slower.
  41989. */
  41990. postProcessScaleFactor: number;
  41991. /**
  41992. * Define an offset for the lens center.
  41993. */
  41994. lensCenterOffset: number;
  41995. /**
  41996. * Define if the current vr camera should compensate the distortion of the lense or not.
  41997. */
  41998. compensateDistortion: boolean;
  41999. /**
  42000. * Defines if multiview should be enabled when rendering (Default: false)
  42001. */
  42002. multiviewEnabled: boolean;
  42003. /**
  42004. * Gets the rendering aspect ratio based on the provided resolutions.
  42005. */
  42006. get aspectRatio(): number;
  42007. /**
  42008. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42009. */
  42010. get aspectRatioFov(): number;
  42011. /**
  42012. * @hidden
  42013. */
  42014. get leftHMatrix(): Matrix;
  42015. /**
  42016. * @hidden
  42017. */
  42018. get rightHMatrix(): Matrix;
  42019. /**
  42020. * @hidden
  42021. */
  42022. get leftPreViewMatrix(): Matrix;
  42023. /**
  42024. * @hidden
  42025. */
  42026. get rightPreViewMatrix(): Matrix;
  42027. /**
  42028. * Get the default VRMetrics based on the most generic setup.
  42029. * @returns the default vr metrics
  42030. */
  42031. static GetDefault(): VRCameraMetrics;
  42032. }
  42033. }
  42034. declare module BABYLON {
  42035. /** @hidden */
  42036. export var vrDistortionCorrectionPixelShader: {
  42037. name: string;
  42038. shader: string;
  42039. };
  42040. }
  42041. declare module BABYLON {
  42042. /**
  42043. * VRDistortionCorrectionPostProcess used for mobile VR
  42044. */
  42045. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42046. private _isRightEye;
  42047. private _distortionFactors;
  42048. private _postProcessScaleFactor;
  42049. private _lensCenterOffset;
  42050. private _scaleIn;
  42051. private _scaleFactor;
  42052. private _lensCenter;
  42053. /**
  42054. * Initializes the VRDistortionCorrectionPostProcess
  42055. * @param name The name of the effect.
  42056. * @param camera The camera to apply the render pass to.
  42057. * @param isRightEye If this is for the right eye distortion
  42058. * @param vrMetrics All the required metrics for the VR camera
  42059. */
  42060. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42061. }
  42062. }
  42063. declare module BABYLON {
  42064. /**
  42065. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42066. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42067. */
  42068. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42069. /**
  42070. * Creates a new VRDeviceOrientationArcRotateCamera
  42071. * @param name defines camera name
  42072. * @param alpha defines the camera rotation along the logitudinal axis
  42073. * @param beta defines the camera rotation along the latitudinal axis
  42074. * @param radius defines the camera distance from its target
  42075. * @param target defines the camera target
  42076. * @param scene defines the scene the camera belongs to
  42077. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42078. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42079. */
  42080. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42081. /**
  42082. * Gets camera class name
  42083. * @returns VRDeviceOrientationArcRotateCamera
  42084. */
  42085. getClassName(): string;
  42086. }
  42087. }
  42088. declare module BABYLON {
  42089. /**
  42090. * Camera used to simulate VR rendering (based on FreeCamera)
  42091. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42092. */
  42093. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42094. /**
  42095. * Creates a new VRDeviceOrientationFreeCamera
  42096. * @param name defines camera name
  42097. * @param position defines the start position of the camera
  42098. * @param scene defines the scene the camera belongs to
  42099. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42100. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42101. */
  42102. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42103. /**
  42104. * Gets camera class name
  42105. * @returns VRDeviceOrientationFreeCamera
  42106. */
  42107. getClassName(): string;
  42108. }
  42109. }
  42110. declare module BABYLON {
  42111. /**
  42112. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42113. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42114. */
  42115. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42116. /**
  42117. * Creates a new VRDeviceOrientationGamepadCamera
  42118. * @param name defines camera name
  42119. * @param position defines the start position of the camera
  42120. * @param scene defines the scene the camera belongs to
  42121. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42122. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42123. */
  42124. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42125. /**
  42126. * Gets camera class name
  42127. * @returns VRDeviceOrientationGamepadCamera
  42128. */
  42129. getClassName(): string;
  42130. }
  42131. }
  42132. declare module BABYLON {
  42133. /** @hidden */
  42134. export var imageProcessingPixelShader: {
  42135. name: string;
  42136. shader: string;
  42137. };
  42138. }
  42139. declare module BABYLON {
  42140. /**
  42141. * ImageProcessingPostProcess
  42142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42143. */
  42144. export class ImageProcessingPostProcess extends PostProcess {
  42145. /**
  42146. * Default configuration related to image processing available in the PBR Material.
  42147. */
  42148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42149. /**
  42150. * Gets the image processing configuration used either in this material.
  42151. */
  42152. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42153. /**
  42154. * Sets the Default image processing configuration used either in the this material.
  42155. *
  42156. * If sets to null, the scene one is in use.
  42157. */
  42158. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42159. /**
  42160. * Keep track of the image processing observer to allow dispose and replace.
  42161. */
  42162. private _imageProcessingObserver;
  42163. /**
  42164. * Attaches a new image processing configuration to the PBR Material.
  42165. * @param configuration
  42166. */
  42167. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42168. /**
  42169. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42170. */
  42171. get colorCurves(): Nullable<ColorCurves>;
  42172. /**
  42173. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42174. */
  42175. set colorCurves(value: Nullable<ColorCurves>);
  42176. /**
  42177. * Gets wether the color curves effect is enabled.
  42178. */
  42179. get colorCurvesEnabled(): boolean;
  42180. /**
  42181. * Sets wether the color curves effect is enabled.
  42182. */
  42183. set colorCurvesEnabled(value: boolean);
  42184. /**
  42185. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42186. */
  42187. get colorGradingTexture(): Nullable<BaseTexture>;
  42188. /**
  42189. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42190. */
  42191. set colorGradingTexture(value: Nullable<BaseTexture>);
  42192. /**
  42193. * Gets wether the color grading effect is enabled.
  42194. */
  42195. get colorGradingEnabled(): boolean;
  42196. /**
  42197. * Gets wether the color grading effect is enabled.
  42198. */
  42199. set colorGradingEnabled(value: boolean);
  42200. /**
  42201. * Gets exposure used in the effect.
  42202. */
  42203. get exposure(): number;
  42204. /**
  42205. * Sets exposure used in the effect.
  42206. */
  42207. set exposure(value: number);
  42208. /**
  42209. * Gets wether tonemapping is enabled or not.
  42210. */
  42211. get toneMappingEnabled(): boolean;
  42212. /**
  42213. * Sets wether tonemapping is enabled or not
  42214. */
  42215. set toneMappingEnabled(value: boolean);
  42216. /**
  42217. * Gets the type of tone mapping effect.
  42218. */
  42219. get toneMappingType(): number;
  42220. /**
  42221. * Sets the type of tone mapping effect.
  42222. */
  42223. set toneMappingType(value: number);
  42224. /**
  42225. * Gets contrast used in the effect.
  42226. */
  42227. get contrast(): number;
  42228. /**
  42229. * Sets contrast used in the effect.
  42230. */
  42231. set contrast(value: number);
  42232. /**
  42233. * Gets Vignette stretch size.
  42234. */
  42235. get vignetteStretch(): number;
  42236. /**
  42237. * Sets Vignette stretch size.
  42238. */
  42239. set vignetteStretch(value: number);
  42240. /**
  42241. * Gets Vignette centre X Offset.
  42242. */
  42243. get vignetteCentreX(): number;
  42244. /**
  42245. * Sets Vignette centre X Offset.
  42246. */
  42247. set vignetteCentreX(value: number);
  42248. /**
  42249. * Gets Vignette centre Y Offset.
  42250. */
  42251. get vignetteCentreY(): number;
  42252. /**
  42253. * Sets Vignette centre Y Offset.
  42254. */
  42255. set vignetteCentreY(value: number);
  42256. /**
  42257. * Gets Vignette weight or intensity of the vignette effect.
  42258. */
  42259. get vignetteWeight(): number;
  42260. /**
  42261. * Sets Vignette weight or intensity of the vignette effect.
  42262. */
  42263. set vignetteWeight(value: number);
  42264. /**
  42265. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42266. * if vignetteEnabled is set to true.
  42267. */
  42268. get vignetteColor(): Color4;
  42269. /**
  42270. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42271. * if vignetteEnabled is set to true.
  42272. */
  42273. set vignetteColor(value: Color4);
  42274. /**
  42275. * Gets Camera field of view used by the Vignette effect.
  42276. */
  42277. get vignetteCameraFov(): number;
  42278. /**
  42279. * Sets Camera field of view used by the Vignette effect.
  42280. */
  42281. set vignetteCameraFov(value: number);
  42282. /**
  42283. * Gets the vignette blend mode allowing different kind of effect.
  42284. */
  42285. get vignetteBlendMode(): number;
  42286. /**
  42287. * Sets the vignette blend mode allowing different kind of effect.
  42288. */
  42289. set vignetteBlendMode(value: number);
  42290. /**
  42291. * Gets wether the vignette effect is enabled.
  42292. */
  42293. get vignetteEnabled(): boolean;
  42294. /**
  42295. * Sets wether the vignette effect is enabled.
  42296. */
  42297. set vignetteEnabled(value: boolean);
  42298. private _fromLinearSpace;
  42299. /**
  42300. * Gets wether the input of the processing is in Gamma or Linear Space.
  42301. */
  42302. get fromLinearSpace(): boolean;
  42303. /**
  42304. * Sets wether the input of the processing is in Gamma or Linear Space.
  42305. */
  42306. set fromLinearSpace(value: boolean);
  42307. /**
  42308. * Defines cache preventing GC.
  42309. */
  42310. private _defines;
  42311. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42312. /**
  42313. * "ImageProcessingPostProcess"
  42314. * @returns "ImageProcessingPostProcess"
  42315. */
  42316. getClassName(): string;
  42317. protected _updateParameters(): void;
  42318. dispose(camera?: Camera): void;
  42319. }
  42320. }
  42321. declare module BABYLON {
  42322. /**
  42323. * Class containing static functions to help procedurally build meshes
  42324. */
  42325. export class GroundBuilder {
  42326. /**
  42327. * Creates a ground mesh
  42328. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42329. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42331. * @param name defines the name of the mesh
  42332. * @param options defines the options used to create the mesh
  42333. * @param scene defines the hosting scene
  42334. * @returns the ground mesh
  42335. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42336. */
  42337. static CreateGround(name: string, options: {
  42338. width?: number;
  42339. height?: number;
  42340. subdivisions?: number;
  42341. subdivisionsX?: number;
  42342. subdivisionsY?: number;
  42343. updatable?: boolean;
  42344. }, scene: any): Mesh;
  42345. /**
  42346. * Creates a tiled ground mesh
  42347. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42348. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42349. * * 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
  42350. * * 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
  42351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42352. * @param name defines the name of the mesh
  42353. * @param options defines the options used to create the mesh
  42354. * @param scene defines the hosting scene
  42355. * @returns the tiled ground mesh
  42356. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42357. */
  42358. static CreateTiledGround(name: string, options: {
  42359. xmin: number;
  42360. zmin: number;
  42361. xmax: number;
  42362. zmax: number;
  42363. subdivisions?: {
  42364. w: number;
  42365. h: number;
  42366. };
  42367. precision?: {
  42368. w: number;
  42369. h: number;
  42370. };
  42371. updatable?: boolean;
  42372. }, scene?: Nullable<Scene>): Mesh;
  42373. /**
  42374. * Creates a ground mesh from a height map
  42375. * * The parameter `url` sets the URL of the height map image resource.
  42376. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42377. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42378. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42379. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42380. * * 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.
  42381. * * 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).
  42382. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42384. * @param name defines the name of the mesh
  42385. * @param url defines the url to the height map
  42386. * @param options defines the options used to create the mesh
  42387. * @param scene defines the hosting scene
  42388. * @returns the ground mesh
  42389. * @see https://doc.babylonjs.com/babylon101/height_map
  42390. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42391. */
  42392. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42393. width?: number;
  42394. height?: number;
  42395. subdivisions?: number;
  42396. minHeight?: number;
  42397. maxHeight?: number;
  42398. colorFilter?: Color3;
  42399. alphaFilter?: number;
  42400. updatable?: boolean;
  42401. onReady?: (mesh: GroundMesh) => void;
  42402. }, scene?: Nullable<Scene>): GroundMesh;
  42403. }
  42404. }
  42405. declare module BABYLON {
  42406. /**
  42407. * Class containing static functions to help procedurally build meshes
  42408. */
  42409. export class TorusBuilder {
  42410. /**
  42411. * Creates a torus mesh
  42412. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42413. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42414. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42416. * * 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
  42417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42418. * @param name defines the name of the mesh
  42419. * @param options defines the options used to create the mesh
  42420. * @param scene defines the hosting scene
  42421. * @returns the torus mesh
  42422. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42423. */
  42424. static CreateTorus(name: string, options: {
  42425. diameter?: number;
  42426. thickness?: number;
  42427. tessellation?: number;
  42428. updatable?: boolean;
  42429. sideOrientation?: number;
  42430. frontUVs?: Vector4;
  42431. backUVs?: Vector4;
  42432. }, scene: any): Mesh;
  42433. }
  42434. }
  42435. declare module BABYLON {
  42436. /**
  42437. * Class containing static functions to help procedurally build meshes
  42438. */
  42439. export class CylinderBuilder {
  42440. /**
  42441. * Creates a cylinder or a cone mesh
  42442. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42443. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42444. * * 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.
  42445. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42446. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42447. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42448. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42449. * * 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).
  42450. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42451. * * 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).
  42452. * * 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
  42453. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42454. * * 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
  42455. * * 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.
  42456. * * If `enclose` is false, a ring surface is one element.
  42457. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42458. * * 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
  42459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42460. * * 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
  42461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42462. * @param name defines the name of the mesh
  42463. * @param options defines the options used to create the mesh
  42464. * @param scene defines the hosting scene
  42465. * @returns the cylinder mesh
  42466. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42467. */
  42468. static CreateCylinder(name: string, options: {
  42469. height?: number;
  42470. diameterTop?: number;
  42471. diameterBottom?: number;
  42472. diameter?: number;
  42473. tessellation?: number;
  42474. subdivisions?: number;
  42475. arc?: number;
  42476. faceColors?: Color4[];
  42477. faceUV?: Vector4[];
  42478. updatable?: boolean;
  42479. hasRings?: boolean;
  42480. enclose?: boolean;
  42481. cap?: number;
  42482. sideOrientation?: number;
  42483. frontUVs?: Vector4;
  42484. backUVs?: Vector4;
  42485. }, scene: any): Mesh;
  42486. }
  42487. }
  42488. declare module BABYLON {
  42489. /**
  42490. * States of the webXR experience
  42491. */
  42492. export enum WebXRState {
  42493. /**
  42494. * Transitioning to being in XR mode
  42495. */
  42496. ENTERING_XR = 0,
  42497. /**
  42498. * Transitioning to non XR mode
  42499. */
  42500. EXITING_XR = 1,
  42501. /**
  42502. * In XR mode and presenting
  42503. */
  42504. IN_XR = 2,
  42505. /**
  42506. * Not entered XR mode
  42507. */
  42508. NOT_IN_XR = 3
  42509. }
  42510. /**
  42511. * Abstraction of the XR render target
  42512. */
  42513. export interface WebXRRenderTarget extends IDisposable {
  42514. /**
  42515. * xrpresent context of the canvas which can be used to display/mirror xr content
  42516. */
  42517. canvasContext: WebGLRenderingContext;
  42518. /**
  42519. * xr layer for the canvas
  42520. */
  42521. xrLayer: Nullable<XRWebGLLayer>;
  42522. /**
  42523. * Initializes the xr layer for the session
  42524. * @param xrSession xr session
  42525. * @returns a promise that will resolve once the XR Layer has been created
  42526. */
  42527. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42528. }
  42529. }
  42530. declare module BABYLON {
  42531. /**
  42532. * COnfiguration object for WebXR output canvas
  42533. */
  42534. export class WebXRManagedOutputCanvasOptions {
  42535. /**
  42536. * An optional canvas in case you wish to create it yourself and provide it here.
  42537. * If not provided, a new canvas will be created
  42538. */
  42539. canvasElement?: HTMLCanvasElement;
  42540. /**
  42541. * Options for this XR Layer output
  42542. */
  42543. canvasOptions?: XRWebGLLayerOptions;
  42544. /**
  42545. * CSS styling for a newly created canvas (if not provided)
  42546. */
  42547. newCanvasCssStyle?: string;
  42548. /**
  42549. * Get the default values of the configuration object
  42550. * @returns default values of this configuration object
  42551. */
  42552. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42553. }
  42554. /**
  42555. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42556. */
  42557. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42558. private _options;
  42559. private _canvas;
  42560. private _engine;
  42561. /**
  42562. * Rendering context of the canvas which can be used to display/mirror xr content
  42563. */
  42564. canvasContext: WebGLRenderingContext;
  42565. /**
  42566. * xr layer for the canvas
  42567. */
  42568. xrLayer: Nullable<XRWebGLLayer>;
  42569. /**
  42570. * Initializes the canvas to be added/removed upon entering/exiting xr
  42571. * @param _xrSessionManager The XR Session manager
  42572. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42573. */
  42574. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42575. /**
  42576. * Disposes of the object
  42577. */
  42578. dispose(): void;
  42579. /**
  42580. * Initializes the xr layer for the session
  42581. * @param xrSession xr session
  42582. * @returns a promise that will resolve once the XR Layer has been created
  42583. */
  42584. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42585. private _addCanvas;
  42586. private _removeCanvas;
  42587. private _setManagedOutputCanvas;
  42588. }
  42589. }
  42590. declare module BABYLON {
  42591. /**
  42592. * Manages an XRSession to work with Babylon's engine
  42593. * @see https://doc.babylonjs.com/how_to/webxr
  42594. */
  42595. export class WebXRSessionManager implements IDisposable {
  42596. /** The scene which the session should be created for */
  42597. scene: Scene;
  42598. private _referenceSpace;
  42599. private _rttProvider;
  42600. private _sessionEnded;
  42601. private _xrNavigator;
  42602. private baseLayer;
  42603. /**
  42604. * The base reference space from which the session started. good if you want to reset your
  42605. * reference space
  42606. */
  42607. baseReferenceSpace: XRReferenceSpace;
  42608. /**
  42609. * Current XR frame
  42610. */
  42611. currentFrame: Nullable<XRFrame>;
  42612. /** WebXR timestamp updated every frame */
  42613. currentTimestamp: number;
  42614. /**
  42615. * Used just in case of a failure to initialize an immersive session.
  42616. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42617. */
  42618. defaultHeightCompensation: number;
  42619. /**
  42620. * Fires every time a new xrFrame arrives which can be used to update the camera
  42621. */
  42622. onXRFrameObservable: Observable<XRFrame>;
  42623. /**
  42624. * Fires when the reference space changed
  42625. */
  42626. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42627. /**
  42628. * Fires when the xr session is ended either by the device or manually done
  42629. */
  42630. onXRSessionEnded: Observable<any>;
  42631. /**
  42632. * Fires when the xr session is ended either by the device or manually done
  42633. */
  42634. onXRSessionInit: Observable<XRSession>;
  42635. /**
  42636. * Underlying xr session
  42637. */
  42638. session: XRSession;
  42639. /**
  42640. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42641. * or get the offset the player is currently at.
  42642. */
  42643. viewerReferenceSpace: XRReferenceSpace;
  42644. /**
  42645. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42646. * @param scene The scene which the session should be created for
  42647. */
  42648. constructor(
  42649. /** The scene which the session should be created for */
  42650. scene: Scene);
  42651. /**
  42652. * The current reference space used in this session. This reference space can constantly change!
  42653. * It is mainly used to offset the camera's position.
  42654. */
  42655. get referenceSpace(): XRReferenceSpace;
  42656. /**
  42657. * Set a new reference space and triggers the observable
  42658. */
  42659. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42660. /**
  42661. * Disposes of the session manager
  42662. */
  42663. dispose(): void;
  42664. /**
  42665. * Stops the xrSession and restores the render loop
  42666. * @returns Promise which resolves after it exits XR
  42667. */
  42668. exitXRAsync(): Promise<void>;
  42669. /**
  42670. * Gets the correct render target texture to be rendered this frame for this eye
  42671. * @param eye the eye for which to get the render target
  42672. * @returns the render target for the specified eye
  42673. */
  42674. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42675. /**
  42676. * Creates a WebXRRenderTarget object for the XR session
  42677. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42678. * @param options optional options to provide when creating a new render target
  42679. * @returns a WebXR render target to which the session can render
  42680. */
  42681. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42682. /**
  42683. * Initializes the manager
  42684. * After initialization enterXR can be called to start an XR session
  42685. * @returns Promise which resolves after it is initialized
  42686. */
  42687. initializeAsync(): Promise<void>;
  42688. /**
  42689. * Initializes an xr session
  42690. * @param xrSessionMode mode to initialize
  42691. * @param xrSessionInit defines optional and required values to pass to the session builder
  42692. * @returns a promise which will resolve once the session has been initialized
  42693. */
  42694. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42695. /**
  42696. * Checks if a session would be supported for the creation options specified
  42697. * @param sessionMode session mode to check if supported eg. immersive-vr
  42698. * @returns A Promise that resolves to true if supported and false if not
  42699. */
  42700. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42701. /**
  42702. * Resets the reference space to the one started the session
  42703. */
  42704. resetReferenceSpace(): void;
  42705. /**
  42706. * Starts rendering to the xr layer
  42707. */
  42708. runXRRenderLoop(): void;
  42709. /**
  42710. * Sets the reference space on the xr session
  42711. * @param referenceSpaceType space to set
  42712. * @returns a promise that will resolve once the reference space has been set
  42713. */
  42714. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42715. /**
  42716. * Updates the render state of the session
  42717. * @param state state to set
  42718. * @returns a promise that resolves once the render state has been updated
  42719. */
  42720. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42721. /**
  42722. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42723. * @param sessionMode defines the session to test
  42724. * @returns a promise with boolean as final value
  42725. */
  42726. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42727. private _createRenderTargetTexture;
  42728. }
  42729. }
  42730. declare module BABYLON {
  42731. /**
  42732. * WebXR Camera which holds the views for the xrSession
  42733. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42734. */
  42735. export class WebXRCamera extends FreeCamera {
  42736. private _xrSessionManager;
  42737. private _firstFrame;
  42738. private _referenceQuaternion;
  42739. private _referencedPosition;
  42740. private _xrInvPositionCache;
  42741. private _xrInvQuaternionCache;
  42742. /**
  42743. * Should position compensation execute on first frame.
  42744. * This is used when copying the position from a native (non XR) camera
  42745. */
  42746. compensateOnFirstFrame: boolean;
  42747. /**
  42748. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42749. * @param name the name of the camera
  42750. * @param scene the scene to add the camera to
  42751. * @param _xrSessionManager a constructed xr session manager
  42752. */
  42753. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42754. /**
  42755. * Return the user's height, unrelated to the current ground.
  42756. * This will be the y position of this camera, when ground level is 0.
  42757. */
  42758. get realWorldHeight(): number;
  42759. /** @hidden */
  42760. _updateForDualEyeDebugging(): void;
  42761. /**
  42762. * Sets this camera's transformation based on a non-vr camera
  42763. * @param otherCamera the non-vr camera to copy the transformation from
  42764. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42765. */
  42766. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42767. /**
  42768. * Gets the current instance class name ("WebXRCamera").
  42769. * @returns the class name
  42770. */
  42771. getClassName(): string;
  42772. private _updateFromXRSession;
  42773. private _updateNumberOfRigCameras;
  42774. private _updateReferenceSpace;
  42775. private _updateReferenceSpaceOffset;
  42776. }
  42777. }
  42778. declare module BABYLON {
  42779. /**
  42780. * Defining the interface required for a (webxr) feature
  42781. */
  42782. export interface IWebXRFeature extends IDisposable {
  42783. /**
  42784. * Is this feature attached
  42785. */
  42786. attached: boolean;
  42787. /**
  42788. * Should auto-attach be disabled?
  42789. */
  42790. disableAutoAttach: boolean;
  42791. /**
  42792. * Attach the feature to the session
  42793. * Will usually be called by the features manager
  42794. *
  42795. * @param force should attachment be forced (even when already attached)
  42796. * @returns true if successful.
  42797. */
  42798. attach(force?: boolean): boolean;
  42799. /**
  42800. * Detach the feature from the session
  42801. * Will usually be called by the features manager
  42802. *
  42803. * @returns true if successful.
  42804. */
  42805. detach(): boolean;
  42806. }
  42807. /**
  42808. * A list of the currently available features without referencing them
  42809. */
  42810. export class WebXRFeatureName {
  42811. /**
  42812. * The name of the anchor system feature
  42813. */
  42814. static ANCHOR_SYSTEM: string;
  42815. /**
  42816. * The name of the background remover feature
  42817. */
  42818. static BACKGROUND_REMOVER: string;
  42819. /**
  42820. * The name of the hit test feature
  42821. */
  42822. static HIT_TEST: string;
  42823. /**
  42824. * physics impostors for xr controllers feature
  42825. */
  42826. static PHYSICS_CONTROLLERS: string;
  42827. /**
  42828. * The name of the plane detection feature
  42829. */
  42830. static PLANE_DETECTION: string;
  42831. /**
  42832. * The name of the pointer selection feature
  42833. */
  42834. static POINTER_SELECTION: string;
  42835. /**
  42836. * The name of the teleportation feature
  42837. */
  42838. static TELEPORTATION: string;
  42839. }
  42840. /**
  42841. * Defining the constructor of a feature. Used to register the modules.
  42842. */
  42843. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42844. /**
  42845. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42846. * It is mainly used in AR sessions.
  42847. *
  42848. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42849. */
  42850. export class WebXRFeaturesManager implements IDisposable {
  42851. private _xrSessionManager;
  42852. private static readonly _AvailableFeatures;
  42853. private _features;
  42854. /**
  42855. * constructs a new features manages.
  42856. *
  42857. * @param _xrSessionManager an instance of WebXRSessionManager
  42858. */
  42859. constructor(_xrSessionManager: WebXRSessionManager);
  42860. /**
  42861. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42862. * Mainly used internally.
  42863. *
  42864. * @param featureName the name of the feature to register
  42865. * @param constructorFunction the function used to construct the module
  42866. * @param version the (babylon) version of the module
  42867. * @param stable is that a stable version of this module
  42868. */
  42869. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42870. /**
  42871. * Returns a constructor of a specific feature.
  42872. *
  42873. * @param featureName the name of the feature to construct
  42874. * @param version the version of the feature to load
  42875. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42876. * @param options optional options provided to the module.
  42877. * @returns a function that, when called, will return a new instance of this feature
  42878. */
  42879. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42880. /**
  42881. * Can be used to return the list of features currently registered
  42882. *
  42883. * @returns an Array of available features
  42884. */
  42885. static GetAvailableFeatures(): string[];
  42886. /**
  42887. * Gets the versions available for a specific feature
  42888. * @param featureName the name of the feature
  42889. * @returns an array with the available versions
  42890. */
  42891. static GetAvailableVersions(featureName: string): string[];
  42892. /**
  42893. * Return the latest unstable version of this feature
  42894. * @param featureName the name of the feature to search
  42895. * @returns the version number. if not found will return -1
  42896. */
  42897. static GetLatestVersionOfFeature(featureName: string): number;
  42898. /**
  42899. * Return the latest stable version of this feature
  42900. * @param featureName the name of the feature to search
  42901. * @returns the version number. if not found will return -1
  42902. */
  42903. static GetStableVersionOfFeature(featureName: string): number;
  42904. /**
  42905. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42906. * Can be used during a session to start a feature
  42907. * @param featureName the name of feature to attach
  42908. */
  42909. attachFeature(featureName: string): void;
  42910. /**
  42911. * Can be used inside a session or when the session ends to detach a specific feature
  42912. * @param featureName the name of the feature to detach
  42913. */
  42914. detachFeature(featureName: string): void;
  42915. /**
  42916. * Used to disable an already-enabled feature
  42917. * The feature will be disposed and will be recreated once enabled.
  42918. * @param featureName the feature to disable
  42919. * @returns true if disable was successful
  42920. */
  42921. disableFeature(featureName: string | {
  42922. Name: string;
  42923. }): boolean;
  42924. /**
  42925. * dispose this features manager
  42926. */
  42927. dispose(): void;
  42928. /**
  42929. * 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.
  42930. * 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.
  42931. *
  42932. * @param featureName the name of the feature to load or the class of the feature
  42933. * @param version optional version to load. if not provided the latest version will be enabled
  42934. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42935. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42936. * @returns a new constructed feature or throws an error if feature not found.
  42937. */
  42938. enableFeature(featureName: string | {
  42939. Name: string;
  42940. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42941. /**
  42942. * get the implementation of an enabled feature.
  42943. * @param featureName the name of the feature to load
  42944. * @returns the feature class, if found
  42945. */
  42946. getEnabledFeature(featureName: string): IWebXRFeature;
  42947. /**
  42948. * Get the list of enabled features
  42949. * @returns an array of enabled features
  42950. */
  42951. getEnabledFeatures(): string[];
  42952. }
  42953. }
  42954. declare module BABYLON {
  42955. /**
  42956. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  42957. * @see https://doc.babylonjs.com/how_to/webxr
  42958. */
  42959. export class WebXRExperienceHelper implements IDisposable {
  42960. private scene;
  42961. private _nonVRCamera;
  42962. private _originalSceneAutoClear;
  42963. private _supported;
  42964. /**
  42965. * Camera used to render xr content
  42966. */
  42967. camera: WebXRCamera;
  42968. /** A features manager for this xr session */
  42969. featuresManager: WebXRFeaturesManager;
  42970. /**
  42971. * Observers registered here will be triggered after the camera's initial transformation is set
  42972. * This can be used to set a different ground level or an extra rotation.
  42973. *
  42974. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42975. * to the position set after this observable is done executing.
  42976. */
  42977. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42978. /**
  42979. * Fires when the state of the experience helper has changed
  42980. */
  42981. onStateChangedObservable: Observable<WebXRState>;
  42982. /** Session manager used to keep track of xr session */
  42983. sessionManager: WebXRSessionManager;
  42984. /**
  42985. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42986. */
  42987. state: WebXRState;
  42988. /**
  42989. * Creates a WebXRExperienceHelper
  42990. * @param scene The scene the helper should be created in
  42991. */
  42992. private constructor();
  42993. /**
  42994. * Creates the experience helper
  42995. * @param scene the scene to attach the experience helper to
  42996. * @returns a promise for the experience helper
  42997. */
  42998. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42999. /**
  43000. * Disposes of the experience helper
  43001. */
  43002. dispose(): void;
  43003. /**
  43004. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43005. * @param sessionMode options for the XR session
  43006. * @param referenceSpaceType frame of reference of the XR session
  43007. * @param renderTarget the output canvas that will be used to enter XR mode
  43008. * @returns promise that resolves after xr mode has entered
  43009. */
  43010. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43011. /**
  43012. * Exits XR mode and returns the scene to its original state
  43013. * @returns promise that resolves after xr mode has exited
  43014. */
  43015. exitXRAsync(): Promise<void>;
  43016. private _nonXRToXRCamera;
  43017. private _setState;
  43018. }
  43019. }
  43020. declare module BABYLON {
  43021. /**
  43022. * X-Y values for axes in WebXR
  43023. */
  43024. export interface IWebXRMotionControllerAxesValue {
  43025. /**
  43026. * The value of the x axis
  43027. */
  43028. x: number;
  43029. /**
  43030. * The value of the y-axis
  43031. */
  43032. y: number;
  43033. }
  43034. /**
  43035. * changed / previous values for the values of this component
  43036. */
  43037. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43038. /**
  43039. * current (this frame) value
  43040. */
  43041. current: T;
  43042. /**
  43043. * previous (last change) value
  43044. */
  43045. previous: T;
  43046. }
  43047. /**
  43048. * Represents changes in the component between current frame and last values recorded
  43049. */
  43050. export interface IWebXRMotionControllerComponentChanges {
  43051. /**
  43052. * will be populated with previous and current values if axes changed
  43053. */
  43054. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43055. /**
  43056. * will be populated with previous and current values if pressed changed
  43057. */
  43058. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43059. /**
  43060. * will be populated with previous and current values if touched changed
  43061. */
  43062. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43063. /**
  43064. * will be populated with previous and current values if value changed
  43065. */
  43066. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43067. }
  43068. /**
  43069. * This class represents a single component (for example button or thumbstick) of a motion controller
  43070. */
  43071. export class WebXRControllerComponent implements IDisposable {
  43072. /**
  43073. * the id of this component
  43074. */
  43075. id: string;
  43076. /**
  43077. * the type of the component
  43078. */
  43079. type: MotionControllerComponentType;
  43080. private _buttonIndex;
  43081. private _axesIndices;
  43082. private _axes;
  43083. private _changes;
  43084. private _currentValue;
  43085. private _hasChanges;
  43086. private _pressed;
  43087. private _touched;
  43088. /**
  43089. * button component type
  43090. */
  43091. static BUTTON_TYPE: MotionControllerComponentType;
  43092. /**
  43093. * squeeze component type
  43094. */
  43095. static SQUEEZE_TYPE: MotionControllerComponentType;
  43096. /**
  43097. * Thumbstick component type
  43098. */
  43099. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43100. /**
  43101. * Touchpad component type
  43102. */
  43103. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43104. /**
  43105. * trigger component type
  43106. */
  43107. static TRIGGER_TYPE: MotionControllerComponentType;
  43108. /**
  43109. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43110. * the axes data changes
  43111. */
  43112. onAxisValueChangedObservable: Observable<{
  43113. x: number;
  43114. y: number;
  43115. }>;
  43116. /**
  43117. * Observers registered here will be triggered when the state of a button changes
  43118. * State change is either pressed / touched / value
  43119. */
  43120. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43121. /**
  43122. * Creates a new component for a motion controller.
  43123. * It is created by the motion controller itself
  43124. *
  43125. * @param id the id of this component
  43126. * @param type the type of the component
  43127. * @param _buttonIndex index in the buttons array of the gamepad
  43128. * @param _axesIndices indices of the values in the axes array of the gamepad
  43129. */
  43130. constructor(
  43131. /**
  43132. * the id of this component
  43133. */
  43134. id: string,
  43135. /**
  43136. * the type of the component
  43137. */
  43138. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43139. /**
  43140. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43141. */
  43142. get axes(): IWebXRMotionControllerAxesValue;
  43143. /**
  43144. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43145. */
  43146. get changes(): IWebXRMotionControllerComponentChanges;
  43147. /**
  43148. * Return whether or not the component changed the last frame
  43149. */
  43150. get hasChanges(): boolean;
  43151. /**
  43152. * is the button currently pressed
  43153. */
  43154. get pressed(): boolean;
  43155. /**
  43156. * is the button currently touched
  43157. */
  43158. get touched(): boolean;
  43159. /**
  43160. * Get the current value of this component
  43161. */
  43162. get value(): number;
  43163. /**
  43164. * Dispose this component
  43165. */
  43166. dispose(): void;
  43167. /**
  43168. * Are there axes correlating to this component
  43169. * @return true is axes data is available
  43170. */
  43171. isAxes(): boolean;
  43172. /**
  43173. * Is this component a button (hence - pressable)
  43174. * @returns true if can be pressed
  43175. */
  43176. isButton(): boolean;
  43177. /**
  43178. * update this component using the gamepad object it is in. Called on every frame
  43179. * @param nativeController the native gamepad controller object
  43180. */
  43181. update(nativeController: IMinimalMotionControllerObject): void;
  43182. }
  43183. }
  43184. declare module BABYLON {
  43185. /**
  43186. * Class used to represent data loading progression
  43187. */
  43188. export class SceneLoaderProgressEvent {
  43189. /** defines if data length to load can be evaluated */
  43190. readonly lengthComputable: boolean;
  43191. /** defines the loaded data length */
  43192. readonly loaded: number;
  43193. /** defines the data length to load */
  43194. readonly total: number;
  43195. /**
  43196. * Create a new progress event
  43197. * @param lengthComputable defines if data length to load can be evaluated
  43198. * @param loaded defines the loaded data length
  43199. * @param total defines the data length to load
  43200. */
  43201. constructor(
  43202. /** defines if data length to load can be evaluated */
  43203. lengthComputable: boolean,
  43204. /** defines the loaded data length */
  43205. loaded: number,
  43206. /** defines the data length to load */
  43207. total: number);
  43208. /**
  43209. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43210. * @param event defines the source event
  43211. * @returns a new SceneLoaderProgressEvent
  43212. */
  43213. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43214. }
  43215. /**
  43216. * Interface used by SceneLoader plugins to define supported file extensions
  43217. */
  43218. export interface ISceneLoaderPluginExtensions {
  43219. /**
  43220. * Defines the list of supported extensions
  43221. */
  43222. [extension: string]: {
  43223. isBinary: boolean;
  43224. };
  43225. }
  43226. /**
  43227. * Interface used by SceneLoader plugin factory
  43228. */
  43229. export interface ISceneLoaderPluginFactory {
  43230. /**
  43231. * Defines the name of the factory
  43232. */
  43233. name: string;
  43234. /**
  43235. * Function called to create a new plugin
  43236. * @return the new plugin
  43237. */
  43238. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43239. /**
  43240. * The callback that returns true if the data can be directly loaded.
  43241. * @param data string containing the file data
  43242. * @returns if the data can be loaded directly
  43243. */
  43244. canDirectLoad?(data: string): boolean;
  43245. }
  43246. /**
  43247. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43248. */
  43249. export interface ISceneLoaderPluginBase {
  43250. /**
  43251. * The friendly name of this plugin.
  43252. */
  43253. name: string;
  43254. /**
  43255. * The file extensions supported by this plugin.
  43256. */
  43257. extensions: string | ISceneLoaderPluginExtensions;
  43258. /**
  43259. * The callback called when loading from a url.
  43260. * @param scene scene loading this url
  43261. * @param url url to load
  43262. * @param onSuccess callback called when the file successfully loads
  43263. * @param onProgress callback called while file is loading (if the server supports this mode)
  43264. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43265. * @param onError callback called when the file fails to load
  43266. * @returns a file request object
  43267. */
  43268. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43269. /**
  43270. * The callback called when loading from a file object.
  43271. * @param scene scene loading this file
  43272. * @param file defines the file to load
  43273. * @param onSuccess defines the callback to call when data is loaded
  43274. * @param onProgress defines the callback to call during loading process
  43275. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43276. * @param onError defines the callback to call when an error occurs
  43277. * @returns a file request object
  43278. */
  43279. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43280. /**
  43281. * The callback that returns true if the data can be directly loaded.
  43282. * @param data string containing the file data
  43283. * @returns if the data can be loaded directly
  43284. */
  43285. canDirectLoad?(data: string): boolean;
  43286. /**
  43287. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43288. * @param scene scene loading this data
  43289. * @param data string containing the data
  43290. * @returns data to pass to the plugin
  43291. */
  43292. directLoad?(scene: Scene, data: string): any;
  43293. /**
  43294. * The callback that allows custom handling of the root url based on the response url.
  43295. * @param rootUrl the original root url
  43296. * @param responseURL the response url if available
  43297. * @returns the new root url
  43298. */
  43299. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43300. }
  43301. /**
  43302. * Interface used to define a SceneLoader plugin
  43303. */
  43304. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43305. /**
  43306. * Import meshes into a scene.
  43307. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43308. * @param scene The scene to import into
  43309. * @param data The data to import
  43310. * @param rootUrl The root url for scene and resources
  43311. * @param meshes The meshes array to import into
  43312. * @param particleSystems The particle systems array to import into
  43313. * @param skeletons The skeletons array to import into
  43314. * @param onError The callback when import fails
  43315. * @returns True if successful or false otherwise
  43316. */
  43317. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43318. /**
  43319. * Load into a scene.
  43320. * @param scene The scene to load into
  43321. * @param data The data to import
  43322. * @param rootUrl The root url for scene and resources
  43323. * @param onError The callback when import fails
  43324. * @returns True if successful or false otherwise
  43325. */
  43326. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43327. /**
  43328. * Load into an asset container.
  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 The loaded asset container
  43334. */
  43335. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43336. }
  43337. /**
  43338. * Interface used to define an async SceneLoader plugin
  43339. */
  43340. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43341. /**
  43342. * Import meshes into a scene.
  43343. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43344. * @param scene The scene to import into
  43345. * @param data The data to import
  43346. * @param rootUrl The root url for scene and resources
  43347. * @param onProgress The callback when the load progresses
  43348. * @param fileName Defines the name of the file to load
  43349. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43350. */
  43351. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43352. meshes: AbstractMesh[];
  43353. particleSystems: IParticleSystem[];
  43354. skeletons: Skeleton[];
  43355. animationGroups: AnimationGroup[];
  43356. }>;
  43357. /**
  43358. * Load into a scene.
  43359. * @param scene The scene to load into
  43360. * @param data The data to import
  43361. * @param rootUrl The root url for scene and resources
  43362. * @param onProgress The callback when the load progresses
  43363. * @param fileName Defines the name of the file to load
  43364. * @returns Nothing
  43365. */
  43366. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43367. /**
  43368. * Load into an asset container.
  43369. * @param scene The scene to load into
  43370. * @param data The data to import
  43371. * @param rootUrl The root url for scene and resources
  43372. * @param onProgress The callback when the load progresses
  43373. * @param fileName Defines the name of the file to load
  43374. * @returns The loaded asset container
  43375. */
  43376. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43377. }
  43378. /**
  43379. * Mode that determines how to handle old animation groups before loading new ones.
  43380. */
  43381. export enum SceneLoaderAnimationGroupLoadingMode {
  43382. /**
  43383. * Reset all old animations to initial state then dispose them.
  43384. */
  43385. Clean = 0,
  43386. /**
  43387. * Stop all old animations.
  43388. */
  43389. Stop = 1,
  43390. /**
  43391. * Restart old animations from first frame.
  43392. */
  43393. Sync = 2,
  43394. /**
  43395. * Old animations remains untouched.
  43396. */
  43397. NoSync = 3
  43398. }
  43399. /**
  43400. * Class used to load scene from various file formats using registered plugins
  43401. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43402. */
  43403. export class SceneLoader {
  43404. /**
  43405. * No logging while loading
  43406. */
  43407. static readonly NO_LOGGING: number;
  43408. /**
  43409. * Minimal logging while loading
  43410. */
  43411. static readonly MINIMAL_LOGGING: number;
  43412. /**
  43413. * Summary logging while loading
  43414. */
  43415. static readonly SUMMARY_LOGGING: number;
  43416. /**
  43417. * Detailled logging while loading
  43418. */
  43419. static readonly DETAILED_LOGGING: number;
  43420. /**
  43421. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43422. */
  43423. static get ForceFullSceneLoadingForIncremental(): boolean;
  43424. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43425. /**
  43426. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43427. */
  43428. static get ShowLoadingScreen(): boolean;
  43429. static set ShowLoadingScreen(value: boolean);
  43430. /**
  43431. * Defines the current logging level (while loading the scene)
  43432. * @ignorenaming
  43433. */
  43434. static get loggingLevel(): number;
  43435. static set loggingLevel(value: number);
  43436. /**
  43437. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43438. */
  43439. static get CleanBoneMatrixWeights(): boolean;
  43440. static set CleanBoneMatrixWeights(value: boolean);
  43441. /**
  43442. * Event raised when a plugin is used to load a scene
  43443. */
  43444. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43445. private static _registeredPlugins;
  43446. private static _getDefaultPlugin;
  43447. private static _getPluginForExtension;
  43448. private static _getPluginForDirectLoad;
  43449. private static _getPluginForFilename;
  43450. private static _getDirectLoad;
  43451. private static _loadData;
  43452. private static _getFileInfo;
  43453. /**
  43454. * Gets a plugin that can load the given extension
  43455. * @param extension defines the extension to load
  43456. * @returns a plugin or null if none works
  43457. */
  43458. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43459. /**
  43460. * Gets a boolean indicating that the given extension can be loaded
  43461. * @param extension defines the extension to load
  43462. * @returns true if the extension is supported
  43463. */
  43464. static IsPluginForExtensionAvailable(extension: string): boolean;
  43465. /**
  43466. * Adds a new plugin to the list of registered plugins
  43467. * @param plugin defines the plugin to add
  43468. */
  43469. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43470. /**
  43471. * Import meshes into a scene
  43472. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43473. * @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)
  43474. * @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)
  43475. * @param scene the instance of BABYLON.Scene to append to
  43476. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43477. * @param onProgress a callback with a progress event for each file being loaded
  43478. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43479. * @param pluginExtension the extension used to determine the plugin
  43480. * @returns The loaded plugin
  43481. */
  43482. 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>;
  43483. /**
  43484. * Import meshes into a scene
  43485. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43486. * @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)
  43487. * @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)
  43488. * @param scene the instance of BABYLON.Scene to append to
  43489. * @param onProgress a callback with a progress event for each file being loaded
  43490. * @param pluginExtension the extension used to determine the plugin
  43491. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43492. */
  43493. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43494. meshes: AbstractMesh[];
  43495. particleSystems: IParticleSystem[];
  43496. skeletons: Skeleton[];
  43497. animationGroups: AnimationGroup[];
  43498. }>;
  43499. /**
  43500. * Load a scene
  43501. * @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)
  43502. * @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)
  43503. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43504. * @param onSuccess a callback with the scene when import succeeds
  43505. * @param onProgress a callback with a progress event for each file being loaded
  43506. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43507. * @param pluginExtension the extension used to determine the plugin
  43508. * @returns The loaded plugin
  43509. */
  43510. 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>;
  43511. /**
  43512. * Load a scene
  43513. * @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)
  43514. * @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)
  43515. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43516. * @param onProgress a callback with a progress event for each file being loaded
  43517. * @param pluginExtension the extension used to determine the plugin
  43518. * @returns The loaded scene
  43519. */
  43520. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43521. /**
  43522. * Append a scene
  43523. * @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)
  43524. * @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)
  43525. * @param scene is the instance of BABYLON.Scene to append to
  43526. * @param onSuccess a callback with the scene when import succeeds
  43527. * @param onProgress a callback with a progress event for each file being loaded
  43528. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43529. * @param pluginExtension the extension used to determine the plugin
  43530. * @returns The loaded plugin
  43531. */
  43532. 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>;
  43533. /**
  43534. * Append a scene
  43535. * @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)
  43536. * @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)
  43537. * @param scene is the instance of BABYLON.Scene to append to
  43538. * @param onProgress a callback with a progress event for each file being loaded
  43539. * @param pluginExtension the extension used to determine the plugin
  43540. * @returns The given scene
  43541. */
  43542. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43543. /**
  43544. * Load a scene into an asset container
  43545. * @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)
  43546. * @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)
  43547. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43548. * @param onSuccess a callback with the scene when import succeeds
  43549. * @param onProgress a callback with a progress event for each file being loaded
  43550. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43551. * @param pluginExtension the extension used to determine the plugin
  43552. * @returns The loaded plugin
  43553. */
  43554. 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>;
  43555. /**
  43556. * Load a scene into an asset container
  43557. * @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)
  43558. * @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)
  43559. * @param scene is the instance of Scene to append to
  43560. * @param onProgress a callback with a progress event for each file being loaded
  43561. * @param pluginExtension the extension used to determine the plugin
  43562. * @returns The loaded asset container
  43563. */
  43564. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43565. /**
  43566. * Import animations from a file into a scene
  43567. * @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)
  43568. * @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)
  43569. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43570. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43571. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43572. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43573. * @param onSuccess a callback with the scene when import succeeds
  43574. * @param onProgress a callback with a progress event for each file being loaded
  43575. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43576. */
  43577. 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;
  43578. /**
  43579. * Import animations from a file into a scene
  43580. * @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)
  43581. * @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)
  43582. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43583. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43584. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43585. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43586. * @param onSuccess a callback with the scene when import succeeds
  43587. * @param onProgress a callback with a progress event for each file being loaded
  43588. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43589. * @returns the updated scene with imported animations
  43590. */
  43591. 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>;
  43592. }
  43593. }
  43594. declare module BABYLON {
  43595. /**
  43596. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43597. */
  43598. export type MotionControllerHandness = "none" | "left" | "right";
  43599. /**
  43600. * The type of components available in motion controllers.
  43601. * This is not the name of the component.
  43602. */
  43603. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43604. /**
  43605. * The state of a controller component
  43606. */
  43607. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43608. /**
  43609. * The schema of motion controller layout.
  43610. * No object will be initialized using this interface
  43611. * This is used just to define the profile.
  43612. */
  43613. export interface IMotionControllerLayout {
  43614. /**
  43615. * Path to load the assets. Usually relative to the base path
  43616. */
  43617. assetPath: string;
  43618. /**
  43619. * Available components (unsorted)
  43620. */
  43621. components: {
  43622. /**
  43623. * A map of component Ids
  43624. */
  43625. [componentId: string]: {
  43626. /**
  43627. * The type of input the component outputs
  43628. */
  43629. type: MotionControllerComponentType;
  43630. /**
  43631. * The indices of this component in the gamepad object
  43632. */
  43633. gamepadIndices: {
  43634. /**
  43635. * Index of button
  43636. */
  43637. button?: number;
  43638. /**
  43639. * If available, index of x-axis
  43640. */
  43641. xAxis?: number;
  43642. /**
  43643. * If available, index of y-axis
  43644. */
  43645. yAxis?: number;
  43646. };
  43647. /**
  43648. * The mesh's root node name
  43649. */
  43650. rootNodeName: string;
  43651. /**
  43652. * Animation definitions for this model
  43653. */
  43654. visualResponses: {
  43655. [stateKey: string]: {
  43656. /**
  43657. * What property will be animated
  43658. */
  43659. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43660. /**
  43661. * What states influence this visual response
  43662. */
  43663. states: MotionControllerComponentStateType[];
  43664. /**
  43665. * Type of animation - movement or visibility
  43666. */
  43667. valueNodeProperty: "transform" | "visibility";
  43668. /**
  43669. * Base node name to move. Its position will be calculated according to the min and max nodes
  43670. */
  43671. valueNodeName?: string;
  43672. /**
  43673. * Minimum movement node
  43674. */
  43675. minNodeName?: string;
  43676. /**
  43677. * Max movement node
  43678. */
  43679. maxNodeName?: string;
  43680. };
  43681. };
  43682. /**
  43683. * If touch enabled, what is the name of node to display user feedback
  43684. */
  43685. touchPointNodeName?: string;
  43686. };
  43687. };
  43688. /**
  43689. * Is it xr standard mapping or not
  43690. */
  43691. gamepadMapping: "" | "xr-standard";
  43692. /**
  43693. * Base root node of this entire model
  43694. */
  43695. rootNodeName: string;
  43696. /**
  43697. * Defines the main button component id
  43698. */
  43699. selectComponentId: string;
  43700. }
  43701. /**
  43702. * A definition for the layout map in the input profile
  43703. */
  43704. export interface IMotionControllerLayoutMap {
  43705. /**
  43706. * Layouts with handness type as a key
  43707. */
  43708. [handness: string]: IMotionControllerLayout;
  43709. }
  43710. /**
  43711. * The XR Input profile schema
  43712. * Profiles can be found here:
  43713. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43714. */
  43715. export interface IMotionControllerProfile {
  43716. /**
  43717. * fallback profiles for this profileId
  43718. */
  43719. fallbackProfileIds: string[];
  43720. /**
  43721. * The layout map, with handness as key
  43722. */
  43723. layouts: IMotionControllerLayoutMap;
  43724. /**
  43725. * The id of this profile
  43726. * correlates to the profile(s) in the xrInput.profiles array
  43727. */
  43728. profileId: string;
  43729. }
  43730. /**
  43731. * A helper-interface for the 3 meshes needed for controller button animation
  43732. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43733. */
  43734. export interface IMotionControllerButtonMeshMap {
  43735. /**
  43736. * the mesh that defines the pressed value mesh position.
  43737. * This is used to find the max-position of this button
  43738. */
  43739. pressedMesh: AbstractMesh;
  43740. /**
  43741. * the mesh that defines the unpressed value mesh position.
  43742. * This is used to find the min (or initial) position of this button
  43743. */
  43744. unpressedMesh: AbstractMesh;
  43745. /**
  43746. * The mesh that will be changed when value changes
  43747. */
  43748. valueMesh: AbstractMesh;
  43749. }
  43750. /**
  43751. * A helper-interface for the 3 meshes needed for controller axis animation.
  43752. * This will be expanded when touchpad animations are fully supported
  43753. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43754. */
  43755. export interface IMotionControllerMeshMap {
  43756. /**
  43757. * the mesh that defines the maximum value mesh position.
  43758. */
  43759. maxMesh?: AbstractMesh;
  43760. /**
  43761. * the mesh that defines the minimum value mesh position.
  43762. */
  43763. minMesh?: AbstractMesh;
  43764. /**
  43765. * The mesh that will be changed when axis value changes
  43766. */
  43767. valueMesh: AbstractMesh;
  43768. }
  43769. /**
  43770. * The elements needed for change-detection of the gamepad objects in motion controllers
  43771. */
  43772. export interface IMinimalMotionControllerObject {
  43773. /**
  43774. * Available axes of this controller
  43775. */
  43776. axes: number[];
  43777. /**
  43778. * An array of available buttons
  43779. */
  43780. buttons: Array<{
  43781. /**
  43782. * Value of the button/trigger
  43783. */
  43784. value: number;
  43785. /**
  43786. * If the button/trigger is currently touched
  43787. */
  43788. touched: boolean;
  43789. /**
  43790. * If the button/trigger is currently pressed
  43791. */
  43792. pressed: boolean;
  43793. }>;
  43794. }
  43795. /**
  43796. * An Abstract Motion controller
  43797. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43798. * Each component has an observable to check for changes in value and state
  43799. */
  43800. export abstract class WebXRAbstractMotionController implements IDisposable {
  43801. protected scene: Scene;
  43802. protected layout: IMotionControllerLayout;
  43803. /**
  43804. * The gamepad object correlating to this controller
  43805. */
  43806. gamepadObject: IMinimalMotionControllerObject;
  43807. /**
  43808. * handness (left/right/none) of this controller
  43809. */
  43810. handness: MotionControllerHandness;
  43811. private _initComponent;
  43812. private _modelReady;
  43813. /**
  43814. * A map of components (WebXRControllerComponent) in this motion controller
  43815. * Components have a ComponentType and can also have both button and axis definitions
  43816. */
  43817. readonly components: {
  43818. [id: string]: WebXRControllerComponent;
  43819. };
  43820. /**
  43821. * Disable the model's animation. Can be set at any time.
  43822. */
  43823. disableAnimation: boolean;
  43824. /**
  43825. * Observers registered here will be triggered when the model of this controller is done loading
  43826. */
  43827. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43828. /**
  43829. * The profile id of this motion controller
  43830. */
  43831. abstract profileId: string;
  43832. /**
  43833. * The root mesh of the model. It is null if the model was not yet initialized
  43834. */
  43835. rootMesh: Nullable<AbstractMesh>;
  43836. /**
  43837. * constructs a new abstract motion controller
  43838. * @param scene the scene to which the model of the controller will be added
  43839. * @param layout The profile layout to load
  43840. * @param gamepadObject The gamepad object correlating to this controller
  43841. * @param handness handness (left/right/none) of this controller
  43842. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43843. */
  43844. constructor(scene: Scene, layout: IMotionControllerLayout,
  43845. /**
  43846. * The gamepad object correlating to this controller
  43847. */
  43848. gamepadObject: IMinimalMotionControllerObject,
  43849. /**
  43850. * handness (left/right/none) of this controller
  43851. */
  43852. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43853. /**
  43854. * Dispose this controller, the model mesh and all its components
  43855. */
  43856. dispose(): void;
  43857. /**
  43858. * Returns all components of specific type
  43859. * @param type the type to search for
  43860. * @return an array of components with this type
  43861. */
  43862. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43863. /**
  43864. * get a component based an its component id as defined in layout.components
  43865. * @param id the id of the component
  43866. * @returns the component correlates to the id or undefined if not found
  43867. */
  43868. getComponent(id: string): WebXRControllerComponent;
  43869. /**
  43870. * Get the list of components available in this motion controller
  43871. * @returns an array of strings correlating to available components
  43872. */
  43873. getComponentIds(): string[];
  43874. /**
  43875. * Get the first component of specific type
  43876. * @param type type of component to find
  43877. * @return a controller component or null if not found
  43878. */
  43879. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43880. /**
  43881. * Get the main (Select) component of this controller as defined in the layout
  43882. * @returns the main component of this controller
  43883. */
  43884. getMainComponent(): WebXRControllerComponent;
  43885. /**
  43886. * Loads the model correlating to this controller
  43887. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43888. * @returns A promise fulfilled with the result of the model loading
  43889. */
  43890. loadModel(): Promise<boolean>;
  43891. /**
  43892. * Update this model using the current XRFrame
  43893. * @param xrFrame the current xr frame to use and update the model
  43894. */
  43895. updateFromXRFrame(xrFrame: XRFrame): void;
  43896. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43897. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43898. /**
  43899. * Moves the axis on the controller mesh based on its current state
  43900. * @param axis the index of the axis
  43901. * @param axisValue the value of the axis which determines the meshes new position
  43902. * @hidden
  43903. */
  43904. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43905. /**
  43906. * Update the model itself with the current frame data
  43907. * @param xrFrame the frame to use for updating the model mesh
  43908. */
  43909. protected updateModel(xrFrame: XRFrame): void;
  43910. /**
  43911. * Get the filename and path for this controller's model
  43912. * @returns a map of filename and path
  43913. */
  43914. protected abstract _getFilenameAndPath(): {
  43915. filename: string;
  43916. path: string;
  43917. };
  43918. /**
  43919. * This function is called before the mesh is loaded. It checks for loading constraints.
  43920. * For example, this function can check if the GLB loader is available
  43921. * If this function returns false, the generic controller will be loaded instead
  43922. * @returns Is the client ready to load the mesh
  43923. */
  43924. protected abstract _getModelLoadingConstraints(): boolean;
  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. private _getGenericFilenameAndPath;
  43942. private _getGenericParentMesh;
  43943. }
  43944. }
  43945. declare module BABYLON {
  43946. /**
  43947. * A generic trigger-only motion controller for WebXR
  43948. */
  43949. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43950. /**
  43951. * Static version of the profile id of this controller
  43952. */
  43953. static ProfileId: string;
  43954. profileId: string;
  43955. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43956. protected _getFilenameAndPath(): {
  43957. filename: string;
  43958. path: string;
  43959. };
  43960. protected _getModelLoadingConstraints(): boolean;
  43961. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43962. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43963. protected _updateModel(): void;
  43964. }
  43965. }
  43966. declare module BABYLON {
  43967. /**
  43968. * Class containing static functions to help procedurally build meshes
  43969. */
  43970. export class SphereBuilder {
  43971. /**
  43972. * Creates a sphere mesh
  43973. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43974. * * 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`)
  43975. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43976. * * 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
  43977. * * 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)
  43978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43979. * * 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
  43980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43981. * @param name defines the name of the mesh
  43982. * @param options defines the options used to create the mesh
  43983. * @param scene defines the hosting scene
  43984. * @returns the sphere mesh
  43985. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43986. */
  43987. static CreateSphere(name: string, options: {
  43988. segments?: number;
  43989. diameter?: number;
  43990. diameterX?: number;
  43991. diameterY?: number;
  43992. diameterZ?: number;
  43993. arc?: number;
  43994. slice?: number;
  43995. sideOrientation?: number;
  43996. frontUVs?: Vector4;
  43997. backUVs?: Vector4;
  43998. updatable?: boolean;
  43999. }, scene?: Nullable<Scene>): Mesh;
  44000. }
  44001. }
  44002. declare module BABYLON {
  44003. /**
  44004. * A profiled motion controller has its profile loaded from an online repository.
  44005. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44006. */
  44007. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44008. private _repositoryUrl;
  44009. private _buttonMeshMapping;
  44010. private _touchDots;
  44011. /**
  44012. * The profile ID of this controller. Will be populated when the controller initializes.
  44013. */
  44014. profileId: string;
  44015. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44016. dispose(): void;
  44017. protected _getFilenameAndPath(): {
  44018. filename: string;
  44019. path: string;
  44020. };
  44021. protected _getModelLoadingConstraints(): boolean;
  44022. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44023. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44024. protected _updateModel(_xrFrame: XRFrame): void;
  44025. }
  44026. }
  44027. declare module BABYLON {
  44028. /**
  44029. * A construction function type to create a new controller based on an xrInput object
  44030. */
  44031. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44032. /**
  44033. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44034. *
  44035. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44036. * it should be replaced with auto-loaded controllers.
  44037. *
  44038. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44039. */
  44040. export class WebXRMotionControllerManager {
  44041. private static _AvailableControllers;
  44042. private static _Fallbacks;
  44043. private static _ProfileLoadingPromises;
  44044. private static _ProfilesList;
  44045. /**
  44046. * The base URL of the online controller repository. Can be changed at any time.
  44047. */
  44048. static BaseRepositoryUrl: string;
  44049. /**
  44050. * Which repository gets priority - local or online
  44051. */
  44052. static PrioritizeOnlineRepository: boolean;
  44053. /**
  44054. * Use the online repository, or use only locally-defined controllers
  44055. */
  44056. static UseOnlineRepository: boolean;
  44057. /**
  44058. * Clear the cache used for profile loading and reload when requested again
  44059. */
  44060. static ClearProfilesCache(): void;
  44061. /**
  44062. * Register the default fallbacks.
  44063. * This function is called automatically when this file is imported.
  44064. */
  44065. static DefaultFallbacks(): void;
  44066. /**
  44067. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44068. * @param profileId the profile to which a fallback needs to be found
  44069. * @return an array with corresponding fallback profiles
  44070. */
  44071. static FindFallbackWithProfileId(profileId: string): string[];
  44072. /**
  44073. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44074. * The order of search:
  44075. *
  44076. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44077. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44078. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44079. * 4) return the generic trigger controller if none were found
  44080. *
  44081. * @param xrInput the xrInput to which a new controller is initialized
  44082. * @param scene the scene to which the model will be added
  44083. * @param forceProfile force a certain profile for this controller
  44084. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44085. */
  44086. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44087. /**
  44088. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44089. *
  44090. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44091. *
  44092. * @param type the profile type to register
  44093. * @param constructFunction the function to be called when loading this profile
  44094. */
  44095. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44096. /**
  44097. * Register a fallback to a specific profile.
  44098. * @param profileId the profileId that will receive the fallbacks
  44099. * @param fallbacks A list of fallback profiles
  44100. */
  44101. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44102. /**
  44103. * Will update the list of profiles available in the repository
  44104. * @return a promise that resolves to a map of profiles available online
  44105. */
  44106. static UpdateProfilesList(): Promise<{
  44107. [profile: string]: string;
  44108. }>;
  44109. private static _LoadProfileFromRepository;
  44110. private static _LoadProfilesFromAvailableControllers;
  44111. }
  44112. }
  44113. declare module BABYLON {
  44114. /**
  44115. * Configuration options for the WebXR controller creation
  44116. */
  44117. export interface IWebXRControllerOptions {
  44118. /**
  44119. * Should the controller mesh be animated when a user interacts with it
  44120. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44121. */
  44122. disableMotionControllerAnimation?: boolean;
  44123. /**
  44124. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44125. */
  44126. doNotLoadControllerMesh?: boolean;
  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. /**
  44134. * Represents an XR controller
  44135. */
  44136. export class WebXRInputSource {
  44137. private _scene;
  44138. /** The underlying input source for the controller */
  44139. inputSource: XRInputSource;
  44140. private _options;
  44141. private _tmpQuaternion;
  44142. private _tmpVector;
  44143. private _uniqueId;
  44144. /**
  44145. * 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
  44146. */
  44147. grip?: AbstractMesh;
  44148. /**
  44149. * If available, this is the gamepad object related to this controller.
  44150. * Using this object it is possible to get click events and trackpad changes of the
  44151. * webxr controller that is currently being used.
  44152. */
  44153. motionController?: WebXRAbstractMotionController;
  44154. /**
  44155. * Event that fires when the controller is removed/disposed.
  44156. * The object provided as event data is this controller, after associated assets were disposed.
  44157. * uniqueId is still available.
  44158. */
  44159. onDisposeObservable: Observable<WebXRInputSource>;
  44160. /**
  44161. * Will be triggered when the mesh associated with the motion controller is done loading.
  44162. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44163. * A shortened version of controller -> motion controller -> on mesh loaded.
  44164. */
  44165. onMeshLoadedObservable: Observable<AbstractMesh>;
  44166. /**
  44167. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44168. */
  44169. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44170. /**
  44171. * Pointer which can be used to select objects or attach a visible laser to
  44172. */
  44173. pointer: AbstractMesh;
  44174. /**
  44175. * Creates the controller
  44176. * @see https://doc.babylonjs.com/how_to/webxr
  44177. * @param _scene the scene which the controller should be associated to
  44178. * @param inputSource the underlying input source for the controller
  44179. * @param _options options for this controller creation
  44180. */
  44181. constructor(_scene: Scene,
  44182. /** The underlying input source for the controller */
  44183. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44184. /**
  44185. * Get this controllers unique id
  44186. */
  44187. get uniqueId(): string;
  44188. /**
  44189. * Disposes of the object
  44190. */
  44191. dispose(): void;
  44192. /**
  44193. * Gets a world space ray coming from the pointer or grip
  44194. * @param result the resulting ray
  44195. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44196. */
  44197. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44198. /**
  44199. * Updates the controller pose based on the given XRFrame
  44200. * @param xrFrame xr frame to update the pose with
  44201. * @param referenceSpace reference space to use
  44202. */
  44203. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44204. }
  44205. }
  44206. declare module BABYLON {
  44207. /**
  44208. * The schema for initialization options of the XR Input class
  44209. */
  44210. export interface IWebXRInputOptions {
  44211. /**
  44212. * If set to true no model will be automatically loaded
  44213. */
  44214. doNotLoadControllerMeshes?: boolean;
  44215. /**
  44216. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44217. * If not found, the xr input profile data will be used.
  44218. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44219. */
  44220. forceInputProfile?: string;
  44221. /**
  44222. * Do not send a request to the controller repository to load the profile.
  44223. *
  44224. * Instead, use the controllers available in babylon itself.
  44225. */
  44226. disableOnlineControllerRepository?: boolean;
  44227. /**
  44228. * A custom URL for the controllers repository
  44229. */
  44230. customControllersRepositoryURL?: string;
  44231. /**
  44232. * Should the controller model's components not move according to the user input
  44233. */
  44234. disableControllerAnimation?: boolean;
  44235. }
  44236. /**
  44237. * XR input used to track XR inputs such as controllers/rays
  44238. */
  44239. export class WebXRInput implements IDisposable {
  44240. /**
  44241. * the xr session manager for this session
  44242. */
  44243. xrSessionManager: WebXRSessionManager;
  44244. /**
  44245. * the WebXR camera for this session. Mainly used for teleportation
  44246. */
  44247. xrCamera: WebXRCamera;
  44248. private readonly options;
  44249. /**
  44250. * XR controllers being tracked
  44251. */
  44252. controllers: Array<WebXRInputSource>;
  44253. private _frameObserver;
  44254. private _sessionEndedObserver;
  44255. private _sessionInitObserver;
  44256. /**
  44257. * Event when a controller has been connected/added
  44258. */
  44259. onControllerAddedObservable: Observable<WebXRInputSource>;
  44260. /**
  44261. * Event when a controller has been removed/disconnected
  44262. */
  44263. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44264. /**
  44265. * Initializes the WebXRInput
  44266. * @param xrSessionManager the xr session manager for this session
  44267. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44268. * @param options = initialization options for this xr input
  44269. */
  44270. constructor(
  44271. /**
  44272. * the xr session manager for this session
  44273. */
  44274. xrSessionManager: WebXRSessionManager,
  44275. /**
  44276. * the WebXR camera for this session. Mainly used for teleportation
  44277. */
  44278. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44279. private _onInputSourcesChange;
  44280. private _addAndRemoveControllers;
  44281. /**
  44282. * Disposes of the object
  44283. */
  44284. dispose(): void;
  44285. }
  44286. }
  44287. declare module BABYLON {
  44288. /**
  44289. * This is the base class for all WebXR features.
  44290. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44291. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44292. */
  44293. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44294. protected _xrSessionManager: WebXRSessionManager;
  44295. private _attached;
  44296. private _removeOnDetach;
  44297. /**
  44298. * Should auto-attach be disabled?
  44299. */
  44300. disableAutoAttach: boolean;
  44301. /**
  44302. * Construct a new (abstract) WebXR feature
  44303. * @param _xrSessionManager the xr session manager for this feature
  44304. */
  44305. constructor(_xrSessionManager: WebXRSessionManager);
  44306. /**
  44307. * Is this feature attached
  44308. */
  44309. get attached(): boolean;
  44310. /**
  44311. * attach this feature
  44312. *
  44313. * @param force should attachment be forced (even when already attached)
  44314. * @returns true if successful, false is failed or already attached
  44315. */
  44316. attach(force?: boolean): boolean;
  44317. /**
  44318. * detach this feature.
  44319. *
  44320. * @returns true if successful, false if failed or already detached
  44321. */
  44322. detach(): boolean;
  44323. /**
  44324. * Dispose this feature and all of the resources attached
  44325. */
  44326. dispose(): void;
  44327. /**
  44328. * This is used to register callbacks that will automatically be removed when detach is called.
  44329. * @param observable the observable to which the observer will be attached
  44330. * @param callback the callback to register
  44331. */
  44332. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44333. /**
  44334. * Code in this function will be executed on each xrFrame received from the browser.
  44335. * This function will not execute after the feature is detached.
  44336. * @param _xrFrame the current frame
  44337. */
  44338. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44339. }
  44340. }
  44341. declare module BABYLON {
  44342. /**
  44343. * Renders a layer on top of an existing scene
  44344. */
  44345. export class UtilityLayerRenderer implements IDisposable {
  44346. /** the original scene that will be rendered on top of */
  44347. originalScene: Scene;
  44348. private _pointerCaptures;
  44349. private _lastPointerEvents;
  44350. private static _DefaultUtilityLayer;
  44351. private static _DefaultKeepDepthUtilityLayer;
  44352. private _sharedGizmoLight;
  44353. private _renderCamera;
  44354. /**
  44355. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44356. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44357. * @returns the camera that is used when rendering the utility layer
  44358. */
  44359. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44360. /**
  44361. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44362. * @param cam the camera that should be used when rendering the utility layer
  44363. */
  44364. setRenderCamera(cam: Nullable<Camera>): void;
  44365. /**
  44366. * @hidden
  44367. * Light which used by gizmos to get light shading
  44368. */
  44369. _getSharedGizmoLight(): HemisphericLight;
  44370. /**
  44371. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44372. */
  44373. pickUtilitySceneFirst: boolean;
  44374. /**
  44375. * 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)
  44376. */
  44377. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44378. /**
  44379. * 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)
  44380. */
  44381. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44382. /**
  44383. * The scene that is rendered on top of the original scene
  44384. */
  44385. utilityLayerScene: Scene;
  44386. /**
  44387. * If the utility layer should automatically be rendered on top of existing scene
  44388. */
  44389. shouldRender: boolean;
  44390. /**
  44391. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44392. */
  44393. onlyCheckPointerDownEvents: boolean;
  44394. /**
  44395. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44396. */
  44397. processAllEvents: boolean;
  44398. /**
  44399. * Observable raised when the pointer move from the utility layer scene to the main scene
  44400. */
  44401. onPointerOutObservable: Observable<number>;
  44402. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44403. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44404. private _afterRenderObserver;
  44405. private _sceneDisposeObserver;
  44406. private _originalPointerObserver;
  44407. /**
  44408. * Instantiates a UtilityLayerRenderer
  44409. * @param originalScene the original scene that will be rendered on top of
  44410. * @param handleEvents boolean indicating if the utility layer should handle events
  44411. */
  44412. constructor(
  44413. /** the original scene that will be rendered on top of */
  44414. originalScene: Scene, handleEvents?: boolean);
  44415. private _notifyObservers;
  44416. /**
  44417. * Renders the utility layers scene on top of the original scene
  44418. */
  44419. render(): void;
  44420. /**
  44421. * Disposes of the renderer
  44422. */
  44423. dispose(): void;
  44424. private _updateCamera;
  44425. }
  44426. }
  44427. declare module BABYLON {
  44428. /**
  44429. * Options interface for the pointer selection module
  44430. */
  44431. export interface IWebXRControllerPointerSelectionOptions {
  44432. /**
  44433. * if provided, this scene will be used to render meshes.
  44434. */
  44435. customUtilityLayerScene?: Scene;
  44436. /**
  44437. * 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)
  44438. * If not disabled, the last picked point will be used to execute a pointer up event
  44439. * If disabled, pointer up event will be triggered right after the pointer down event.
  44440. * Used in screen and gaze target ray mode only
  44441. */
  44442. disablePointerUpOnTouchOut: boolean;
  44443. /**
  44444. * For gaze mode (time to select instead of press)
  44445. */
  44446. forceGazeMode: boolean;
  44447. /**
  44448. * 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
  44449. * to start a new countdown to the pointer down event.
  44450. * Defaults to 1.
  44451. */
  44452. gazeModePointerMovedFactor?: number;
  44453. /**
  44454. * Different button type to use instead of the main component
  44455. */
  44456. overrideButtonId?: string;
  44457. /**
  44458. * use this rendering group id for the meshes (optional)
  44459. */
  44460. renderingGroupId?: number;
  44461. /**
  44462. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44463. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44464. * 3000 means 3 seconds between pointing at something and selecting it
  44465. */
  44466. timeToSelect?: number;
  44467. /**
  44468. * Should meshes created here be added to a utility layer or the main scene
  44469. */
  44470. useUtilityLayer?: boolean;
  44471. /**
  44472. * the xr input to use with this pointer selection
  44473. */
  44474. xrInput: WebXRInput;
  44475. }
  44476. /**
  44477. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44478. */
  44479. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44480. private readonly _options;
  44481. private static _idCounter;
  44482. private _attachController;
  44483. private _controllers;
  44484. private _scene;
  44485. private _tmpVectorForPickCompare;
  44486. /**
  44487. * The module's name
  44488. */
  44489. static readonly Name: string;
  44490. /**
  44491. * The (Babylon) version of this module.
  44492. * This is an integer representing the implementation version.
  44493. * This number does not correspond to the WebXR specs version
  44494. */
  44495. static readonly Version: number;
  44496. /**
  44497. * Disable lighting on the laser pointer (so it will always be visible)
  44498. */
  44499. disablePointerLighting: boolean;
  44500. /**
  44501. * Disable lighting on the selection mesh (so it will always be visible)
  44502. */
  44503. disableSelectionMeshLighting: boolean;
  44504. /**
  44505. * Should the laser pointer be displayed
  44506. */
  44507. displayLaserPointer: boolean;
  44508. /**
  44509. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44510. */
  44511. displaySelectionMesh: boolean;
  44512. /**
  44513. * This color will be set to the laser pointer when selection is triggered
  44514. */
  44515. laserPointerPickedColor: Color3;
  44516. /**
  44517. * Default color of the laser pointer
  44518. */
  44519. lasterPointerDefaultColor: Color3;
  44520. /**
  44521. * default color of the selection ring
  44522. */
  44523. selectionMeshDefaultColor: Color3;
  44524. /**
  44525. * This color will be applied to the selection ring when selection is triggered
  44526. */
  44527. selectionMeshPickedColor: Color3;
  44528. /**
  44529. * constructs a new background remover module
  44530. * @param _xrSessionManager the session manager for this module
  44531. * @param _options read-only options to be used in this module
  44532. */
  44533. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44534. /**
  44535. * attach this feature
  44536. * Will usually be called by the features manager
  44537. *
  44538. * @returns true if successful.
  44539. */
  44540. attach(): boolean;
  44541. /**
  44542. * detach this feature.
  44543. * Will usually be called by the features manager
  44544. *
  44545. * @returns true if successful.
  44546. */
  44547. detach(): boolean;
  44548. /**
  44549. * Will get the mesh under a specific pointer.
  44550. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44551. * @param controllerId the controllerId to check
  44552. * @returns The mesh under pointer or null if no mesh is under the pointer
  44553. */
  44554. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44555. /**
  44556. * Get the xr controller that correlates to the pointer id in the pointer event
  44557. *
  44558. * @param id the pointer id to search for
  44559. * @returns the controller that correlates to this id or null if not found
  44560. */
  44561. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44562. protected _onXRFrame(_xrFrame: XRFrame): void;
  44563. private _attachGazeMode;
  44564. private _attachScreenRayMode;
  44565. private _attachTrackedPointerRayMode;
  44566. private _convertNormalToDirectionOfRay;
  44567. private _detachController;
  44568. private _generateNewMeshPair;
  44569. private _pickingMoved;
  44570. private _updatePointerDistance;
  44571. }
  44572. }
  44573. declare module BABYLON {
  44574. /**
  44575. * Button which can be used to enter a different mode of XR
  44576. */
  44577. export class WebXREnterExitUIButton {
  44578. /** button element */
  44579. element: HTMLElement;
  44580. /** XR initialization options for the button */
  44581. sessionMode: XRSessionMode;
  44582. /** Reference space type */
  44583. referenceSpaceType: XRReferenceSpaceType;
  44584. /**
  44585. * Creates a WebXREnterExitUIButton
  44586. * @param element button element
  44587. * @param sessionMode XR initialization session mode
  44588. * @param referenceSpaceType the type of reference space to be used
  44589. */
  44590. constructor(
  44591. /** button element */
  44592. element: HTMLElement,
  44593. /** XR initialization options for the button */
  44594. sessionMode: XRSessionMode,
  44595. /** Reference space type */
  44596. referenceSpaceType: XRReferenceSpaceType);
  44597. /**
  44598. * Extendable function which can be used to update the button's visuals when the state changes
  44599. * @param activeButton the current active button in the UI
  44600. */
  44601. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44602. }
  44603. /**
  44604. * Options to create the webXR UI
  44605. */
  44606. export class WebXREnterExitUIOptions {
  44607. /**
  44608. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44609. */
  44610. customButtons?: Array<WebXREnterExitUIButton>;
  44611. /**
  44612. * A reference space type to use when creating the default button.
  44613. * Default is local-floor
  44614. */
  44615. referenceSpaceType?: XRReferenceSpaceType;
  44616. /**
  44617. * Context to enter xr with
  44618. */
  44619. renderTarget?: Nullable<WebXRRenderTarget>;
  44620. /**
  44621. * A session mode to use when creating the default button.
  44622. * Default is immersive-vr
  44623. */
  44624. sessionMode?: XRSessionMode;
  44625. }
  44626. /**
  44627. * UI to allow the user to enter/exit XR mode
  44628. */
  44629. export class WebXREnterExitUI implements IDisposable {
  44630. private scene;
  44631. /** version of the options passed to this UI */
  44632. options: WebXREnterExitUIOptions;
  44633. private _activeButton;
  44634. private _buttons;
  44635. private _overlay;
  44636. /**
  44637. * Fired every time the active button is changed.
  44638. *
  44639. * When xr is entered via a button that launches xr that button will be the callback parameter
  44640. *
  44641. * When exiting xr the callback parameter will be null)
  44642. */
  44643. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44644. /**
  44645. *
  44646. * @param scene babylon scene object to use
  44647. * @param options (read-only) version of the options passed to this UI
  44648. */
  44649. private constructor();
  44650. /**
  44651. * Creates UI to allow the user to enter/exit XR mode
  44652. * @param scene the scene to add the ui to
  44653. * @param helper the xr experience helper to enter/exit xr with
  44654. * @param options options to configure the UI
  44655. * @returns the created ui
  44656. */
  44657. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44658. /**
  44659. * Disposes of the XR UI component
  44660. */
  44661. dispose(): void;
  44662. private _updateButtons;
  44663. }
  44664. }
  44665. declare module BABYLON {
  44666. /**
  44667. * Class containing static functions to help procedurally build meshes
  44668. */
  44669. export class LinesBuilder {
  44670. /**
  44671. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44672. * * 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
  44673. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44674. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44675. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44676. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44677. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44678. * * 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
  44679. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44682. * @param name defines the name of the new line system
  44683. * @param options defines the options used to create the line system
  44684. * @param scene defines the hosting scene
  44685. * @returns a new line system mesh
  44686. */
  44687. static CreateLineSystem(name: string, options: {
  44688. lines: Vector3[][];
  44689. updatable?: boolean;
  44690. instance?: Nullable<LinesMesh>;
  44691. colors?: Nullable<Color4[][]>;
  44692. useVertexAlpha?: boolean;
  44693. }, scene: Nullable<Scene>): LinesMesh;
  44694. /**
  44695. * Creates a line mesh
  44696. * 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
  44697. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44698. * * The parameter `points` is an array successive Vector3
  44699. * * 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
  44700. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44701. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44702. * * When updating an instance, remember that only point positions can change, not the number of points
  44703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44705. * @param name defines the name of the new line system
  44706. * @param options defines the options used to create the line system
  44707. * @param scene defines the hosting scene
  44708. * @returns a new line mesh
  44709. */
  44710. static CreateLines(name: string, options: {
  44711. points: Vector3[];
  44712. updatable?: boolean;
  44713. instance?: Nullable<LinesMesh>;
  44714. colors?: Color4[];
  44715. useVertexAlpha?: boolean;
  44716. }, scene?: Nullable<Scene>): LinesMesh;
  44717. /**
  44718. * Creates a dashed line mesh
  44719. * * 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
  44720. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44721. * * The parameter `points` is an array successive Vector3
  44722. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44723. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44724. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44725. * * 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
  44726. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44727. * * When updating an instance, remember that only point positions can change, not the number of points
  44728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44729. * @param name defines the name of the mesh
  44730. * @param options defines the options used to create the mesh
  44731. * @param scene defines the hosting scene
  44732. * @returns the dashed line mesh
  44733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44734. */
  44735. static CreateDashedLines(name: string, options: {
  44736. points: Vector3[];
  44737. dashSize?: number;
  44738. gapSize?: number;
  44739. dashNb?: number;
  44740. updatable?: boolean;
  44741. instance?: LinesMesh;
  44742. useVertexAlpha?: boolean;
  44743. }, scene?: Nullable<Scene>): LinesMesh;
  44744. }
  44745. }
  44746. declare module BABYLON {
  44747. /**
  44748. * The options container for the teleportation module
  44749. */
  44750. export interface IWebXRTeleportationOptions {
  44751. /**
  44752. * if provided, this scene will be used to render meshes.
  44753. */
  44754. customUtilityLayerScene?: Scene;
  44755. /**
  44756. * Values to configure the default target mesh
  44757. */
  44758. defaultTargetMeshOptions?: {
  44759. /**
  44760. * Fill color of the teleportation area
  44761. */
  44762. teleportationFillColor?: string;
  44763. /**
  44764. * Border color for the teleportation area
  44765. */
  44766. teleportationBorderColor?: string;
  44767. /**
  44768. * Disable the mesh's animation sequence
  44769. */
  44770. disableAnimation?: boolean;
  44771. /**
  44772. * Disable lighting on the material or the ring and arrow
  44773. */
  44774. disableLighting?: boolean;
  44775. /**
  44776. * Override the default material of the torus and arrow
  44777. */
  44778. torusArrowMaterial?: Material;
  44779. };
  44780. /**
  44781. * A list of meshes to use as floor meshes.
  44782. * Meshes can be added and removed after initializing the feature using the
  44783. * addFloorMesh and removeFloorMesh functions
  44784. * If empty, rotation will still work
  44785. */
  44786. floorMeshes?: AbstractMesh[];
  44787. /**
  44788. * use this rendering group id for the meshes (optional)
  44789. */
  44790. renderingGroupId?: number;
  44791. /**
  44792. * Should teleportation move only to snap points
  44793. */
  44794. snapPointsOnly?: boolean;
  44795. /**
  44796. * An array of points to which the teleportation will snap to.
  44797. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44798. */
  44799. snapPositions?: Vector3[];
  44800. /**
  44801. * How close should the teleportation ray be in order to snap to position.
  44802. * Default to 0.8 units (meters)
  44803. */
  44804. snapToPositionRadius?: number;
  44805. /**
  44806. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44807. * If you want to support rotation, make sure your mesh has a direction indicator.
  44808. *
  44809. * When left untouched, the default mesh will be initialized.
  44810. */
  44811. teleportationTargetMesh?: AbstractMesh;
  44812. /**
  44813. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  44814. */
  44815. timeToTeleport?: number;
  44816. /**
  44817. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  44818. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  44819. */
  44820. useMainComponentOnly?: boolean;
  44821. /**
  44822. * Should meshes created here be added to a utility layer or the main scene
  44823. */
  44824. useUtilityLayer?: boolean;
  44825. /**
  44826. * Babylon XR Input class for controller
  44827. */
  44828. xrInput: WebXRInput;
  44829. }
  44830. /**
  44831. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  44832. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44833. * the input of the attached controllers.
  44834. */
  44835. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44836. private _options;
  44837. private _controllers;
  44838. private _currentTeleportationControllerId;
  44839. private _floorMeshes;
  44840. private _quadraticBezierCurve;
  44841. private _selectionFeature;
  44842. private _snapToPositions;
  44843. private _snappedToPoint;
  44844. private _teleportationRingMaterial?;
  44845. private _tmpRay;
  44846. private _tmpVector;
  44847. /**
  44848. * The module's name
  44849. */
  44850. static readonly Name: string;
  44851. /**
  44852. * The (Babylon) version of this module.
  44853. * This is an integer representing the implementation version.
  44854. * This number does not correspond to the webxr specs version
  44855. */
  44856. static readonly Version: number;
  44857. /**
  44858. * Is movement backwards enabled
  44859. */
  44860. backwardsMovementEnabled: boolean;
  44861. /**
  44862. * Distance to travel when moving backwards
  44863. */
  44864. backwardsTeleportationDistance: number;
  44865. /**
  44866. * The distance from the user to the inspection point in the direction of the controller
  44867. * A higher number will allow the user to move further
  44868. * defaults to 5 (meters, in xr units)
  44869. */
  44870. parabolicCheckRadius: number;
  44871. /**
  44872. * Should the module support parabolic ray on top of direct ray
  44873. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44874. * Very helpful when moving between floors / different heights
  44875. */
  44876. parabolicRayEnabled: boolean;
  44877. /**
  44878. * How much rotation should be applied when rotating right and left
  44879. */
  44880. rotationAngle: number;
  44881. /**
  44882. * Is rotation enabled when moving forward?
  44883. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44884. */
  44885. rotationEnabled: boolean;
  44886. /**
  44887. * constructs a new anchor system
  44888. * @param _xrSessionManager an instance of WebXRSessionManager
  44889. * @param _options configuration object for this feature
  44890. */
  44891. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44892. /**
  44893. * Get the snapPointsOnly flag
  44894. */
  44895. get snapPointsOnly(): boolean;
  44896. /**
  44897. * Sets the snapPointsOnly flag
  44898. * @param snapToPoints should teleportation be exclusively to snap points
  44899. */
  44900. set snapPointsOnly(snapToPoints: boolean);
  44901. /**
  44902. * Add a new mesh to the floor meshes array
  44903. * @param mesh the mesh to use as floor mesh
  44904. */
  44905. addFloorMesh(mesh: AbstractMesh): void;
  44906. /**
  44907. * Add a new snap-to point to fix teleportation to this position
  44908. * @param newSnapPoint The new Snap-To point
  44909. */
  44910. addSnapPoint(newSnapPoint: Vector3): void;
  44911. attach(): boolean;
  44912. detach(): boolean;
  44913. dispose(): void;
  44914. /**
  44915. * Remove a mesh from the floor meshes array
  44916. * @param mesh the mesh to remove
  44917. */
  44918. removeFloorMesh(mesh: AbstractMesh): void;
  44919. /**
  44920. * Remove a mesh from the floor meshes array using its name
  44921. * @param name the mesh name to remove
  44922. */
  44923. removeFloorMeshByName(name: string): void;
  44924. /**
  44925. * 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
  44926. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  44927. * @returns was the point found and removed or not
  44928. */
  44929. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  44930. /**
  44931. * This function sets a selection feature that will be disabled when
  44932. * the forward ray is shown and will be reattached when hidden.
  44933. * This is used to remove the selection rays when moving.
  44934. * @param selectionFeature the feature to disable when forward movement is enabled
  44935. */
  44936. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44937. protected _onXRFrame(_xrFrame: XRFrame): void;
  44938. private _attachController;
  44939. private _createDefaultTargetMesh;
  44940. private _detachController;
  44941. private _findClosestSnapPointWithRadius;
  44942. private _setTargetMeshPosition;
  44943. private _setTargetMeshVisibility;
  44944. private _showParabolicPath;
  44945. private _teleportForward;
  44946. }
  44947. }
  44948. declare module BABYLON {
  44949. /**
  44950. * Options for the default xr helper
  44951. */
  44952. export class WebXRDefaultExperienceOptions {
  44953. /**
  44954. * Enable or disable default UI to enter XR
  44955. */
  44956. disableDefaultUI?: boolean;
  44957. /**
  44958. * Should teleportation not initialize. defaults to false.
  44959. */
  44960. disableTeleportation?: boolean;
  44961. /**
  44962. * Floor meshes that will be used for teleport
  44963. */
  44964. floorMeshes?: Array<AbstractMesh>;
  44965. /**
  44966. * If set to true, the first frame will not be used to reset position
  44967. * The first frame is mainly used when copying transformation from the old camera
  44968. * Mainly used in AR
  44969. */
  44970. ignoreNativeCameraTransformation?: boolean;
  44971. /**
  44972. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44973. */
  44974. inputOptions?: IWebXRInputOptions;
  44975. /**
  44976. * optional configuration for the output canvas
  44977. */
  44978. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44979. /**
  44980. * optional UI options. This can be used among other to change session mode and reference space type
  44981. */
  44982. uiOptions?: WebXREnterExitUIOptions;
  44983. /**
  44984. * When loading teleportation and pointer select, use stable versions instead of latest.
  44985. */
  44986. useStablePlugins?: boolean;
  44987. }
  44988. /**
  44989. * Default experience which provides a similar setup to the previous webVRExperience
  44990. */
  44991. export class WebXRDefaultExperience {
  44992. /**
  44993. * Base experience
  44994. */
  44995. baseExperience: WebXRExperienceHelper;
  44996. /**
  44997. * Enables ui for entering/exiting xr
  44998. */
  44999. enterExitUI: WebXREnterExitUI;
  45000. /**
  45001. * Input experience extension
  45002. */
  45003. input: WebXRInput;
  45004. /**
  45005. * Enables laser pointer and selection
  45006. */
  45007. pointerSelection: WebXRControllerPointerSelection;
  45008. /**
  45009. * Default target xr should render to
  45010. */
  45011. renderTarget: WebXRRenderTarget;
  45012. /**
  45013. * Enables teleportation
  45014. */
  45015. teleportation: WebXRMotionControllerTeleportation;
  45016. private constructor();
  45017. /**
  45018. * Creates the default xr experience
  45019. * @param scene scene
  45020. * @param options options for basic configuration
  45021. * @returns resulting WebXRDefaultExperience
  45022. */
  45023. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45024. /**
  45025. * DIsposes of the experience helper
  45026. */
  45027. dispose(): void;
  45028. }
  45029. }
  45030. declare module BABYLON {
  45031. /**
  45032. * Options to modify the vr teleportation behavior.
  45033. */
  45034. export interface VRTeleportationOptions {
  45035. /**
  45036. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45037. */
  45038. floorMeshName?: string;
  45039. /**
  45040. * A list of meshes to be used as the teleportation floor. (default: empty)
  45041. */
  45042. floorMeshes?: Mesh[];
  45043. /**
  45044. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45045. */
  45046. teleportationMode?: number;
  45047. /**
  45048. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45049. */
  45050. teleportationTime?: number;
  45051. /**
  45052. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45053. */
  45054. teleportationSpeed?: number;
  45055. /**
  45056. * The easing function used in the animation or null for Linear. (default CircleEase)
  45057. */
  45058. easingFunction?: EasingFunction;
  45059. }
  45060. /**
  45061. * Options to modify the vr experience helper's behavior.
  45062. */
  45063. export interface VRExperienceHelperOptions extends WebVROptions {
  45064. /**
  45065. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45066. */
  45067. createDeviceOrientationCamera?: boolean;
  45068. /**
  45069. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45070. */
  45071. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45072. /**
  45073. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45074. */
  45075. laserToggle?: boolean;
  45076. /**
  45077. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45078. */
  45079. floorMeshes?: Mesh[];
  45080. /**
  45081. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45082. */
  45083. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45084. /**
  45085. * Defines if WebXR should be used instead of WebVR (if available)
  45086. */
  45087. useXR?: boolean;
  45088. }
  45089. /**
  45090. * Event containing information after VR has been entered
  45091. */
  45092. export class OnAfterEnteringVRObservableEvent {
  45093. /**
  45094. * If entering vr was successful
  45095. */
  45096. success: boolean;
  45097. }
  45098. /**
  45099. * Helps to quickly add VR support to an existing scene.
  45100. * See http://doc.babylonjs.com/how_to/webvr_helper
  45101. */
  45102. export class VRExperienceHelper {
  45103. /** Options to modify the vr experience helper's behavior. */
  45104. webVROptions: VRExperienceHelperOptions;
  45105. private _scene;
  45106. private _position;
  45107. private _btnVR;
  45108. private _btnVRDisplayed;
  45109. private _webVRsupported;
  45110. private _webVRready;
  45111. private _webVRrequesting;
  45112. private _webVRpresenting;
  45113. private _hasEnteredVR;
  45114. private _fullscreenVRpresenting;
  45115. private _inputElement;
  45116. private _webVRCamera;
  45117. private _vrDeviceOrientationCamera;
  45118. private _deviceOrientationCamera;
  45119. private _existingCamera;
  45120. private _onKeyDown;
  45121. private _onVrDisplayPresentChange;
  45122. private _onVRDisplayChanged;
  45123. private _onVRRequestPresentStart;
  45124. private _onVRRequestPresentComplete;
  45125. /**
  45126. * 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)
  45127. */
  45128. enableGazeEvenWhenNoPointerLock: boolean;
  45129. /**
  45130. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45131. */
  45132. exitVROnDoubleTap: boolean;
  45133. /**
  45134. * Observable raised right before entering VR.
  45135. */
  45136. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45137. /**
  45138. * Observable raised when entering VR has completed.
  45139. */
  45140. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45141. /**
  45142. * Observable raised when exiting VR.
  45143. */
  45144. onExitingVRObservable: Observable<VRExperienceHelper>;
  45145. /**
  45146. * Observable raised when controller mesh is loaded.
  45147. */
  45148. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45149. /** Return this.onEnteringVRObservable
  45150. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45151. */
  45152. get onEnteringVR(): Observable<VRExperienceHelper>;
  45153. /** Return this.onExitingVRObservable
  45154. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45155. */
  45156. get onExitingVR(): Observable<VRExperienceHelper>;
  45157. /** Return this.onControllerMeshLoadedObservable
  45158. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45159. */
  45160. get onControllerMeshLoaded(): Observable<WebVRController>;
  45161. private _rayLength;
  45162. private _useCustomVRButton;
  45163. private _teleportationRequested;
  45164. private _teleportActive;
  45165. private _floorMeshName;
  45166. private _floorMeshesCollection;
  45167. private _teleportationMode;
  45168. private _teleportationTime;
  45169. private _teleportationSpeed;
  45170. private _teleportationEasing;
  45171. private _rotationAllowed;
  45172. private _teleportBackwardsVector;
  45173. private _teleportationTarget;
  45174. private _isDefaultTeleportationTarget;
  45175. private _postProcessMove;
  45176. private _teleportationFillColor;
  45177. private _teleportationBorderColor;
  45178. private _rotationAngle;
  45179. private _haloCenter;
  45180. private _cameraGazer;
  45181. private _padSensibilityUp;
  45182. private _padSensibilityDown;
  45183. private _leftController;
  45184. private _rightController;
  45185. private _gazeColor;
  45186. private _laserColor;
  45187. private _pickedLaserColor;
  45188. private _pickedGazeColor;
  45189. /**
  45190. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45191. */
  45192. onNewMeshSelected: Observable<AbstractMesh>;
  45193. /**
  45194. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45195. * This observable will provide the mesh and the controller used to select the mesh
  45196. */
  45197. onMeshSelectedWithController: Observable<{
  45198. mesh: AbstractMesh;
  45199. controller: WebVRController;
  45200. }>;
  45201. /**
  45202. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45203. */
  45204. onNewMeshPicked: Observable<PickingInfo>;
  45205. private _circleEase;
  45206. /**
  45207. * Observable raised before camera teleportation
  45208. */
  45209. onBeforeCameraTeleport: Observable<Vector3>;
  45210. /**
  45211. * Observable raised after camera teleportation
  45212. */
  45213. onAfterCameraTeleport: Observable<Vector3>;
  45214. /**
  45215. * Observable raised when current selected mesh gets unselected
  45216. */
  45217. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45218. private _raySelectionPredicate;
  45219. /**
  45220. * To be optionaly changed by user to define custom ray selection
  45221. */
  45222. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45223. /**
  45224. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45225. */
  45226. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45227. /**
  45228. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45229. */
  45230. teleportationEnabled: boolean;
  45231. private _defaultHeight;
  45232. private _teleportationInitialized;
  45233. private _interactionsEnabled;
  45234. private _interactionsRequested;
  45235. private _displayGaze;
  45236. private _displayLaserPointer;
  45237. /**
  45238. * The mesh used to display where the user is going to teleport.
  45239. */
  45240. get teleportationTarget(): Mesh;
  45241. /**
  45242. * Sets the mesh to be used to display where the user is going to teleport.
  45243. */
  45244. set teleportationTarget(value: Mesh);
  45245. /**
  45246. * 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
  45247. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45248. * See http://doc.babylonjs.com/resources/baking_transformations
  45249. */
  45250. get gazeTrackerMesh(): Mesh;
  45251. set gazeTrackerMesh(value: Mesh);
  45252. /**
  45253. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45254. */
  45255. updateGazeTrackerScale: boolean;
  45256. /**
  45257. * If the gaze trackers color should be updated when selecting meshes
  45258. */
  45259. updateGazeTrackerColor: boolean;
  45260. /**
  45261. * If the controller laser color should be updated when selecting meshes
  45262. */
  45263. updateControllerLaserColor: boolean;
  45264. /**
  45265. * The gaze tracking mesh corresponding to the left controller
  45266. */
  45267. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45268. /**
  45269. * The gaze tracking mesh corresponding to the right controller
  45270. */
  45271. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45272. /**
  45273. * If the ray of the gaze should be displayed.
  45274. */
  45275. get displayGaze(): boolean;
  45276. /**
  45277. * Sets if the ray of the gaze should be displayed.
  45278. */
  45279. set displayGaze(value: boolean);
  45280. /**
  45281. * If the ray of the LaserPointer should be displayed.
  45282. */
  45283. get displayLaserPointer(): boolean;
  45284. /**
  45285. * Sets if the ray of the LaserPointer should be displayed.
  45286. */
  45287. set displayLaserPointer(value: boolean);
  45288. /**
  45289. * The deviceOrientationCamera used as the camera when not in VR.
  45290. */
  45291. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45292. /**
  45293. * Based on the current WebVR support, returns the current VR camera used.
  45294. */
  45295. get currentVRCamera(): Nullable<Camera>;
  45296. /**
  45297. * The webVRCamera which is used when in VR.
  45298. */
  45299. get webVRCamera(): WebVRFreeCamera;
  45300. /**
  45301. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45302. */
  45303. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45304. /**
  45305. * The html button that is used to trigger entering into VR.
  45306. */
  45307. get vrButton(): Nullable<HTMLButtonElement>;
  45308. private get _teleportationRequestInitiated();
  45309. /**
  45310. * Defines whether or not Pointer lock should be requested when switching to
  45311. * full screen.
  45312. */
  45313. requestPointerLockOnFullScreen: boolean;
  45314. /**
  45315. * If asking to force XR, this will be populated with the default xr experience
  45316. */
  45317. xr: WebXRDefaultExperience;
  45318. /**
  45319. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45320. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45321. */
  45322. xrTestDone: boolean;
  45323. /**
  45324. * Instantiates a VRExperienceHelper.
  45325. * Helps to quickly add VR support to an existing scene.
  45326. * @param scene The scene the VRExperienceHelper belongs to.
  45327. * @param webVROptions Options to modify the vr experience helper's behavior.
  45328. */
  45329. constructor(scene: Scene,
  45330. /** Options to modify the vr experience helper's behavior. */
  45331. webVROptions?: VRExperienceHelperOptions);
  45332. private completeVRInit;
  45333. private _onDefaultMeshLoaded;
  45334. private _onResize;
  45335. private _onFullscreenChange;
  45336. /**
  45337. * Gets a value indicating if we are currently in VR mode.
  45338. */
  45339. get isInVRMode(): boolean;
  45340. private onVrDisplayPresentChange;
  45341. private onVRDisplayChanged;
  45342. private moveButtonToBottomRight;
  45343. private displayVRButton;
  45344. private updateButtonVisibility;
  45345. private _cachedAngularSensibility;
  45346. /**
  45347. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45348. * Otherwise, will use the fullscreen API.
  45349. */
  45350. enterVR(): void;
  45351. /**
  45352. * Attempt to exit VR, or fullscreen.
  45353. */
  45354. exitVR(): void;
  45355. /**
  45356. * The position of the vr experience helper.
  45357. */
  45358. get position(): Vector3;
  45359. /**
  45360. * Sets the position of the vr experience helper.
  45361. */
  45362. set position(value: Vector3);
  45363. /**
  45364. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45365. */
  45366. enableInteractions(): void;
  45367. private get _noControllerIsActive();
  45368. private beforeRender;
  45369. private _isTeleportationFloor;
  45370. /**
  45371. * Adds a floor mesh to be used for teleportation.
  45372. * @param floorMesh the mesh to be used for teleportation.
  45373. */
  45374. addFloorMesh(floorMesh: Mesh): void;
  45375. /**
  45376. * Removes a floor mesh from being used for teleportation.
  45377. * @param floorMesh the mesh to be removed.
  45378. */
  45379. removeFloorMesh(floorMesh: Mesh): void;
  45380. /**
  45381. * Enables interactions and teleportation using the VR controllers and gaze.
  45382. * @param vrTeleportationOptions options to modify teleportation behavior.
  45383. */
  45384. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45385. private _onNewGamepadConnected;
  45386. private _tryEnableInteractionOnController;
  45387. private _onNewGamepadDisconnected;
  45388. private _enableInteractionOnController;
  45389. private _checkTeleportWithRay;
  45390. private _checkRotate;
  45391. private _checkTeleportBackwards;
  45392. private _enableTeleportationOnController;
  45393. private _createTeleportationCircles;
  45394. private _displayTeleportationTarget;
  45395. private _hideTeleportationTarget;
  45396. private _rotateCamera;
  45397. private _moveTeleportationSelectorTo;
  45398. private _workingVector;
  45399. private _workingQuaternion;
  45400. private _workingMatrix;
  45401. /**
  45402. * Time Constant Teleportation Mode
  45403. */
  45404. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45405. /**
  45406. * Speed Constant Teleportation Mode
  45407. */
  45408. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45409. /**
  45410. * Teleports the users feet to the desired location
  45411. * @param location The location where the user's feet should be placed
  45412. */
  45413. teleportCamera(location: Vector3): void;
  45414. private _convertNormalToDirectionOfRay;
  45415. private _castRayAndSelectObject;
  45416. private _notifySelectedMeshUnselected;
  45417. /**
  45418. * Permanently set new colors for the laser pointer
  45419. * @param color the new laser color
  45420. * @param pickedColor the new laser color when picked mesh detected
  45421. */
  45422. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45423. /**
  45424. * Set lighting enabled / disabled on the laser pointer of both controllers
  45425. * @param enabled should the lighting be enabled on the laser pointer
  45426. */
  45427. setLaserLightingState(enabled?: boolean): void;
  45428. /**
  45429. * Permanently set new colors for the gaze pointer
  45430. * @param color the new gaze color
  45431. * @param pickedColor the new gaze color when picked mesh detected
  45432. */
  45433. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45434. /**
  45435. * Sets the color of the laser ray from the vr controllers.
  45436. * @param color new color for the ray.
  45437. */
  45438. changeLaserColor(color: Color3): void;
  45439. /**
  45440. * Sets the color of the ray from the vr headsets gaze.
  45441. * @param color new color for the ray.
  45442. */
  45443. changeGazeColor(color: Color3): void;
  45444. /**
  45445. * Exits VR and disposes of the vr experience helper
  45446. */
  45447. dispose(): void;
  45448. /**
  45449. * Gets the name of the VRExperienceHelper class
  45450. * @returns "VRExperienceHelper"
  45451. */
  45452. getClassName(): string;
  45453. }
  45454. }
  45455. declare module BABYLON {
  45456. /**
  45457. * Contains an array of blocks representing the octree
  45458. */
  45459. export interface IOctreeContainer<T> {
  45460. /**
  45461. * Blocks within the octree
  45462. */
  45463. blocks: Array<OctreeBlock<T>>;
  45464. }
  45465. /**
  45466. * Class used to store a cell in an octree
  45467. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45468. */
  45469. export class OctreeBlock<T> {
  45470. /**
  45471. * Gets the content of the current block
  45472. */
  45473. entries: T[];
  45474. /**
  45475. * Gets the list of block children
  45476. */
  45477. blocks: Array<OctreeBlock<T>>;
  45478. private _depth;
  45479. private _maxDepth;
  45480. private _capacity;
  45481. private _minPoint;
  45482. private _maxPoint;
  45483. private _boundingVectors;
  45484. private _creationFunc;
  45485. /**
  45486. * Creates a new block
  45487. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45488. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45489. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45490. * @param depth defines the current depth of this block in the octree
  45491. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45492. * @param creationFunc defines a callback to call when an element is added to the block
  45493. */
  45494. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45495. /**
  45496. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45497. */
  45498. get capacity(): number;
  45499. /**
  45500. * Gets the minimum vector (in world space) of the block's bounding box
  45501. */
  45502. get minPoint(): Vector3;
  45503. /**
  45504. * Gets the maximum vector (in world space) of the block's bounding box
  45505. */
  45506. get maxPoint(): Vector3;
  45507. /**
  45508. * Add a new element to this block
  45509. * @param entry defines the element to add
  45510. */
  45511. addEntry(entry: T): void;
  45512. /**
  45513. * Remove an element from this block
  45514. * @param entry defines the element to remove
  45515. */
  45516. removeEntry(entry: T): void;
  45517. /**
  45518. * Add an array of elements to this block
  45519. * @param entries defines the array of elements to add
  45520. */
  45521. addEntries(entries: T[]): void;
  45522. /**
  45523. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45524. * @param frustumPlanes defines the frustum planes to test
  45525. * @param selection defines the array to store current content if selection is positive
  45526. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45527. */
  45528. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45529. /**
  45530. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45531. * @param sphereCenter defines the bounding sphere center
  45532. * @param sphereRadius defines the bounding sphere radius
  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. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45537. /**
  45538. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45539. * @param ray defines the ray to test with
  45540. * @param selection defines the array to store current content if selection is positive
  45541. */
  45542. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45543. /**
  45544. * Subdivide the content into child blocks (this block will then be empty)
  45545. */
  45546. createInnerBlocks(): void;
  45547. /**
  45548. * @hidden
  45549. */
  45550. 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;
  45551. }
  45552. }
  45553. declare module BABYLON {
  45554. /**
  45555. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45556. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45557. */
  45558. export class Octree<T> {
  45559. /** 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.) */
  45560. maxDepth: number;
  45561. /**
  45562. * Blocks within the octree containing objects
  45563. */
  45564. blocks: Array<OctreeBlock<T>>;
  45565. /**
  45566. * Content stored in the octree
  45567. */
  45568. dynamicContent: T[];
  45569. private _maxBlockCapacity;
  45570. private _selectionContent;
  45571. private _creationFunc;
  45572. /**
  45573. * Creates a octree
  45574. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45575. * @param creationFunc function to be used to instatiate the octree
  45576. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45577. * @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.)
  45578. */
  45579. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45580. /** 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.) */
  45581. maxDepth?: number);
  45582. /**
  45583. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45584. * @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);
  45585. * @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);
  45586. * @param entries meshes to be added to the octree blocks
  45587. */
  45588. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45589. /**
  45590. * Adds a mesh to the octree
  45591. * @param entry Mesh to add to the octree
  45592. */
  45593. addMesh(entry: T): void;
  45594. /**
  45595. * Remove an element from the octree
  45596. * @param entry defines the element to remove
  45597. */
  45598. removeMesh(entry: T): void;
  45599. /**
  45600. * Selects an array of meshes within the frustum
  45601. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45602. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45603. * @returns array of meshes within the frustum
  45604. */
  45605. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45606. /**
  45607. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45608. * @param sphereCenter defines the bounding sphere center
  45609. * @param sphereRadius defines the bounding sphere radius
  45610. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45611. * @returns an array of objects that intersect the sphere
  45612. */
  45613. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45614. /**
  45615. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45616. * @param ray defines the ray to test with
  45617. * @returns array of intersected objects
  45618. */
  45619. intersectsRay(ray: Ray): SmartArray<T>;
  45620. /**
  45621. * Adds a mesh into the octree block if it intersects the block
  45622. */
  45623. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45624. /**
  45625. * Adds a submesh into the octree block if it intersects the block
  45626. */
  45627. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45628. }
  45629. }
  45630. declare module BABYLON {
  45631. interface Scene {
  45632. /**
  45633. * @hidden
  45634. * Backing Filed
  45635. */
  45636. _selectionOctree: Octree<AbstractMesh>;
  45637. /**
  45638. * Gets the octree used to boost mesh selection (picking)
  45639. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45640. */
  45641. selectionOctree: Octree<AbstractMesh>;
  45642. /**
  45643. * Creates or updates the octree used to boost selection (picking)
  45644. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45645. * @param maxCapacity defines the maximum capacity per leaf
  45646. * @param maxDepth defines the maximum depth of the octree
  45647. * @returns an octree of AbstractMesh
  45648. */
  45649. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45650. }
  45651. interface AbstractMesh {
  45652. /**
  45653. * @hidden
  45654. * Backing Field
  45655. */
  45656. _submeshesOctree: Octree<SubMesh>;
  45657. /**
  45658. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45659. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45660. * @param maxCapacity defines the maximum size of each block (64 by default)
  45661. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45662. * @returns the new octree
  45663. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45665. */
  45666. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45667. }
  45668. /**
  45669. * Defines the octree scene component responsible to manage any octrees
  45670. * in a given scene.
  45671. */
  45672. export class OctreeSceneComponent {
  45673. /**
  45674. * The component name help to identify the component in the list of scene components.
  45675. */
  45676. readonly name: string;
  45677. /**
  45678. * The scene the component belongs to.
  45679. */
  45680. scene: Scene;
  45681. /**
  45682. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45683. */
  45684. readonly checksIsEnabled: boolean;
  45685. /**
  45686. * Creates a new instance of the component for the given scene
  45687. * @param scene Defines the scene to register the component in
  45688. */
  45689. constructor(scene: Scene);
  45690. /**
  45691. * Registers the component in a given scene
  45692. */
  45693. register(): void;
  45694. /**
  45695. * Return the list of active meshes
  45696. * @returns the list of active meshes
  45697. */
  45698. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45699. /**
  45700. * Return the list of active sub meshes
  45701. * @param mesh The mesh to get the candidates sub meshes from
  45702. * @returns the list of active sub meshes
  45703. */
  45704. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45705. private _tempRay;
  45706. /**
  45707. * Return the list of sub meshes intersecting with a given local ray
  45708. * @param mesh defines the mesh to find the submesh for
  45709. * @param localRay defines the ray in local space
  45710. * @returns the list of intersecting sub meshes
  45711. */
  45712. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45713. /**
  45714. * Return the list of sub meshes colliding with a collider
  45715. * @param mesh defines the mesh to find the submesh for
  45716. * @param collider defines the collider to evaluate the collision against
  45717. * @returns the list of colliding sub meshes
  45718. */
  45719. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45720. /**
  45721. * Rebuilds the elements related to this component in case of
  45722. * context lost for instance.
  45723. */
  45724. rebuild(): void;
  45725. /**
  45726. * Disposes the component and the associated ressources.
  45727. */
  45728. dispose(): void;
  45729. }
  45730. }
  45731. declare module BABYLON {
  45732. /**
  45733. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45734. */
  45735. export class Gizmo implements IDisposable {
  45736. /** The utility layer the gizmo will be added to */
  45737. gizmoLayer: UtilityLayerRenderer;
  45738. /**
  45739. * The root mesh of the gizmo
  45740. */
  45741. _rootMesh: Mesh;
  45742. private _attachedMesh;
  45743. /**
  45744. * Ratio for the scale of the gizmo (Default: 1)
  45745. */
  45746. scaleRatio: number;
  45747. /**
  45748. * If a custom mesh has been set (Default: false)
  45749. */
  45750. protected _customMeshSet: boolean;
  45751. /**
  45752. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45753. * * When set, interactions will be enabled
  45754. */
  45755. get attachedMesh(): Nullable<AbstractMesh>;
  45756. set attachedMesh(value: Nullable<AbstractMesh>);
  45757. /**
  45758. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45759. * @param mesh The mesh to replace the default mesh of the gizmo
  45760. */
  45761. setCustomMesh(mesh: Mesh): void;
  45762. /**
  45763. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45764. */
  45765. updateGizmoRotationToMatchAttachedMesh: boolean;
  45766. /**
  45767. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45768. */
  45769. updateGizmoPositionToMatchAttachedMesh: boolean;
  45770. /**
  45771. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45772. */
  45773. updateScale: boolean;
  45774. protected _interactionsEnabled: boolean;
  45775. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45776. private _beforeRenderObserver;
  45777. private _tempVector;
  45778. /**
  45779. * Creates a gizmo
  45780. * @param gizmoLayer The utility layer the gizmo will be added to
  45781. */
  45782. constructor(
  45783. /** The utility layer the gizmo will be added to */
  45784. gizmoLayer?: UtilityLayerRenderer);
  45785. /**
  45786. * Updates the gizmo to match the attached mesh's position/rotation
  45787. */
  45788. protected _update(): void;
  45789. /**
  45790. * Disposes of the gizmo
  45791. */
  45792. dispose(): void;
  45793. }
  45794. }
  45795. declare module BABYLON {
  45796. /**
  45797. * Single plane drag gizmo
  45798. */
  45799. export class PlaneDragGizmo extends Gizmo {
  45800. /**
  45801. * Drag behavior responsible for the gizmos dragging interactions
  45802. */
  45803. dragBehavior: PointerDragBehavior;
  45804. private _pointerObserver;
  45805. /**
  45806. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45807. */
  45808. snapDistance: number;
  45809. /**
  45810. * Event that fires each time the gizmo snaps to a new location.
  45811. * * snapDistance is the the change in distance
  45812. */
  45813. onSnapObservable: Observable<{
  45814. snapDistance: number;
  45815. }>;
  45816. private _plane;
  45817. private _coloredMaterial;
  45818. private _hoverMaterial;
  45819. private _isEnabled;
  45820. private _parent;
  45821. /** @hidden */
  45822. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45823. /** @hidden */
  45824. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45825. /**
  45826. * Creates a PlaneDragGizmo
  45827. * @param gizmoLayer The utility layer the gizmo will be added to
  45828. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45829. * @param color The color of the gizmo
  45830. */
  45831. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45832. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45833. /**
  45834. * If the gizmo is enabled
  45835. */
  45836. set isEnabled(value: boolean);
  45837. get isEnabled(): boolean;
  45838. /**
  45839. * Disposes of the gizmo
  45840. */
  45841. dispose(): void;
  45842. }
  45843. }
  45844. declare module BABYLON {
  45845. /**
  45846. * Gizmo that enables dragging a mesh along 3 axis
  45847. */
  45848. export class PositionGizmo extends Gizmo {
  45849. /**
  45850. * Internal gizmo used for interactions on the x axis
  45851. */
  45852. xGizmo: AxisDragGizmo;
  45853. /**
  45854. * Internal gizmo used for interactions on the y axis
  45855. */
  45856. yGizmo: AxisDragGizmo;
  45857. /**
  45858. * Internal gizmo used for interactions on the z axis
  45859. */
  45860. zGizmo: AxisDragGizmo;
  45861. /**
  45862. * Internal gizmo used for interactions on the yz plane
  45863. */
  45864. xPlaneGizmo: PlaneDragGizmo;
  45865. /**
  45866. * Internal gizmo used for interactions on the xz plane
  45867. */
  45868. yPlaneGizmo: PlaneDragGizmo;
  45869. /**
  45870. * Internal gizmo used for interactions on the xy plane
  45871. */
  45872. zPlaneGizmo: PlaneDragGizmo;
  45873. /**
  45874. * private variables
  45875. */
  45876. private _meshAttached;
  45877. private _updateGizmoRotationToMatchAttachedMesh;
  45878. private _snapDistance;
  45879. private _scaleRatio;
  45880. /** Fires an event when any of it's sub gizmos are dragged */
  45881. onDragStartObservable: Observable<unknown>;
  45882. /** Fires an event when any of it's sub gizmos are released from dragging */
  45883. onDragEndObservable: Observable<unknown>;
  45884. /**
  45885. * If set to true, planar drag is enabled
  45886. */
  45887. private _planarGizmoEnabled;
  45888. get attachedMesh(): Nullable<AbstractMesh>;
  45889. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45890. /**
  45891. * Creates a PositionGizmo
  45892. * @param gizmoLayer The utility layer the gizmo will be added to
  45893. */
  45894. constructor(gizmoLayer?: UtilityLayerRenderer);
  45895. /**
  45896. * If the planar drag gizmo is enabled
  45897. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45898. */
  45899. set planarGizmoEnabled(value: boolean);
  45900. get planarGizmoEnabled(): boolean;
  45901. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45902. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45903. /**
  45904. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45905. */
  45906. set snapDistance(value: number);
  45907. get snapDistance(): number;
  45908. /**
  45909. * Ratio for the scale of the gizmo (Default: 1)
  45910. */
  45911. set scaleRatio(value: number);
  45912. get scaleRatio(): number;
  45913. /**
  45914. * Disposes of the gizmo
  45915. */
  45916. dispose(): void;
  45917. /**
  45918. * CustomMeshes are not supported by this gizmo
  45919. * @param mesh The mesh to replace the default mesh of the gizmo
  45920. */
  45921. setCustomMesh(mesh: Mesh): void;
  45922. }
  45923. }
  45924. declare module BABYLON {
  45925. /**
  45926. * Single axis drag gizmo
  45927. */
  45928. export class AxisDragGizmo extends Gizmo {
  45929. /**
  45930. * Drag behavior responsible for the gizmos dragging interactions
  45931. */
  45932. dragBehavior: PointerDragBehavior;
  45933. private _pointerObserver;
  45934. /**
  45935. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45936. */
  45937. snapDistance: number;
  45938. /**
  45939. * Event that fires each time the gizmo snaps to a new location.
  45940. * * snapDistance is the the change in distance
  45941. */
  45942. onSnapObservable: Observable<{
  45943. snapDistance: number;
  45944. }>;
  45945. private _isEnabled;
  45946. private _parent;
  45947. private _arrow;
  45948. private _coloredMaterial;
  45949. private _hoverMaterial;
  45950. /** @hidden */
  45951. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45952. /** @hidden */
  45953. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45954. /**
  45955. * Creates an AxisDragGizmo
  45956. * @param gizmoLayer The utility layer the gizmo will be added to
  45957. * @param dragAxis The axis which the gizmo will be able to drag on
  45958. * @param color The color of the gizmo
  45959. */
  45960. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45961. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45962. /**
  45963. * If the gizmo is enabled
  45964. */
  45965. set isEnabled(value: boolean);
  45966. get isEnabled(): boolean;
  45967. /**
  45968. * Disposes of the gizmo
  45969. */
  45970. dispose(): void;
  45971. }
  45972. }
  45973. declare module BABYLON.Debug {
  45974. /**
  45975. * The Axes viewer will show 3 axes in a specific point in space
  45976. */
  45977. export class AxesViewer {
  45978. private _xAxis;
  45979. private _yAxis;
  45980. private _zAxis;
  45981. private _scaleLinesFactor;
  45982. private _instanced;
  45983. /**
  45984. * Gets the hosting scene
  45985. */
  45986. scene: Scene;
  45987. /**
  45988. * Gets or sets a number used to scale line length
  45989. */
  45990. scaleLines: number;
  45991. /** Gets the node hierarchy used to render x-axis */
  45992. get xAxis(): TransformNode;
  45993. /** Gets the node hierarchy used to render y-axis */
  45994. get yAxis(): TransformNode;
  45995. /** Gets the node hierarchy used to render z-axis */
  45996. get zAxis(): TransformNode;
  45997. /**
  45998. * Creates a new AxesViewer
  45999. * @param scene defines the hosting scene
  46000. * @param scaleLines defines a number used to scale line length (1 by default)
  46001. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46002. * @param xAxis defines the node hierarchy used to render the x-axis
  46003. * @param yAxis defines the node hierarchy used to render the y-axis
  46004. * @param zAxis defines the node hierarchy used to render the z-axis
  46005. */
  46006. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46007. /**
  46008. * Force the viewer to update
  46009. * @param position defines the position of the viewer
  46010. * @param xaxis defines the x axis of the viewer
  46011. * @param yaxis defines the y axis of the viewer
  46012. * @param zaxis defines the z axis of the viewer
  46013. */
  46014. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46015. /**
  46016. * Creates an instance of this axes viewer.
  46017. * @returns a new axes viewer with instanced meshes
  46018. */
  46019. createInstance(): AxesViewer;
  46020. /** Releases resources */
  46021. dispose(): void;
  46022. private static _SetRenderingGroupId;
  46023. }
  46024. }
  46025. declare module BABYLON.Debug {
  46026. /**
  46027. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46028. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46029. */
  46030. export class BoneAxesViewer extends AxesViewer {
  46031. /**
  46032. * Gets or sets the target mesh where to display the axes viewer
  46033. */
  46034. mesh: Nullable<Mesh>;
  46035. /**
  46036. * Gets or sets the target bone where to display the axes viewer
  46037. */
  46038. bone: Nullable<Bone>;
  46039. /** Gets current position */
  46040. pos: Vector3;
  46041. /** Gets direction of X axis */
  46042. xaxis: Vector3;
  46043. /** Gets direction of Y axis */
  46044. yaxis: Vector3;
  46045. /** Gets direction of Z axis */
  46046. zaxis: Vector3;
  46047. /**
  46048. * Creates a new BoneAxesViewer
  46049. * @param scene defines the hosting scene
  46050. * @param bone defines the target bone
  46051. * @param mesh defines the target mesh
  46052. * @param scaleLines defines a scaling factor for line length (1 by default)
  46053. */
  46054. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46055. /**
  46056. * Force the viewer to update
  46057. */
  46058. update(): void;
  46059. /** Releases resources */
  46060. dispose(): void;
  46061. }
  46062. }
  46063. declare module BABYLON {
  46064. /**
  46065. * Interface used to define scene explorer extensibility option
  46066. */
  46067. export interface IExplorerExtensibilityOption {
  46068. /**
  46069. * Define the option label
  46070. */
  46071. label: string;
  46072. /**
  46073. * Defines the action to execute on click
  46074. */
  46075. action: (entity: any) => void;
  46076. }
  46077. /**
  46078. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46079. */
  46080. export interface IExplorerExtensibilityGroup {
  46081. /**
  46082. * Defines a predicate to test if a given type mut be extended
  46083. */
  46084. predicate: (entity: any) => boolean;
  46085. /**
  46086. * Gets the list of options added to a type
  46087. */
  46088. entries: IExplorerExtensibilityOption[];
  46089. }
  46090. /**
  46091. * Interface used to define the options to use to create the Inspector
  46092. */
  46093. export interface IInspectorOptions {
  46094. /**
  46095. * Display in overlay mode (default: false)
  46096. */
  46097. overlay?: boolean;
  46098. /**
  46099. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46100. */
  46101. globalRoot?: HTMLElement;
  46102. /**
  46103. * Display the Scene explorer
  46104. */
  46105. showExplorer?: boolean;
  46106. /**
  46107. * Display the property inspector
  46108. */
  46109. showInspector?: boolean;
  46110. /**
  46111. * Display in embed mode (both panes on the right)
  46112. */
  46113. embedMode?: boolean;
  46114. /**
  46115. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46116. */
  46117. handleResize?: boolean;
  46118. /**
  46119. * Allow the panes to popup (default: true)
  46120. */
  46121. enablePopup?: boolean;
  46122. /**
  46123. * Allow the panes to be closed by users (default: true)
  46124. */
  46125. enableClose?: boolean;
  46126. /**
  46127. * Optional list of extensibility entries
  46128. */
  46129. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46130. /**
  46131. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46132. */
  46133. inspectorURL?: string;
  46134. /**
  46135. * Optional initial tab (default to DebugLayerTab.Properties)
  46136. */
  46137. initialTab?: DebugLayerTab;
  46138. }
  46139. interface Scene {
  46140. /**
  46141. * @hidden
  46142. * Backing field
  46143. */
  46144. _debugLayer: DebugLayer;
  46145. /**
  46146. * Gets the debug layer (aka Inspector) associated with the scene
  46147. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46148. */
  46149. debugLayer: DebugLayer;
  46150. }
  46151. /**
  46152. * Enum of inspector action tab
  46153. */
  46154. export enum DebugLayerTab {
  46155. /**
  46156. * Properties tag (default)
  46157. */
  46158. Properties = 0,
  46159. /**
  46160. * Debug tab
  46161. */
  46162. Debug = 1,
  46163. /**
  46164. * Statistics tab
  46165. */
  46166. Statistics = 2,
  46167. /**
  46168. * Tools tab
  46169. */
  46170. Tools = 3,
  46171. /**
  46172. * Settings tab
  46173. */
  46174. Settings = 4
  46175. }
  46176. /**
  46177. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46178. * what is happening in your scene
  46179. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46180. */
  46181. export class DebugLayer {
  46182. /**
  46183. * Define the url to get the inspector script from.
  46184. * By default it uses the babylonjs CDN.
  46185. * @ignoreNaming
  46186. */
  46187. static InspectorURL: string;
  46188. private _scene;
  46189. private BJSINSPECTOR;
  46190. private _onPropertyChangedObservable?;
  46191. /**
  46192. * Observable triggered when a property is changed through the inspector.
  46193. */
  46194. get onPropertyChangedObservable(): any;
  46195. /**
  46196. * Instantiates a new debug layer.
  46197. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46198. * what is happening in your scene
  46199. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46200. * @param scene Defines the scene to inspect
  46201. */
  46202. constructor(scene: Scene);
  46203. /** Creates the inspector window. */
  46204. private _createInspector;
  46205. /**
  46206. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46207. * @param entity defines the entity to select
  46208. * @param lineContainerTitle defines the specific block to highlight
  46209. */
  46210. select(entity: any, lineContainerTitle?: string): void;
  46211. /** Get the inspector from bundle or global */
  46212. private _getGlobalInspector;
  46213. /**
  46214. * Get if the inspector is visible or not.
  46215. * @returns true if visible otherwise, false
  46216. */
  46217. isVisible(): boolean;
  46218. /**
  46219. * Hide the inspector and close its window.
  46220. */
  46221. hide(): void;
  46222. /**
  46223. * Launch the debugLayer.
  46224. * @param config Define the configuration of the inspector
  46225. * @return a promise fulfilled when the debug layer is visible
  46226. */
  46227. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46228. }
  46229. }
  46230. declare module BABYLON {
  46231. /**
  46232. * Class containing static functions to help procedurally build meshes
  46233. */
  46234. export class BoxBuilder {
  46235. /**
  46236. * Creates a box mesh
  46237. * * The parameter `size` sets the size (float) of each box side (default 1)
  46238. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46239. * * 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)
  46240. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46242. * * 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
  46243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46244. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46245. * @param name defines the name of the mesh
  46246. * @param options defines the options used to create the mesh
  46247. * @param scene defines the hosting scene
  46248. * @returns the box mesh
  46249. */
  46250. static CreateBox(name: string, options: {
  46251. size?: number;
  46252. width?: number;
  46253. height?: number;
  46254. depth?: number;
  46255. faceUV?: Vector4[];
  46256. faceColors?: Color4[];
  46257. sideOrientation?: number;
  46258. frontUVs?: Vector4;
  46259. backUVs?: Vector4;
  46260. wrap?: boolean;
  46261. topBaseAt?: number;
  46262. bottomBaseAt?: number;
  46263. updatable?: boolean;
  46264. }, scene?: Nullable<Scene>): Mesh;
  46265. }
  46266. }
  46267. declare module BABYLON.Debug {
  46268. /**
  46269. * Used to show the physics impostor around the specific mesh
  46270. */
  46271. export class PhysicsViewer {
  46272. /** @hidden */
  46273. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46274. /** @hidden */
  46275. protected _meshes: Array<Nullable<AbstractMesh>>;
  46276. /** @hidden */
  46277. protected _scene: Nullable<Scene>;
  46278. /** @hidden */
  46279. protected _numMeshes: number;
  46280. /** @hidden */
  46281. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46282. private _renderFunction;
  46283. private _utilityLayer;
  46284. private _debugBoxMesh;
  46285. private _debugSphereMesh;
  46286. private _debugCylinderMesh;
  46287. private _debugMaterial;
  46288. private _debugMeshMeshes;
  46289. /**
  46290. * Creates a new PhysicsViewer
  46291. * @param scene defines the hosting scene
  46292. */
  46293. constructor(scene: Scene);
  46294. /** @hidden */
  46295. protected _updateDebugMeshes(): void;
  46296. /**
  46297. * Renders a specified physic impostor
  46298. * @param impostor defines the impostor to render
  46299. * @param targetMesh defines the mesh represented by the impostor
  46300. * @returns the new debug mesh used to render the impostor
  46301. */
  46302. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46303. /**
  46304. * Hides a specified physic impostor
  46305. * @param impostor defines the impostor to hide
  46306. */
  46307. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46308. private _getDebugMaterial;
  46309. private _getDebugBoxMesh;
  46310. private _getDebugSphereMesh;
  46311. private _getDebugCylinderMesh;
  46312. private _getDebugMeshMesh;
  46313. private _getDebugMesh;
  46314. /** Releases all resources */
  46315. dispose(): void;
  46316. }
  46317. }
  46318. declare module BABYLON {
  46319. /**
  46320. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46321. * in order to better appreciate the issue one might have.
  46322. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46323. */
  46324. export class RayHelper {
  46325. /**
  46326. * Defines the ray we are currently tryin to visualize.
  46327. */
  46328. ray: Nullable<Ray>;
  46329. private _renderPoints;
  46330. private _renderLine;
  46331. private _renderFunction;
  46332. private _scene;
  46333. private _updateToMeshFunction;
  46334. private _attachedToMesh;
  46335. private _meshSpaceDirection;
  46336. private _meshSpaceOrigin;
  46337. /**
  46338. * Helper function to create a colored helper in a scene in one line.
  46339. * @param ray Defines the ray we are currently tryin to visualize
  46340. * @param scene Defines the scene the ray is used in
  46341. * @param color Defines the color we want to see the ray in
  46342. * @returns The newly created ray helper.
  46343. */
  46344. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46345. /**
  46346. * Instantiate a new ray helper.
  46347. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46348. * in order to better appreciate the issue one might have.
  46349. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46350. * @param ray Defines the ray we are currently tryin to visualize
  46351. */
  46352. constructor(ray: Ray);
  46353. /**
  46354. * Shows the ray we are willing to debug.
  46355. * @param scene Defines the scene the ray needs to be rendered in
  46356. * @param color Defines the color the ray needs to be rendered in
  46357. */
  46358. show(scene: Scene, color?: Color3): void;
  46359. /**
  46360. * Hides the ray we are debugging.
  46361. */
  46362. hide(): void;
  46363. private _render;
  46364. /**
  46365. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46366. * @param mesh Defines the mesh we want the helper attached to
  46367. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46368. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46369. * @param length Defines the length of the ray
  46370. */
  46371. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46372. /**
  46373. * Detach the ray helper from the mesh it has previously been attached to.
  46374. */
  46375. detachFromMesh(): void;
  46376. private _updateToMesh;
  46377. /**
  46378. * Dispose the helper and release its associated resources.
  46379. */
  46380. dispose(): void;
  46381. }
  46382. }
  46383. declare module BABYLON.Debug {
  46384. /**
  46385. * Class used to render a debug view of a given skeleton
  46386. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46387. */
  46388. export class SkeletonViewer {
  46389. /** defines the skeleton to render */
  46390. skeleton: Skeleton;
  46391. /** defines the mesh attached to the skeleton */
  46392. mesh: AbstractMesh;
  46393. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46394. autoUpdateBonesMatrices: boolean;
  46395. /** defines the rendering group id to use with the viewer */
  46396. renderingGroupId: number;
  46397. /** Gets or sets the color used to render the skeleton */
  46398. color: Color3;
  46399. private _scene;
  46400. private _debugLines;
  46401. private _debugMesh;
  46402. private _isEnabled;
  46403. private _renderFunction;
  46404. private _utilityLayer;
  46405. /**
  46406. * Returns the mesh used to render the bones
  46407. */
  46408. get debugMesh(): Nullable<LinesMesh>;
  46409. /**
  46410. * Creates a new SkeletonViewer
  46411. * @param skeleton defines the skeleton to render
  46412. * @param mesh defines the mesh attached to the skeleton
  46413. * @param scene defines the hosting scene
  46414. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46415. * @param renderingGroupId defines the rendering group id to use with the viewer
  46416. */
  46417. constructor(
  46418. /** defines the skeleton to render */
  46419. skeleton: Skeleton,
  46420. /** defines the mesh attached to the skeleton */
  46421. mesh: AbstractMesh, scene: Scene,
  46422. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46423. autoUpdateBonesMatrices?: boolean,
  46424. /** defines the rendering group id to use with the viewer */
  46425. renderingGroupId?: number);
  46426. /** Gets or sets a boolean indicating if the viewer is enabled */
  46427. set isEnabled(value: boolean);
  46428. get isEnabled(): boolean;
  46429. private _getBonePosition;
  46430. private _getLinesForBonesWithLength;
  46431. private _getLinesForBonesNoLength;
  46432. /** Update the viewer to sync with current skeleton state */
  46433. update(): void;
  46434. /** Release associated resources */
  46435. dispose(): void;
  46436. }
  46437. }
  46438. declare module BABYLON {
  46439. /**
  46440. * Options to create the null engine
  46441. */
  46442. export class NullEngineOptions {
  46443. /**
  46444. * Render width (Default: 512)
  46445. */
  46446. renderWidth: number;
  46447. /**
  46448. * Render height (Default: 256)
  46449. */
  46450. renderHeight: number;
  46451. /**
  46452. * Texture size (Default: 512)
  46453. */
  46454. textureSize: number;
  46455. /**
  46456. * If delta time between frames should be constant
  46457. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46458. */
  46459. deterministicLockstep: boolean;
  46460. /**
  46461. * Maximum about of steps between frames (Default: 4)
  46462. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46463. */
  46464. lockstepMaxSteps: number;
  46465. }
  46466. /**
  46467. * The null engine class provides support for headless version of babylon.js.
  46468. * This can be used in server side scenario or for testing purposes
  46469. */
  46470. export class NullEngine extends Engine {
  46471. private _options;
  46472. /**
  46473. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46475. * @returns true if engine is in deterministic lock step mode
  46476. */
  46477. isDeterministicLockStep(): boolean;
  46478. /**
  46479. * Gets the max steps when engine is running in deterministic lock step
  46480. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46481. * @returns the max steps
  46482. */
  46483. getLockstepMaxSteps(): number;
  46484. /**
  46485. * Gets the current hardware scaling level.
  46486. * By default the hardware scaling level is computed from the window device ratio.
  46487. * 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.
  46488. * @returns a number indicating the current hardware scaling level
  46489. */
  46490. getHardwareScalingLevel(): number;
  46491. constructor(options?: NullEngineOptions);
  46492. /**
  46493. * Creates a vertex buffer
  46494. * @param vertices the data for the vertex buffer
  46495. * @returns the new WebGL static buffer
  46496. */
  46497. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46498. /**
  46499. * Creates a new index buffer
  46500. * @param indices defines the content of the index buffer
  46501. * @param updatable defines if the index buffer must be updatable
  46502. * @returns a new webGL buffer
  46503. */
  46504. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46505. /**
  46506. * Clear the current render buffer or the current render target (if any is set up)
  46507. * @param color defines the color to use
  46508. * @param backBuffer defines if the back buffer must be cleared
  46509. * @param depth defines if the depth buffer must be cleared
  46510. * @param stencil defines if the stencil buffer must be cleared
  46511. */
  46512. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46513. /**
  46514. * Gets the current render width
  46515. * @param useScreen defines if screen size must be used (or the current render target if any)
  46516. * @returns a number defining the current render width
  46517. */
  46518. getRenderWidth(useScreen?: boolean): number;
  46519. /**
  46520. * Gets the current render height
  46521. * @param useScreen defines if screen size must be used (or the current render target if any)
  46522. * @returns a number defining the current render height
  46523. */
  46524. getRenderHeight(useScreen?: boolean): number;
  46525. /**
  46526. * Set the WebGL's viewport
  46527. * @param viewport defines the viewport element to be used
  46528. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46529. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46530. */
  46531. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46532. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46533. /**
  46534. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46535. * @param pipelineContext defines the pipeline context to use
  46536. * @param uniformsNames defines the list of uniform names
  46537. * @returns an array of webGL uniform locations
  46538. */
  46539. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46540. /**
  46541. * Gets the lsit of active attributes for a given webGL program
  46542. * @param pipelineContext defines the pipeline context to use
  46543. * @param attributesNames defines the list of attribute names to get
  46544. * @returns an array of indices indicating the offset of each attribute
  46545. */
  46546. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46547. /**
  46548. * Binds an effect to the webGL context
  46549. * @param effect defines the effect to bind
  46550. */
  46551. bindSamplers(effect: Effect): void;
  46552. /**
  46553. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46554. * @param effect defines the effect to activate
  46555. */
  46556. enableEffect(effect: Effect): void;
  46557. /**
  46558. * Set various states to the webGL context
  46559. * @param culling defines backface culling state
  46560. * @param zOffset defines the value to apply to zOffset (0 by default)
  46561. * @param force defines if states must be applied even if cache is up to date
  46562. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46563. */
  46564. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46565. /**
  46566. * Set the value of an uniform to an array of int32
  46567. * @param uniform defines the webGL uniform location where to store the value
  46568. * @param array defines the array of int32 to store
  46569. */
  46570. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46571. /**
  46572. * Set the value of an uniform to an array of int32 (stored as vec2)
  46573. * @param uniform defines the webGL uniform location where to store the value
  46574. * @param array defines the array of int32 to store
  46575. */
  46576. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46577. /**
  46578. * Set the value of an uniform to an array of int32 (stored as vec3)
  46579. * @param uniform defines the webGL uniform location where to store the value
  46580. * @param array defines the array of int32 to store
  46581. */
  46582. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46583. /**
  46584. * Set the value of an uniform to an array of int32 (stored as vec4)
  46585. * @param uniform defines the webGL uniform location where to store the value
  46586. * @param array defines the array of int32 to store
  46587. */
  46588. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46589. /**
  46590. * Set the value of an uniform to an array of float32
  46591. * @param uniform defines the webGL uniform location where to store the value
  46592. * @param array defines the array of float32 to store
  46593. */
  46594. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46595. /**
  46596. * Set the value of an uniform to an array of float32 (stored as vec2)
  46597. * @param uniform defines the webGL uniform location where to store the value
  46598. * @param array defines the array of float32 to store
  46599. */
  46600. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46601. /**
  46602. * Set the value of an uniform to an array of float32 (stored as vec3)
  46603. * @param uniform defines the webGL uniform location where to store the value
  46604. * @param array defines the array of float32 to store
  46605. */
  46606. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46607. /**
  46608. * Set the value of an uniform to an array of float32 (stored as vec4)
  46609. * @param uniform defines the webGL uniform location where to store the value
  46610. * @param array defines the array of float32 to store
  46611. */
  46612. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46613. /**
  46614. * Set the value of an uniform to an array of number
  46615. * @param uniform defines the webGL uniform location where to store the value
  46616. * @param array defines the array of number to store
  46617. */
  46618. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46619. /**
  46620. * Set the value of an uniform to an array of number (stored as vec2)
  46621. * @param uniform defines the webGL uniform location where to store the value
  46622. * @param array defines the array of number to store
  46623. */
  46624. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46625. /**
  46626. * Set the value of an uniform to an array of number (stored as vec3)
  46627. * @param uniform defines the webGL uniform location where to store the value
  46628. * @param array defines the array of number to store
  46629. */
  46630. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46631. /**
  46632. * Set the value of an uniform to an array of number (stored as vec4)
  46633. * @param uniform defines the webGL uniform location where to store the value
  46634. * @param array defines the array of number to store
  46635. */
  46636. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46637. /**
  46638. * Set the value of an uniform to an array of float32 (stored as matrices)
  46639. * @param uniform defines the webGL uniform location where to store the value
  46640. * @param matrices defines the array of float32 to store
  46641. */
  46642. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46643. /**
  46644. * Set the value of an uniform to a matrix (3x3)
  46645. * @param uniform defines the webGL uniform location where to store the value
  46646. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46647. */
  46648. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46649. /**
  46650. * Set the value of an uniform to a matrix (2x2)
  46651. * @param uniform defines the webGL uniform location where to store the value
  46652. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46653. */
  46654. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46655. /**
  46656. * Set the value of an uniform to a number (float)
  46657. * @param uniform defines the webGL uniform location where to store the value
  46658. * @param value defines the float number to store
  46659. */
  46660. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46661. /**
  46662. * Set the value of an uniform to a vec2
  46663. * @param uniform defines the webGL uniform location where to store the value
  46664. * @param x defines the 1st component of the value
  46665. * @param y defines the 2nd component of the value
  46666. */
  46667. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46668. /**
  46669. * Set the value of an uniform to a vec3
  46670. * @param uniform defines the webGL uniform location where to store the value
  46671. * @param x defines the 1st component of the value
  46672. * @param y defines the 2nd component of the value
  46673. * @param z defines the 3rd component of the value
  46674. */
  46675. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46676. /**
  46677. * Set the value of an uniform to a boolean
  46678. * @param uniform defines the webGL uniform location where to store the value
  46679. * @param bool defines the boolean to store
  46680. */
  46681. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46682. /**
  46683. * Set the value of an uniform to a vec4
  46684. * @param uniform defines the webGL uniform location where to store the value
  46685. * @param x defines the 1st component of the value
  46686. * @param y defines the 2nd component of the value
  46687. * @param z defines the 3rd component of the value
  46688. * @param w defines the 4th component of the value
  46689. */
  46690. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46691. /**
  46692. * Sets the current alpha mode
  46693. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46694. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46695. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46696. */
  46697. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46698. /**
  46699. * Bind webGl buffers directly to the webGL context
  46700. * @param vertexBuffers defines the vertex buffer to bind
  46701. * @param indexBuffer defines the index buffer to bind
  46702. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46703. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46704. * @param effect defines the effect associated with the vertex buffer
  46705. */
  46706. bindBuffers(vertexBuffers: {
  46707. [key: string]: VertexBuffer;
  46708. }, indexBuffer: DataBuffer, effect: Effect): void;
  46709. /**
  46710. * Force the entire cache to be cleared
  46711. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46712. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46713. */
  46714. wipeCaches(bruteForce?: boolean): void;
  46715. /**
  46716. * Send a draw order
  46717. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46718. * @param indexStart defines the starting index
  46719. * @param indexCount defines the number of index to draw
  46720. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46721. */
  46722. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46723. /**
  46724. * Draw a list of indexed primitives
  46725. * @param fillMode defines the primitive to use
  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. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46731. /**
  46732. * Draw a list of unindexed primitives
  46733. * @param fillMode defines the primitive to use
  46734. * @param verticesStart defines the index of first vertex to draw
  46735. * @param verticesCount defines the count of vertices to draw
  46736. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46737. */
  46738. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46739. /** @hidden */
  46740. _createTexture(): WebGLTexture;
  46741. /** @hidden */
  46742. _releaseTexture(texture: InternalTexture): void;
  46743. /**
  46744. * Usually called from Texture.ts.
  46745. * Passed information to create a WebGLTexture
  46746. * @param urlArg defines a value which contains one of the following:
  46747. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46748. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46749. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46750. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46751. * @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)
  46752. * @param scene needed for loading to the correct scene
  46753. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46754. * @param onLoad optional callback to be called upon successful completion
  46755. * @param onError optional callback to be called upon failure
  46756. * @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
  46757. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46758. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46759. * @param forcedExtension defines the extension to use to pick the right loader
  46760. * @param mimeType defines an optional mime type
  46761. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46762. */
  46763. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  46764. /**
  46765. * Creates a new render target texture
  46766. * @param size defines the size of the texture
  46767. * @param options defines the options used to create the texture
  46768. * @returns a new render target texture stored in an InternalTexture
  46769. */
  46770. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46771. /**
  46772. * Update the sampling mode of a given texture
  46773. * @param samplingMode defines the required sampling mode
  46774. * @param texture defines the texture to update
  46775. */
  46776. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46777. /**
  46778. * Binds the frame buffer to the specified texture.
  46779. * @param texture The texture to render to or null for the default canvas
  46780. * @param faceIndex The face of the texture to render to in case of cube texture
  46781. * @param requiredWidth The width of the target to render to
  46782. * @param requiredHeight The height of the target to render to
  46783. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46784. * @param lodLevel defines le lod level to bind to the frame buffer
  46785. */
  46786. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46787. /**
  46788. * Unbind the current render target texture from the webGL context
  46789. * @param texture defines the render target texture to unbind
  46790. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46791. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46792. */
  46793. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46794. /**
  46795. * Creates a dynamic vertex buffer
  46796. * @param vertices the data for the dynamic vertex buffer
  46797. * @returns the new WebGL dynamic buffer
  46798. */
  46799. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46800. /**
  46801. * Update the content of a dynamic texture
  46802. * @param texture defines the texture to update
  46803. * @param canvas defines the canvas containing the source
  46804. * @param invertY defines if data must be stored with Y axis inverted
  46805. * @param premulAlpha defines if alpha is stored as premultiplied
  46806. * @param format defines the format of the data
  46807. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46808. */
  46809. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46810. /**
  46811. * Gets a boolean indicating if all created effects are ready
  46812. * @returns true if all effects are ready
  46813. */
  46814. areAllEffectsReady(): boolean;
  46815. /**
  46816. * @hidden
  46817. * Get the current error code of the webGL context
  46818. * @returns the error code
  46819. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46820. */
  46821. getError(): number;
  46822. /** @hidden */
  46823. _getUnpackAlignement(): number;
  46824. /** @hidden */
  46825. _unpackFlipY(value: boolean): void;
  46826. /**
  46827. * Update a dynamic index buffer
  46828. * @param indexBuffer defines the target index buffer
  46829. * @param indices defines the data to update
  46830. * @param offset defines the offset in the target index buffer where update should start
  46831. */
  46832. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46833. /**
  46834. * Updates a dynamic vertex buffer.
  46835. * @param vertexBuffer the vertex buffer to update
  46836. * @param vertices the data used to update the vertex buffer
  46837. * @param byteOffset the byte offset of the data (optional)
  46838. * @param byteLength the byte length of the data (optional)
  46839. */
  46840. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46841. /** @hidden */
  46842. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46843. /** @hidden */
  46844. _bindTexture(channel: number, texture: InternalTexture): void;
  46845. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46846. /**
  46847. * 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
  46848. */
  46849. releaseEffects(): void;
  46850. displayLoadingUI(): void;
  46851. hideLoadingUI(): void;
  46852. /** @hidden */
  46853. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46854. /** @hidden */
  46855. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46856. /** @hidden */
  46857. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46858. /** @hidden */
  46859. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46860. }
  46861. }
  46862. declare module BABYLON {
  46863. /**
  46864. * @hidden
  46865. **/
  46866. export class _TimeToken {
  46867. _startTimeQuery: Nullable<WebGLQuery>;
  46868. _endTimeQuery: Nullable<WebGLQuery>;
  46869. _timeElapsedQuery: Nullable<WebGLQuery>;
  46870. _timeElapsedQueryEnded: boolean;
  46871. }
  46872. }
  46873. declare module BABYLON {
  46874. /** @hidden */
  46875. export class _OcclusionDataStorage {
  46876. /** @hidden */
  46877. occlusionInternalRetryCounter: number;
  46878. /** @hidden */
  46879. isOcclusionQueryInProgress: boolean;
  46880. /** @hidden */
  46881. isOccluded: boolean;
  46882. /** @hidden */
  46883. occlusionRetryCount: number;
  46884. /** @hidden */
  46885. occlusionType: number;
  46886. /** @hidden */
  46887. occlusionQueryAlgorithmType: number;
  46888. }
  46889. interface Engine {
  46890. /**
  46891. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46892. * @return the new query
  46893. */
  46894. createQuery(): WebGLQuery;
  46895. /**
  46896. * Delete and release a webGL query
  46897. * @param query defines the query to delete
  46898. * @return the current engine
  46899. */
  46900. deleteQuery(query: WebGLQuery): Engine;
  46901. /**
  46902. * Check if a given query has resolved and got its value
  46903. * @param query defines the query to check
  46904. * @returns true if the query got its value
  46905. */
  46906. isQueryResultAvailable(query: WebGLQuery): boolean;
  46907. /**
  46908. * Gets the value of a given query
  46909. * @param query defines the query to check
  46910. * @returns the value of the query
  46911. */
  46912. getQueryResult(query: WebGLQuery): number;
  46913. /**
  46914. * Initiates an occlusion query
  46915. * @param algorithmType defines the algorithm to use
  46916. * @param query defines the query to use
  46917. * @returns the current engine
  46918. * @see http://doc.babylonjs.com/features/occlusionquery
  46919. */
  46920. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46921. /**
  46922. * Ends an occlusion query
  46923. * @see http://doc.babylonjs.com/features/occlusionquery
  46924. * @param algorithmType defines the algorithm to use
  46925. * @returns the current engine
  46926. */
  46927. endOcclusionQuery(algorithmType: number): Engine;
  46928. /**
  46929. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46930. * Please note that only one query can be issued at a time
  46931. * @returns a time token used to track the time span
  46932. */
  46933. startTimeQuery(): Nullable<_TimeToken>;
  46934. /**
  46935. * Ends a time query
  46936. * @param token defines the token used to measure the time span
  46937. * @returns the time spent (in ns)
  46938. */
  46939. endTimeQuery(token: _TimeToken): int;
  46940. /** @hidden */
  46941. _currentNonTimestampToken: Nullable<_TimeToken>;
  46942. /** @hidden */
  46943. _createTimeQuery(): WebGLQuery;
  46944. /** @hidden */
  46945. _deleteTimeQuery(query: WebGLQuery): void;
  46946. /** @hidden */
  46947. _getGlAlgorithmType(algorithmType: number): number;
  46948. /** @hidden */
  46949. _getTimeQueryResult(query: WebGLQuery): any;
  46950. /** @hidden */
  46951. _getTimeQueryAvailability(query: WebGLQuery): any;
  46952. }
  46953. interface AbstractMesh {
  46954. /**
  46955. * Backing filed
  46956. * @hidden
  46957. */
  46958. __occlusionDataStorage: _OcclusionDataStorage;
  46959. /**
  46960. * Access property
  46961. * @hidden
  46962. */
  46963. _occlusionDataStorage: _OcclusionDataStorage;
  46964. /**
  46965. * 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.
  46966. * The default value is -1 which means don't break the query and wait till the result
  46967. * @see http://doc.babylonjs.com/features/occlusionquery
  46968. */
  46969. occlusionRetryCount: number;
  46970. /**
  46971. * 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:
  46972. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46973. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46974. * * 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.
  46975. * @see http://doc.babylonjs.com/features/occlusionquery
  46976. */
  46977. occlusionType: number;
  46978. /**
  46979. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46980. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46981. * * 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.
  46982. * @see http://doc.babylonjs.com/features/occlusionquery
  46983. */
  46984. occlusionQueryAlgorithmType: number;
  46985. /**
  46986. * 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
  46987. * @see http://doc.babylonjs.com/features/occlusionquery
  46988. */
  46989. isOccluded: boolean;
  46990. /**
  46991. * Flag to check the progress status of the query
  46992. * @see http://doc.babylonjs.com/features/occlusionquery
  46993. */
  46994. isOcclusionQueryInProgress: boolean;
  46995. }
  46996. }
  46997. declare module BABYLON {
  46998. /** @hidden */
  46999. export var _forceTransformFeedbackToBundle: boolean;
  47000. interface Engine {
  47001. /**
  47002. * Creates a webGL transform feedback object
  47003. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47004. * @returns the webGL transform feedback object
  47005. */
  47006. createTransformFeedback(): WebGLTransformFeedback;
  47007. /**
  47008. * Delete a webGL transform feedback object
  47009. * @param value defines the webGL transform feedback object to delete
  47010. */
  47011. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47012. /**
  47013. * Bind a webGL transform feedback object to the webgl context
  47014. * @param value defines the webGL transform feedback object to bind
  47015. */
  47016. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47017. /**
  47018. * Begins a transform feedback operation
  47019. * @param usePoints defines if points or triangles must be used
  47020. */
  47021. beginTransformFeedback(usePoints: boolean): void;
  47022. /**
  47023. * Ends a transform feedback operation
  47024. */
  47025. endTransformFeedback(): void;
  47026. /**
  47027. * Specify the varyings to use with transform feedback
  47028. * @param program defines the associated webGL program
  47029. * @param value defines the list of strings representing the varying names
  47030. */
  47031. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47032. /**
  47033. * Bind a webGL buffer for a transform feedback operation
  47034. * @param value defines the webGL buffer to bind
  47035. */
  47036. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47037. }
  47038. }
  47039. declare module BABYLON {
  47040. /**
  47041. * Creation options of the multi render target texture.
  47042. */
  47043. export interface IMultiRenderTargetOptions {
  47044. /**
  47045. * Define if the texture needs to create mip maps after render.
  47046. */
  47047. generateMipMaps?: boolean;
  47048. /**
  47049. * Define the types of all the draw buffers we want to create
  47050. */
  47051. types?: number[];
  47052. /**
  47053. * Define the sampling modes of all the draw buffers we want to create
  47054. */
  47055. samplingModes?: number[];
  47056. /**
  47057. * Define if a depth buffer is required
  47058. */
  47059. generateDepthBuffer?: boolean;
  47060. /**
  47061. * Define if a stencil buffer is required
  47062. */
  47063. generateStencilBuffer?: boolean;
  47064. /**
  47065. * Define if a depth texture is required instead of a depth buffer
  47066. */
  47067. generateDepthTexture?: boolean;
  47068. /**
  47069. * Define the number of desired draw buffers
  47070. */
  47071. textureCount?: number;
  47072. /**
  47073. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47074. */
  47075. doNotChangeAspectRatio?: boolean;
  47076. /**
  47077. * Define the default type of the buffers we are creating
  47078. */
  47079. defaultType?: number;
  47080. }
  47081. /**
  47082. * A multi render target, like a render target provides the ability to render to a texture.
  47083. * Unlike the render target, it can render to several draw buffers in one draw.
  47084. * This is specially interesting in deferred rendering or for any effects requiring more than
  47085. * just one color from a single pass.
  47086. */
  47087. export class MultiRenderTarget extends RenderTargetTexture {
  47088. private _internalTextures;
  47089. private _textures;
  47090. private _multiRenderTargetOptions;
  47091. /**
  47092. * Get if draw buffers are currently supported by the used hardware and browser.
  47093. */
  47094. get isSupported(): boolean;
  47095. /**
  47096. * Get the list of textures generated by the multi render target.
  47097. */
  47098. get textures(): Texture[];
  47099. /**
  47100. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47101. */
  47102. get depthTexture(): Texture;
  47103. /**
  47104. * Set the wrapping mode on U of all the textures we are rendering to.
  47105. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47106. */
  47107. set wrapU(wrap: number);
  47108. /**
  47109. * Set the wrapping mode on V of all the textures we are rendering to.
  47110. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47111. */
  47112. set wrapV(wrap: number);
  47113. /**
  47114. * Instantiate a new multi render target texture.
  47115. * A multi render target, like a render target provides the ability to render to a texture.
  47116. * Unlike the render target, it can render to several draw buffers in one draw.
  47117. * This is specially interesting in deferred rendering or for any effects requiring more than
  47118. * just one color from a single pass.
  47119. * @param name Define the name of the texture
  47120. * @param size Define the size of the buffers to render to
  47121. * @param count Define the number of target we are rendering into
  47122. * @param scene Define the scene the texture belongs to
  47123. * @param options Define the options used to create the multi render target
  47124. */
  47125. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47126. /** @hidden */
  47127. _rebuild(): void;
  47128. private _createInternalTextures;
  47129. private _createTextures;
  47130. /**
  47131. * Define the number of samples used if MSAA is enabled.
  47132. */
  47133. get samples(): number;
  47134. set samples(value: number);
  47135. /**
  47136. * Resize all the textures in the multi render target.
  47137. * Be carrefull as it will recreate all the data in the new texture.
  47138. * @param size Define the new size
  47139. */
  47140. resize(size: any): void;
  47141. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47142. /**
  47143. * Dispose the render targets and their associated resources
  47144. */
  47145. dispose(): void;
  47146. /**
  47147. * Release all the underlying texture used as draw buffers.
  47148. */
  47149. releaseInternalTextures(): void;
  47150. }
  47151. }
  47152. declare module BABYLON {
  47153. interface ThinEngine {
  47154. /**
  47155. * Unbind a list of render target textures from the webGL context
  47156. * This is used only when drawBuffer extension or webGL2 are active
  47157. * @param textures defines the render target textures to unbind
  47158. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47159. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47160. */
  47161. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47162. /**
  47163. * Create a multi render target texture
  47164. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47165. * @param size defines the size of the texture
  47166. * @param options defines the creation options
  47167. * @returns the cube texture as an InternalTexture
  47168. */
  47169. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47170. /**
  47171. * Update the sample count for a given multiple render target texture
  47172. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47173. * @param textures defines the textures to update
  47174. * @param samples defines the sample count to set
  47175. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47176. */
  47177. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47178. }
  47179. }
  47180. declare module BABYLON {
  47181. /**
  47182. * Class used to define an additional view for the engine
  47183. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47184. */
  47185. export class EngineView {
  47186. /** Defines the canvas where to render the view */
  47187. target: HTMLCanvasElement;
  47188. /** Defines an optional camera used to render the view (will use active camera else) */
  47189. camera?: Camera;
  47190. }
  47191. interface Engine {
  47192. /**
  47193. * Gets or sets the HTML element to use for attaching events
  47194. */
  47195. inputElement: Nullable<HTMLElement>;
  47196. /**
  47197. * Gets the current engine view
  47198. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47199. */
  47200. activeView: Nullable<EngineView>;
  47201. /** Gets or sets the list of views */
  47202. views: EngineView[];
  47203. /**
  47204. * Register a new child canvas
  47205. * @param canvas defines the canvas to register
  47206. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47207. * @returns the associated view
  47208. */
  47209. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47210. /**
  47211. * Remove a registered child canvas
  47212. * @param canvas defines the canvas to remove
  47213. * @returns the current engine
  47214. */
  47215. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47216. }
  47217. }
  47218. declare module BABYLON {
  47219. /**
  47220. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47221. */
  47222. export interface CubeMapInfo {
  47223. /**
  47224. * The pixel array for the front face.
  47225. * This is stored in format, left to right, up to down format.
  47226. */
  47227. front: Nullable<ArrayBufferView>;
  47228. /**
  47229. * The pixel array for the back face.
  47230. * This is stored in format, left to right, up to down format.
  47231. */
  47232. back: Nullable<ArrayBufferView>;
  47233. /**
  47234. * The pixel array for the left face.
  47235. * This is stored in format, left to right, up to down format.
  47236. */
  47237. left: Nullable<ArrayBufferView>;
  47238. /**
  47239. * The pixel array for the right face.
  47240. * This is stored in format, left to right, up to down format.
  47241. */
  47242. right: Nullable<ArrayBufferView>;
  47243. /**
  47244. * The pixel array for the up face.
  47245. * This is stored in format, left to right, up to down format.
  47246. */
  47247. up: Nullable<ArrayBufferView>;
  47248. /**
  47249. * The pixel array for the down face.
  47250. * This is stored in format, left to right, up to down format.
  47251. */
  47252. down: Nullable<ArrayBufferView>;
  47253. /**
  47254. * The size of the cubemap stored.
  47255. *
  47256. * Each faces will be size * size pixels.
  47257. */
  47258. size: number;
  47259. /**
  47260. * The format of the texture.
  47261. *
  47262. * RGBA, RGB.
  47263. */
  47264. format: number;
  47265. /**
  47266. * The type of the texture data.
  47267. *
  47268. * UNSIGNED_INT, FLOAT.
  47269. */
  47270. type: number;
  47271. /**
  47272. * Specifies whether the texture is in gamma space.
  47273. */
  47274. gammaSpace: boolean;
  47275. }
  47276. /**
  47277. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47278. */
  47279. export class PanoramaToCubeMapTools {
  47280. private static FACE_FRONT;
  47281. private static FACE_BACK;
  47282. private static FACE_RIGHT;
  47283. private static FACE_LEFT;
  47284. private static FACE_DOWN;
  47285. private static FACE_UP;
  47286. /**
  47287. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47288. *
  47289. * @param float32Array The source data.
  47290. * @param inputWidth The width of the input panorama.
  47291. * @param inputHeight The height of the input panorama.
  47292. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47293. * @return The cubemap data
  47294. */
  47295. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47296. private static CreateCubemapTexture;
  47297. private static CalcProjectionSpherical;
  47298. }
  47299. }
  47300. declare module BABYLON {
  47301. /**
  47302. * Helper class dealing with the extraction of spherical polynomial dataArray
  47303. * from a cube map.
  47304. */
  47305. export class CubeMapToSphericalPolynomialTools {
  47306. private static FileFaces;
  47307. /**
  47308. * Converts a texture to the according Spherical Polynomial data.
  47309. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47310. *
  47311. * @param texture The texture to extract the information from.
  47312. * @return The Spherical Polynomial data.
  47313. */
  47314. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47315. /**
  47316. * Converts a cubemap 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 cubeInfo The Cube map to extract the information from.
  47320. * @return The Spherical Polynomial data.
  47321. */
  47322. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47323. }
  47324. }
  47325. declare module BABYLON {
  47326. interface BaseTexture {
  47327. /**
  47328. * Get the polynomial representation of the texture data.
  47329. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47330. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47331. */
  47332. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47333. }
  47334. }
  47335. declare module BABYLON {
  47336. /** @hidden */
  47337. export var rgbdEncodePixelShader: {
  47338. name: string;
  47339. shader: string;
  47340. };
  47341. }
  47342. declare module BABYLON {
  47343. /** @hidden */
  47344. export var rgbdDecodePixelShader: {
  47345. name: string;
  47346. shader: string;
  47347. };
  47348. }
  47349. declare module BABYLON {
  47350. /**
  47351. * Raw texture data and descriptor sufficient for WebGL texture upload
  47352. */
  47353. export interface EnvironmentTextureInfo {
  47354. /**
  47355. * Version of the environment map
  47356. */
  47357. version: number;
  47358. /**
  47359. * Width of image
  47360. */
  47361. width: number;
  47362. /**
  47363. * Irradiance information stored in the file.
  47364. */
  47365. irradiance: any;
  47366. /**
  47367. * Specular information stored in the file.
  47368. */
  47369. specular: any;
  47370. }
  47371. /**
  47372. * Defines One Image in the file. It requires only the position in the file
  47373. * as well as the length.
  47374. */
  47375. interface BufferImageData {
  47376. /**
  47377. * Length of the image data.
  47378. */
  47379. length: number;
  47380. /**
  47381. * Position of the data from the null terminator delimiting the end of the JSON.
  47382. */
  47383. position: number;
  47384. }
  47385. /**
  47386. * Defines the specular data enclosed in the file.
  47387. * This corresponds to the version 1 of the data.
  47388. */
  47389. export interface EnvironmentTextureSpecularInfoV1 {
  47390. /**
  47391. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47392. */
  47393. specularDataPosition?: number;
  47394. /**
  47395. * This contains all the images data needed to reconstruct the cubemap.
  47396. */
  47397. mipmaps: Array<BufferImageData>;
  47398. /**
  47399. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47400. */
  47401. lodGenerationScale: number;
  47402. }
  47403. /**
  47404. * Sets of helpers addressing the serialization and deserialization of environment texture
  47405. * stored in a BabylonJS env file.
  47406. * Those files are usually stored as .env files.
  47407. */
  47408. export class EnvironmentTextureTools {
  47409. /**
  47410. * Magic number identifying the env file.
  47411. */
  47412. private static _MagicBytes;
  47413. /**
  47414. * Gets the environment info from an env file.
  47415. * @param data The array buffer containing the .env bytes.
  47416. * @returns the environment file info (the json header) if successfully parsed.
  47417. */
  47418. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47419. /**
  47420. * Creates an environment texture from a loaded cube texture.
  47421. * @param texture defines the cube texture to convert in env file
  47422. * @return a promise containing the environment data if succesfull.
  47423. */
  47424. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47425. /**
  47426. * Creates a JSON representation of the spherical data.
  47427. * @param texture defines the texture containing the polynomials
  47428. * @return the JSON representation of the spherical info
  47429. */
  47430. private static _CreateEnvTextureIrradiance;
  47431. /**
  47432. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47433. * @param data the image data
  47434. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47435. * @return the views described by info providing access to the underlying buffer
  47436. */
  47437. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47438. /**
  47439. * Uploads the texture info contained in the env file to the GPU.
  47440. * @param texture defines the internal texture to upload to
  47441. * @param data defines the data to load
  47442. * @param info defines the texture info retrieved through the GetEnvInfo method
  47443. * @returns a promise
  47444. */
  47445. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47446. private static _OnImageReadyAsync;
  47447. /**
  47448. * Uploads the levels of image data to the GPU.
  47449. * @param texture defines the internal texture to upload to
  47450. * @param imageData defines the array buffer views of image data [mipmap][face]
  47451. * @returns a promise
  47452. */
  47453. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47454. /**
  47455. * Uploads spherical polynomials information to the texture.
  47456. * @param texture defines the texture we are trying to upload the information to
  47457. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47458. */
  47459. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47460. /** @hidden */
  47461. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47462. }
  47463. }
  47464. declare module BABYLON {
  47465. /**
  47466. * Contains position and normal vectors for a vertex
  47467. */
  47468. export class PositionNormalVertex {
  47469. /** the position of the vertex (defaut: 0,0,0) */
  47470. position: Vector3;
  47471. /** the normal of the vertex (defaut: 0,1,0) */
  47472. normal: Vector3;
  47473. /**
  47474. * Creates a PositionNormalVertex
  47475. * @param position the position of the vertex (defaut: 0,0,0)
  47476. * @param normal the normal of the vertex (defaut: 0,1,0)
  47477. */
  47478. constructor(
  47479. /** the position of the vertex (defaut: 0,0,0) */
  47480. position?: Vector3,
  47481. /** the normal of the vertex (defaut: 0,1,0) */
  47482. normal?: Vector3);
  47483. /**
  47484. * Clones the PositionNormalVertex
  47485. * @returns the cloned PositionNormalVertex
  47486. */
  47487. clone(): PositionNormalVertex;
  47488. }
  47489. /**
  47490. * Contains position, normal and uv vectors for a vertex
  47491. */
  47492. export class PositionNormalTextureVertex {
  47493. /** the position of the vertex (defaut: 0,0,0) */
  47494. position: Vector3;
  47495. /** the normal of the vertex (defaut: 0,1,0) */
  47496. normal: Vector3;
  47497. /** the uv of the vertex (default: 0,0) */
  47498. uv: Vector2;
  47499. /**
  47500. * Creates a PositionNormalTextureVertex
  47501. * @param position the position of the vertex (defaut: 0,0,0)
  47502. * @param normal the normal of the vertex (defaut: 0,1,0)
  47503. * @param uv the uv of the vertex (default: 0,0)
  47504. */
  47505. constructor(
  47506. /** the position of the vertex (defaut: 0,0,0) */
  47507. position?: Vector3,
  47508. /** the normal of the vertex (defaut: 0,1,0) */
  47509. normal?: Vector3,
  47510. /** the uv of the vertex (default: 0,0) */
  47511. uv?: Vector2);
  47512. /**
  47513. * Clones the PositionNormalTextureVertex
  47514. * @returns the cloned PositionNormalTextureVertex
  47515. */
  47516. clone(): PositionNormalTextureVertex;
  47517. }
  47518. }
  47519. declare module BABYLON {
  47520. /** @hidden */
  47521. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47522. private _genericAttributeLocation;
  47523. private _varyingLocationCount;
  47524. private _varyingLocationMap;
  47525. private _replacements;
  47526. private _textureCount;
  47527. private _uniforms;
  47528. lineProcessor(line: string): string;
  47529. attributeProcessor(attribute: string): string;
  47530. varyingProcessor(varying: string, isFragment: boolean): string;
  47531. uniformProcessor(uniform: string): string;
  47532. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47533. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47534. }
  47535. }
  47536. declare module BABYLON {
  47537. /**
  47538. * Container for accessors for natively-stored mesh data buffers.
  47539. */
  47540. class NativeDataBuffer extends DataBuffer {
  47541. /**
  47542. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47543. */
  47544. nativeIndexBuffer?: any;
  47545. /**
  47546. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47547. */
  47548. nativeVertexBuffer?: any;
  47549. }
  47550. /** @hidden */
  47551. class NativeTexture extends InternalTexture {
  47552. getInternalTexture(): InternalTexture;
  47553. getViewCount(): number;
  47554. }
  47555. /** @hidden */
  47556. export class NativeEngine extends Engine {
  47557. private readonly _native;
  47558. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47559. private readonly INVALID_HANDLE;
  47560. getHardwareScalingLevel(): number;
  47561. constructor();
  47562. /**
  47563. * Can be used to override the current requestAnimationFrame requester.
  47564. * @hidden
  47565. */
  47566. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47567. /**
  47568. * Override default engine behavior.
  47569. * @param color
  47570. * @param backBuffer
  47571. * @param depth
  47572. * @param stencil
  47573. */
  47574. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47575. /**
  47576. * Gets host document
  47577. * @returns the host document object
  47578. */
  47579. getHostDocument(): Nullable<Document>;
  47580. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47581. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47582. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47583. recordVertexArrayObject(vertexBuffers: {
  47584. [key: string]: VertexBuffer;
  47585. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47586. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47587. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47588. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47589. /**
  47590. * Draw a list of indexed primitives
  47591. * @param fillMode defines the primitive to use
  47592. * @param indexStart defines the starting index
  47593. * @param indexCount defines the number of index to draw
  47594. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47595. */
  47596. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47597. /**
  47598. * Draw a list of unindexed primitives
  47599. * @param fillMode defines the primitive to use
  47600. * @param verticesStart defines the index of first vertex to draw
  47601. * @param verticesCount defines the count of vertices to draw
  47602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47603. */
  47604. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47605. createPipelineContext(): IPipelineContext;
  47606. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47607. /** @hidden */
  47608. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47609. /** @hidden */
  47610. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47611. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47612. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47613. protected _setProgram(program: WebGLProgram): void;
  47614. _releaseEffect(effect: Effect): void;
  47615. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47616. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47617. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47618. bindSamplers(effect: Effect): void;
  47619. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47620. getRenderWidth(useScreen?: boolean): number;
  47621. getRenderHeight(useScreen?: boolean): number;
  47622. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47623. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47624. /**
  47625. * Set the z offset to apply to current rendering
  47626. * @param value defines the offset to apply
  47627. */
  47628. setZOffset(value: number): void;
  47629. /**
  47630. * Gets the current value of the zOffset
  47631. * @returns the current zOffset state
  47632. */
  47633. getZOffset(): number;
  47634. /**
  47635. * Enable or disable depth buffering
  47636. * @param enable defines the state to set
  47637. */
  47638. setDepthBuffer(enable: boolean): void;
  47639. /**
  47640. * Gets a boolean indicating if depth writing is enabled
  47641. * @returns the current depth writing state
  47642. */
  47643. getDepthWrite(): boolean;
  47644. /**
  47645. * Enable or disable depth writing
  47646. * @param enable defines the state to set
  47647. */
  47648. setDepthWrite(enable: boolean): void;
  47649. /**
  47650. * Enable or disable color writing
  47651. * @param enable defines the state to set
  47652. */
  47653. setColorWrite(enable: boolean): void;
  47654. /**
  47655. * Gets a boolean indicating if color writing is enabled
  47656. * @returns the current color writing state
  47657. */
  47658. getColorWrite(): boolean;
  47659. /**
  47660. * Sets alpha constants used by some alpha blending modes
  47661. * @param r defines the red component
  47662. * @param g defines the green component
  47663. * @param b defines the blue component
  47664. * @param a defines the alpha component
  47665. */
  47666. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47667. /**
  47668. * Sets the current alpha mode
  47669. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47670. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47671. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47672. */
  47673. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47674. /**
  47675. * Gets the current alpha mode
  47676. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47677. * @returns the current alpha mode
  47678. */
  47679. getAlphaMode(): number;
  47680. setInt(uniform: WebGLUniformLocation, int: number): void;
  47681. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47682. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47683. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47684. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47685. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47686. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47687. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47688. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47689. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47690. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47691. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47692. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47693. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47694. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47695. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47696. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47697. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47698. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47699. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47700. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47701. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47702. wipeCaches(bruteForce?: boolean): void;
  47703. _createTexture(): WebGLTexture;
  47704. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47705. /**
  47706. * Usually called from Texture.ts.
  47707. * Passed information to create a WebGLTexture
  47708. * @param urlArg defines a value which contains one of the following:
  47709. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47710. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47711. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47712. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47713. * @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)
  47714. * @param scene needed for loading to the correct scene
  47715. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47716. * @param onLoad optional callback to be called upon successful completion
  47717. * @param onError optional callback to be called upon failure
  47718. * @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
  47719. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47720. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47721. * @param forcedExtension defines the extension to use to pick the right loader
  47722. * @param mimeType defines an optional mime type
  47723. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47724. */
  47725. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  47726. /**
  47727. * Creates a cube texture
  47728. * @param rootUrl defines the url where the files to load is located
  47729. * @param scene defines the current scene
  47730. * @param files defines the list of files to load (1 per face)
  47731. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47732. * @param onLoad defines an optional callback raised when the texture is loaded
  47733. * @param onError defines an optional callback raised if there is an issue to load the texture
  47734. * @param format defines the format of the data
  47735. * @param forcedExtension defines the extension to use to pick the right loader
  47736. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47737. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47738. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47739. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47740. * @returns the cube texture as an InternalTexture
  47741. */
  47742. 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;
  47743. private _getSamplingFilter;
  47744. private static _GetNativeTextureFormat;
  47745. createRenderTargetTexture(size: number | {
  47746. width: number;
  47747. height: number;
  47748. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47749. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47750. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47751. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47752. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47753. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47754. /**
  47755. * Updates a dynamic vertex buffer.
  47756. * @param vertexBuffer the vertex buffer to update
  47757. * @param data the data used to update the vertex buffer
  47758. * @param byteOffset the byte offset of the data (optional)
  47759. * @param byteLength the byte length of the data (optional)
  47760. */
  47761. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47762. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47763. private _updateAnisotropicLevel;
  47764. private _getAddressMode;
  47765. /** @hidden */
  47766. _bindTexture(channel: number, texture: InternalTexture): void;
  47767. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47768. releaseEffects(): void;
  47769. /** @hidden */
  47770. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47771. /** @hidden */
  47772. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47773. /** @hidden */
  47774. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47775. /** @hidden */
  47776. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47777. }
  47778. }
  47779. declare module BABYLON {
  47780. /**
  47781. * Gather the list of clipboard event types as constants.
  47782. */
  47783. export class ClipboardEventTypes {
  47784. /**
  47785. * The clipboard event is fired when a copy command is active (pressed).
  47786. */
  47787. static readonly COPY: number;
  47788. /**
  47789. * The clipboard event is fired when a cut command is active (pressed).
  47790. */
  47791. static readonly CUT: number;
  47792. /**
  47793. * The clipboard event is fired when a paste command is active (pressed).
  47794. */
  47795. static readonly PASTE: number;
  47796. }
  47797. /**
  47798. * This class is used to store clipboard related info for the onClipboardObservable event.
  47799. */
  47800. export class ClipboardInfo {
  47801. /**
  47802. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47803. */
  47804. type: number;
  47805. /**
  47806. * Defines the related dom event
  47807. */
  47808. event: ClipboardEvent;
  47809. /**
  47810. *Creates an instance of ClipboardInfo.
  47811. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47812. * @param event Defines the related dom event
  47813. */
  47814. constructor(
  47815. /**
  47816. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47817. */
  47818. type: number,
  47819. /**
  47820. * Defines the related dom event
  47821. */
  47822. event: ClipboardEvent);
  47823. /**
  47824. * Get the clipboard event's type from the keycode.
  47825. * @param keyCode Defines the keyCode for the current keyboard event.
  47826. * @return {number}
  47827. */
  47828. static GetTypeFromCharacter(keyCode: number): number;
  47829. }
  47830. }
  47831. declare module BABYLON {
  47832. /**
  47833. * Google Daydream controller
  47834. */
  47835. export class DaydreamController extends WebVRController {
  47836. /**
  47837. * Base Url for the controller model.
  47838. */
  47839. static MODEL_BASE_URL: string;
  47840. /**
  47841. * File name for the controller model.
  47842. */
  47843. static MODEL_FILENAME: string;
  47844. /**
  47845. * Gamepad Id prefix used to identify Daydream Controller.
  47846. */
  47847. static readonly GAMEPAD_ID_PREFIX: string;
  47848. /**
  47849. * Creates a new DaydreamController from a gamepad
  47850. * @param vrGamepad the gamepad that the controller should be created from
  47851. */
  47852. constructor(vrGamepad: any);
  47853. /**
  47854. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47855. * @param scene scene in which to add meshes
  47856. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47857. */
  47858. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47859. /**
  47860. * Called once for each button that changed state since the last frame
  47861. * @param buttonIdx Which button index changed
  47862. * @param state New state of the button
  47863. * @param changes Which properties on the state changed since last frame
  47864. */
  47865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47866. }
  47867. }
  47868. declare module BABYLON {
  47869. /**
  47870. * Gear VR Controller
  47871. */
  47872. export class GearVRController extends WebVRController {
  47873. /**
  47874. * Base Url for the controller model.
  47875. */
  47876. static MODEL_BASE_URL: string;
  47877. /**
  47878. * File name for the controller model.
  47879. */
  47880. static MODEL_FILENAME: string;
  47881. /**
  47882. * Gamepad Id prefix used to identify this controller.
  47883. */
  47884. static readonly GAMEPAD_ID_PREFIX: string;
  47885. private readonly _buttonIndexToObservableNameMap;
  47886. /**
  47887. * Creates a new GearVRController from a gamepad
  47888. * @param vrGamepad the gamepad that the controller should be created from
  47889. */
  47890. constructor(vrGamepad: any);
  47891. /**
  47892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47893. * @param scene scene in which to add meshes
  47894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47895. */
  47896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47897. /**
  47898. * Called once for each button that changed state since the last frame
  47899. * @param buttonIdx Which button index changed
  47900. * @param state New state of the button
  47901. * @param changes Which properties on the state changed since last frame
  47902. */
  47903. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47904. }
  47905. }
  47906. declare module BABYLON {
  47907. /**
  47908. * Generic Controller
  47909. */
  47910. export class GenericController extends WebVRController {
  47911. /**
  47912. * Base Url for the controller model.
  47913. */
  47914. static readonly MODEL_BASE_URL: string;
  47915. /**
  47916. * File name for the controller model.
  47917. */
  47918. static readonly MODEL_FILENAME: string;
  47919. /**
  47920. * Creates a new GenericController from a gamepad
  47921. * @param vrGamepad the gamepad that the controller should be created from
  47922. */
  47923. constructor(vrGamepad: any);
  47924. /**
  47925. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47926. * @param scene scene in which to add meshes
  47927. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47928. */
  47929. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47930. /**
  47931. * Called once for each button that changed state since the last frame
  47932. * @param buttonIdx Which button index changed
  47933. * @param state New state of the button
  47934. * @param changes Which properties on the state changed since last frame
  47935. */
  47936. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47937. }
  47938. }
  47939. declare module BABYLON {
  47940. /**
  47941. * Oculus Touch Controller
  47942. */
  47943. export class OculusTouchController extends WebVRController {
  47944. /**
  47945. * Base Url for the controller model.
  47946. */
  47947. static MODEL_BASE_URL: string;
  47948. /**
  47949. * File name for the left controller model.
  47950. */
  47951. static MODEL_LEFT_FILENAME: string;
  47952. /**
  47953. * File name for the right controller model.
  47954. */
  47955. static MODEL_RIGHT_FILENAME: string;
  47956. /**
  47957. * Base Url for the Quest controller model.
  47958. */
  47959. static QUEST_MODEL_BASE_URL: string;
  47960. /**
  47961. * @hidden
  47962. * If the controllers are running on a device that needs the updated Quest controller models
  47963. */
  47964. static _IsQuest: boolean;
  47965. /**
  47966. * Fired when the secondary trigger on this controller is modified
  47967. */
  47968. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47969. /**
  47970. * Fired when the thumb rest on this controller is modified
  47971. */
  47972. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47973. /**
  47974. * Creates a new OculusTouchController from a gamepad
  47975. * @param vrGamepad the gamepad that the controller should be created from
  47976. */
  47977. constructor(vrGamepad: any);
  47978. /**
  47979. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47980. * @param scene scene in which to add meshes
  47981. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47982. */
  47983. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47984. /**
  47985. * Fired when the A button on this controller is modified
  47986. */
  47987. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47988. /**
  47989. * Fired when the B button on this controller is modified
  47990. */
  47991. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47992. /**
  47993. * Fired when the X button on this controller is modified
  47994. */
  47995. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47996. /**
  47997. * Fired when the Y button on this controller is modified
  47998. */
  47999. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48000. /**
  48001. * Called once for each button that changed state since the last frame
  48002. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48003. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48004. * 2) secondary trigger (same)
  48005. * 3) A (right) X (left), touch, pressed = value
  48006. * 4) B / Y
  48007. * 5) thumb rest
  48008. * @param buttonIdx Which button index changed
  48009. * @param state New state of the button
  48010. * @param changes Which properties on the state changed since last frame
  48011. */
  48012. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48013. }
  48014. }
  48015. declare module BABYLON {
  48016. /**
  48017. * Vive Controller
  48018. */
  48019. export class ViveController extends WebVRController {
  48020. /**
  48021. * Base Url for the controller model.
  48022. */
  48023. static MODEL_BASE_URL: string;
  48024. /**
  48025. * File name for the controller model.
  48026. */
  48027. static MODEL_FILENAME: string;
  48028. /**
  48029. * Creates a new ViveController from a gamepad
  48030. * @param vrGamepad the gamepad that the controller should be created from
  48031. */
  48032. constructor(vrGamepad: any);
  48033. /**
  48034. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48035. * @param scene scene in which to add meshes
  48036. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48037. */
  48038. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48039. /**
  48040. * Fired when the left button on this controller is modified
  48041. */
  48042. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48043. /**
  48044. * Fired when the right button on this controller is modified
  48045. */
  48046. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48047. /**
  48048. * Fired when the menu button on this controller is modified
  48049. */
  48050. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48051. /**
  48052. * Called once for each button that changed state since the last frame
  48053. * Vive mapping:
  48054. * 0: touchpad
  48055. * 1: trigger
  48056. * 2: left AND right buttons
  48057. * 3: menu button
  48058. * @param buttonIdx Which button index changed
  48059. * @param state New state of the button
  48060. * @param changes Which properties on the state changed since last frame
  48061. */
  48062. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48063. }
  48064. }
  48065. declare module BABYLON {
  48066. /**
  48067. * Defines the WindowsMotionController object that the state of the windows motion controller
  48068. */
  48069. export class WindowsMotionController extends WebVRController {
  48070. /**
  48071. * The base url used to load the left and right controller models
  48072. */
  48073. static MODEL_BASE_URL: string;
  48074. /**
  48075. * The name of the left controller model file
  48076. */
  48077. static MODEL_LEFT_FILENAME: string;
  48078. /**
  48079. * The name of the right controller model file
  48080. */
  48081. static MODEL_RIGHT_FILENAME: string;
  48082. /**
  48083. * The controller name prefix for this controller type
  48084. */
  48085. static readonly GAMEPAD_ID_PREFIX: string;
  48086. /**
  48087. * The controller id pattern for this controller type
  48088. */
  48089. private static readonly GAMEPAD_ID_PATTERN;
  48090. private _loadedMeshInfo;
  48091. protected readonly _mapping: {
  48092. buttons: string[];
  48093. buttonMeshNames: {
  48094. 'trigger': string;
  48095. 'menu': string;
  48096. 'grip': string;
  48097. 'thumbstick': string;
  48098. 'trackpad': string;
  48099. };
  48100. buttonObservableNames: {
  48101. 'trigger': string;
  48102. 'menu': string;
  48103. 'grip': string;
  48104. 'thumbstick': string;
  48105. 'trackpad': string;
  48106. };
  48107. axisMeshNames: string[];
  48108. pointingPoseMeshName: string;
  48109. };
  48110. /**
  48111. * Fired when the trackpad on this controller is clicked
  48112. */
  48113. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48114. /**
  48115. * Fired when the trackpad on this controller is modified
  48116. */
  48117. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48118. /**
  48119. * The current x and y values of this controller's trackpad
  48120. */
  48121. trackpad: StickValues;
  48122. /**
  48123. * Creates a new WindowsMotionController from a gamepad
  48124. * @param vrGamepad the gamepad that the controller should be created from
  48125. */
  48126. constructor(vrGamepad: any);
  48127. /**
  48128. * Fired when the trigger on this controller is modified
  48129. */
  48130. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48131. /**
  48132. * Fired when the menu button on this controller is modified
  48133. */
  48134. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48135. /**
  48136. * Fired when the grip button on this controller is modified
  48137. */
  48138. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48139. /**
  48140. * Fired when the thumbstick button on this controller is modified
  48141. */
  48142. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48143. /**
  48144. * Fired when the touchpad button on this controller is modified
  48145. */
  48146. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48147. /**
  48148. * Fired when the touchpad values on this controller are modified
  48149. */
  48150. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48151. protected _updateTrackpad(): void;
  48152. /**
  48153. * Called once per frame by the engine.
  48154. */
  48155. update(): void;
  48156. /**
  48157. * Called once for each button that changed state since the last frame
  48158. * @param buttonIdx Which button index changed
  48159. * @param state New state of the button
  48160. * @param changes Which properties on the state changed since last frame
  48161. */
  48162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48163. /**
  48164. * Moves the buttons on the controller mesh based on their current state
  48165. * @param buttonName the name of the button to move
  48166. * @param buttonValue the value of the button which determines the buttons new position
  48167. */
  48168. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48169. /**
  48170. * Moves the axis on the controller mesh based on its current state
  48171. * @param axis the index of the axis
  48172. * @param axisValue the value of the axis which determines the meshes new position
  48173. * @hidden
  48174. */
  48175. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48176. /**
  48177. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48178. * @param scene scene in which to add meshes
  48179. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48180. */
  48181. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48182. /**
  48183. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48184. * can be transformed by button presses and axes values, based on this._mapping.
  48185. *
  48186. * @param scene scene in which the meshes exist
  48187. * @param meshes list of meshes that make up the controller model to process
  48188. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48189. */
  48190. private processModel;
  48191. private createMeshInfo;
  48192. /**
  48193. * Gets the ray of the controller in the direction the controller is pointing
  48194. * @param length the length the resulting ray should be
  48195. * @returns a ray in the direction the controller is pointing
  48196. */
  48197. getForwardRay(length?: number): Ray;
  48198. /**
  48199. * Disposes of the controller
  48200. */
  48201. dispose(): void;
  48202. }
  48203. /**
  48204. * This class represents a new windows motion controller in XR.
  48205. */
  48206. export class XRWindowsMotionController extends WindowsMotionController {
  48207. /**
  48208. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48209. */
  48210. protected readonly _mapping: {
  48211. buttons: string[];
  48212. buttonMeshNames: {
  48213. 'trigger': string;
  48214. 'menu': string;
  48215. 'grip': string;
  48216. 'thumbstick': string;
  48217. 'trackpad': string;
  48218. };
  48219. buttonObservableNames: {
  48220. 'trigger': string;
  48221. 'menu': string;
  48222. 'grip': string;
  48223. 'thumbstick': string;
  48224. 'trackpad': string;
  48225. };
  48226. axisMeshNames: string[];
  48227. pointingPoseMeshName: string;
  48228. };
  48229. /**
  48230. * Construct a new XR-Based windows motion controller
  48231. *
  48232. * @param gamepadInfo the gamepad object from the browser
  48233. */
  48234. constructor(gamepadInfo: any);
  48235. /**
  48236. * holds the thumbstick values (X,Y)
  48237. */
  48238. thumbstickValues: StickValues;
  48239. /**
  48240. * Fired when the thumbstick on this controller is clicked
  48241. */
  48242. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48243. /**
  48244. * Fired when the thumbstick on this controller is modified
  48245. */
  48246. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48247. /**
  48248. * Fired when the touchpad button on this controller is modified
  48249. */
  48250. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48251. /**
  48252. * Fired when the touchpad values on this controller are modified
  48253. */
  48254. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48255. /**
  48256. * Fired when the thumbstick button on this controller is modified
  48257. * here to prevent breaking changes
  48258. */
  48259. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48260. /**
  48261. * updating the thumbstick(!) and not the trackpad.
  48262. * This is named this way due to the difference between WebVR and XR and to avoid
  48263. * changing the parent class.
  48264. */
  48265. protected _updateTrackpad(): void;
  48266. /**
  48267. * Disposes the class with joy
  48268. */
  48269. dispose(): void;
  48270. }
  48271. }
  48272. declare module BABYLON {
  48273. /**
  48274. * Class containing static functions to help procedurally build meshes
  48275. */
  48276. export class PolyhedronBuilder {
  48277. /**
  48278. * Creates a polyhedron mesh
  48279. * * 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
  48280. * * The parameter `size` (positive float, default 1) sets the polygon size
  48281. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48282. * * 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`
  48283. * * 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
  48284. * * 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)`)
  48285. * * 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
  48286. * * 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
  48287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48288. * * 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
  48289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48290. * @param name defines the name of the mesh
  48291. * @param options defines the options used to create the mesh
  48292. * @param scene defines the hosting scene
  48293. * @returns the polyhedron mesh
  48294. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48295. */
  48296. static CreatePolyhedron(name: string, options: {
  48297. type?: number;
  48298. size?: number;
  48299. sizeX?: number;
  48300. sizeY?: number;
  48301. sizeZ?: number;
  48302. custom?: any;
  48303. faceUV?: Vector4[];
  48304. faceColors?: Color4[];
  48305. flat?: boolean;
  48306. updatable?: boolean;
  48307. sideOrientation?: number;
  48308. frontUVs?: Vector4;
  48309. backUVs?: Vector4;
  48310. }, scene?: Nullable<Scene>): Mesh;
  48311. }
  48312. }
  48313. declare module BABYLON {
  48314. /**
  48315. * Gizmo that enables scaling a mesh along 3 axis
  48316. */
  48317. export class ScaleGizmo extends Gizmo {
  48318. /**
  48319. * Internal gizmo used for interactions on the x axis
  48320. */
  48321. xGizmo: AxisScaleGizmo;
  48322. /**
  48323. * Internal gizmo used for interactions on the y axis
  48324. */
  48325. yGizmo: AxisScaleGizmo;
  48326. /**
  48327. * Internal gizmo used for interactions on the z axis
  48328. */
  48329. zGizmo: AxisScaleGizmo;
  48330. /**
  48331. * Internal gizmo used to scale all axis equally
  48332. */
  48333. uniformScaleGizmo: AxisScaleGizmo;
  48334. private _meshAttached;
  48335. private _updateGizmoRotationToMatchAttachedMesh;
  48336. private _snapDistance;
  48337. private _scaleRatio;
  48338. private _uniformScalingMesh;
  48339. private _octahedron;
  48340. private _sensitivity;
  48341. /** Fires an event when any of it's sub gizmos are dragged */
  48342. onDragStartObservable: Observable<unknown>;
  48343. /** Fires an event when any of it's sub gizmos are released from dragging */
  48344. onDragEndObservable: Observable<unknown>;
  48345. get attachedMesh(): Nullable<AbstractMesh>;
  48346. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48347. /**
  48348. * Creates a ScaleGizmo
  48349. * @param gizmoLayer The utility layer the gizmo will be added to
  48350. */
  48351. constructor(gizmoLayer?: UtilityLayerRenderer);
  48352. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48353. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48354. /**
  48355. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48356. */
  48357. set snapDistance(value: number);
  48358. get snapDistance(): number;
  48359. /**
  48360. * Ratio for the scale of the gizmo (Default: 1)
  48361. */
  48362. set scaleRatio(value: number);
  48363. get scaleRatio(): number;
  48364. /**
  48365. * Sensitivity factor for dragging (Default: 1)
  48366. */
  48367. set sensitivity(value: number);
  48368. get sensitivity(): number;
  48369. /**
  48370. * Disposes of the gizmo
  48371. */
  48372. dispose(): void;
  48373. }
  48374. }
  48375. declare module BABYLON {
  48376. /**
  48377. * Single axis scale gizmo
  48378. */
  48379. export class AxisScaleGizmo extends Gizmo {
  48380. /**
  48381. * Drag behavior responsible for the gizmos dragging interactions
  48382. */
  48383. dragBehavior: PointerDragBehavior;
  48384. private _pointerObserver;
  48385. /**
  48386. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48387. */
  48388. snapDistance: number;
  48389. /**
  48390. * Event that fires each time the gizmo snaps to a new location.
  48391. * * snapDistance is the the change in distance
  48392. */
  48393. onSnapObservable: Observable<{
  48394. snapDistance: number;
  48395. }>;
  48396. /**
  48397. * If the scaling operation should be done on all axis (default: false)
  48398. */
  48399. uniformScaling: boolean;
  48400. /**
  48401. * Custom sensitivity value for the drag strength
  48402. */
  48403. sensitivity: number;
  48404. private _isEnabled;
  48405. private _parent;
  48406. private _arrow;
  48407. private _coloredMaterial;
  48408. private _hoverMaterial;
  48409. /**
  48410. * Creates an AxisScaleGizmo
  48411. * @param gizmoLayer The utility layer the gizmo will be added to
  48412. * @param dragAxis The axis which the gizmo will be able to scale on
  48413. * @param color The color of the gizmo
  48414. */
  48415. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48416. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48417. /**
  48418. * If the gizmo is enabled
  48419. */
  48420. set isEnabled(value: boolean);
  48421. get isEnabled(): boolean;
  48422. /**
  48423. * Disposes of the gizmo
  48424. */
  48425. dispose(): void;
  48426. /**
  48427. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48428. * @param mesh The mesh to replace the default mesh of the gizmo
  48429. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48430. */
  48431. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48432. }
  48433. }
  48434. declare module BABYLON {
  48435. /**
  48436. * Bounding box gizmo
  48437. */
  48438. export class BoundingBoxGizmo extends Gizmo {
  48439. private _lineBoundingBox;
  48440. private _rotateSpheresParent;
  48441. private _scaleBoxesParent;
  48442. private _boundingDimensions;
  48443. private _renderObserver;
  48444. private _pointerObserver;
  48445. private _scaleDragSpeed;
  48446. private _tmpQuaternion;
  48447. private _tmpVector;
  48448. private _tmpRotationMatrix;
  48449. /**
  48450. * 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)
  48451. */
  48452. ignoreChildren: boolean;
  48453. /**
  48454. * 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)
  48455. */
  48456. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48457. /**
  48458. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48459. */
  48460. rotationSphereSize: number;
  48461. /**
  48462. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48463. */
  48464. scaleBoxSize: number;
  48465. /**
  48466. * 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)
  48467. */
  48468. fixedDragMeshScreenSize: boolean;
  48469. /**
  48470. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48471. */
  48472. fixedDragMeshScreenSizeDistanceFactor: number;
  48473. /**
  48474. * Fired when a rotation sphere or scale box is dragged
  48475. */
  48476. onDragStartObservable: Observable<{}>;
  48477. /**
  48478. * Fired when a scale box is dragged
  48479. */
  48480. onScaleBoxDragObservable: Observable<{}>;
  48481. /**
  48482. * Fired when a scale box drag is ended
  48483. */
  48484. onScaleBoxDragEndObservable: Observable<{}>;
  48485. /**
  48486. * Fired when a rotation sphere is dragged
  48487. */
  48488. onRotationSphereDragObservable: Observable<{}>;
  48489. /**
  48490. * Fired when a rotation sphere drag is ended
  48491. */
  48492. onRotationSphereDragEndObservable: Observable<{}>;
  48493. /**
  48494. * 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)
  48495. */
  48496. scalePivot: Nullable<Vector3>;
  48497. /**
  48498. * Mesh used as a pivot to rotate the attached mesh
  48499. */
  48500. private _anchorMesh;
  48501. private _existingMeshScale;
  48502. private _dragMesh;
  48503. private pointerDragBehavior;
  48504. private coloredMaterial;
  48505. private hoverColoredMaterial;
  48506. /**
  48507. * Sets the color of the bounding box gizmo
  48508. * @param color the color to set
  48509. */
  48510. setColor(color: Color3): void;
  48511. /**
  48512. * Creates an BoundingBoxGizmo
  48513. * @param gizmoLayer The utility layer the gizmo will be added to
  48514. * @param color The color of the gizmo
  48515. */
  48516. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48517. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48518. private _selectNode;
  48519. /**
  48520. * Updates the bounding box information for the Gizmo
  48521. */
  48522. updateBoundingBox(): void;
  48523. private _updateRotationSpheres;
  48524. private _updateScaleBoxes;
  48525. /**
  48526. * Enables rotation on the specified axis and disables rotation on the others
  48527. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48528. */
  48529. setEnabledRotationAxis(axis: string): void;
  48530. /**
  48531. * Enables/disables scaling
  48532. * @param enable if scaling should be enabled
  48533. */
  48534. setEnabledScaling(enable: boolean): void;
  48535. private _updateDummy;
  48536. /**
  48537. * Enables a pointer drag behavior on the bounding box of the gizmo
  48538. */
  48539. enableDragBehavior(): void;
  48540. /**
  48541. * Disposes of the gizmo
  48542. */
  48543. dispose(): void;
  48544. /**
  48545. * 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)
  48546. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48547. * @returns the bounding box mesh with the passed in mesh as a child
  48548. */
  48549. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48550. /**
  48551. * CustomMeshes are not supported by this gizmo
  48552. * @param mesh The mesh to replace the default mesh of the gizmo
  48553. */
  48554. setCustomMesh(mesh: Mesh): void;
  48555. }
  48556. }
  48557. declare module BABYLON {
  48558. /**
  48559. * Single plane rotation gizmo
  48560. */
  48561. export class PlaneRotationGizmo extends Gizmo {
  48562. /**
  48563. * Drag behavior responsible for the gizmos dragging interactions
  48564. */
  48565. dragBehavior: PointerDragBehavior;
  48566. private _pointerObserver;
  48567. /**
  48568. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48569. */
  48570. snapDistance: number;
  48571. /**
  48572. * Event that fires each time the gizmo snaps to a new location.
  48573. * * snapDistance is the the change in distance
  48574. */
  48575. onSnapObservable: Observable<{
  48576. snapDistance: number;
  48577. }>;
  48578. private _isEnabled;
  48579. private _parent;
  48580. /**
  48581. * Creates a PlaneRotationGizmo
  48582. * @param gizmoLayer The utility layer the gizmo will be added to
  48583. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48584. * @param color The color of the gizmo
  48585. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48586. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48587. */
  48588. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48589. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48590. /**
  48591. * If the gizmo is enabled
  48592. */
  48593. set isEnabled(value: boolean);
  48594. get isEnabled(): boolean;
  48595. /**
  48596. * Disposes of the gizmo
  48597. */
  48598. dispose(): void;
  48599. }
  48600. }
  48601. declare module BABYLON {
  48602. /**
  48603. * Gizmo that enables rotating a mesh along 3 axis
  48604. */
  48605. export class RotationGizmo extends Gizmo {
  48606. /**
  48607. * Internal gizmo used for interactions on the x axis
  48608. */
  48609. xGizmo: PlaneRotationGizmo;
  48610. /**
  48611. * Internal gizmo used for interactions on the y axis
  48612. */
  48613. yGizmo: PlaneRotationGizmo;
  48614. /**
  48615. * Internal gizmo used for interactions on the z axis
  48616. */
  48617. zGizmo: PlaneRotationGizmo;
  48618. /** Fires an event when any of it's sub gizmos are dragged */
  48619. onDragStartObservable: Observable<unknown>;
  48620. /** Fires an event when any of it's sub gizmos are released from dragging */
  48621. onDragEndObservable: Observable<unknown>;
  48622. private _meshAttached;
  48623. get attachedMesh(): Nullable<AbstractMesh>;
  48624. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48625. /**
  48626. * Creates a RotationGizmo
  48627. * @param gizmoLayer The utility layer the gizmo will be added to
  48628. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48629. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48630. */
  48631. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48632. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48633. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48634. /**
  48635. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48636. */
  48637. set snapDistance(value: number);
  48638. get snapDistance(): number;
  48639. /**
  48640. * Ratio for the scale of the gizmo (Default: 1)
  48641. */
  48642. set scaleRatio(value: number);
  48643. get scaleRatio(): number;
  48644. /**
  48645. * Disposes of the gizmo
  48646. */
  48647. dispose(): void;
  48648. /**
  48649. * CustomMeshes are not supported by this gizmo
  48650. * @param mesh The mesh to replace the default mesh of the gizmo
  48651. */
  48652. setCustomMesh(mesh: Mesh): void;
  48653. }
  48654. }
  48655. declare module BABYLON {
  48656. /**
  48657. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48658. */
  48659. export class GizmoManager implements IDisposable {
  48660. private scene;
  48661. /**
  48662. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48663. */
  48664. gizmos: {
  48665. positionGizmo: Nullable<PositionGizmo>;
  48666. rotationGizmo: Nullable<RotationGizmo>;
  48667. scaleGizmo: Nullable<ScaleGizmo>;
  48668. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48669. };
  48670. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48671. clearGizmoOnEmptyPointerEvent: boolean;
  48672. /** Fires an event when the manager is attached to a mesh */
  48673. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48674. private _gizmosEnabled;
  48675. private _pointerObserver;
  48676. private _attachedMesh;
  48677. private _boundingBoxColor;
  48678. private _defaultUtilityLayer;
  48679. private _defaultKeepDepthUtilityLayer;
  48680. /**
  48681. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48682. */
  48683. boundingBoxDragBehavior: SixDofDragBehavior;
  48684. /**
  48685. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48686. */
  48687. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48688. /**
  48689. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48690. */
  48691. usePointerToAttachGizmos: boolean;
  48692. /**
  48693. * Utility layer that the bounding box gizmo belongs to
  48694. */
  48695. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48696. /**
  48697. * Utility layer that all gizmos besides bounding box belong to
  48698. */
  48699. get utilityLayer(): UtilityLayerRenderer;
  48700. /**
  48701. * Instatiates a gizmo manager
  48702. * @param scene the scene to overlay the gizmos on top of
  48703. */
  48704. constructor(scene: Scene);
  48705. /**
  48706. * Attaches a set of gizmos to the specified mesh
  48707. * @param mesh The mesh the gizmo's should be attached to
  48708. */
  48709. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48710. /**
  48711. * If the position gizmo is enabled
  48712. */
  48713. set positionGizmoEnabled(value: boolean);
  48714. get positionGizmoEnabled(): boolean;
  48715. /**
  48716. * If the rotation gizmo is enabled
  48717. */
  48718. set rotationGizmoEnabled(value: boolean);
  48719. get rotationGizmoEnabled(): boolean;
  48720. /**
  48721. * If the scale gizmo is enabled
  48722. */
  48723. set scaleGizmoEnabled(value: boolean);
  48724. get scaleGizmoEnabled(): boolean;
  48725. /**
  48726. * If the boundingBox gizmo is enabled
  48727. */
  48728. set boundingBoxGizmoEnabled(value: boolean);
  48729. get boundingBoxGizmoEnabled(): boolean;
  48730. /**
  48731. * Disposes of the gizmo manager
  48732. */
  48733. dispose(): void;
  48734. }
  48735. }
  48736. declare module BABYLON {
  48737. /**
  48738. * A directional light is defined by a direction (what a surprise!).
  48739. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48740. * 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.
  48741. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48742. */
  48743. export class DirectionalLight extends ShadowLight {
  48744. private _shadowFrustumSize;
  48745. /**
  48746. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48747. */
  48748. get shadowFrustumSize(): number;
  48749. /**
  48750. * Specifies a fix frustum size for the shadow generation.
  48751. */
  48752. set shadowFrustumSize(value: number);
  48753. private _shadowOrthoScale;
  48754. /**
  48755. * Gets the shadow projection scale against the optimal computed one.
  48756. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48757. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48758. */
  48759. get shadowOrthoScale(): number;
  48760. /**
  48761. * Sets the shadow projection scale against the optimal computed one.
  48762. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48763. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48764. */
  48765. set shadowOrthoScale(value: number);
  48766. /**
  48767. * Automatically compute the projection matrix to best fit (including all the casters)
  48768. * on each frame.
  48769. */
  48770. autoUpdateExtends: boolean;
  48771. /**
  48772. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48773. * on each frame. autoUpdateExtends must be set to true for this to work
  48774. */
  48775. autoCalcShadowZBounds: boolean;
  48776. private _orthoLeft;
  48777. private _orthoRight;
  48778. private _orthoTop;
  48779. private _orthoBottom;
  48780. /**
  48781. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48782. * The directional light is emitted from everywhere in the given direction.
  48783. * It can cast shadows.
  48784. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48785. * @param name The friendly name of the light
  48786. * @param direction The direction of the light
  48787. * @param scene The scene the light belongs to
  48788. */
  48789. constructor(name: string, direction: Vector3, scene: Scene);
  48790. /**
  48791. * Returns the string "DirectionalLight".
  48792. * @return The class name
  48793. */
  48794. getClassName(): string;
  48795. /**
  48796. * Returns the integer 1.
  48797. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48798. */
  48799. getTypeID(): number;
  48800. /**
  48801. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48802. * Returns the DirectionalLight Shadow projection matrix.
  48803. */
  48804. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48805. /**
  48806. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48807. * Returns the DirectionalLight Shadow projection matrix.
  48808. */
  48809. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48810. /**
  48811. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48812. * Returns the DirectionalLight Shadow projection matrix.
  48813. */
  48814. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48815. protected _buildUniformLayout(): void;
  48816. /**
  48817. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48818. * @param effect The effect to update
  48819. * @param lightIndex The index of the light in the effect to update
  48820. * @returns The directional light
  48821. */
  48822. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48823. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48824. /**
  48825. * Gets the minZ used for shadow according to both the scene and the light.
  48826. *
  48827. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48828. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48829. * @param activeCamera The camera we are returning the min for
  48830. * @returns the depth min z
  48831. */
  48832. getDepthMinZ(activeCamera: Camera): number;
  48833. /**
  48834. * Gets the maxZ used for shadow according to both the scene and the light.
  48835. *
  48836. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48837. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48838. * @param activeCamera The camera we are returning the max for
  48839. * @returns the depth max z
  48840. */
  48841. getDepthMaxZ(activeCamera: Camera): number;
  48842. /**
  48843. * Prepares the list of defines specific to the light type.
  48844. * @param defines the list of defines
  48845. * @param lightIndex defines the index of the light for the effect
  48846. */
  48847. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48848. }
  48849. }
  48850. declare module BABYLON {
  48851. /**
  48852. * Class containing static functions to help procedurally build meshes
  48853. */
  48854. export class HemisphereBuilder {
  48855. /**
  48856. * Creates a hemisphere mesh
  48857. * @param name defines the name of the mesh
  48858. * @param options defines the options used to create the mesh
  48859. * @param scene defines the hosting scene
  48860. * @returns the hemisphere mesh
  48861. */
  48862. static CreateHemisphere(name: string, options: {
  48863. segments?: number;
  48864. diameter?: number;
  48865. sideOrientation?: number;
  48866. }, scene: any): Mesh;
  48867. }
  48868. }
  48869. declare module BABYLON {
  48870. /**
  48871. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48872. * These values define a cone of light starting from the position, emitting toward the direction.
  48873. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48874. * and the exponent defines the speed of the decay of the light with distance (reach).
  48875. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48876. */
  48877. export class SpotLight extends ShadowLight {
  48878. private _angle;
  48879. private _innerAngle;
  48880. private _cosHalfAngle;
  48881. private _lightAngleScale;
  48882. private _lightAngleOffset;
  48883. /**
  48884. * Gets the cone angle of the spot light in Radians.
  48885. */
  48886. get angle(): number;
  48887. /**
  48888. * Sets the cone angle of the spot light in Radians.
  48889. */
  48890. set angle(value: number);
  48891. /**
  48892. * Only used in gltf falloff mode, this defines the angle where
  48893. * the directional falloff will start before cutting at angle which could be seen
  48894. * as outer angle.
  48895. */
  48896. get innerAngle(): number;
  48897. /**
  48898. * Only used in gltf falloff mode, this defines the angle where
  48899. * the directional falloff will start before cutting at angle which could be seen
  48900. * as outer angle.
  48901. */
  48902. set innerAngle(value: number);
  48903. private _shadowAngleScale;
  48904. /**
  48905. * Allows scaling the angle of the light for shadow generation only.
  48906. */
  48907. get shadowAngleScale(): number;
  48908. /**
  48909. * Allows scaling the angle of the light for shadow generation only.
  48910. */
  48911. set shadowAngleScale(value: number);
  48912. /**
  48913. * The light decay speed with the distance from the emission spot.
  48914. */
  48915. exponent: number;
  48916. private _projectionTextureMatrix;
  48917. /**
  48918. * Allows reading the projecton texture
  48919. */
  48920. get projectionTextureMatrix(): Matrix;
  48921. protected _projectionTextureLightNear: number;
  48922. /**
  48923. * Gets the near clip of the Spotlight for texture projection.
  48924. */
  48925. get projectionTextureLightNear(): number;
  48926. /**
  48927. * Sets the near clip of the Spotlight for texture projection.
  48928. */
  48929. set projectionTextureLightNear(value: number);
  48930. protected _projectionTextureLightFar: number;
  48931. /**
  48932. * Gets the far clip of the Spotlight for texture projection.
  48933. */
  48934. get projectionTextureLightFar(): number;
  48935. /**
  48936. * Sets the far clip of the Spotlight for texture projection.
  48937. */
  48938. set projectionTextureLightFar(value: number);
  48939. protected _projectionTextureUpDirection: Vector3;
  48940. /**
  48941. * Gets the Up vector of the Spotlight for texture projection.
  48942. */
  48943. get projectionTextureUpDirection(): Vector3;
  48944. /**
  48945. * Sets the Up vector of the Spotlight for texture projection.
  48946. */
  48947. set projectionTextureUpDirection(value: Vector3);
  48948. private _projectionTexture;
  48949. /**
  48950. * Gets the projection texture of the light.
  48951. */
  48952. get projectionTexture(): Nullable<BaseTexture>;
  48953. /**
  48954. * Sets the projection texture of the light.
  48955. */
  48956. set projectionTexture(value: Nullable<BaseTexture>);
  48957. private _projectionTextureViewLightDirty;
  48958. private _projectionTextureProjectionLightDirty;
  48959. private _projectionTextureDirty;
  48960. private _projectionTextureViewTargetVector;
  48961. private _projectionTextureViewLightMatrix;
  48962. private _projectionTextureProjectionLightMatrix;
  48963. private _projectionTextureScalingMatrix;
  48964. /**
  48965. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48966. * It can cast shadows.
  48967. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48968. * @param name The light friendly name
  48969. * @param position The position of the spot light in the scene
  48970. * @param direction The direction of the light in the scene
  48971. * @param angle The cone angle of the light in Radians
  48972. * @param exponent The light decay speed with the distance from the emission spot
  48973. * @param scene The scene the lights belongs to
  48974. */
  48975. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48976. /**
  48977. * Returns the string "SpotLight".
  48978. * @returns the class name
  48979. */
  48980. getClassName(): string;
  48981. /**
  48982. * Returns the integer 2.
  48983. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48984. */
  48985. getTypeID(): number;
  48986. /**
  48987. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48988. */
  48989. protected _setDirection(value: Vector3): void;
  48990. /**
  48991. * Overrides the position setter to recompute the projection texture view light Matrix.
  48992. */
  48993. protected _setPosition(value: Vector3): void;
  48994. /**
  48995. * 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.
  48996. * Returns the SpotLight.
  48997. */
  48998. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48999. protected _computeProjectionTextureViewLightMatrix(): void;
  49000. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49001. /**
  49002. * Main function for light texture projection matrix computing.
  49003. */
  49004. protected _computeProjectionTextureMatrix(): void;
  49005. protected _buildUniformLayout(): void;
  49006. private _computeAngleValues;
  49007. /**
  49008. * Sets the passed Effect "effect" with the Light textures.
  49009. * @param effect The effect to update
  49010. * @param lightIndex The index of the light in the effect to update
  49011. * @returns The light
  49012. */
  49013. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49014. /**
  49015. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49016. * @param effect The effect to update
  49017. * @param lightIndex The index of the light in the effect to update
  49018. * @returns The spot light
  49019. */
  49020. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49021. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49022. /**
  49023. * Disposes the light and the associated resources.
  49024. */
  49025. dispose(): void;
  49026. /**
  49027. * Prepares the list of defines specific to the light type.
  49028. * @param defines the list of defines
  49029. * @param lightIndex defines the index of the light for the effect
  49030. */
  49031. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49032. }
  49033. }
  49034. declare module BABYLON {
  49035. /**
  49036. * Gizmo that enables viewing a light
  49037. */
  49038. export class LightGizmo extends Gizmo {
  49039. private _lightMesh;
  49040. private _material;
  49041. private _cachedPosition;
  49042. private _cachedForward;
  49043. private _attachedMeshParent;
  49044. /**
  49045. * Creates a LightGizmo
  49046. * @param gizmoLayer The utility layer the gizmo will be added to
  49047. */
  49048. constructor(gizmoLayer?: UtilityLayerRenderer);
  49049. private _light;
  49050. /**
  49051. * The light that the gizmo is attached to
  49052. */
  49053. set light(light: Nullable<Light>);
  49054. get light(): Nullable<Light>;
  49055. /**
  49056. * Gets the material used to render the light gizmo
  49057. */
  49058. get material(): StandardMaterial;
  49059. /**
  49060. * @hidden
  49061. * Updates the gizmo to match the attached mesh's position/rotation
  49062. */
  49063. protected _update(): void;
  49064. private static _Scale;
  49065. /**
  49066. * Creates the lines for a light mesh
  49067. */
  49068. private static _CreateLightLines;
  49069. /**
  49070. * Disposes of the light gizmo
  49071. */
  49072. dispose(): void;
  49073. private static _CreateHemisphericLightMesh;
  49074. private static _CreatePointLightMesh;
  49075. private static _CreateSpotLightMesh;
  49076. private static _CreateDirectionalLightMesh;
  49077. }
  49078. }
  49079. declare module BABYLON {
  49080. /** @hidden */
  49081. export var backgroundFragmentDeclaration: {
  49082. name: string;
  49083. shader: string;
  49084. };
  49085. }
  49086. declare module BABYLON {
  49087. /** @hidden */
  49088. export var backgroundUboDeclaration: {
  49089. name: string;
  49090. shader: string;
  49091. };
  49092. }
  49093. declare module BABYLON {
  49094. /** @hidden */
  49095. export var backgroundPixelShader: {
  49096. name: string;
  49097. shader: string;
  49098. };
  49099. }
  49100. declare module BABYLON {
  49101. /** @hidden */
  49102. export var backgroundVertexDeclaration: {
  49103. name: string;
  49104. shader: string;
  49105. };
  49106. }
  49107. declare module BABYLON {
  49108. /** @hidden */
  49109. export var backgroundVertexShader: {
  49110. name: string;
  49111. shader: string;
  49112. };
  49113. }
  49114. declare module BABYLON {
  49115. /**
  49116. * Background material used to create an efficient environement around your scene.
  49117. */
  49118. export class BackgroundMaterial extends PushMaterial {
  49119. /**
  49120. * Standard reflectance value at parallel view angle.
  49121. */
  49122. static StandardReflectance0: number;
  49123. /**
  49124. * Standard reflectance value at grazing angle.
  49125. */
  49126. static StandardReflectance90: number;
  49127. protected _primaryColor: Color3;
  49128. /**
  49129. * Key light Color (multiply against the environement texture)
  49130. */
  49131. primaryColor: Color3;
  49132. protected __perceptualColor: Nullable<Color3>;
  49133. /**
  49134. * Experimental Internal Use Only.
  49135. *
  49136. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49137. * This acts as a helper to set the primary color to a more "human friendly" value.
  49138. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49139. * output color as close as possible from the chosen value.
  49140. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49141. * part of lighting setup.)
  49142. */
  49143. get _perceptualColor(): Nullable<Color3>;
  49144. set _perceptualColor(value: Nullable<Color3>);
  49145. protected _primaryColorShadowLevel: float;
  49146. /**
  49147. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49148. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49149. */
  49150. get primaryColorShadowLevel(): float;
  49151. set primaryColorShadowLevel(value: float);
  49152. protected _primaryColorHighlightLevel: float;
  49153. /**
  49154. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49155. * The primary color is used at the level chosen to define what the white area would look.
  49156. */
  49157. get primaryColorHighlightLevel(): float;
  49158. set primaryColorHighlightLevel(value: float);
  49159. protected _reflectionTexture: Nullable<BaseTexture>;
  49160. /**
  49161. * Reflection Texture used in the material.
  49162. * Should be author in a specific way for the best result (refer to the documentation).
  49163. */
  49164. reflectionTexture: Nullable<BaseTexture>;
  49165. protected _reflectionBlur: float;
  49166. /**
  49167. * Reflection Texture level of blur.
  49168. *
  49169. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49170. * texture twice.
  49171. */
  49172. reflectionBlur: float;
  49173. protected _diffuseTexture: Nullable<BaseTexture>;
  49174. /**
  49175. * Diffuse Texture used in the material.
  49176. * Should be author in a specific way for the best result (refer to the documentation).
  49177. */
  49178. diffuseTexture: Nullable<BaseTexture>;
  49179. protected _shadowLights: Nullable<IShadowLight[]>;
  49180. /**
  49181. * Specify the list of lights casting shadow on the material.
  49182. * All scene shadow lights will be included if null.
  49183. */
  49184. shadowLights: Nullable<IShadowLight[]>;
  49185. protected _shadowLevel: float;
  49186. /**
  49187. * Helps adjusting the shadow to a softer level if required.
  49188. * 0 means black shadows and 1 means no shadows.
  49189. */
  49190. shadowLevel: float;
  49191. protected _sceneCenter: Vector3;
  49192. /**
  49193. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49194. * It is usually zero but might be interesting to modify according to your setup.
  49195. */
  49196. sceneCenter: Vector3;
  49197. protected _opacityFresnel: boolean;
  49198. /**
  49199. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49200. * This helps ensuring a nice transition when the camera goes under the ground.
  49201. */
  49202. opacityFresnel: boolean;
  49203. protected _reflectionFresnel: boolean;
  49204. /**
  49205. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49206. * This helps adding a mirror texture on the ground.
  49207. */
  49208. reflectionFresnel: boolean;
  49209. protected _reflectionFalloffDistance: number;
  49210. /**
  49211. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49212. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49213. */
  49214. reflectionFalloffDistance: number;
  49215. protected _reflectionAmount: number;
  49216. /**
  49217. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49218. */
  49219. reflectionAmount: number;
  49220. protected _reflectionReflectance0: number;
  49221. /**
  49222. * This specifies the weight of the reflection at grazing angle.
  49223. */
  49224. reflectionReflectance0: number;
  49225. protected _reflectionReflectance90: number;
  49226. /**
  49227. * This specifies the weight of the reflection at a perpendicular point of view.
  49228. */
  49229. reflectionReflectance90: number;
  49230. /**
  49231. * Sets the reflection reflectance fresnel values according to the default standard
  49232. * empirically know to work well :-)
  49233. */
  49234. set reflectionStandardFresnelWeight(value: number);
  49235. protected _useRGBColor: boolean;
  49236. /**
  49237. * Helps to directly use the maps channels instead of their level.
  49238. */
  49239. useRGBColor: boolean;
  49240. protected _enableNoise: boolean;
  49241. /**
  49242. * This helps reducing the banding effect that could occur on the background.
  49243. */
  49244. enableNoise: boolean;
  49245. /**
  49246. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49247. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49248. * Recommended to be keep at 1.0 except for special cases.
  49249. */
  49250. get fovMultiplier(): number;
  49251. set fovMultiplier(value: number);
  49252. private _fovMultiplier;
  49253. /**
  49254. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49255. */
  49256. useEquirectangularFOV: boolean;
  49257. private _maxSimultaneousLights;
  49258. /**
  49259. * Number of Simultaneous lights allowed on the material.
  49260. */
  49261. maxSimultaneousLights: int;
  49262. /**
  49263. * Default configuration related to image processing available in the Background Material.
  49264. */
  49265. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49266. /**
  49267. * Keep track of the image processing observer to allow dispose and replace.
  49268. */
  49269. private _imageProcessingObserver;
  49270. /**
  49271. * Attaches a new image processing configuration to the PBR Material.
  49272. * @param configuration (if null the scene configuration will be use)
  49273. */
  49274. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49275. /**
  49276. * Gets the image processing configuration used either in this material.
  49277. */
  49278. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49279. /**
  49280. * Sets the Default image processing configuration used either in the this material.
  49281. *
  49282. * If sets to null, the scene one is in use.
  49283. */
  49284. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49285. /**
  49286. * Gets wether the color curves effect is enabled.
  49287. */
  49288. get cameraColorCurvesEnabled(): boolean;
  49289. /**
  49290. * Sets wether the color curves effect is enabled.
  49291. */
  49292. set cameraColorCurvesEnabled(value: boolean);
  49293. /**
  49294. * Gets wether the color grading effect is enabled.
  49295. */
  49296. get cameraColorGradingEnabled(): boolean;
  49297. /**
  49298. * Gets wether the color grading effect is enabled.
  49299. */
  49300. set cameraColorGradingEnabled(value: boolean);
  49301. /**
  49302. * Gets wether tonemapping is enabled or not.
  49303. */
  49304. get cameraToneMappingEnabled(): boolean;
  49305. /**
  49306. * Sets wether tonemapping is enabled or not
  49307. */
  49308. set cameraToneMappingEnabled(value: boolean);
  49309. /**
  49310. * The camera exposure used on this material.
  49311. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49312. * This corresponds to a photographic exposure.
  49313. */
  49314. get cameraExposure(): float;
  49315. /**
  49316. * The camera exposure used on this material.
  49317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49318. * This corresponds to a photographic exposure.
  49319. */
  49320. set cameraExposure(value: float);
  49321. /**
  49322. * Gets The camera contrast used on this material.
  49323. */
  49324. get cameraContrast(): float;
  49325. /**
  49326. * Sets The camera contrast used on this material.
  49327. */
  49328. set cameraContrast(value: float);
  49329. /**
  49330. * Gets the Color Grading 2D Lookup Texture.
  49331. */
  49332. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49333. /**
  49334. * Sets the Color Grading 2D Lookup Texture.
  49335. */
  49336. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49337. /**
  49338. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49339. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49340. * 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;
  49341. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49342. */
  49343. get cameraColorCurves(): Nullable<ColorCurves>;
  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. set cameraColorCurves(value: Nullable<ColorCurves>);
  49351. /**
  49352. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49353. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49354. */
  49355. switchToBGR: boolean;
  49356. private _renderTargets;
  49357. private _reflectionControls;
  49358. private _white;
  49359. private _primaryShadowColor;
  49360. private _primaryHighlightColor;
  49361. /**
  49362. * Instantiates a Background Material in the given scene
  49363. * @param name The friendly name of the material
  49364. * @param scene The scene to add the material to
  49365. */
  49366. constructor(name: string, scene: Scene);
  49367. /**
  49368. * Gets a boolean indicating that current material needs to register RTT
  49369. */
  49370. get hasRenderTargetTextures(): boolean;
  49371. /**
  49372. * The entire material has been created in order to prevent overdraw.
  49373. * @returns false
  49374. */
  49375. needAlphaTesting(): boolean;
  49376. /**
  49377. * The entire material has been created in order to prevent overdraw.
  49378. * @returns true if blending is enable
  49379. */
  49380. needAlphaBlending(): boolean;
  49381. /**
  49382. * Checks wether the material is ready to be rendered for a given mesh.
  49383. * @param mesh The mesh to render
  49384. * @param subMesh The submesh to check against
  49385. * @param useInstances Specify wether or not the material is used with instances
  49386. * @returns true if all the dependencies are ready (Textures, Effects...)
  49387. */
  49388. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49389. /**
  49390. * Compute the primary color according to the chosen perceptual color.
  49391. */
  49392. private _computePrimaryColorFromPerceptualColor;
  49393. /**
  49394. * Compute the highlights and shadow colors according to their chosen levels.
  49395. */
  49396. private _computePrimaryColors;
  49397. /**
  49398. * Build the uniform buffer used in the material.
  49399. */
  49400. buildUniformLayout(): void;
  49401. /**
  49402. * Unbind the material.
  49403. */
  49404. unbind(): void;
  49405. /**
  49406. * Bind only the world matrix to the material.
  49407. * @param world The world matrix to bind.
  49408. */
  49409. bindOnlyWorldMatrix(world: Matrix): void;
  49410. /**
  49411. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49412. * @param world The world matrix to bind.
  49413. * @param subMesh The submesh to bind for.
  49414. */
  49415. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49416. /**
  49417. * Checks to see if a texture is used in the material.
  49418. * @param texture - Base texture to use.
  49419. * @returns - Boolean specifying if a texture is used in the material.
  49420. */
  49421. hasTexture(texture: BaseTexture): boolean;
  49422. /**
  49423. * Dispose the material.
  49424. * @param forceDisposeEffect Force disposal of the associated effect.
  49425. * @param forceDisposeTextures Force disposal of the associated textures.
  49426. */
  49427. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49428. /**
  49429. * Clones the material.
  49430. * @param name The cloned name.
  49431. * @returns The cloned material.
  49432. */
  49433. clone(name: string): BackgroundMaterial;
  49434. /**
  49435. * Serializes the current material to its JSON representation.
  49436. * @returns The JSON representation.
  49437. */
  49438. serialize(): any;
  49439. /**
  49440. * Gets the class name of the material
  49441. * @returns "BackgroundMaterial"
  49442. */
  49443. getClassName(): string;
  49444. /**
  49445. * Parse a JSON input to create back a background material.
  49446. * @param source The JSON data to parse
  49447. * @param scene The scene to create the parsed material in
  49448. * @param rootUrl The root url of the assets the material depends upon
  49449. * @returns the instantiated BackgroundMaterial.
  49450. */
  49451. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49452. }
  49453. }
  49454. declare module BABYLON {
  49455. /**
  49456. * Represents the different options available during the creation of
  49457. * a Environment helper.
  49458. *
  49459. * This can control the default ground, skybox and image processing setup of your scene.
  49460. */
  49461. export interface IEnvironmentHelperOptions {
  49462. /**
  49463. * Specifies whether or not to create a ground.
  49464. * True by default.
  49465. */
  49466. createGround: boolean;
  49467. /**
  49468. * Specifies the ground size.
  49469. * 15 by default.
  49470. */
  49471. groundSize: number;
  49472. /**
  49473. * The texture used on the ground for the main color.
  49474. * Comes from the BabylonJS CDN by default.
  49475. *
  49476. * Remarks: Can be either a texture or a url.
  49477. */
  49478. groundTexture: string | BaseTexture;
  49479. /**
  49480. * The color mixed in the ground texture by default.
  49481. * BabylonJS clearColor by default.
  49482. */
  49483. groundColor: Color3;
  49484. /**
  49485. * Specifies the ground opacity.
  49486. * 1 by default.
  49487. */
  49488. groundOpacity: number;
  49489. /**
  49490. * Enables the ground to receive shadows.
  49491. * True by default.
  49492. */
  49493. enableGroundShadow: boolean;
  49494. /**
  49495. * Helps preventing the shadow to be fully black on the ground.
  49496. * 0.5 by default.
  49497. */
  49498. groundShadowLevel: number;
  49499. /**
  49500. * Creates a mirror texture attach to the ground.
  49501. * false by default.
  49502. */
  49503. enableGroundMirror: boolean;
  49504. /**
  49505. * Specifies the ground mirror size ratio.
  49506. * 0.3 by default as the default kernel is 64.
  49507. */
  49508. groundMirrorSizeRatio: number;
  49509. /**
  49510. * Specifies the ground mirror blur kernel size.
  49511. * 64 by default.
  49512. */
  49513. groundMirrorBlurKernel: number;
  49514. /**
  49515. * Specifies the ground mirror visibility amount.
  49516. * 1 by default
  49517. */
  49518. groundMirrorAmount: number;
  49519. /**
  49520. * Specifies the ground mirror reflectance weight.
  49521. * This uses the standard weight of the background material to setup the fresnel effect
  49522. * of the mirror.
  49523. * 1 by default.
  49524. */
  49525. groundMirrorFresnelWeight: number;
  49526. /**
  49527. * Specifies the ground mirror Falloff distance.
  49528. * This can helps reducing the size of the reflection.
  49529. * 0 by Default.
  49530. */
  49531. groundMirrorFallOffDistance: number;
  49532. /**
  49533. * Specifies the ground mirror texture type.
  49534. * Unsigned Int by Default.
  49535. */
  49536. groundMirrorTextureType: number;
  49537. /**
  49538. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49539. * the shown objects.
  49540. */
  49541. groundYBias: number;
  49542. /**
  49543. * Specifies whether or not to create a skybox.
  49544. * True by default.
  49545. */
  49546. createSkybox: boolean;
  49547. /**
  49548. * Specifies the skybox size.
  49549. * 20 by default.
  49550. */
  49551. skyboxSize: number;
  49552. /**
  49553. * The texture used on the skybox for the main color.
  49554. * Comes from the BabylonJS CDN by default.
  49555. *
  49556. * Remarks: Can be either a texture or a url.
  49557. */
  49558. skyboxTexture: string | BaseTexture;
  49559. /**
  49560. * The color mixed in the skybox texture by default.
  49561. * BabylonJS clearColor by default.
  49562. */
  49563. skyboxColor: Color3;
  49564. /**
  49565. * The background rotation around the Y axis of the scene.
  49566. * This helps aligning the key lights of your scene with the background.
  49567. * 0 by default.
  49568. */
  49569. backgroundYRotation: number;
  49570. /**
  49571. * Compute automatically the size of the elements to best fit with the scene.
  49572. */
  49573. sizeAuto: boolean;
  49574. /**
  49575. * Default position of the rootMesh if autoSize is not true.
  49576. */
  49577. rootPosition: Vector3;
  49578. /**
  49579. * Sets up the image processing in the scene.
  49580. * true by default.
  49581. */
  49582. setupImageProcessing: boolean;
  49583. /**
  49584. * The texture used as your environment texture in the scene.
  49585. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49586. *
  49587. * Remarks: Can be either a texture or a url.
  49588. */
  49589. environmentTexture: string | BaseTexture;
  49590. /**
  49591. * The value of the exposure to apply to the scene.
  49592. * 0.6 by default if setupImageProcessing is true.
  49593. */
  49594. cameraExposure: number;
  49595. /**
  49596. * The value of the contrast to apply to the scene.
  49597. * 1.6 by default if setupImageProcessing is true.
  49598. */
  49599. cameraContrast: number;
  49600. /**
  49601. * Specifies whether or not tonemapping should be enabled in the scene.
  49602. * true by default if setupImageProcessing is true.
  49603. */
  49604. toneMappingEnabled: boolean;
  49605. }
  49606. /**
  49607. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49608. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49609. * It also helps with the default setup of your imageProcessing configuration.
  49610. */
  49611. export class EnvironmentHelper {
  49612. /**
  49613. * Default ground texture URL.
  49614. */
  49615. private static _groundTextureCDNUrl;
  49616. /**
  49617. * Default skybox texture URL.
  49618. */
  49619. private static _skyboxTextureCDNUrl;
  49620. /**
  49621. * Default environment texture URL.
  49622. */
  49623. private static _environmentTextureCDNUrl;
  49624. /**
  49625. * Creates the default options for the helper.
  49626. */
  49627. private static _getDefaultOptions;
  49628. private _rootMesh;
  49629. /**
  49630. * Gets the root mesh created by the helper.
  49631. */
  49632. get rootMesh(): Mesh;
  49633. private _skybox;
  49634. /**
  49635. * Gets the skybox created by the helper.
  49636. */
  49637. get skybox(): Nullable<Mesh>;
  49638. private _skyboxTexture;
  49639. /**
  49640. * Gets the skybox texture created by the helper.
  49641. */
  49642. get skyboxTexture(): Nullable<BaseTexture>;
  49643. private _skyboxMaterial;
  49644. /**
  49645. * Gets the skybox material created by the helper.
  49646. */
  49647. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49648. private _ground;
  49649. /**
  49650. * Gets the ground mesh created by the helper.
  49651. */
  49652. get ground(): Nullable<Mesh>;
  49653. private _groundTexture;
  49654. /**
  49655. * Gets the ground texture created by the helper.
  49656. */
  49657. get groundTexture(): Nullable<BaseTexture>;
  49658. private _groundMirror;
  49659. /**
  49660. * Gets the ground mirror created by the helper.
  49661. */
  49662. get groundMirror(): Nullable<MirrorTexture>;
  49663. /**
  49664. * Gets the ground mirror render list to helps pushing the meshes
  49665. * you wish in the ground reflection.
  49666. */
  49667. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49668. private _groundMaterial;
  49669. /**
  49670. * Gets the ground material created by the helper.
  49671. */
  49672. get groundMaterial(): Nullable<BackgroundMaterial>;
  49673. /**
  49674. * Stores the creation options.
  49675. */
  49676. private readonly _scene;
  49677. private _options;
  49678. /**
  49679. * This observable will be notified with any error during the creation of the environment,
  49680. * mainly texture creation errors.
  49681. */
  49682. onErrorObservable: Observable<{
  49683. message?: string;
  49684. exception?: any;
  49685. }>;
  49686. /**
  49687. * constructor
  49688. * @param options Defines the options we want to customize the helper
  49689. * @param scene The scene to add the material to
  49690. */
  49691. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49692. /**
  49693. * Updates the background according to the new options
  49694. * @param options
  49695. */
  49696. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49697. /**
  49698. * Sets the primary color of all the available elements.
  49699. * @param color the main color to affect to the ground and the background
  49700. */
  49701. setMainColor(color: Color3): void;
  49702. /**
  49703. * Setup the image processing according to the specified options.
  49704. */
  49705. private _setupImageProcessing;
  49706. /**
  49707. * Setup the environment texture according to the specified options.
  49708. */
  49709. private _setupEnvironmentTexture;
  49710. /**
  49711. * Setup the background according to the specified options.
  49712. */
  49713. private _setupBackground;
  49714. /**
  49715. * Get the scene sizes according to the setup.
  49716. */
  49717. private _getSceneSize;
  49718. /**
  49719. * Setup the ground according to the specified options.
  49720. */
  49721. private _setupGround;
  49722. /**
  49723. * Setup the ground material according to the specified options.
  49724. */
  49725. private _setupGroundMaterial;
  49726. /**
  49727. * Setup the ground diffuse texture according to the specified options.
  49728. */
  49729. private _setupGroundDiffuseTexture;
  49730. /**
  49731. * Setup the ground mirror texture according to the specified options.
  49732. */
  49733. private _setupGroundMirrorTexture;
  49734. /**
  49735. * Setup the ground to receive the mirror texture.
  49736. */
  49737. private _setupMirrorInGroundMaterial;
  49738. /**
  49739. * Setup the skybox according to the specified options.
  49740. */
  49741. private _setupSkybox;
  49742. /**
  49743. * Setup the skybox material according to the specified options.
  49744. */
  49745. private _setupSkyboxMaterial;
  49746. /**
  49747. * Setup the skybox reflection texture according to the specified options.
  49748. */
  49749. private _setupSkyboxReflectionTexture;
  49750. private _errorHandler;
  49751. /**
  49752. * Dispose all the elements created by the Helper.
  49753. */
  49754. dispose(): void;
  49755. }
  49756. }
  49757. declare module BABYLON {
  49758. /**
  49759. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49760. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49761. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49762. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49763. */
  49764. export class PhotoDome extends TransformNode {
  49765. /**
  49766. * Define the image as a Monoscopic panoramic 360 image.
  49767. */
  49768. static readonly MODE_MONOSCOPIC: number;
  49769. /**
  49770. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49771. */
  49772. static readonly MODE_TOPBOTTOM: number;
  49773. /**
  49774. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49775. */
  49776. static readonly MODE_SIDEBYSIDE: number;
  49777. private _useDirectMapping;
  49778. /**
  49779. * The texture being displayed on the sphere
  49780. */
  49781. protected _photoTexture: Texture;
  49782. /**
  49783. * Gets or sets the texture being displayed on the sphere
  49784. */
  49785. get photoTexture(): Texture;
  49786. set photoTexture(value: Texture);
  49787. /**
  49788. * Observable raised when an error occured while loading the 360 image
  49789. */
  49790. onLoadErrorObservable: Observable<string>;
  49791. /**
  49792. * The skybox material
  49793. */
  49794. protected _material: BackgroundMaterial;
  49795. /**
  49796. * The surface used for the skybox
  49797. */
  49798. protected _mesh: Mesh;
  49799. /**
  49800. * Gets the mesh used for the skybox.
  49801. */
  49802. get mesh(): Mesh;
  49803. /**
  49804. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49805. * Also see the options.resolution property.
  49806. */
  49807. get fovMultiplier(): number;
  49808. set fovMultiplier(value: number);
  49809. private _imageMode;
  49810. /**
  49811. * Gets or set the current video mode for the video. It can be:
  49812. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49813. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49814. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49815. */
  49816. get imageMode(): number;
  49817. set imageMode(value: number);
  49818. /**
  49819. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49820. * @param name Element's name, child elements will append suffixes for their own names.
  49821. * @param urlsOfPhoto defines the url of the photo to display
  49822. * @param options defines an object containing optional or exposed sub element properties
  49823. * @param onError defines a callback called when an error occured while loading the texture
  49824. */
  49825. constructor(name: string, urlOfPhoto: string, options: {
  49826. resolution?: number;
  49827. size?: number;
  49828. useDirectMapping?: boolean;
  49829. faceForward?: boolean;
  49830. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49831. private _onBeforeCameraRenderObserver;
  49832. private _changeImageMode;
  49833. /**
  49834. * Releases resources associated with this node.
  49835. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49836. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49837. */
  49838. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49839. }
  49840. }
  49841. declare module BABYLON {
  49842. /**
  49843. * Class used to host RGBD texture specific utilities
  49844. */
  49845. export class RGBDTextureTools {
  49846. /**
  49847. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49848. * @param texture the texture to expand.
  49849. */
  49850. static ExpandRGBDTexture(texture: Texture): void;
  49851. }
  49852. }
  49853. declare module BABYLON {
  49854. /**
  49855. * Class used to host texture specific utilities
  49856. */
  49857. export class BRDFTextureTools {
  49858. /**
  49859. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49860. * @param scene defines the hosting scene
  49861. * @returns the environment BRDF texture
  49862. */
  49863. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49864. private static _environmentBRDFBase64Texture;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /**
  49869. * @hidden
  49870. */
  49871. export interface IMaterialClearCoatDefines {
  49872. CLEARCOAT: boolean;
  49873. CLEARCOAT_DEFAULTIOR: boolean;
  49874. CLEARCOAT_TEXTURE: boolean;
  49875. CLEARCOAT_TEXTUREDIRECTUV: number;
  49876. CLEARCOAT_BUMP: boolean;
  49877. CLEARCOAT_BUMPDIRECTUV: number;
  49878. CLEARCOAT_TINT: boolean;
  49879. CLEARCOAT_TINT_TEXTURE: boolean;
  49880. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49881. /** @hidden */
  49882. _areTexturesDirty: boolean;
  49883. }
  49884. /**
  49885. * Define the code related to the clear coat parameters of the pbr material.
  49886. */
  49887. export class PBRClearCoatConfiguration {
  49888. /**
  49889. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49890. * The default fits with a polyurethane material.
  49891. */
  49892. private static readonly _DefaultIndexOfRefraction;
  49893. private _isEnabled;
  49894. /**
  49895. * Defines if the clear coat is enabled in the material.
  49896. */
  49897. isEnabled: boolean;
  49898. /**
  49899. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49900. */
  49901. intensity: number;
  49902. /**
  49903. * Defines the clear coat layer roughness.
  49904. */
  49905. roughness: number;
  49906. private _indexOfRefraction;
  49907. /**
  49908. * Defines the index of refraction of the clear coat.
  49909. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49910. * The default fits with a polyurethane material.
  49911. * Changing the default value is more performance intensive.
  49912. */
  49913. indexOfRefraction: number;
  49914. private _texture;
  49915. /**
  49916. * Stores the clear coat values in a texture.
  49917. */
  49918. texture: Nullable<BaseTexture>;
  49919. private _bumpTexture;
  49920. /**
  49921. * Define the clear coat specific bump texture.
  49922. */
  49923. bumpTexture: Nullable<BaseTexture>;
  49924. private _isTintEnabled;
  49925. /**
  49926. * Defines if the clear coat tint is enabled in the material.
  49927. */
  49928. isTintEnabled: boolean;
  49929. /**
  49930. * Defines the clear coat tint of the material.
  49931. * This is only use if tint is enabled
  49932. */
  49933. tintColor: Color3;
  49934. /**
  49935. * Defines the distance at which the tint color should be found in the
  49936. * clear coat media.
  49937. * This is only use if tint is enabled
  49938. */
  49939. tintColorAtDistance: number;
  49940. /**
  49941. * Defines the clear coat layer thickness.
  49942. * This is only use if tint is enabled
  49943. */
  49944. tintThickness: number;
  49945. private _tintTexture;
  49946. /**
  49947. * Stores the clear tint values in a texture.
  49948. * rgb is tint
  49949. * a is a thickness factor
  49950. */
  49951. tintTexture: Nullable<BaseTexture>;
  49952. /** @hidden */
  49953. private _internalMarkAllSubMeshesAsTexturesDirty;
  49954. /** @hidden */
  49955. _markAllSubMeshesAsTexturesDirty(): void;
  49956. /**
  49957. * Instantiate a new istance of clear coat configuration.
  49958. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49959. */
  49960. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49961. /**
  49962. * Gets wehter the submesh is ready to be used or not.
  49963. * @param defines the list of "defines" to update.
  49964. * @param scene defines the scene the material belongs to.
  49965. * @param engine defines the engine the material belongs to.
  49966. * @param disableBumpMap defines wether the material disables bump or not.
  49967. * @returns - boolean indicating that the submesh is ready or not.
  49968. */
  49969. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49970. /**
  49971. * Checks to see if a texture is used in the material.
  49972. * @param defines the list of "defines" to update.
  49973. * @param scene defines the scene to the material belongs to.
  49974. */
  49975. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49976. /**
  49977. * Binds the material data.
  49978. * @param uniformBuffer defines the Uniform buffer to fill in.
  49979. * @param scene defines the scene the material belongs to.
  49980. * @param engine defines the engine the material belongs to.
  49981. * @param disableBumpMap defines wether the material disables bump or not.
  49982. * @param isFrozen defines wether the material is frozen or not.
  49983. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49984. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49985. */
  49986. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49987. /**
  49988. * Checks to see if a texture is used in the material.
  49989. * @param texture - Base texture to use.
  49990. * @returns - Boolean specifying if a texture is used in the material.
  49991. */
  49992. hasTexture(texture: BaseTexture): boolean;
  49993. /**
  49994. * Returns an array of the actively used textures.
  49995. * @param activeTextures Array of BaseTextures
  49996. */
  49997. getActiveTextures(activeTextures: BaseTexture[]): void;
  49998. /**
  49999. * Returns the animatable textures.
  50000. * @param animatables Array of animatable textures.
  50001. */
  50002. getAnimatables(animatables: IAnimatable[]): void;
  50003. /**
  50004. * Disposes the resources of the material.
  50005. * @param forceDisposeTextures - Forces the disposal of all textures.
  50006. */
  50007. dispose(forceDisposeTextures?: boolean): void;
  50008. /**
  50009. * Get the current class name of the texture useful for serialization or dynamic coding.
  50010. * @returns "PBRClearCoatConfiguration"
  50011. */
  50012. getClassName(): string;
  50013. /**
  50014. * Add fallbacks to the effect fallbacks list.
  50015. * @param defines defines the Base texture to use.
  50016. * @param fallbacks defines the current fallback list.
  50017. * @param currentRank defines the current fallback rank.
  50018. * @returns the new fallback rank.
  50019. */
  50020. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50021. /**
  50022. * Add the required uniforms to the current list.
  50023. * @param uniforms defines the current uniform list.
  50024. */
  50025. static AddUniforms(uniforms: string[]): void;
  50026. /**
  50027. * Add the required samplers to the current list.
  50028. * @param samplers defines the current sampler list.
  50029. */
  50030. static AddSamplers(samplers: string[]): void;
  50031. /**
  50032. * Add the required uniforms to the current buffer.
  50033. * @param uniformBuffer defines the current uniform buffer.
  50034. */
  50035. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50036. /**
  50037. * Makes a duplicate of the current configuration into another one.
  50038. * @param clearCoatConfiguration define the config where to copy the info
  50039. */
  50040. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50041. /**
  50042. * Serializes this clear coat configuration.
  50043. * @returns - An object with the serialized config.
  50044. */
  50045. serialize(): any;
  50046. /**
  50047. * Parses a anisotropy Configuration from a serialized object.
  50048. * @param source - Serialized object.
  50049. * @param scene Defines the scene we are parsing for
  50050. * @param rootUrl Defines the rootUrl to load from
  50051. */
  50052. parse(source: any, scene: Scene, rootUrl: string): void;
  50053. }
  50054. }
  50055. declare module BABYLON {
  50056. /**
  50057. * @hidden
  50058. */
  50059. export interface IMaterialAnisotropicDefines {
  50060. ANISOTROPIC: boolean;
  50061. ANISOTROPIC_TEXTURE: boolean;
  50062. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50063. MAINUV1: boolean;
  50064. _areTexturesDirty: boolean;
  50065. _needUVs: boolean;
  50066. }
  50067. /**
  50068. * Define the code related to the anisotropic parameters of the pbr material.
  50069. */
  50070. export class PBRAnisotropicConfiguration {
  50071. private _isEnabled;
  50072. /**
  50073. * Defines if the anisotropy is enabled in the material.
  50074. */
  50075. isEnabled: boolean;
  50076. /**
  50077. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50078. */
  50079. intensity: number;
  50080. /**
  50081. * Defines if the effect is along the tangents, bitangents or in between.
  50082. * By default, the effect is "strectching" the highlights along the tangents.
  50083. */
  50084. direction: Vector2;
  50085. private _texture;
  50086. /**
  50087. * Stores the anisotropy values in a texture.
  50088. * rg is direction (like normal from -1 to 1)
  50089. * b is a intensity
  50090. */
  50091. texture: Nullable<BaseTexture>;
  50092. /** @hidden */
  50093. private _internalMarkAllSubMeshesAsTexturesDirty;
  50094. /** @hidden */
  50095. _markAllSubMeshesAsTexturesDirty(): void;
  50096. /**
  50097. * Instantiate a new istance of anisotropy configuration.
  50098. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50099. */
  50100. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50101. /**
  50102. * Specifies that the submesh is ready to be used.
  50103. * @param defines the list of "defines" to update.
  50104. * @param scene defines the scene the material belongs to.
  50105. * @returns - boolean indicating that the submesh is ready or not.
  50106. */
  50107. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50108. /**
  50109. * Checks to see if a texture is used in the material.
  50110. * @param defines the list of "defines" to update.
  50111. * @param mesh the mesh we are preparing the defines for.
  50112. * @param scene defines the scene the material belongs to.
  50113. */
  50114. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50115. /**
  50116. * Binds the material data.
  50117. * @param uniformBuffer defines the Uniform buffer to fill in.
  50118. * @param scene defines the scene the material belongs to.
  50119. * @param isFrozen defines wether the material is frozen or not.
  50120. */
  50121. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50122. /**
  50123. * Checks to see if a texture is used in the material.
  50124. * @param texture - Base texture to use.
  50125. * @returns - Boolean specifying if a texture is used in the material.
  50126. */
  50127. hasTexture(texture: BaseTexture): boolean;
  50128. /**
  50129. * Returns an array of the actively used textures.
  50130. * @param activeTextures Array of BaseTextures
  50131. */
  50132. getActiveTextures(activeTextures: BaseTexture[]): void;
  50133. /**
  50134. * Returns the animatable textures.
  50135. * @param animatables Array of animatable textures.
  50136. */
  50137. getAnimatables(animatables: IAnimatable[]): void;
  50138. /**
  50139. * Disposes the resources of the material.
  50140. * @param forceDisposeTextures - Forces the disposal of all textures.
  50141. */
  50142. dispose(forceDisposeTextures?: boolean): void;
  50143. /**
  50144. * Get the current class name of the texture useful for serialization or dynamic coding.
  50145. * @returns "PBRAnisotropicConfiguration"
  50146. */
  50147. getClassName(): string;
  50148. /**
  50149. * Add fallbacks to the effect fallbacks list.
  50150. * @param defines defines the Base texture to use.
  50151. * @param fallbacks defines the current fallback list.
  50152. * @param currentRank defines the current fallback rank.
  50153. * @returns the new fallback rank.
  50154. */
  50155. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50156. /**
  50157. * Add the required uniforms to the current list.
  50158. * @param uniforms defines the current uniform list.
  50159. */
  50160. static AddUniforms(uniforms: string[]): void;
  50161. /**
  50162. * Add the required uniforms to the current buffer.
  50163. * @param uniformBuffer defines the current uniform buffer.
  50164. */
  50165. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50166. /**
  50167. * Add the required samplers to the current list.
  50168. * @param samplers defines the current sampler list.
  50169. */
  50170. static AddSamplers(samplers: string[]): void;
  50171. /**
  50172. * Makes a duplicate of the current configuration into another one.
  50173. * @param anisotropicConfiguration define the config where to copy the info
  50174. */
  50175. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50176. /**
  50177. * Serializes this anisotropy configuration.
  50178. * @returns - An object with the serialized config.
  50179. */
  50180. serialize(): any;
  50181. /**
  50182. * Parses a anisotropy Configuration from a serialized object.
  50183. * @param source - Serialized object.
  50184. * @param scene Defines the scene we are parsing for
  50185. * @param rootUrl Defines the rootUrl to load from
  50186. */
  50187. parse(source: any, scene: Scene, rootUrl: string): void;
  50188. }
  50189. }
  50190. declare module BABYLON {
  50191. /**
  50192. * @hidden
  50193. */
  50194. export interface IMaterialBRDFDefines {
  50195. BRDF_V_HEIGHT_CORRELATED: boolean;
  50196. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50197. SPHERICAL_HARMONICS: boolean;
  50198. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50199. /** @hidden */
  50200. _areMiscDirty: boolean;
  50201. }
  50202. /**
  50203. * Define the code related to the BRDF parameters of the pbr material.
  50204. */
  50205. export class PBRBRDFConfiguration {
  50206. /**
  50207. * Default value used for the energy conservation.
  50208. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50209. */
  50210. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50211. /**
  50212. * Default value used for the Smith Visibility Height Correlated mode.
  50213. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50214. */
  50215. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50216. /**
  50217. * Default value used for the IBL diffuse part.
  50218. * This can help switching back to the polynomials mode globally which is a tiny bit
  50219. * less GPU intensive at the drawback of a lower quality.
  50220. */
  50221. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50222. /**
  50223. * Default value used for activating energy conservation for the specular workflow.
  50224. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50225. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50226. */
  50227. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50228. private _useEnergyConservation;
  50229. /**
  50230. * Defines if the material uses energy conservation.
  50231. */
  50232. useEnergyConservation: boolean;
  50233. private _useSmithVisibilityHeightCorrelated;
  50234. /**
  50235. * LEGACY Mode set to false
  50236. * Defines if the material uses height smith correlated visibility term.
  50237. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50238. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50239. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50240. * Not relying on height correlated will also disable energy conservation.
  50241. */
  50242. useSmithVisibilityHeightCorrelated: boolean;
  50243. private _useSphericalHarmonics;
  50244. /**
  50245. * LEGACY Mode set to false
  50246. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50247. * diffuse part of the IBL.
  50248. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50249. * to the ground truth.
  50250. */
  50251. useSphericalHarmonics: boolean;
  50252. private _useSpecularGlossinessInputEnergyConservation;
  50253. /**
  50254. * Defines if the material uses energy conservation, when the specular workflow is active.
  50255. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50256. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50257. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50258. */
  50259. useSpecularGlossinessInputEnergyConservation: boolean;
  50260. /** @hidden */
  50261. private _internalMarkAllSubMeshesAsMiscDirty;
  50262. /** @hidden */
  50263. _markAllSubMeshesAsMiscDirty(): void;
  50264. /**
  50265. * Instantiate a new istance of clear coat configuration.
  50266. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50267. */
  50268. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50269. /**
  50270. * Checks to see if a texture is used in the material.
  50271. * @param defines the list of "defines" to update.
  50272. */
  50273. prepareDefines(defines: IMaterialBRDFDefines): void;
  50274. /**
  50275. * Get the current class name of the texture useful for serialization or dynamic coding.
  50276. * @returns "PBRClearCoatConfiguration"
  50277. */
  50278. getClassName(): string;
  50279. /**
  50280. * Makes a duplicate of the current configuration into another one.
  50281. * @param brdfConfiguration define the config where to copy the info
  50282. */
  50283. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50284. /**
  50285. * Serializes this BRDF configuration.
  50286. * @returns - An object with the serialized config.
  50287. */
  50288. serialize(): any;
  50289. /**
  50290. * Parses a anisotropy Configuration from a serialized object.
  50291. * @param source - Serialized object.
  50292. * @param scene Defines the scene we are parsing for
  50293. * @param rootUrl Defines the rootUrl to load from
  50294. */
  50295. parse(source: any, scene: Scene, rootUrl: string): void;
  50296. }
  50297. }
  50298. declare module BABYLON {
  50299. /**
  50300. * @hidden
  50301. */
  50302. export interface IMaterialSheenDefines {
  50303. SHEEN: boolean;
  50304. SHEEN_TEXTURE: boolean;
  50305. SHEEN_TEXTUREDIRECTUV: number;
  50306. SHEEN_LINKWITHALBEDO: boolean;
  50307. /** @hidden */
  50308. _areTexturesDirty: boolean;
  50309. }
  50310. /**
  50311. * Define the code related to the Sheen parameters of the pbr material.
  50312. */
  50313. export class PBRSheenConfiguration {
  50314. private _isEnabled;
  50315. /**
  50316. * Defines if the material uses sheen.
  50317. */
  50318. isEnabled: boolean;
  50319. private _linkSheenWithAlbedo;
  50320. /**
  50321. * Defines if the sheen is linked to the sheen color.
  50322. */
  50323. linkSheenWithAlbedo: boolean;
  50324. /**
  50325. * Defines the sheen intensity.
  50326. */
  50327. intensity: number;
  50328. /**
  50329. * Defines the sheen color.
  50330. */
  50331. color: Color3;
  50332. private _texture;
  50333. /**
  50334. * Stores the sheen tint values in a texture.
  50335. * rgb is tint
  50336. * a is a intensity
  50337. */
  50338. texture: Nullable<BaseTexture>;
  50339. /** @hidden */
  50340. private _internalMarkAllSubMeshesAsTexturesDirty;
  50341. /** @hidden */
  50342. _markAllSubMeshesAsTexturesDirty(): void;
  50343. /**
  50344. * Instantiate a new istance of clear coat configuration.
  50345. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50346. */
  50347. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50348. /**
  50349. * Specifies that the submesh is ready to be used.
  50350. * @param defines the list of "defines" to update.
  50351. * @param scene defines the scene the material belongs to.
  50352. * @returns - boolean indicating that the submesh is ready or not.
  50353. */
  50354. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50355. /**
  50356. * Checks to see if a texture is used in the material.
  50357. * @param defines the list of "defines" to update.
  50358. * @param scene defines the scene the material belongs to.
  50359. */
  50360. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50361. /**
  50362. * Binds the material data.
  50363. * @param uniformBuffer defines the Uniform buffer to fill in.
  50364. * @param scene defines the scene the material belongs to.
  50365. * @param isFrozen defines wether the material is frozen or not.
  50366. */
  50367. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50368. /**
  50369. * Checks to see if a texture is used in the material.
  50370. * @param texture - Base texture to use.
  50371. * @returns - Boolean specifying if a texture is used in the material.
  50372. */
  50373. hasTexture(texture: BaseTexture): boolean;
  50374. /**
  50375. * Returns an array of the actively used textures.
  50376. * @param activeTextures Array of BaseTextures
  50377. */
  50378. getActiveTextures(activeTextures: BaseTexture[]): void;
  50379. /**
  50380. * Returns the animatable textures.
  50381. * @param animatables Array of animatable textures.
  50382. */
  50383. getAnimatables(animatables: IAnimatable[]): void;
  50384. /**
  50385. * Disposes the resources of the material.
  50386. * @param forceDisposeTextures - Forces the disposal of all textures.
  50387. */
  50388. dispose(forceDisposeTextures?: boolean): void;
  50389. /**
  50390. * Get the current class name of the texture useful for serialization or dynamic coding.
  50391. * @returns "PBRSheenConfiguration"
  50392. */
  50393. getClassName(): string;
  50394. /**
  50395. * Add fallbacks to the effect fallbacks list.
  50396. * @param defines defines the Base texture to use.
  50397. * @param fallbacks defines the current fallback list.
  50398. * @param currentRank defines the current fallback rank.
  50399. * @returns the new fallback rank.
  50400. */
  50401. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50402. /**
  50403. * Add the required uniforms to the current list.
  50404. * @param uniforms defines the current uniform list.
  50405. */
  50406. static AddUniforms(uniforms: string[]): void;
  50407. /**
  50408. * Add the required uniforms to the current buffer.
  50409. * @param uniformBuffer defines the current uniform buffer.
  50410. */
  50411. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50412. /**
  50413. * Add the required samplers to the current list.
  50414. * @param samplers defines the current sampler list.
  50415. */
  50416. static AddSamplers(samplers: string[]): void;
  50417. /**
  50418. * Makes a duplicate of the current configuration into another one.
  50419. * @param sheenConfiguration define the config where to copy the info
  50420. */
  50421. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50422. /**
  50423. * Serializes this BRDF configuration.
  50424. * @returns - An object with the serialized config.
  50425. */
  50426. serialize(): any;
  50427. /**
  50428. * Parses a anisotropy Configuration from a serialized object.
  50429. * @param source - Serialized object.
  50430. * @param scene Defines the scene we are parsing for
  50431. * @param rootUrl Defines the rootUrl to load from
  50432. */
  50433. parse(source: any, scene: Scene, rootUrl: string): void;
  50434. }
  50435. }
  50436. declare module BABYLON {
  50437. /**
  50438. * @hidden
  50439. */
  50440. export interface IMaterialSubSurfaceDefines {
  50441. SUBSURFACE: boolean;
  50442. SS_REFRACTION: boolean;
  50443. SS_TRANSLUCENCY: boolean;
  50444. SS_SCATERRING: boolean;
  50445. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50446. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50447. SS_REFRACTIONMAP_3D: boolean;
  50448. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50449. SS_LODINREFRACTIONALPHA: boolean;
  50450. SS_GAMMAREFRACTION: boolean;
  50451. SS_RGBDREFRACTION: boolean;
  50452. SS_LINEARSPECULARREFRACTION: boolean;
  50453. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50454. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50455. /** @hidden */
  50456. _areTexturesDirty: boolean;
  50457. }
  50458. /**
  50459. * Define the code related to the sub surface parameters of the pbr material.
  50460. */
  50461. export class PBRSubSurfaceConfiguration {
  50462. private _isRefractionEnabled;
  50463. /**
  50464. * Defines if the refraction is enabled in the material.
  50465. */
  50466. isRefractionEnabled: boolean;
  50467. private _isTranslucencyEnabled;
  50468. /**
  50469. * Defines if the translucency is enabled in the material.
  50470. */
  50471. isTranslucencyEnabled: boolean;
  50472. private _isScatteringEnabled;
  50473. /**
  50474. * Defines the refraction intensity of the material.
  50475. * The refraction when enabled replaces the Diffuse part of the material.
  50476. * The intensity helps transitionning between diffuse and refraction.
  50477. */
  50478. refractionIntensity: number;
  50479. /**
  50480. * Defines the translucency intensity of the material.
  50481. * When translucency has been enabled, this defines how much of the "translucency"
  50482. * is addded to the diffuse part of the material.
  50483. */
  50484. translucencyIntensity: number;
  50485. /**
  50486. * Defines the scattering intensity of the material.
  50487. * When scattering has been enabled, this defines how much of the "scattered light"
  50488. * is addded to the diffuse part of the material.
  50489. */
  50490. scatteringIntensity: number;
  50491. private _thicknessTexture;
  50492. /**
  50493. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50494. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50495. * 0 would mean minimumThickness
  50496. * 1 would mean maximumThickness
  50497. * The other channels might be use as a mask to vary the different effects intensity.
  50498. */
  50499. thicknessTexture: Nullable<BaseTexture>;
  50500. private _refractionTexture;
  50501. /**
  50502. * Defines the texture to use for refraction.
  50503. */
  50504. refractionTexture: Nullable<BaseTexture>;
  50505. private _indexOfRefraction;
  50506. /**
  50507. * Defines the index of refraction used in the material.
  50508. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50509. */
  50510. indexOfRefraction: number;
  50511. private _invertRefractionY;
  50512. /**
  50513. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50514. */
  50515. invertRefractionY: boolean;
  50516. private _linkRefractionWithTransparency;
  50517. /**
  50518. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50519. * Materials half opaque for instance using refraction could benefit from this control.
  50520. */
  50521. linkRefractionWithTransparency: boolean;
  50522. /**
  50523. * Defines the minimum thickness stored in the thickness map.
  50524. * If no thickness map is defined, this value will be used to simulate thickness.
  50525. */
  50526. minimumThickness: number;
  50527. /**
  50528. * Defines the maximum thickness stored in the thickness map.
  50529. */
  50530. maximumThickness: number;
  50531. /**
  50532. * Defines the volume tint of the material.
  50533. * This is used for both translucency and scattering.
  50534. */
  50535. tintColor: Color3;
  50536. /**
  50537. * Defines the distance at which the tint color should be found in the media.
  50538. * This is used for refraction only.
  50539. */
  50540. tintColorAtDistance: number;
  50541. /**
  50542. * Defines how far each channel transmit through the media.
  50543. * It is defined as a color to simplify it selection.
  50544. */
  50545. diffusionDistance: Color3;
  50546. private _useMaskFromThicknessTexture;
  50547. /**
  50548. * Stores the intensity of the different subsurface effects in the thickness texture.
  50549. * * the green channel is the translucency intensity.
  50550. * * the blue channel is the scattering intensity.
  50551. * * the alpha channel is the refraction intensity.
  50552. */
  50553. useMaskFromThicknessTexture: boolean;
  50554. /** @hidden */
  50555. private _internalMarkAllSubMeshesAsTexturesDirty;
  50556. /** @hidden */
  50557. _markAllSubMeshesAsTexturesDirty(): void;
  50558. /**
  50559. * Instantiate a new istance of sub surface configuration.
  50560. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50561. */
  50562. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50563. /**
  50564. * Gets wehter the submesh is ready to be used or not.
  50565. * @param defines the list of "defines" to update.
  50566. * @param scene defines the scene the material belongs to.
  50567. * @returns - boolean indicating that the submesh is ready or not.
  50568. */
  50569. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50570. /**
  50571. * Checks to see if a texture is used in the material.
  50572. * @param defines the list of "defines" to update.
  50573. * @param scene defines the scene to the material belongs to.
  50574. */
  50575. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50576. /**
  50577. * Binds the material data.
  50578. * @param uniformBuffer defines the Uniform buffer to fill in.
  50579. * @param scene defines the scene the material belongs to.
  50580. * @param engine defines the engine the material belongs to.
  50581. * @param isFrozen defines wether the material is frozen or not.
  50582. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50583. */
  50584. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50585. /**
  50586. * Unbinds the material from the mesh.
  50587. * @param activeEffect defines the effect that should be unbound from.
  50588. * @returns true if unbound, otherwise false
  50589. */
  50590. unbind(activeEffect: Effect): boolean;
  50591. /**
  50592. * Returns the texture used for refraction or null if none is used.
  50593. * @param scene defines the scene the material belongs to.
  50594. * @returns - Refraction texture if present. If no refraction texture and refraction
  50595. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50596. */
  50597. private _getRefractionTexture;
  50598. /**
  50599. * Returns true if alpha blending should be disabled.
  50600. */
  50601. get disableAlphaBlending(): boolean;
  50602. /**
  50603. * Fills the list of render target textures.
  50604. * @param renderTargets the list of render targets to update
  50605. */
  50606. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50607. /**
  50608. * Checks to see if a texture is used in the material.
  50609. * @param texture - Base texture to use.
  50610. * @returns - Boolean specifying if a texture is used in the material.
  50611. */
  50612. hasTexture(texture: BaseTexture): boolean;
  50613. /**
  50614. * Gets a boolean indicating that current material needs to register RTT
  50615. * @returns true if this uses a render target otherwise false.
  50616. */
  50617. hasRenderTargetTextures(): boolean;
  50618. /**
  50619. * Returns an array of the actively used textures.
  50620. * @param activeTextures Array of BaseTextures
  50621. */
  50622. getActiveTextures(activeTextures: BaseTexture[]): void;
  50623. /**
  50624. * Returns the animatable textures.
  50625. * @param animatables Array of animatable textures.
  50626. */
  50627. getAnimatables(animatables: IAnimatable[]): void;
  50628. /**
  50629. * Disposes the resources of the material.
  50630. * @param forceDisposeTextures - Forces the disposal of all textures.
  50631. */
  50632. dispose(forceDisposeTextures?: boolean): void;
  50633. /**
  50634. * Get the current class name of the texture useful for serialization or dynamic coding.
  50635. * @returns "PBRSubSurfaceConfiguration"
  50636. */
  50637. getClassName(): string;
  50638. /**
  50639. * Add fallbacks to the effect fallbacks list.
  50640. * @param defines defines the Base texture to use.
  50641. * @param fallbacks defines the current fallback list.
  50642. * @param currentRank defines the current fallback rank.
  50643. * @returns the new fallback rank.
  50644. */
  50645. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50646. /**
  50647. * Add the required uniforms to the current list.
  50648. * @param uniforms defines the current uniform list.
  50649. */
  50650. static AddUniforms(uniforms: string[]): void;
  50651. /**
  50652. * Add the required samplers to the current list.
  50653. * @param samplers defines the current sampler list.
  50654. */
  50655. static AddSamplers(samplers: string[]): void;
  50656. /**
  50657. * Add the required uniforms to the current buffer.
  50658. * @param uniformBuffer defines the current uniform buffer.
  50659. */
  50660. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50661. /**
  50662. * Makes a duplicate of the current configuration into another one.
  50663. * @param configuration define the config where to copy the info
  50664. */
  50665. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50666. /**
  50667. * Serializes this Sub Surface configuration.
  50668. * @returns - An object with the serialized config.
  50669. */
  50670. serialize(): any;
  50671. /**
  50672. * Parses a anisotropy Configuration from a serialized object.
  50673. * @param source - Serialized object.
  50674. * @param scene Defines the scene we are parsing for
  50675. * @param rootUrl Defines the rootUrl to load from
  50676. */
  50677. parse(source: any, scene: Scene, rootUrl: string): void;
  50678. }
  50679. }
  50680. declare module BABYLON {
  50681. /** @hidden */
  50682. export var pbrFragmentDeclaration: {
  50683. name: string;
  50684. shader: string;
  50685. };
  50686. }
  50687. declare module BABYLON {
  50688. /** @hidden */
  50689. export var pbrUboDeclaration: {
  50690. name: string;
  50691. shader: string;
  50692. };
  50693. }
  50694. declare module BABYLON {
  50695. /** @hidden */
  50696. export var pbrFragmentExtraDeclaration: {
  50697. name: string;
  50698. shader: string;
  50699. };
  50700. }
  50701. declare module BABYLON {
  50702. /** @hidden */
  50703. export var pbrFragmentSamplersDeclaration: {
  50704. name: string;
  50705. shader: string;
  50706. };
  50707. }
  50708. declare module BABYLON {
  50709. /** @hidden */
  50710. export var pbrHelperFunctions: {
  50711. name: string;
  50712. shader: string;
  50713. };
  50714. }
  50715. declare module BABYLON {
  50716. /** @hidden */
  50717. export var harmonicsFunctions: {
  50718. name: string;
  50719. shader: string;
  50720. };
  50721. }
  50722. declare module BABYLON {
  50723. /** @hidden */
  50724. export var pbrDirectLightingSetupFunctions: {
  50725. name: string;
  50726. shader: string;
  50727. };
  50728. }
  50729. declare module BABYLON {
  50730. /** @hidden */
  50731. export var pbrDirectLightingFalloffFunctions: {
  50732. name: string;
  50733. shader: string;
  50734. };
  50735. }
  50736. declare module BABYLON {
  50737. /** @hidden */
  50738. export var pbrBRDFFunctions: {
  50739. name: string;
  50740. shader: string;
  50741. };
  50742. }
  50743. declare module BABYLON {
  50744. /** @hidden */
  50745. export var pbrDirectLightingFunctions: {
  50746. name: string;
  50747. shader: string;
  50748. };
  50749. }
  50750. declare module BABYLON {
  50751. /** @hidden */
  50752. export var pbrIBLFunctions: {
  50753. name: string;
  50754. shader: string;
  50755. };
  50756. }
  50757. declare module BABYLON {
  50758. /** @hidden */
  50759. export var pbrDebug: {
  50760. name: string;
  50761. shader: string;
  50762. };
  50763. }
  50764. declare module BABYLON {
  50765. /** @hidden */
  50766. export var pbrPixelShader: {
  50767. name: string;
  50768. shader: string;
  50769. };
  50770. }
  50771. declare module BABYLON {
  50772. /** @hidden */
  50773. export var pbrVertexDeclaration: {
  50774. name: string;
  50775. shader: string;
  50776. };
  50777. }
  50778. declare module BABYLON {
  50779. /** @hidden */
  50780. export var pbrVertexShader: {
  50781. name: string;
  50782. shader: string;
  50783. };
  50784. }
  50785. declare module BABYLON {
  50786. /**
  50787. * Manages the defines for the PBR Material.
  50788. * @hidden
  50789. */
  50790. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50791. PBR: boolean;
  50792. MAINUV1: boolean;
  50793. MAINUV2: boolean;
  50794. UV1: boolean;
  50795. UV2: boolean;
  50796. ALBEDO: boolean;
  50797. GAMMAALBEDO: boolean;
  50798. ALBEDODIRECTUV: number;
  50799. VERTEXCOLOR: boolean;
  50800. AMBIENT: boolean;
  50801. AMBIENTDIRECTUV: number;
  50802. AMBIENTINGRAYSCALE: boolean;
  50803. OPACITY: boolean;
  50804. VERTEXALPHA: boolean;
  50805. OPACITYDIRECTUV: number;
  50806. OPACITYRGB: boolean;
  50807. ALPHATEST: boolean;
  50808. DEPTHPREPASS: boolean;
  50809. ALPHABLEND: boolean;
  50810. ALPHAFROMALBEDO: boolean;
  50811. ALPHATESTVALUE: string;
  50812. SPECULAROVERALPHA: boolean;
  50813. RADIANCEOVERALPHA: boolean;
  50814. ALPHAFRESNEL: boolean;
  50815. LINEARALPHAFRESNEL: boolean;
  50816. PREMULTIPLYALPHA: boolean;
  50817. EMISSIVE: boolean;
  50818. EMISSIVEDIRECTUV: number;
  50819. REFLECTIVITY: boolean;
  50820. REFLECTIVITYDIRECTUV: number;
  50821. SPECULARTERM: boolean;
  50822. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50823. MICROSURFACEAUTOMATIC: boolean;
  50824. LODBASEDMICROSFURACE: boolean;
  50825. MICROSURFACEMAP: boolean;
  50826. MICROSURFACEMAPDIRECTUV: number;
  50827. METALLICWORKFLOW: boolean;
  50828. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50829. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50830. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50831. AOSTOREINMETALMAPRED: boolean;
  50832. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50833. ENVIRONMENTBRDF: boolean;
  50834. ENVIRONMENTBRDF_RGBD: boolean;
  50835. NORMAL: boolean;
  50836. TANGENT: boolean;
  50837. BUMP: boolean;
  50838. BUMPDIRECTUV: number;
  50839. OBJECTSPACE_NORMALMAP: boolean;
  50840. PARALLAX: boolean;
  50841. PARALLAXOCCLUSION: boolean;
  50842. NORMALXYSCALE: boolean;
  50843. LIGHTMAP: boolean;
  50844. LIGHTMAPDIRECTUV: number;
  50845. USELIGHTMAPASSHADOWMAP: boolean;
  50846. GAMMALIGHTMAP: boolean;
  50847. RGBDLIGHTMAP: boolean;
  50848. REFLECTION: boolean;
  50849. REFLECTIONMAP_3D: boolean;
  50850. REFLECTIONMAP_SPHERICAL: boolean;
  50851. REFLECTIONMAP_PLANAR: boolean;
  50852. REFLECTIONMAP_CUBIC: boolean;
  50853. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50854. REFLECTIONMAP_PROJECTION: boolean;
  50855. REFLECTIONMAP_SKYBOX: boolean;
  50856. REFLECTIONMAP_EXPLICIT: boolean;
  50857. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50858. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50859. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50860. INVERTCUBICMAP: boolean;
  50861. USESPHERICALFROMREFLECTIONMAP: boolean;
  50862. USEIRRADIANCEMAP: boolean;
  50863. SPHERICAL_HARMONICS: boolean;
  50864. USESPHERICALINVERTEX: boolean;
  50865. REFLECTIONMAP_OPPOSITEZ: boolean;
  50866. LODINREFLECTIONALPHA: boolean;
  50867. GAMMAREFLECTION: boolean;
  50868. RGBDREFLECTION: boolean;
  50869. LINEARSPECULARREFLECTION: boolean;
  50870. RADIANCEOCCLUSION: boolean;
  50871. HORIZONOCCLUSION: boolean;
  50872. INSTANCES: boolean;
  50873. NUM_BONE_INFLUENCERS: number;
  50874. BonesPerMesh: number;
  50875. BONETEXTURE: boolean;
  50876. NONUNIFORMSCALING: boolean;
  50877. MORPHTARGETS: boolean;
  50878. MORPHTARGETS_NORMAL: boolean;
  50879. MORPHTARGETS_TANGENT: boolean;
  50880. MORPHTARGETS_UV: boolean;
  50881. NUM_MORPH_INFLUENCERS: number;
  50882. IMAGEPROCESSING: boolean;
  50883. VIGNETTE: boolean;
  50884. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50885. VIGNETTEBLENDMODEOPAQUE: boolean;
  50886. TONEMAPPING: boolean;
  50887. TONEMAPPING_ACES: boolean;
  50888. CONTRAST: boolean;
  50889. COLORCURVES: boolean;
  50890. COLORGRADING: boolean;
  50891. COLORGRADING3D: boolean;
  50892. SAMPLER3DGREENDEPTH: boolean;
  50893. SAMPLER3DBGRMAP: boolean;
  50894. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50895. EXPOSURE: boolean;
  50896. MULTIVIEW: boolean;
  50897. USEPHYSICALLIGHTFALLOFF: boolean;
  50898. USEGLTFLIGHTFALLOFF: boolean;
  50899. TWOSIDEDLIGHTING: boolean;
  50900. SHADOWFLOAT: boolean;
  50901. CLIPPLANE: boolean;
  50902. CLIPPLANE2: boolean;
  50903. CLIPPLANE3: boolean;
  50904. CLIPPLANE4: boolean;
  50905. CLIPPLANE5: boolean;
  50906. CLIPPLANE6: boolean;
  50907. POINTSIZE: boolean;
  50908. FOG: boolean;
  50909. LOGARITHMICDEPTH: boolean;
  50910. FORCENORMALFORWARD: boolean;
  50911. SPECULARAA: boolean;
  50912. CLEARCOAT: boolean;
  50913. CLEARCOAT_DEFAULTIOR: boolean;
  50914. CLEARCOAT_TEXTURE: boolean;
  50915. CLEARCOAT_TEXTUREDIRECTUV: number;
  50916. CLEARCOAT_BUMP: boolean;
  50917. CLEARCOAT_BUMPDIRECTUV: number;
  50918. CLEARCOAT_TINT: boolean;
  50919. CLEARCOAT_TINT_TEXTURE: boolean;
  50920. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50921. ANISOTROPIC: boolean;
  50922. ANISOTROPIC_TEXTURE: boolean;
  50923. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50924. BRDF_V_HEIGHT_CORRELATED: boolean;
  50925. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50926. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50927. SHEEN: boolean;
  50928. SHEEN_TEXTURE: boolean;
  50929. SHEEN_TEXTUREDIRECTUV: number;
  50930. SHEEN_LINKWITHALBEDO: boolean;
  50931. SUBSURFACE: boolean;
  50932. SS_REFRACTION: boolean;
  50933. SS_TRANSLUCENCY: boolean;
  50934. SS_SCATERRING: boolean;
  50935. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50936. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50937. SS_REFRACTIONMAP_3D: boolean;
  50938. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50939. SS_LODINREFRACTIONALPHA: boolean;
  50940. SS_GAMMAREFRACTION: boolean;
  50941. SS_RGBDREFRACTION: boolean;
  50942. SS_LINEARSPECULARREFRACTION: boolean;
  50943. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50944. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50945. UNLIT: boolean;
  50946. DEBUGMODE: number;
  50947. /**
  50948. * Initializes the PBR Material defines.
  50949. */
  50950. constructor();
  50951. /**
  50952. * Resets the PBR Material defines.
  50953. */
  50954. reset(): void;
  50955. }
  50956. /**
  50957. * The Physically based material base class of BJS.
  50958. *
  50959. * This offers the main features of a standard PBR material.
  50960. * For more information, please refer to the documentation :
  50961. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50962. */
  50963. export abstract class PBRBaseMaterial extends PushMaterial {
  50964. /**
  50965. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50966. */
  50967. static readonly PBRMATERIAL_OPAQUE: number;
  50968. /**
  50969. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50970. */
  50971. static readonly PBRMATERIAL_ALPHATEST: number;
  50972. /**
  50973. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50974. */
  50975. static readonly PBRMATERIAL_ALPHABLEND: number;
  50976. /**
  50977. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50978. * They are also discarded below the alpha cutoff threshold to improve performances.
  50979. */
  50980. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50981. /**
  50982. * Defines the default value of how much AO map is occluding the analytical lights
  50983. * (point spot...).
  50984. */
  50985. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50986. /**
  50987. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50988. */
  50989. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50990. /**
  50991. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50992. * to enhance interoperability with other engines.
  50993. */
  50994. static readonly LIGHTFALLOFF_GLTF: number;
  50995. /**
  50996. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50997. * to enhance interoperability with other materials.
  50998. */
  50999. static readonly LIGHTFALLOFF_STANDARD: number;
  51000. /**
  51001. * Intensity of the direct lights e.g. the four lights available in your scene.
  51002. * This impacts both the direct diffuse and specular highlights.
  51003. */
  51004. protected _directIntensity: number;
  51005. /**
  51006. * Intensity of the emissive part of the material.
  51007. * This helps controlling the emissive effect without modifying the emissive color.
  51008. */
  51009. protected _emissiveIntensity: number;
  51010. /**
  51011. * Intensity of the environment e.g. how much the environment will light the object
  51012. * either through harmonics for rough material or through the refelction for shiny ones.
  51013. */
  51014. protected _environmentIntensity: number;
  51015. /**
  51016. * This is a special control allowing the reduction of the specular highlights coming from the
  51017. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51018. */
  51019. protected _specularIntensity: number;
  51020. /**
  51021. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51022. */
  51023. private _lightingInfos;
  51024. /**
  51025. * Debug Control allowing disabling the bump map on this material.
  51026. */
  51027. protected _disableBumpMap: boolean;
  51028. /**
  51029. * AKA Diffuse Texture in standard nomenclature.
  51030. */
  51031. protected _albedoTexture: Nullable<BaseTexture>;
  51032. /**
  51033. * AKA Occlusion Texture in other nomenclature.
  51034. */
  51035. protected _ambientTexture: Nullable<BaseTexture>;
  51036. /**
  51037. * AKA Occlusion Texture Intensity in other nomenclature.
  51038. */
  51039. protected _ambientTextureStrength: number;
  51040. /**
  51041. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51042. * 1 means it completely occludes it
  51043. * 0 mean it has no impact
  51044. */
  51045. protected _ambientTextureImpactOnAnalyticalLights: number;
  51046. /**
  51047. * Stores the alpha values in a texture.
  51048. */
  51049. protected _opacityTexture: Nullable<BaseTexture>;
  51050. /**
  51051. * Stores the reflection values in a texture.
  51052. */
  51053. protected _reflectionTexture: Nullable<BaseTexture>;
  51054. /**
  51055. * Stores the emissive values in a texture.
  51056. */
  51057. protected _emissiveTexture: Nullable<BaseTexture>;
  51058. /**
  51059. * AKA Specular texture in other nomenclature.
  51060. */
  51061. protected _reflectivityTexture: Nullable<BaseTexture>;
  51062. /**
  51063. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51064. */
  51065. protected _metallicTexture: Nullable<BaseTexture>;
  51066. /**
  51067. * Specifies the metallic scalar of the metallic/roughness workflow.
  51068. * Can also be used to scale the metalness values of the metallic texture.
  51069. */
  51070. protected _metallic: Nullable<number>;
  51071. /**
  51072. * Specifies the roughness scalar of the metallic/roughness workflow.
  51073. * Can also be used to scale the roughness values of the metallic texture.
  51074. */
  51075. protected _roughness: Nullable<number>;
  51076. /**
  51077. * Specifies the an F0 factor to help configuring the material F0.
  51078. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51079. * to 0.5 the previously hard coded value stays the same.
  51080. * Can also be used to scale the F0 values of the metallic texture.
  51081. */
  51082. protected _metallicF0Factor: number;
  51083. /**
  51084. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51085. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51086. * your expectation as it multiplies with the texture data.
  51087. */
  51088. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51089. /**
  51090. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51091. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51092. */
  51093. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51094. /**
  51095. * Stores surface normal data used to displace a mesh in a texture.
  51096. */
  51097. protected _bumpTexture: Nullable<BaseTexture>;
  51098. /**
  51099. * Stores the pre-calculated light information of a mesh in a texture.
  51100. */
  51101. protected _lightmapTexture: Nullable<BaseTexture>;
  51102. /**
  51103. * The color of a material in ambient lighting.
  51104. */
  51105. protected _ambientColor: Color3;
  51106. /**
  51107. * AKA Diffuse Color in other nomenclature.
  51108. */
  51109. protected _albedoColor: Color3;
  51110. /**
  51111. * AKA Specular Color in other nomenclature.
  51112. */
  51113. protected _reflectivityColor: Color3;
  51114. /**
  51115. * The color applied when light is reflected from a material.
  51116. */
  51117. protected _reflectionColor: Color3;
  51118. /**
  51119. * The color applied when light is emitted from a material.
  51120. */
  51121. protected _emissiveColor: Color3;
  51122. /**
  51123. * AKA Glossiness in other nomenclature.
  51124. */
  51125. protected _microSurface: number;
  51126. /**
  51127. * Specifies that the material will use the light map as a show map.
  51128. */
  51129. protected _useLightmapAsShadowmap: boolean;
  51130. /**
  51131. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51132. * makes the reflect vector face the model (under horizon).
  51133. */
  51134. protected _useHorizonOcclusion: boolean;
  51135. /**
  51136. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51137. * too much the area relying on ambient texture to define their ambient occlusion.
  51138. */
  51139. protected _useRadianceOcclusion: boolean;
  51140. /**
  51141. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51142. */
  51143. protected _useAlphaFromAlbedoTexture: boolean;
  51144. /**
  51145. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51146. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51147. */
  51148. protected _useSpecularOverAlpha: boolean;
  51149. /**
  51150. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51151. */
  51152. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51153. /**
  51154. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51155. */
  51156. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51157. /**
  51158. * Specifies if the metallic texture contains the roughness information in its green channel.
  51159. */
  51160. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51161. /**
  51162. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51163. */
  51164. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51165. /**
  51166. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51167. */
  51168. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51169. /**
  51170. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51171. */
  51172. protected _useAmbientInGrayScale: boolean;
  51173. /**
  51174. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51175. * The material will try to infer what glossiness each pixel should be.
  51176. */
  51177. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51178. /**
  51179. * Defines the falloff type used in this material.
  51180. * It by default is Physical.
  51181. */
  51182. protected _lightFalloff: number;
  51183. /**
  51184. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51185. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51186. */
  51187. protected _useRadianceOverAlpha: boolean;
  51188. /**
  51189. * Allows using an object space normal map (instead of tangent space).
  51190. */
  51191. protected _useObjectSpaceNormalMap: boolean;
  51192. /**
  51193. * Allows using the bump map in parallax mode.
  51194. */
  51195. protected _useParallax: boolean;
  51196. /**
  51197. * Allows using the bump map in parallax occlusion mode.
  51198. */
  51199. protected _useParallaxOcclusion: boolean;
  51200. /**
  51201. * Controls the scale bias of the parallax mode.
  51202. */
  51203. protected _parallaxScaleBias: number;
  51204. /**
  51205. * If sets to true, disables all the lights affecting the material.
  51206. */
  51207. protected _disableLighting: boolean;
  51208. /**
  51209. * Number of Simultaneous lights allowed on the material.
  51210. */
  51211. protected _maxSimultaneousLights: number;
  51212. /**
  51213. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51214. */
  51215. protected _invertNormalMapX: boolean;
  51216. /**
  51217. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51218. */
  51219. protected _invertNormalMapY: boolean;
  51220. /**
  51221. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51222. */
  51223. protected _twoSidedLighting: boolean;
  51224. /**
  51225. * Defines the alpha limits in alpha test mode.
  51226. */
  51227. protected _alphaCutOff: number;
  51228. /**
  51229. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51230. */
  51231. protected _forceAlphaTest: boolean;
  51232. /**
  51233. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51234. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51235. */
  51236. protected _useAlphaFresnel: boolean;
  51237. /**
  51238. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51239. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51240. */
  51241. protected _useLinearAlphaFresnel: boolean;
  51242. /**
  51243. * The transparency mode of the material.
  51244. */
  51245. protected _transparencyMode: Nullable<number>;
  51246. /**
  51247. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51248. * from cos thetav and roughness:
  51249. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51250. */
  51251. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51252. /**
  51253. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51254. */
  51255. protected _forceIrradianceInFragment: boolean;
  51256. /**
  51257. * Force normal to face away from face.
  51258. */
  51259. protected _forceNormalForward: boolean;
  51260. /**
  51261. * Enables specular anti aliasing in the PBR shader.
  51262. * It will both interacts on the Geometry for analytical and IBL lighting.
  51263. * It also prefilter the roughness map based on the bump values.
  51264. */
  51265. protected _enableSpecularAntiAliasing: boolean;
  51266. /**
  51267. * Default configuration related to image processing available in the PBR Material.
  51268. */
  51269. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51270. /**
  51271. * Keep track of the image processing observer to allow dispose and replace.
  51272. */
  51273. private _imageProcessingObserver;
  51274. /**
  51275. * Attaches a new image processing configuration to the PBR Material.
  51276. * @param configuration
  51277. */
  51278. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51279. /**
  51280. * Stores the available render targets.
  51281. */
  51282. private _renderTargets;
  51283. /**
  51284. * Sets the global ambient color for the material used in lighting calculations.
  51285. */
  51286. private _globalAmbientColor;
  51287. /**
  51288. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51289. */
  51290. private _useLogarithmicDepth;
  51291. /**
  51292. * If set to true, no lighting calculations will be applied.
  51293. */
  51294. private _unlit;
  51295. private _debugMode;
  51296. /**
  51297. * @hidden
  51298. * This is reserved for the inspector.
  51299. * Defines the material debug mode.
  51300. * It helps seeing only some components of the material while troubleshooting.
  51301. */
  51302. debugMode: number;
  51303. /**
  51304. * @hidden
  51305. * This is reserved for the inspector.
  51306. * Specify from where on screen the debug mode should start.
  51307. * The value goes from -1 (full screen) to 1 (not visible)
  51308. * It helps with side by side comparison against the final render
  51309. * This defaults to -1
  51310. */
  51311. private debugLimit;
  51312. /**
  51313. * @hidden
  51314. * This is reserved for the inspector.
  51315. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51316. * You can use the factor to better multiply the final value.
  51317. */
  51318. private debugFactor;
  51319. /**
  51320. * Defines the clear coat layer parameters for the material.
  51321. */
  51322. readonly clearCoat: PBRClearCoatConfiguration;
  51323. /**
  51324. * Defines the anisotropic parameters for the material.
  51325. */
  51326. readonly anisotropy: PBRAnisotropicConfiguration;
  51327. /**
  51328. * Defines the BRDF parameters for the material.
  51329. */
  51330. readonly brdf: PBRBRDFConfiguration;
  51331. /**
  51332. * Defines the Sheen parameters for the material.
  51333. */
  51334. readonly sheen: PBRSheenConfiguration;
  51335. /**
  51336. * Defines the SubSurface parameters for the material.
  51337. */
  51338. readonly subSurface: PBRSubSurfaceConfiguration;
  51339. /**
  51340. * Custom callback helping to override the default shader used in the material.
  51341. */
  51342. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51343. protected _rebuildInParallel: boolean;
  51344. /**
  51345. * Instantiates a new PBRMaterial instance.
  51346. *
  51347. * @param name The material name
  51348. * @param scene The scene the material will be use in.
  51349. */
  51350. constructor(name: string, scene: Scene);
  51351. /**
  51352. * Gets a boolean indicating that current material needs to register RTT
  51353. */
  51354. get hasRenderTargetTextures(): boolean;
  51355. /**
  51356. * Gets the name of the material class.
  51357. */
  51358. getClassName(): string;
  51359. /**
  51360. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51361. */
  51362. get useLogarithmicDepth(): boolean;
  51363. /**
  51364. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51365. */
  51366. set useLogarithmicDepth(value: boolean);
  51367. /**
  51368. * Gets the current transparency mode.
  51369. */
  51370. get transparencyMode(): Nullable<number>;
  51371. /**
  51372. * Sets the transparency mode of the material.
  51373. *
  51374. * | Value | Type | Description |
  51375. * | ----- | ----------------------------------- | ----------- |
  51376. * | 0 | OPAQUE | |
  51377. * | 1 | ALPHATEST | |
  51378. * | 2 | ALPHABLEND | |
  51379. * | 3 | ALPHATESTANDBLEND | |
  51380. *
  51381. */
  51382. set transparencyMode(value: Nullable<number>);
  51383. /**
  51384. * Returns true if alpha blending should be disabled.
  51385. */
  51386. private get _disableAlphaBlending();
  51387. /**
  51388. * Specifies whether or not this material should be rendered in alpha blend mode.
  51389. */
  51390. needAlphaBlending(): boolean;
  51391. /**
  51392. * Specifies if the mesh will require alpha blending.
  51393. * @param mesh - BJS mesh.
  51394. */
  51395. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51396. /**
  51397. * Specifies whether or not this material should be rendered in alpha test mode.
  51398. */
  51399. needAlphaTesting(): boolean;
  51400. /**
  51401. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51402. */
  51403. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51404. /**
  51405. * Gets the texture used for the alpha test.
  51406. */
  51407. getAlphaTestTexture(): Nullable<BaseTexture>;
  51408. /**
  51409. * Specifies that the submesh is ready to be used.
  51410. * @param mesh - BJS mesh.
  51411. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51412. * @param useInstances - Specifies that instances should be used.
  51413. * @returns - boolean indicating that the submesh is ready or not.
  51414. */
  51415. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51416. /**
  51417. * Specifies if the material uses metallic roughness workflow.
  51418. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51419. */
  51420. isMetallicWorkflow(): boolean;
  51421. private _prepareEffect;
  51422. private _prepareDefines;
  51423. /**
  51424. * Force shader compilation
  51425. */
  51426. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51427. /**
  51428. * Initializes the uniform buffer layout for the shader.
  51429. */
  51430. buildUniformLayout(): void;
  51431. /**
  51432. * Unbinds the material from the mesh
  51433. */
  51434. unbind(): void;
  51435. /**
  51436. * Binds the submesh data.
  51437. * @param world - The world matrix.
  51438. * @param mesh - The BJS mesh.
  51439. * @param subMesh - A submesh of the BJS mesh.
  51440. */
  51441. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51442. /**
  51443. * Returns the animatable textures.
  51444. * @returns - Array of animatable textures.
  51445. */
  51446. getAnimatables(): IAnimatable[];
  51447. /**
  51448. * Returns the texture used for reflections.
  51449. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51450. */
  51451. private _getReflectionTexture;
  51452. /**
  51453. * Returns an array of the actively used textures.
  51454. * @returns - Array of BaseTextures
  51455. */
  51456. getActiveTextures(): BaseTexture[];
  51457. /**
  51458. * Checks to see if a texture is used in the material.
  51459. * @param texture - Base texture to use.
  51460. * @returns - Boolean specifying if a texture is used in the material.
  51461. */
  51462. hasTexture(texture: BaseTexture): boolean;
  51463. /**
  51464. * Disposes the resources of the material.
  51465. * @param forceDisposeEffect - Forces the disposal of effects.
  51466. * @param forceDisposeTextures - Forces the disposal of all textures.
  51467. */
  51468. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51469. }
  51470. }
  51471. declare module BABYLON {
  51472. /**
  51473. * The Physically based material of BJS.
  51474. *
  51475. * This offers the main features of a standard PBR material.
  51476. * For more information, please refer to the documentation :
  51477. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51478. */
  51479. export class PBRMaterial extends PBRBaseMaterial {
  51480. /**
  51481. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51482. */
  51483. static readonly PBRMATERIAL_OPAQUE: number;
  51484. /**
  51485. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51486. */
  51487. static readonly PBRMATERIAL_ALPHATEST: number;
  51488. /**
  51489. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51490. */
  51491. static readonly PBRMATERIAL_ALPHABLEND: number;
  51492. /**
  51493. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51494. * They are also discarded below the alpha cutoff threshold to improve performances.
  51495. */
  51496. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51497. /**
  51498. * Defines the default value of how much AO map is occluding the analytical lights
  51499. * (point spot...).
  51500. */
  51501. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51502. /**
  51503. * Intensity of the direct lights e.g. the four lights available in your scene.
  51504. * This impacts both the direct diffuse and specular highlights.
  51505. */
  51506. directIntensity: number;
  51507. /**
  51508. * Intensity of the emissive part of the material.
  51509. * This helps controlling the emissive effect without modifying the emissive color.
  51510. */
  51511. emissiveIntensity: number;
  51512. /**
  51513. * Intensity of the environment e.g. how much the environment will light the object
  51514. * either through harmonics for rough material or through the refelction for shiny ones.
  51515. */
  51516. environmentIntensity: number;
  51517. /**
  51518. * This is a special control allowing the reduction of the specular highlights coming from the
  51519. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51520. */
  51521. specularIntensity: number;
  51522. /**
  51523. * Debug Control allowing disabling the bump map on this material.
  51524. */
  51525. disableBumpMap: boolean;
  51526. /**
  51527. * AKA Diffuse Texture in standard nomenclature.
  51528. */
  51529. albedoTexture: BaseTexture;
  51530. /**
  51531. * AKA Occlusion Texture in other nomenclature.
  51532. */
  51533. ambientTexture: BaseTexture;
  51534. /**
  51535. * AKA Occlusion Texture Intensity in other nomenclature.
  51536. */
  51537. ambientTextureStrength: number;
  51538. /**
  51539. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51540. * 1 means it completely occludes it
  51541. * 0 mean it has no impact
  51542. */
  51543. ambientTextureImpactOnAnalyticalLights: number;
  51544. /**
  51545. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51546. */
  51547. opacityTexture: BaseTexture;
  51548. /**
  51549. * Stores the reflection values in a texture.
  51550. */
  51551. reflectionTexture: Nullable<BaseTexture>;
  51552. /**
  51553. * Stores the emissive values in a texture.
  51554. */
  51555. emissiveTexture: BaseTexture;
  51556. /**
  51557. * AKA Specular texture in other nomenclature.
  51558. */
  51559. reflectivityTexture: BaseTexture;
  51560. /**
  51561. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51562. */
  51563. metallicTexture: BaseTexture;
  51564. /**
  51565. * Specifies the metallic scalar of the metallic/roughness workflow.
  51566. * Can also be used to scale the metalness values of the metallic texture.
  51567. */
  51568. metallic: Nullable<number>;
  51569. /**
  51570. * Specifies the roughness scalar of the metallic/roughness workflow.
  51571. * Can also be used to scale the roughness values of the metallic texture.
  51572. */
  51573. roughness: Nullable<number>;
  51574. /**
  51575. * Specifies the an F0 factor to help configuring the material F0.
  51576. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51577. * to 0.5 the previously hard coded value stays the same.
  51578. * Can also be used to scale the F0 values of the metallic texture.
  51579. */
  51580. metallicF0Factor: number;
  51581. /**
  51582. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51583. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51584. * your expectation as it multiplies with the texture data.
  51585. */
  51586. useMetallicF0FactorFromMetallicTexture: boolean;
  51587. /**
  51588. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51589. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51590. */
  51591. microSurfaceTexture: BaseTexture;
  51592. /**
  51593. * Stores surface normal data used to displace a mesh in a texture.
  51594. */
  51595. bumpTexture: BaseTexture;
  51596. /**
  51597. * Stores the pre-calculated light information of a mesh in a texture.
  51598. */
  51599. lightmapTexture: BaseTexture;
  51600. /**
  51601. * Stores the refracted light information in a texture.
  51602. */
  51603. get refractionTexture(): Nullable<BaseTexture>;
  51604. set refractionTexture(value: Nullable<BaseTexture>);
  51605. /**
  51606. * The color of a material in ambient lighting.
  51607. */
  51608. ambientColor: Color3;
  51609. /**
  51610. * AKA Diffuse Color in other nomenclature.
  51611. */
  51612. albedoColor: Color3;
  51613. /**
  51614. * AKA Specular Color in other nomenclature.
  51615. */
  51616. reflectivityColor: Color3;
  51617. /**
  51618. * The color reflected from the material.
  51619. */
  51620. reflectionColor: Color3;
  51621. /**
  51622. * The color emitted from the material.
  51623. */
  51624. emissiveColor: Color3;
  51625. /**
  51626. * AKA Glossiness in other nomenclature.
  51627. */
  51628. microSurface: number;
  51629. /**
  51630. * source material index of refraction (IOR)' / 'destination material IOR.
  51631. */
  51632. get indexOfRefraction(): number;
  51633. set indexOfRefraction(value: number);
  51634. /**
  51635. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51636. */
  51637. get invertRefractionY(): boolean;
  51638. set invertRefractionY(value: boolean);
  51639. /**
  51640. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51641. * Materials half opaque for instance using refraction could benefit from this control.
  51642. */
  51643. get linkRefractionWithTransparency(): boolean;
  51644. set linkRefractionWithTransparency(value: boolean);
  51645. /**
  51646. * If true, the light map contains occlusion information instead of lighting info.
  51647. */
  51648. useLightmapAsShadowmap: boolean;
  51649. /**
  51650. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51651. */
  51652. useAlphaFromAlbedoTexture: boolean;
  51653. /**
  51654. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51655. */
  51656. forceAlphaTest: boolean;
  51657. /**
  51658. * Defines the alpha limits in alpha test mode.
  51659. */
  51660. alphaCutOff: number;
  51661. /**
  51662. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51663. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51664. */
  51665. useSpecularOverAlpha: boolean;
  51666. /**
  51667. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51668. */
  51669. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51670. /**
  51671. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51672. */
  51673. useRoughnessFromMetallicTextureAlpha: boolean;
  51674. /**
  51675. * Specifies if the metallic texture contains the roughness information in its green channel.
  51676. */
  51677. useRoughnessFromMetallicTextureGreen: boolean;
  51678. /**
  51679. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51680. */
  51681. useMetallnessFromMetallicTextureBlue: boolean;
  51682. /**
  51683. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51684. */
  51685. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51686. /**
  51687. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51688. */
  51689. useAmbientInGrayScale: boolean;
  51690. /**
  51691. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51692. * The material will try to infer what glossiness each pixel should be.
  51693. */
  51694. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51695. /**
  51696. * BJS is using an harcoded light falloff based on a manually sets up range.
  51697. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51698. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51699. */
  51700. get usePhysicalLightFalloff(): 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. set usePhysicalLightFalloff(value: boolean);
  51707. /**
  51708. * In order to support the falloff compatibility with gltf, a special mode has been added
  51709. * to reproduce the gltf light falloff.
  51710. */
  51711. get useGLTFLightFalloff(): boolean;
  51712. /**
  51713. * In order to support the falloff compatibility with gltf, a special mode has been added
  51714. * to reproduce the gltf light falloff.
  51715. */
  51716. set useGLTFLightFalloff(value: boolean);
  51717. /**
  51718. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51719. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51720. */
  51721. useRadianceOverAlpha: boolean;
  51722. /**
  51723. * Allows using an object space normal map (instead of tangent space).
  51724. */
  51725. useObjectSpaceNormalMap: boolean;
  51726. /**
  51727. * Allows using the bump map in parallax mode.
  51728. */
  51729. useParallax: boolean;
  51730. /**
  51731. * Allows using the bump map in parallax occlusion mode.
  51732. */
  51733. useParallaxOcclusion: boolean;
  51734. /**
  51735. * Controls the scale bias of the parallax mode.
  51736. */
  51737. parallaxScaleBias: number;
  51738. /**
  51739. * If sets to true, disables all the lights affecting the material.
  51740. */
  51741. disableLighting: boolean;
  51742. /**
  51743. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51744. */
  51745. forceIrradianceInFragment: boolean;
  51746. /**
  51747. * Number of Simultaneous lights allowed on the material.
  51748. */
  51749. maxSimultaneousLights: number;
  51750. /**
  51751. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51752. */
  51753. invertNormalMapX: boolean;
  51754. /**
  51755. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51756. */
  51757. invertNormalMapY: boolean;
  51758. /**
  51759. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51760. */
  51761. twoSidedLighting: boolean;
  51762. /**
  51763. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51764. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51765. */
  51766. useAlphaFresnel: boolean;
  51767. /**
  51768. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51769. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51770. */
  51771. useLinearAlphaFresnel: boolean;
  51772. /**
  51773. * Let user defines the brdf lookup texture used for IBL.
  51774. * A default 8bit version is embedded but you could point at :
  51775. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51776. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51777. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51778. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51779. */
  51780. environmentBRDFTexture: Nullable<BaseTexture>;
  51781. /**
  51782. * Force normal to face away from face.
  51783. */
  51784. forceNormalForward: boolean;
  51785. /**
  51786. * Enables specular anti aliasing in the PBR shader.
  51787. * It will both interacts on the Geometry for analytical and IBL lighting.
  51788. * It also prefilter the roughness map based on the bump values.
  51789. */
  51790. enableSpecularAntiAliasing: boolean;
  51791. /**
  51792. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51793. * makes the reflect vector face the model (under horizon).
  51794. */
  51795. useHorizonOcclusion: boolean;
  51796. /**
  51797. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51798. * too much the area relying on ambient texture to define their ambient occlusion.
  51799. */
  51800. useRadianceOcclusion: boolean;
  51801. /**
  51802. * If set to true, no lighting calculations will be applied.
  51803. */
  51804. unlit: boolean;
  51805. /**
  51806. * Gets the image processing configuration used either in this material.
  51807. */
  51808. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51809. /**
  51810. * Sets the Default image processing configuration used either in the this material.
  51811. *
  51812. * If sets to null, the scene one is in use.
  51813. */
  51814. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51815. /**
  51816. * Gets wether the color curves effect is enabled.
  51817. */
  51818. get cameraColorCurvesEnabled(): boolean;
  51819. /**
  51820. * Sets wether the color curves effect is enabled.
  51821. */
  51822. set cameraColorCurvesEnabled(value: boolean);
  51823. /**
  51824. * Gets wether the color grading effect is enabled.
  51825. */
  51826. get cameraColorGradingEnabled(): boolean;
  51827. /**
  51828. * Gets wether the color grading effect is enabled.
  51829. */
  51830. set cameraColorGradingEnabled(value: boolean);
  51831. /**
  51832. * Gets wether tonemapping is enabled or not.
  51833. */
  51834. get cameraToneMappingEnabled(): boolean;
  51835. /**
  51836. * Sets wether tonemapping is enabled or not
  51837. */
  51838. set cameraToneMappingEnabled(value: boolean);
  51839. /**
  51840. * The camera exposure used on this material.
  51841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51842. * This corresponds to a photographic exposure.
  51843. */
  51844. get cameraExposure(): number;
  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. set cameraExposure(value: number);
  51851. /**
  51852. * Gets The camera contrast used on this material.
  51853. */
  51854. get cameraContrast(): number;
  51855. /**
  51856. * Sets The camera contrast used on this material.
  51857. */
  51858. set cameraContrast(value: number);
  51859. /**
  51860. * Gets the Color Grading 2D Lookup Texture.
  51861. */
  51862. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51863. /**
  51864. * Sets the Color Grading 2D Lookup Texture.
  51865. */
  51866. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51867. /**
  51868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51870. * 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;
  51871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51872. */
  51873. get cameraColorCurves(): Nullable<ColorCurves>;
  51874. /**
  51875. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51876. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51877. * 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;
  51878. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51879. */
  51880. set cameraColorCurves(value: Nullable<ColorCurves>);
  51881. /**
  51882. * Instantiates a new PBRMaterial instance.
  51883. *
  51884. * @param name The material name
  51885. * @param scene The scene the material will be use in.
  51886. */
  51887. constructor(name: string, scene: Scene);
  51888. /**
  51889. * Returns the name of this material class.
  51890. */
  51891. getClassName(): string;
  51892. /**
  51893. * Makes a duplicate of the current material.
  51894. * @param name - name to use for the new material.
  51895. */
  51896. clone(name: string): PBRMaterial;
  51897. /**
  51898. * Serializes this PBR Material.
  51899. * @returns - An object with the serialized material.
  51900. */
  51901. serialize(): any;
  51902. /**
  51903. * Parses a PBR Material from a serialized object.
  51904. * @param source - Serialized object.
  51905. * @param scene - BJS scene instance.
  51906. * @param rootUrl - url for the scene object
  51907. * @returns - PBRMaterial
  51908. */
  51909. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51910. }
  51911. }
  51912. declare module BABYLON {
  51913. /**
  51914. * Direct draw surface info
  51915. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51916. */
  51917. export interface DDSInfo {
  51918. /**
  51919. * Width of the texture
  51920. */
  51921. width: number;
  51922. /**
  51923. * Width of the texture
  51924. */
  51925. height: number;
  51926. /**
  51927. * Number of Mipmaps for the texture
  51928. * @see https://en.wikipedia.org/wiki/Mipmap
  51929. */
  51930. mipmapCount: number;
  51931. /**
  51932. * If the textures format is a known fourCC format
  51933. * @see https://www.fourcc.org/
  51934. */
  51935. isFourCC: boolean;
  51936. /**
  51937. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51938. */
  51939. isRGB: boolean;
  51940. /**
  51941. * If the texture is a lumincance format
  51942. */
  51943. isLuminance: boolean;
  51944. /**
  51945. * If this is a cube texture
  51946. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51947. */
  51948. isCube: boolean;
  51949. /**
  51950. * If the texture is a compressed format eg. FOURCC_DXT1
  51951. */
  51952. isCompressed: boolean;
  51953. /**
  51954. * The dxgiFormat of the texture
  51955. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51956. */
  51957. dxgiFormat: number;
  51958. /**
  51959. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51960. */
  51961. textureType: number;
  51962. /**
  51963. * Sphericle polynomial created for the dds texture
  51964. */
  51965. sphericalPolynomial?: SphericalPolynomial;
  51966. }
  51967. /**
  51968. * Class used to provide DDS decompression tools
  51969. */
  51970. export class DDSTools {
  51971. /**
  51972. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51973. */
  51974. static StoreLODInAlphaChannel: boolean;
  51975. /**
  51976. * Gets DDS information from an array buffer
  51977. * @param data defines the array buffer view to read data from
  51978. * @returns the DDS information
  51979. */
  51980. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  51981. private static _FloatView;
  51982. private static _Int32View;
  51983. private static _ToHalfFloat;
  51984. private static _FromHalfFloat;
  51985. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51986. private static _GetHalfFloatRGBAArrayBuffer;
  51987. private static _GetFloatRGBAArrayBuffer;
  51988. private static _GetFloatAsUIntRGBAArrayBuffer;
  51989. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51990. private static _GetRGBAArrayBuffer;
  51991. private static _ExtractLongWordOrder;
  51992. private static _GetRGBArrayBuffer;
  51993. private static _GetLuminanceArrayBuffer;
  51994. /**
  51995. * Uploads DDS Levels to a Babylon Texture
  51996. * @hidden
  51997. */
  51998. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51999. }
  52000. interface ThinEngine {
  52001. /**
  52002. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52003. * @param rootUrl defines the url where the file to load is located
  52004. * @param scene defines the current scene
  52005. * @param lodScale defines scale to apply to the mip map selection
  52006. * @param lodOffset defines offset to apply to the mip map selection
  52007. * @param onLoad defines an optional callback raised when the texture is loaded
  52008. * @param onError defines an optional callback raised if there is an issue to load the texture
  52009. * @param format defines the format of the data
  52010. * @param forcedExtension defines the extension to use to pick the right loader
  52011. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52012. * @returns the cube texture as an InternalTexture
  52013. */
  52014. 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;
  52015. }
  52016. }
  52017. declare module BABYLON {
  52018. /**
  52019. * Implementation of the DDS Texture Loader.
  52020. * @hidden
  52021. */
  52022. export class _DDSTextureLoader implements IInternalTextureLoader {
  52023. /**
  52024. * Defines wether the loader supports cascade loading the different faces.
  52025. */
  52026. readonly supportCascades: boolean;
  52027. /**
  52028. * This returns if the loader support the current file information.
  52029. * @param extension defines the file extension of the file being loaded
  52030. * @returns true if the loader can load the specified file
  52031. */
  52032. canLoad(extension: string): boolean;
  52033. /**
  52034. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52035. * @param data contains the texture data
  52036. * @param texture defines the BabylonJS internal texture
  52037. * @param createPolynomials will be true if polynomials have been requested
  52038. * @param onLoad defines the callback to trigger once the texture is ready
  52039. * @param onError defines the callback to trigger in case of error
  52040. */
  52041. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52042. /**
  52043. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52044. * @param data contains the texture data
  52045. * @param texture defines the BabylonJS internal texture
  52046. * @param callback defines the method to call once ready to upload
  52047. */
  52048. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52049. }
  52050. }
  52051. declare module BABYLON {
  52052. /**
  52053. * Implementation of the ENV Texture Loader.
  52054. * @hidden
  52055. */
  52056. export class _ENVTextureLoader implements IInternalTextureLoader {
  52057. /**
  52058. * Defines wether the loader supports cascade loading the different faces.
  52059. */
  52060. readonly supportCascades: boolean;
  52061. /**
  52062. * This returns if the loader support the current file information.
  52063. * @param extension defines the file extension of the file being loaded
  52064. * @returns true if the loader can load the specified file
  52065. */
  52066. canLoad(extension: string): boolean;
  52067. /**
  52068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52069. * @param data contains the texture data
  52070. * @param texture defines the BabylonJS internal texture
  52071. * @param createPolynomials will be true if polynomials have been requested
  52072. * @param onLoad defines the callback to trigger once the texture is ready
  52073. * @param onError defines the callback to trigger in case of error
  52074. */
  52075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52076. /**
  52077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52078. * @param data contains the texture data
  52079. * @param texture defines the BabylonJS internal texture
  52080. * @param callback defines the method to call once ready to upload
  52081. */
  52082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52083. }
  52084. }
  52085. declare module BABYLON {
  52086. /**
  52087. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52088. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52089. */
  52090. export class KhronosTextureContainer {
  52091. /** contents of the KTX container file */
  52092. data: ArrayBufferView;
  52093. private static HEADER_LEN;
  52094. private static COMPRESSED_2D;
  52095. private static COMPRESSED_3D;
  52096. private static TEX_2D;
  52097. private static TEX_3D;
  52098. /**
  52099. * Gets the openGL type
  52100. */
  52101. glType: number;
  52102. /**
  52103. * Gets the openGL type size
  52104. */
  52105. glTypeSize: number;
  52106. /**
  52107. * Gets the openGL format
  52108. */
  52109. glFormat: number;
  52110. /**
  52111. * Gets the openGL internal format
  52112. */
  52113. glInternalFormat: number;
  52114. /**
  52115. * Gets the base internal format
  52116. */
  52117. glBaseInternalFormat: number;
  52118. /**
  52119. * Gets image width in pixel
  52120. */
  52121. pixelWidth: number;
  52122. /**
  52123. * Gets image height in pixel
  52124. */
  52125. pixelHeight: number;
  52126. /**
  52127. * Gets image depth in pixels
  52128. */
  52129. pixelDepth: number;
  52130. /**
  52131. * Gets the number of array elements
  52132. */
  52133. numberOfArrayElements: number;
  52134. /**
  52135. * Gets the number of faces
  52136. */
  52137. numberOfFaces: number;
  52138. /**
  52139. * Gets the number of mipmap levels
  52140. */
  52141. numberOfMipmapLevels: number;
  52142. /**
  52143. * Gets the bytes of key value data
  52144. */
  52145. bytesOfKeyValueData: number;
  52146. /**
  52147. * Gets the load type
  52148. */
  52149. loadType: number;
  52150. /**
  52151. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52152. */
  52153. isInvalid: boolean;
  52154. /**
  52155. * Creates a new KhronosTextureContainer
  52156. * @param data contents of the KTX container file
  52157. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52158. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52159. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52160. */
  52161. constructor(
  52162. /** contents of the KTX container file */
  52163. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52164. /**
  52165. * Uploads KTX content to a Babylon Texture.
  52166. * It is assumed that the texture has already been created & is currently bound
  52167. * @hidden
  52168. */
  52169. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52170. private _upload2DCompressedLevels;
  52171. /**
  52172. * Checks if the given data starts with a KTX file identifier.
  52173. * @param data the data to check
  52174. * @returns true if the data is a KTX file or false otherwise
  52175. */
  52176. static IsValid(data: ArrayBufferView): boolean;
  52177. }
  52178. }
  52179. declare module BABYLON {
  52180. /**
  52181. * Class for loading KTX2 files
  52182. * !!! Experimental Extension Subject to Changes !!!
  52183. * @hidden
  52184. */
  52185. export class KhronosTextureContainer2 {
  52186. private static _ModulePromise;
  52187. private static _TranscodeFormat;
  52188. constructor(engine: ThinEngine);
  52189. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52190. private _determineTranscodeFormat;
  52191. /**
  52192. * Checks if the given data starts with a KTX2 file identifier.
  52193. * @param data the data to check
  52194. * @returns true if the data is a KTX2 file or false otherwise
  52195. */
  52196. static IsValid(data: ArrayBufferView): boolean;
  52197. }
  52198. }
  52199. declare module BABYLON {
  52200. /**
  52201. * Implementation of the KTX Texture Loader.
  52202. * @hidden
  52203. */
  52204. export class _KTXTextureLoader implements IInternalTextureLoader {
  52205. /**
  52206. * Defines wether the loader supports cascade loading the different faces.
  52207. */
  52208. readonly supportCascades: boolean;
  52209. /**
  52210. * This returns if the loader support the current file information.
  52211. * @param extension defines the file extension of the file being loaded
  52212. * @returns true if the loader can load the specified file
  52213. */
  52214. canLoad(extension: string): boolean;
  52215. /**
  52216. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52217. * @param data contains the texture data
  52218. * @param texture defines the BabylonJS internal texture
  52219. * @param createPolynomials will be true if polynomials have been requested
  52220. * @param onLoad defines the callback to trigger once the texture is ready
  52221. * @param onError defines the callback to trigger in case of error
  52222. */
  52223. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52224. /**
  52225. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52226. * @param data contains the texture data
  52227. * @param texture defines the BabylonJS internal texture
  52228. * @param callback defines the method to call once ready to upload
  52229. */
  52230. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52231. }
  52232. }
  52233. declare module BABYLON {
  52234. /** @hidden */
  52235. export var _forceSceneHelpersToBundle: boolean;
  52236. interface Scene {
  52237. /**
  52238. * Creates a default light for the scene.
  52239. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52240. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52241. */
  52242. createDefaultLight(replace?: boolean): void;
  52243. /**
  52244. * Creates a default camera for the scene.
  52245. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52246. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52247. * @param replace has default false, when true replaces the active camera in the scene
  52248. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52249. */
  52250. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52251. /**
  52252. * Creates a default camera and a default light.
  52253. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52254. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52255. * @param replace has the default false, when true replaces the active camera/light in the scene
  52256. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52257. */
  52258. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52259. /**
  52260. * Creates a new sky box
  52261. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52262. * @param environmentTexture defines the texture to use as environment texture
  52263. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52264. * @param scale defines the overall scale of the skybox
  52265. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52266. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52267. * @returns a new mesh holding the sky box
  52268. */
  52269. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52270. /**
  52271. * Creates a new environment
  52272. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52273. * @param options defines the options you can use to configure the environment
  52274. * @returns the new EnvironmentHelper
  52275. */
  52276. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52277. /**
  52278. * Creates a new VREXperienceHelper
  52279. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52280. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52281. * @returns a new VREXperienceHelper
  52282. */
  52283. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52284. /**
  52285. * Creates a new WebXRDefaultExperience
  52286. * @see http://doc.babylonjs.com/how_to/webxr
  52287. * @param options experience options
  52288. * @returns a promise for a new WebXRDefaultExperience
  52289. */
  52290. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52291. }
  52292. }
  52293. declare module BABYLON {
  52294. /**
  52295. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52296. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52297. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52298. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52299. */
  52300. export class VideoDome extends TransformNode {
  52301. /**
  52302. * Define the video source as a Monoscopic panoramic 360 video.
  52303. */
  52304. static readonly MODE_MONOSCOPIC: number;
  52305. /**
  52306. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52307. */
  52308. static readonly MODE_TOPBOTTOM: number;
  52309. /**
  52310. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52311. */
  52312. static readonly MODE_SIDEBYSIDE: number;
  52313. private _halfDome;
  52314. private _useDirectMapping;
  52315. /**
  52316. * The video texture being displayed on the sphere
  52317. */
  52318. protected _videoTexture: VideoTexture;
  52319. /**
  52320. * Gets the video texture being displayed on the sphere
  52321. */
  52322. get videoTexture(): VideoTexture;
  52323. /**
  52324. * The skybox material
  52325. */
  52326. protected _material: BackgroundMaterial;
  52327. /**
  52328. * The surface used for the skybox
  52329. */
  52330. protected _mesh: Mesh;
  52331. /**
  52332. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52333. */
  52334. private _halfDomeMask;
  52335. /**
  52336. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52337. * Also see the options.resolution property.
  52338. */
  52339. get fovMultiplier(): number;
  52340. set fovMultiplier(value: number);
  52341. private _videoMode;
  52342. /**
  52343. * Gets or set the current video mode for the video. It can be:
  52344. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52345. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52346. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52347. */
  52348. get videoMode(): number;
  52349. set videoMode(value: number);
  52350. /**
  52351. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52352. *
  52353. */
  52354. get halfDome(): boolean;
  52355. /**
  52356. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52357. */
  52358. set halfDome(enabled: boolean);
  52359. /**
  52360. * Oberserver used in Stereoscopic VR Mode.
  52361. */
  52362. private _onBeforeCameraRenderObserver;
  52363. /**
  52364. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52365. * @param name Element's name, child elements will append suffixes for their own names.
  52366. * @param urlsOrVideo defines the url(s) or the video element to use
  52367. * @param options An object containing optional or exposed sub element properties
  52368. */
  52369. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52370. resolution?: number;
  52371. clickToPlay?: boolean;
  52372. autoPlay?: boolean;
  52373. loop?: boolean;
  52374. size?: number;
  52375. poster?: string;
  52376. faceForward?: boolean;
  52377. useDirectMapping?: boolean;
  52378. halfDomeMode?: boolean;
  52379. }, scene: Scene);
  52380. private _changeVideoMode;
  52381. /**
  52382. * Releases resources associated with this node.
  52383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52385. */
  52386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52387. }
  52388. }
  52389. declare module BABYLON {
  52390. /**
  52391. * This class can be used to get instrumentation data from a Babylon engine
  52392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52393. */
  52394. export class EngineInstrumentation implements IDisposable {
  52395. /**
  52396. * Define the instrumented engine.
  52397. */
  52398. engine: Engine;
  52399. private _captureGPUFrameTime;
  52400. private _gpuFrameTimeToken;
  52401. private _gpuFrameTime;
  52402. private _captureShaderCompilationTime;
  52403. private _shaderCompilationTime;
  52404. private _onBeginFrameObserver;
  52405. private _onEndFrameObserver;
  52406. private _onBeforeShaderCompilationObserver;
  52407. private _onAfterShaderCompilationObserver;
  52408. /**
  52409. * Gets the perf counter used for GPU frame time
  52410. */
  52411. get gpuFrameTimeCounter(): PerfCounter;
  52412. /**
  52413. * Gets the GPU frame time capture status
  52414. */
  52415. get captureGPUFrameTime(): boolean;
  52416. /**
  52417. * Enable or disable the GPU frame time capture
  52418. */
  52419. set captureGPUFrameTime(value: boolean);
  52420. /**
  52421. * Gets the perf counter used for shader compilation time
  52422. */
  52423. get shaderCompilationTimeCounter(): PerfCounter;
  52424. /**
  52425. * Gets the shader compilation time capture status
  52426. */
  52427. get captureShaderCompilationTime(): boolean;
  52428. /**
  52429. * Enable or disable the shader compilation time capture
  52430. */
  52431. set captureShaderCompilationTime(value: boolean);
  52432. /**
  52433. * Instantiates a new engine instrumentation.
  52434. * This class can be used to get instrumentation data from a Babylon engine
  52435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52436. * @param engine Defines the engine to instrument
  52437. */
  52438. constructor(
  52439. /**
  52440. * Define the instrumented engine.
  52441. */
  52442. engine: Engine);
  52443. /**
  52444. * Dispose and release associated resources.
  52445. */
  52446. dispose(): void;
  52447. }
  52448. }
  52449. declare module BABYLON {
  52450. /**
  52451. * This class can be used to get instrumentation data from a Babylon engine
  52452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52453. */
  52454. export class SceneInstrumentation implements IDisposable {
  52455. /**
  52456. * Defines the scene to instrument
  52457. */
  52458. scene: Scene;
  52459. private _captureActiveMeshesEvaluationTime;
  52460. private _activeMeshesEvaluationTime;
  52461. private _captureRenderTargetsRenderTime;
  52462. private _renderTargetsRenderTime;
  52463. private _captureFrameTime;
  52464. private _frameTime;
  52465. private _captureRenderTime;
  52466. private _renderTime;
  52467. private _captureInterFrameTime;
  52468. private _interFrameTime;
  52469. private _captureParticlesRenderTime;
  52470. private _particlesRenderTime;
  52471. private _captureSpritesRenderTime;
  52472. private _spritesRenderTime;
  52473. private _capturePhysicsTime;
  52474. private _physicsTime;
  52475. private _captureAnimationsTime;
  52476. private _animationsTime;
  52477. private _captureCameraRenderTime;
  52478. private _cameraRenderTime;
  52479. private _onBeforeActiveMeshesEvaluationObserver;
  52480. private _onAfterActiveMeshesEvaluationObserver;
  52481. private _onBeforeRenderTargetsRenderObserver;
  52482. private _onAfterRenderTargetsRenderObserver;
  52483. private _onAfterRenderObserver;
  52484. private _onBeforeDrawPhaseObserver;
  52485. private _onAfterDrawPhaseObserver;
  52486. private _onBeforeAnimationsObserver;
  52487. private _onBeforeParticlesRenderingObserver;
  52488. private _onAfterParticlesRenderingObserver;
  52489. private _onBeforeSpritesRenderingObserver;
  52490. private _onAfterSpritesRenderingObserver;
  52491. private _onBeforePhysicsObserver;
  52492. private _onAfterPhysicsObserver;
  52493. private _onAfterAnimationsObserver;
  52494. private _onBeforeCameraRenderObserver;
  52495. private _onAfterCameraRenderObserver;
  52496. /**
  52497. * Gets the perf counter used for active meshes evaluation time
  52498. */
  52499. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52500. /**
  52501. * Gets the active meshes evaluation time capture status
  52502. */
  52503. get captureActiveMeshesEvaluationTime(): boolean;
  52504. /**
  52505. * Enable or disable the active meshes evaluation time capture
  52506. */
  52507. set captureActiveMeshesEvaluationTime(value: boolean);
  52508. /**
  52509. * Gets the perf counter used for render targets render time
  52510. */
  52511. get renderTargetsRenderTimeCounter(): PerfCounter;
  52512. /**
  52513. * Gets the render targets render time capture status
  52514. */
  52515. get captureRenderTargetsRenderTime(): boolean;
  52516. /**
  52517. * Enable or disable the render targets render time capture
  52518. */
  52519. set captureRenderTargetsRenderTime(value: boolean);
  52520. /**
  52521. * Gets the perf counter used for particles render time
  52522. */
  52523. get particlesRenderTimeCounter(): PerfCounter;
  52524. /**
  52525. * Gets the particles render time capture status
  52526. */
  52527. get captureParticlesRenderTime(): boolean;
  52528. /**
  52529. * Enable or disable the particles render time capture
  52530. */
  52531. set captureParticlesRenderTime(value: boolean);
  52532. /**
  52533. * Gets the perf counter used for sprites render time
  52534. */
  52535. get spritesRenderTimeCounter(): PerfCounter;
  52536. /**
  52537. * Gets the sprites render time capture status
  52538. */
  52539. get captureSpritesRenderTime(): boolean;
  52540. /**
  52541. * Enable or disable the sprites render time capture
  52542. */
  52543. set captureSpritesRenderTime(value: boolean);
  52544. /**
  52545. * Gets the perf counter used for physics time
  52546. */
  52547. get physicsTimeCounter(): PerfCounter;
  52548. /**
  52549. * Gets the physics time capture status
  52550. */
  52551. get capturePhysicsTime(): boolean;
  52552. /**
  52553. * Enable or disable the physics time capture
  52554. */
  52555. set capturePhysicsTime(value: boolean);
  52556. /**
  52557. * Gets the perf counter used for animations time
  52558. */
  52559. get animationsTimeCounter(): PerfCounter;
  52560. /**
  52561. * Gets the animations time capture status
  52562. */
  52563. get captureAnimationsTime(): boolean;
  52564. /**
  52565. * Enable or disable the animations time capture
  52566. */
  52567. set captureAnimationsTime(value: boolean);
  52568. /**
  52569. * Gets the perf counter used for frame time capture
  52570. */
  52571. get frameTimeCounter(): PerfCounter;
  52572. /**
  52573. * Gets the frame time capture status
  52574. */
  52575. get captureFrameTime(): boolean;
  52576. /**
  52577. * Enable or disable the frame time capture
  52578. */
  52579. set captureFrameTime(value: boolean);
  52580. /**
  52581. * Gets the perf counter used for inter-frames time capture
  52582. */
  52583. get interFrameTimeCounter(): PerfCounter;
  52584. /**
  52585. * Gets the inter-frames time capture status
  52586. */
  52587. get captureInterFrameTime(): boolean;
  52588. /**
  52589. * Enable or disable the inter-frames time capture
  52590. */
  52591. set captureInterFrameTime(value: boolean);
  52592. /**
  52593. * Gets the perf counter used for render time capture
  52594. */
  52595. get renderTimeCounter(): PerfCounter;
  52596. /**
  52597. * Gets the render time capture status
  52598. */
  52599. get captureRenderTime(): boolean;
  52600. /**
  52601. * Enable or disable the render time capture
  52602. */
  52603. set captureRenderTime(value: boolean);
  52604. /**
  52605. * Gets the perf counter used for camera render time capture
  52606. */
  52607. get cameraRenderTimeCounter(): PerfCounter;
  52608. /**
  52609. * Gets the camera render time capture status
  52610. */
  52611. get captureCameraRenderTime(): boolean;
  52612. /**
  52613. * Enable or disable the camera render time capture
  52614. */
  52615. set captureCameraRenderTime(value: boolean);
  52616. /**
  52617. * Gets the perf counter used for draw calls
  52618. */
  52619. get drawCallsCounter(): PerfCounter;
  52620. /**
  52621. * Instantiates a new scene instrumentation.
  52622. * This class can be used to get instrumentation data from a Babylon engine
  52623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52624. * @param scene Defines the scene to instrument
  52625. */
  52626. constructor(
  52627. /**
  52628. * Defines the scene to instrument
  52629. */
  52630. scene: Scene);
  52631. /**
  52632. * Dispose and release associated resources.
  52633. */
  52634. dispose(): void;
  52635. }
  52636. }
  52637. declare module BABYLON {
  52638. /** @hidden */
  52639. export var glowMapGenerationPixelShader: {
  52640. name: string;
  52641. shader: string;
  52642. };
  52643. }
  52644. declare module BABYLON {
  52645. /** @hidden */
  52646. export var glowMapGenerationVertexShader: {
  52647. name: string;
  52648. shader: string;
  52649. };
  52650. }
  52651. declare module BABYLON {
  52652. /**
  52653. * Effect layer options. This helps customizing the behaviour
  52654. * of the effect layer.
  52655. */
  52656. export interface IEffectLayerOptions {
  52657. /**
  52658. * Multiplication factor apply to the canvas size to compute the render target size
  52659. * used to generated the objects (the smaller the faster).
  52660. */
  52661. mainTextureRatio: number;
  52662. /**
  52663. * Enforces a fixed size texture to ensure effect stability across devices.
  52664. */
  52665. mainTextureFixedSize?: number;
  52666. /**
  52667. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52668. */
  52669. alphaBlendingMode: number;
  52670. /**
  52671. * The camera attached to the layer.
  52672. */
  52673. camera: Nullable<Camera>;
  52674. /**
  52675. * The rendering group to draw the layer in.
  52676. */
  52677. renderingGroupId: number;
  52678. }
  52679. /**
  52680. * The effect layer Helps adding post process effect blended with the main pass.
  52681. *
  52682. * This can be for instance use to generate glow or higlight effects on the scene.
  52683. *
  52684. * The effect layer class can not be used directly and is intented to inherited from to be
  52685. * customized per effects.
  52686. */
  52687. export abstract class EffectLayer {
  52688. private _vertexBuffers;
  52689. private _indexBuffer;
  52690. private _cachedDefines;
  52691. private _effectLayerMapGenerationEffect;
  52692. private _effectLayerOptions;
  52693. private _mergeEffect;
  52694. protected _scene: Scene;
  52695. protected _engine: Engine;
  52696. protected _maxSize: number;
  52697. protected _mainTextureDesiredSize: ISize;
  52698. protected _mainTexture: RenderTargetTexture;
  52699. protected _shouldRender: boolean;
  52700. protected _postProcesses: PostProcess[];
  52701. protected _textures: BaseTexture[];
  52702. protected _emissiveTextureAndColor: {
  52703. texture: Nullable<BaseTexture>;
  52704. color: Color4;
  52705. };
  52706. /**
  52707. * The name of the layer
  52708. */
  52709. name: string;
  52710. /**
  52711. * The clear color of the texture used to generate the glow map.
  52712. */
  52713. neutralColor: Color4;
  52714. /**
  52715. * Specifies whether the highlight layer is enabled or not.
  52716. */
  52717. isEnabled: boolean;
  52718. /**
  52719. * Gets the camera attached to the layer.
  52720. */
  52721. get camera(): Nullable<Camera>;
  52722. /**
  52723. * Gets the rendering group id the layer should render in.
  52724. */
  52725. get renderingGroupId(): number;
  52726. set renderingGroupId(renderingGroupId: number);
  52727. /**
  52728. * An event triggered when the effect layer has been disposed.
  52729. */
  52730. onDisposeObservable: Observable<EffectLayer>;
  52731. /**
  52732. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52733. */
  52734. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52735. /**
  52736. * An event triggered when the generated texture is being merged in the scene.
  52737. */
  52738. onBeforeComposeObservable: Observable<EffectLayer>;
  52739. /**
  52740. * An event triggered when the mesh is rendered into the effect render target.
  52741. */
  52742. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52743. /**
  52744. * An event triggered after the mesh has been rendered into the effect render target.
  52745. */
  52746. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52747. /**
  52748. * An event triggered when the generated texture has been merged in the scene.
  52749. */
  52750. onAfterComposeObservable: Observable<EffectLayer>;
  52751. /**
  52752. * An event triggered when the efffect layer changes its size.
  52753. */
  52754. onSizeChangedObservable: Observable<EffectLayer>;
  52755. /** @hidden */
  52756. static _SceneComponentInitialization: (scene: Scene) => void;
  52757. /**
  52758. * Instantiates a new effect Layer and references it in the scene.
  52759. * @param name The name of the layer
  52760. * @param scene The scene to use the layer in
  52761. */
  52762. constructor(
  52763. /** The Friendly of the effect in the scene */
  52764. name: string, scene: Scene);
  52765. /**
  52766. * Get the effect name of the layer.
  52767. * @return The effect name
  52768. */
  52769. abstract getEffectName(): string;
  52770. /**
  52771. * Checks for the readiness of the element composing the layer.
  52772. * @param subMesh the mesh to check for
  52773. * @param useInstances specify whether or not to use instances to render the mesh
  52774. * @return true if ready otherwise, false
  52775. */
  52776. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52777. /**
  52778. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52779. * @returns true if the effect requires stencil during the main canvas render pass.
  52780. */
  52781. abstract needStencil(): boolean;
  52782. /**
  52783. * Create the merge effect. This is the shader use to blit the information back
  52784. * to the main canvas at the end of the scene rendering.
  52785. * @returns The effect containing the shader used to merge the effect on the main canvas
  52786. */
  52787. protected abstract _createMergeEffect(): Effect;
  52788. /**
  52789. * Creates the render target textures and post processes used in the effect layer.
  52790. */
  52791. protected abstract _createTextureAndPostProcesses(): void;
  52792. /**
  52793. * Implementation specific of rendering the generating effect on the main canvas.
  52794. * @param effect The effect used to render through
  52795. */
  52796. protected abstract _internalRender(effect: Effect): void;
  52797. /**
  52798. * Sets the required values for both the emissive texture and and the main color.
  52799. */
  52800. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52801. /**
  52802. * Free any resources and references associated to a mesh.
  52803. * Internal use
  52804. * @param mesh The mesh to free.
  52805. */
  52806. abstract _disposeMesh(mesh: Mesh): void;
  52807. /**
  52808. * Serializes this layer (Glow or Highlight for example)
  52809. * @returns a serialized layer object
  52810. */
  52811. abstract serialize?(): any;
  52812. /**
  52813. * Initializes the effect layer with the required options.
  52814. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52815. */
  52816. protected _init(options: Partial<IEffectLayerOptions>): void;
  52817. /**
  52818. * Generates the index buffer of the full screen quad blending to the main canvas.
  52819. */
  52820. private _generateIndexBuffer;
  52821. /**
  52822. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52823. */
  52824. private _generateVertexBuffer;
  52825. /**
  52826. * Sets the main texture desired size which is the closest power of two
  52827. * of the engine canvas size.
  52828. */
  52829. private _setMainTextureSize;
  52830. /**
  52831. * Creates the main texture for the effect layer.
  52832. */
  52833. protected _createMainTexture(): void;
  52834. /**
  52835. * Adds specific effects defines.
  52836. * @param defines The defines to add specifics to.
  52837. */
  52838. protected _addCustomEffectDefines(defines: string[]): void;
  52839. /**
  52840. * Checks for the readiness of the element composing the layer.
  52841. * @param subMesh the mesh to check for
  52842. * @param useInstances specify whether or not to use instances to render the mesh
  52843. * @param emissiveTexture the associated emissive texture used to generate the glow
  52844. * @return true if ready otherwise, false
  52845. */
  52846. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52847. /**
  52848. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52849. */
  52850. render(): void;
  52851. /**
  52852. * Determine if a given mesh will be used in the current effect.
  52853. * @param mesh mesh to test
  52854. * @returns true if the mesh will be used
  52855. */
  52856. hasMesh(mesh: AbstractMesh): boolean;
  52857. /**
  52858. * Returns true if the layer contains information to display, otherwise false.
  52859. * @returns true if the glow layer should be rendered
  52860. */
  52861. shouldRender(): boolean;
  52862. /**
  52863. * Returns true if the mesh should render, otherwise false.
  52864. * @param mesh The mesh to render
  52865. * @returns true if it should render otherwise false
  52866. */
  52867. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52868. /**
  52869. * Returns true if the mesh can be rendered, otherwise false.
  52870. * @param mesh The mesh to render
  52871. * @param material The material used on the mesh
  52872. * @returns true if it can be rendered otherwise false
  52873. */
  52874. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52875. /**
  52876. * Returns true if the mesh should render, otherwise false.
  52877. * @param mesh The mesh to render
  52878. * @returns true if it should render otherwise false
  52879. */
  52880. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52881. /**
  52882. * Renders the submesh passed in parameter to the generation map.
  52883. */
  52884. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52885. /**
  52886. * Defines whether the current material of the mesh should be use to render the effect.
  52887. * @param mesh defines the current mesh to render
  52888. */
  52889. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52890. /**
  52891. * Rebuild the required buffers.
  52892. * @hidden Internal use only.
  52893. */
  52894. _rebuild(): void;
  52895. /**
  52896. * Dispose only the render target textures and post process.
  52897. */
  52898. private _disposeTextureAndPostProcesses;
  52899. /**
  52900. * Dispose the highlight layer and free resources.
  52901. */
  52902. dispose(): void;
  52903. /**
  52904. * Gets the class name of the effect layer
  52905. * @returns the string with the class name of the effect layer
  52906. */
  52907. getClassName(): string;
  52908. /**
  52909. * Creates an effect layer from parsed effect layer data
  52910. * @param parsedEffectLayer defines effect layer data
  52911. * @param scene defines the current scene
  52912. * @param rootUrl defines the root URL containing the effect layer information
  52913. * @returns a parsed effect Layer
  52914. */
  52915. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52916. }
  52917. }
  52918. declare module BABYLON {
  52919. interface AbstractScene {
  52920. /**
  52921. * The list of effect layers (highlights/glow) added to the scene
  52922. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52923. * @see http://doc.babylonjs.com/how_to/glow_layer
  52924. */
  52925. effectLayers: Array<EffectLayer>;
  52926. /**
  52927. * Removes the given effect layer from this scene.
  52928. * @param toRemove defines the effect layer to remove
  52929. * @returns the index of the removed effect layer
  52930. */
  52931. removeEffectLayer(toRemove: EffectLayer): number;
  52932. /**
  52933. * Adds the given effect layer to this scene
  52934. * @param newEffectLayer defines the effect layer to add
  52935. */
  52936. addEffectLayer(newEffectLayer: EffectLayer): void;
  52937. }
  52938. /**
  52939. * Defines the layer scene component responsible to manage any effect layers
  52940. * in a given scene.
  52941. */
  52942. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52943. /**
  52944. * The component name helpfull to identify the component in the list of scene components.
  52945. */
  52946. readonly name: string;
  52947. /**
  52948. * The scene the component belongs to.
  52949. */
  52950. scene: Scene;
  52951. private _engine;
  52952. private _renderEffects;
  52953. private _needStencil;
  52954. private _previousStencilState;
  52955. /**
  52956. * Creates a new instance of the component for the given scene
  52957. * @param scene Defines the scene to register the component in
  52958. */
  52959. constructor(scene: Scene);
  52960. /**
  52961. * Registers the component in a given scene
  52962. */
  52963. register(): void;
  52964. /**
  52965. * Rebuilds the elements related to this component in case of
  52966. * context lost for instance.
  52967. */
  52968. rebuild(): void;
  52969. /**
  52970. * Serializes the component data to the specified json object
  52971. * @param serializationObject The object to serialize to
  52972. */
  52973. serialize(serializationObject: any): void;
  52974. /**
  52975. * Adds all the elements from the container to the scene
  52976. * @param container the container holding the elements
  52977. */
  52978. addFromContainer(container: AbstractScene): void;
  52979. /**
  52980. * Removes all the elements in the container from the scene
  52981. * @param container contains the elements to remove
  52982. * @param dispose if the removed element should be disposed (default: false)
  52983. */
  52984. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52985. /**
  52986. * Disposes the component and the associated ressources.
  52987. */
  52988. dispose(): void;
  52989. private _isReadyForMesh;
  52990. private _renderMainTexture;
  52991. private _setStencil;
  52992. private _setStencilBack;
  52993. private _draw;
  52994. private _drawCamera;
  52995. private _drawRenderingGroup;
  52996. }
  52997. }
  52998. declare module BABYLON {
  52999. /** @hidden */
  53000. export var glowMapMergePixelShader: {
  53001. name: string;
  53002. shader: string;
  53003. };
  53004. }
  53005. declare module BABYLON {
  53006. /** @hidden */
  53007. export var glowMapMergeVertexShader: {
  53008. name: string;
  53009. shader: string;
  53010. };
  53011. }
  53012. declare module BABYLON {
  53013. interface AbstractScene {
  53014. /**
  53015. * Return a the first highlight layer of the scene with a given name.
  53016. * @param name The name of the highlight layer to look for.
  53017. * @return The highlight layer if found otherwise null.
  53018. */
  53019. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53020. }
  53021. /**
  53022. * Glow layer options. This helps customizing the behaviour
  53023. * of the glow layer.
  53024. */
  53025. export interface IGlowLayerOptions {
  53026. /**
  53027. * Multiplication factor apply to the canvas size to compute the render target size
  53028. * used to generated the glowing objects (the smaller the faster).
  53029. */
  53030. mainTextureRatio: number;
  53031. /**
  53032. * Enforces a fixed size texture to ensure resize independant blur.
  53033. */
  53034. mainTextureFixedSize?: number;
  53035. /**
  53036. * How big is the kernel of the blur texture.
  53037. */
  53038. blurKernelSize: number;
  53039. /**
  53040. * The camera attached to the layer.
  53041. */
  53042. camera: Nullable<Camera>;
  53043. /**
  53044. * Enable MSAA by chosing the number of samples.
  53045. */
  53046. mainTextureSamples?: number;
  53047. /**
  53048. * The rendering group to draw the layer in.
  53049. */
  53050. renderingGroupId: number;
  53051. }
  53052. /**
  53053. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53054. *
  53055. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53056. *
  53057. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53058. */
  53059. export class GlowLayer extends EffectLayer {
  53060. /**
  53061. * Effect Name of the layer.
  53062. */
  53063. static readonly EffectName: string;
  53064. /**
  53065. * The default blur kernel size used for the glow.
  53066. */
  53067. static DefaultBlurKernelSize: number;
  53068. /**
  53069. * The default texture size ratio used for the glow.
  53070. */
  53071. static DefaultTextureRatio: number;
  53072. /**
  53073. * Sets the kernel size of the blur.
  53074. */
  53075. set blurKernelSize(value: number);
  53076. /**
  53077. * Gets the kernel size of the blur.
  53078. */
  53079. get blurKernelSize(): number;
  53080. /**
  53081. * Sets the glow intensity.
  53082. */
  53083. set intensity(value: number);
  53084. /**
  53085. * Gets the glow intensity.
  53086. */
  53087. get intensity(): number;
  53088. private _options;
  53089. private _intensity;
  53090. private _horizontalBlurPostprocess1;
  53091. private _verticalBlurPostprocess1;
  53092. private _horizontalBlurPostprocess2;
  53093. private _verticalBlurPostprocess2;
  53094. private _blurTexture1;
  53095. private _blurTexture2;
  53096. private _postProcesses1;
  53097. private _postProcesses2;
  53098. private _includedOnlyMeshes;
  53099. private _excludedMeshes;
  53100. private _meshesUsingTheirOwnMaterials;
  53101. /**
  53102. * Callback used to let the user override the color selection on a per mesh basis
  53103. */
  53104. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53105. /**
  53106. * Callback used to let the user override the texture selection on a per mesh basis
  53107. */
  53108. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53109. /**
  53110. * Instantiates a new glow Layer and references it to the scene.
  53111. * @param name The name of the layer
  53112. * @param scene The scene to use the layer in
  53113. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53114. */
  53115. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53116. /**
  53117. * Get the effect name of the layer.
  53118. * @return The effect name
  53119. */
  53120. getEffectName(): string;
  53121. /**
  53122. * Create the merge effect. This is the shader use to blit the information back
  53123. * to the main canvas at the end of the scene rendering.
  53124. */
  53125. protected _createMergeEffect(): Effect;
  53126. /**
  53127. * Creates the render target textures and post processes used in the glow layer.
  53128. */
  53129. protected _createTextureAndPostProcesses(): void;
  53130. /**
  53131. * Checks for the readiness of the element composing the layer.
  53132. * @param subMesh the mesh to check for
  53133. * @param useInstances specify wether or not to use instances to render the mesh
  53134. * @param emissiveTexture the associated emissive texture used to generate the glow
  53135. * @return true if ready otherwise, false
  53136. */
  53137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53138. /**
  53139. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53140. */
  53141. needStencil(): boolean;
  53142. /**
  53143. * Returns true if the mesh can be rendered, otherwise false.
  53144. * @param mesh The mesh to render
  53145. * @param material The material used on the mesh
  53146. * @returns true if it can be rendered otherwise false
  53147. */
  53148. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53149. /**
  53150. * Implementation specific of rendering the generating effect on the main canvas.
  53151. * @param effect The effect used to render through
  53152. */
  53153. protected _internalRender(effect: Effect): void;
  53154. /**
  53155. * Sets the required values for both the emissive texture and and the main color.
  53156. */
  53157. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53158. /**
  53159. * Returns true if the mesh should render, otherwise false.
  53160. * @param mesh The mesh to render
  53161. * @returns true if it should render otherwise false
  53162. */
  53163. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53164. /**
  53165. * Adds specific effects defines.
  53166. * @param defines The defines to add specifics to.
  53167. */
  53168. protected _addCustomEffectDefines(defines: string[]): void;
  53169. /**
  53170. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53171. * @param mesh The mesh to exclude from the glow layer
  53172. */
  53173. addExcludedMesh(mesh: Mesh): void;
  53174. /**
  53175. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53176. * @param mesh The mesh to remove
  53177. */
  53178. removeExcludedMesh(mesh: Mesh): void;
  53179. /**
  53180. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53181. * @param mesh The mesh to include in the glow layer
  53182. */
  53183. addIncludedOnlyMesh(mesh: Mesh): void;
  53184. /**
  53185. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53186. * @param mesh The mesh to remove
  53187. */
  53188. removeIncludedOnlyMesh(mesh: Mesh): void;
  53189. /**
  53190. * Determine if a given mesh will be used in the glow layer
  53191. * @param mesh The mesh to test
  53192. * @returns true if the mesh will be highlighted by the current glow layer
  53193. */
  53194. hasMesh(mesh: AbstractMesh): boolean;
  53195. /**
  53196. * Defines whether the current material of the mesh should be use to render the effect.
  53197. * @param mesh defines the current mesh to render
  53198. */
  53199. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53200. /**
  53201. * Add a mesh to be rendered through its own material and not with emissive only.
  53202. * @param mesh The mesh for which we need to use its material
  53203. */
  53204. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53205. /**
  53206. * Remove a mesh from being rendered through its own material and not with emissive only.
  53207. * @param mesh The mesh for which we need to not use its material
  53208. */
  53209. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53210. /**
  53211. * Free any resources and references associated to a mesh.
  53212. * Internal use
  53213. * @param mesh The mesh to free.
  53214. * @hidden
  53215. */
  53216. _disposeMesh(mesh: Mesh): void;
  53217. /**
  53218. * Gets the class name of the effect layer
  53219. * @returns the string with the class name of the effect layer
  53220. */
  53221. getClassName(): string;
  53222. /**
  53223. * Serializes this glow layer
  53224. * @returns a serialized glow layer object
  53225. */
  53226. serialize(): any;
  53227. /**
  53228. * Creates a Glow Layer from parsed glow layer data
  53229. * @param parsedGlowLayer defines glow layer data
  53230. * @param scene defines the current scene
  53231. * @param rootUrl defines the root URL containing the glow layer information
  53232. * @returns a parsed Glow Layer
  53233. */
  53234. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53235. }
  53236. }
  53237. declare module BABYLON {
  53238. /** @hidden */
  53239. export var glowBlurPostProcessPixelShader: {
  53240. name: string;
  53241. shader: string;
  53242. };
  53243. }
  53244. declare module BABYLON {
  53245. interface AbstractScene {
  53246. /**
  53247. * Return a the first highlight layer of the scene with a given name.
  53248. * @param name The name of the highlight layer to look for.
  53249. * @return The highlight layer if found otherwise null.
  53250. */
  53251. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53252. }
  53253. /**
  53254. * Highlight layer options. This helps customizing the behaviour
  53255. * of the highlight layer.
  53256. */
  53257. export interface IHighlightLayerOptions {
  53258. /**
  53259. * Multiplication factor apply to the canvas size to compute the render target size
  53260. * used to generated the glowing objects (the smaller the faster).
  53261. */
  53262. mainTextureRatio: number;
  53263. /**
  53264. * Enforces a fixed size texture to ensure resize independant blur.
  53265. */
  53266. mainTextureFixedSize?: number;
  53267. /**
  53268. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53269. * of the picture to blur (the smaller the faster).
  53270. */
  53271. blurTextureSizeRatio: number;
  53272. /**
  53273. * How big in texel of the blur texture is the vertical blur.
  53274. */
  53275. blurVerticalSize: number;
  53276. /**
  53277. * How big in texel of the blur texture is the horizontal blur.
  53278. */
  53279. blurHorizontalSize: number;
  53280. /**
  53281. * Alpha blending mode used to apply the blur. Default is combine.
  53282. */
  53283. alphaBlendingMode: number;
  53284. /**
  53285. * The camera attached to the layer.
  53286. */
  53287. camera: Nullable<Camera>;
  53288. /**
  53289. * Should we display highlight as a solid stroke?
  53290. */
  53291. isStroke?: boolean;
  53292. /**
  53293. * The rendering group to draw the layer in.
  53294. */
  53295. renderingGroupId: number;
  53296. }
  53297. /**
  53298. * The highlight layer Helps adding a glow effect around a mesh.
  53299. *
  53300. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53301. * glowy meshes to your scene.
  53302. *
  53303. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53304. */
  53305. export class HighlightLayer extends EffectLayer {
  53306. name: string;
  53307. /**
  53308. * Effect Name of the highlight layer.
  53309. */
  53310. static readonly EffectName: string;
  53311. /**
  53312. * The neutral color used during the preparation of the glow effect.
  53313. * This is black by default as the blend operation is a blend operation.
  53314. */
  53315. static NeutralColor: Color4;
  53316. /**
  53317. * Stencil value used for glowing meshes.
  53318. */
  53319. static GlowingMeshStencilReference: number;
  53320. /**
  53321. * Stencil value used for the other meshes in the scene.
  53322. */
  53323. static NormalMeshStencilReference: number;
  53324. /**
  53325. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53326. */
  53327. innerGlow: boolean;
  53328. /**
  53329. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53330. */
  53331. outerGlow: boolean;
  53332. /**
  53333. * Specifies the horizontal size of the blur.
  53334. */
  53335. set blurHorizontalSize(value: number);
  53336. /**
  53337. * Specifies the vertical size of the blur.
  53338. */
  53339. set blurVerticalSize(value: number);
  53340. /**
  53341. * Gets the horizontal size of the blur.
  53342. */
  53343. get blurHorizontalSize(): number;
  53344. /**
  53345. * Gets the vertical size of the blur.
  53346. */
  53347. get blurVerticalSize(): number;
  53348. /**
  53349. * An event triggered when the highlight layer is being blurred.
  53350. */
  53351. onBeforeBlurObservable: Observable<HighlightLayer>;
  53352. /**
  53353. * An event triggered when the highlight layer has been blurred.
  53354. */
  53355. onAfterBlurObservable: Observable<HighlightLayer>;
  53356. private _instanceGlowingMeshStencilReference;
  53357. private _options;
  53358. private _downSamplePostprocess;
  53359. private _horizontalBlurPostprocess;
  53360. private _verticalBlurPostprocess;
  53361. private _blurTexture;
  53362. private _meshes;
  53363. private _excludedMeshes;
  53364. /**
  53365. * Instantiates a new highlight Layer and references it to the scene..
  53366. * @param name The name of the layer
  53367. * @param scene The scene to use the layer in
  53368. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53369. */
  53370. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53371. /**
  53372. * Get the effect name of the layer.
  53373. * @return The effect name
  53374. */
  53375. getEffectName(): string;
  53376. /**
  53377. * Create the merge effect. This is the shader use to blit the information back
  53378. * to the main canvas at the end of the scene rendering.
  53379. */
  53380. protected _createMergeEffect(): Effect;
  53381. /**
  53382. * Creates the render target textures and post processes used in the highlight layer.
  53383. */
  53384. protected _createTextureAndPostProcesses(): void;
  53385. /**
  53386. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53387. */
  53388. needStencil(): boolean;
  53389. /**
  53390. * Checks for the readiness of the element composing the layer.
  53391. * @param subMesh the mesh to check for
  53392. * @param useInstances specify wether or not to use instances to render the mesh
  53393. * @param emissiveTexture the associated emissive texture used to generate the glow
  53394. * @return true if ready otherwise, false
  53395. */
  53396. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53397. /**
  53398. * Implementation specific of rendering the generating effect on the main canvas.
  53399. * @param effect The effect used to render through
  53400. */
  53401. protected _internalRender(effect: Effect): void;
  53402. /**
  53403. * Returns true if the layer contains information to display, otherwise false.
  53404. */
  53405. shouldRender(): boolean;
  53406. /**
  53407. * Returns true if the mesh should render, otherwise false.
  53408. * @param mesh The mesh to render
  53409. * @returns true if it should render otherwise false
  53410. */
  53411. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53412. /**
  53413. * Sets the required values for both the emissive texture and and the main color.
  53414. */
  53415. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53416. /**
  53417. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53418. * @param mesh The mesh to exclude from the highlight layer
  53419. */
  53420. addExcludedMesh(mesh: Mesh): void;
  53421. /**
  53422. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53423. * @param mesh The mesh to highlight
  53424. */
  53425. removeExcludedMesh(mesh: Mesh): void;
  53426. /**
  53427. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53428. * @param mesh mesh to test
  53429. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53430. */
  53431. hasMesh(mesh: AbstractMesh): boolean;
  53432. /**
  53433. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53434. * @param mesh The mesh to highlight
  53435. * @param color The color of the highlight
  53436. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53437. */
  53438. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53439. /**
  53440. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53441. * @param mesh The mesh to highlight
  53442. */
  53443. removeMesh(mesh: Mesh): void;
  53444. /**
  53445. * Remove all the meshes currently referenced in the highlight layer
  53446. */
  53447. removeAllMeshes(): void;
  53448. /**
  53449. * Force the stencil to the normal expected value for none glowing parts
  53450. */
  53451. private _defaultStencilReference;
  53452. /**
  53453. * Free any resources and references associated to a mesh.
  53454. * Internal use
  53455. * @param mesh The mesh to free.
  53456. * @hidden
  53457. */
  53458. _disposeMesh(mesh: Mesh): void;
  53459. /**
  53460. * Dispose the highlight layer and free resources.
  53461. */
  53462. dispose(): void;
  53463. /**
  53464. * Gets the class name of the effect layer
  53465. * @returns the string with the class name of the effect layer
  53466. */
  53467. getClassName(): string;
  53468. /**
  53469. * Serializes this Highlight layer
  53470. * @returns a serialized Highlight layer object
  53471. */
  53472. serialize(): any;
  53473. /**
  53474. * Creates a Highlight layer from parsed Highlight layer data
  53475. * @param parsedHightlightLayer defines the Highlight layer data
  53476. * @param scene defines the current scene
  53477. * @param rootUrl defines the root URL containing the Highlight layer information
  53478. * @returns a parsed Highlight layer
  53479. */
  53480. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53481. }
  53482. }
  53483. declare module BABYLON {
  53484. interface AbstractScene {
  53485. /**
  53486. * The list of layers (background and foreground) of the scene
  53487. */
  53488. layers: Array<Layer>;
  53489. }
  53490. /**
  53491. * Defines the layer scene component responsible to manage any layers
  53492. * in a given scene.
  53493. */
  53494. export class LayerSceneComponent implements ISceneComponent {
  53495. /**
  53496. * The component name helpfull to identify the component in the list of scene components.
  53497. */
  53498. readonly name: string;
  53499. /**
  53500. * The scene the component belongs to.
  53501. */
  53502. scene: Scene;
  53503. private _engine;
  53504. /**
  53505. * Creates a new instance of the component for the given scene
  53506. * @param scene Defines the scene to register the component in
  53507. */
  53508. constructor(scene: Scene);
  53509. /**
  53510. * Registers the component in a given scene
  53511. */
  53512. register(): void;
  53513. /**
  53514. * Rebuilds the elements related to this component in case of
  53515. * context lost for instance.
  53516. */
  53517. rebuild(): void;
  53518. /**
  53519. * Disposes the component and the associated ressources.
  53520. */
  53521. dispose(): void;
  53522. private _draw;
  53523. private _drawCameraPredicate;
  53524. private _drawCameraBackground;
  53525. private _drawCameraForeground;
  53526. private _drawRenderTargetPredicate;
  53527. private _drawRenderTargetBackground;
  53528. private _drawRenderTargetForeground;
  53529. /**
  53530. * Adds all the elements from the container to the scene
  53531. * @param container the container holding the elements
  53532. */
  53533. addFromContainer(container: AbstractScene): void;
  53534. /**
  53535. * Removes all the elements in the container from the scene
  53536. * @param container contains the elements to remove
  53537. * @param dispose if the removed element should be disposed (default: false)
  53538. */
  53539. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53540. }
  53541. }
  53542. declare module BABYLON {
  53543. /** @hidden */
  53544. export var layerPixelShader: {
  53545. name: string;
  53546. shader: string;
  53547. };
  53548. }
  53549. declare module BABYLON {
  53550. /** @hidden */
  53551. export var layerVertexShader: {
  53552. name: string;
  53553. shader: string;
  53554. };
  53555. }
  53556. declare module BABYLON {
  53557. /**
  53558. * This represents a full screen 2d layer.
  53559. * This can be useful to display a picture in the background of your scene for instance.
  53560. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53561. */
  53562. export class Layer {
  53563. /**
  53564. * Define the name of the layer.
  53565. */
  53566. name: string;
  53567. /**
  53568. * Define the texture the layer should display.
  53569. */
  53570. texture: Nullable<Texture>;
  53571. /**
  53572. * Is the layer in background or foreground.
  53573. */
  53574. isBackground: boolean;
  53575. /**
  53576. * Define the color of the layer (instead of texture).
  53577. */
  53578. color: Color4;
  53579. /**
  53580. * Define the scale of the layer in order to zoom in out of the texture.
  53581. */
  53582. scale: Vector2;
  53583. /**
  53584. * Define an offset for the layer in order to shift the texture.
  53585. */
  53586. offset: Vector2;
  53587. /**
  53588. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53589. */
  53590. alphaBlendingMode: number;
  53591. /**
  53592. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53593. * Alpha test will not mix with the background color in case of transparency.
  53594. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53595. */
  53596. alphaTest: boolean;
  53597. /**
  53598. * Define a mask to restrict the layer to only some of the scene cameras.
  53599. */
  53600. layerMask: number;
  53601. /**
  53602. * Define the list of render target the layer is visible into.
  53603. */
  53604. renderTargetTextures: RenderTargetTexture[];
  53605. /**
  53606. * Define if the layer is only used in renderTarget or if it also
  53607. * renders in the main frame buffer of the canvas.
  53608. */
  53609. renderOnlyInRenderTargetTextures: boolean;
  53610. private _scene;
  53611. private _vertexBuffers;
  53612. private _indexBuffer;
  53613. private _effect;
  53614. private _previousDefines;
  53615. /**
  53616. * An event triggered when the layer is disposed.
  53617. */
  53618. onDisposeObservable: Observable<Layer>;
  53619. private _onDisposeObserver;
  53620. /**
  53621. * Back compatibility with callback before the onDisposeObservable existed.
  53622. * The set callback will be triggered when the layer has been disposed.
  53623. */
  53624. set onDispose(callback: () => void);
  53625. /**
  53626. * An event triggered before rendering the scene
  53627. */
  53628. onBeforeRenderObservable: Observable<Layer>;
  53629. private _onBeforeRenderObserver;
  53630. /**
  53631. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53632. * The set callback will be triggered just before rendering the layer.
  53633. */
  53634. set onBeforeRender(callback: () => void);
  53635. /**
  53636. * An event triggered after rendering the scene
  53637. */
  53638. onAfterRenderObservable: Observable<Layer>;
  53639. private _onAfterRenderObserver;
  53640. /**
  53641. * Back compatibility with callback before the onAfterRenderObservable existed.
  53642. * The set callback will be triggered just after rendering the layer.
  53643. */
  53644. set onAfterRender(callback: () => void);
  53645. /**
  53646. * Instantiates a new layer.
  53647. * This represents a full screen 2d layer.
  53648. * This can be useful to display a picture in the background of your scene for instance.
  53649. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53650. * @param name Define the name of the layer in the scene
  53651. * @param imgUrl Define the url of the texture to display in the layer
  53652. * @param scene Define the scene the layer belongs to
  53653. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53654. * @param color Defines a color for the layer
  53655. */
  53656. constructor(
  53657. /**
  53658. * Define the name of the layer.
  53659. */
  53660. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53661. private _createIndexBuffer;
  53662. /** @hidden */
  53663. _rebuild(): void;
  53664. /**
  53665. * Renders the layer in the scene.
  53666. */
  53667. render(): void;
  53668. /**
  53669. * Disposes and releases the associated ressources.
  53670. */
  53671. dispose(): void;
  53672. }
  53673. }
  53674. declare module BABYLON {
  53675. /** @hidden */
  53676. export var lensFlarePixelShader: {
  53677. name: string;
  53678. shader: string;
  53679. };
  53680. }
  53681. declare module BABYLON {
  53682. /** @hidden */
  53683. export var lensFlareVertexShader: {
  53684. name: string;
  53685. shader: string;
  53686. };
  53687. }
  53688. declare module BABYLON {
  53689. /**
  53690. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53691. * It is usually composed of several `lensFlare`.
  53692. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53693. */
  53694. export class LensFlareSystem {
  53695. /**
  53696. * Define the name of the lens flare system
  53697. */
  53698. name: string;
  53699. /**
  53700. * List of lens flares used in this system.
  53701. */
  53702. lensFlares: LensFlare[];
  53703. /**
  53704. * Define a limit from the border the lens flare can be visible.
  53705. */
  53706. borderLimit: number;
  53707. /**
  53708. * Define a viewport border we do not want to see the lens flare in.
  53709. */
  53710. viewportBorder: number;
  53711. /**
  53712. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53713. */
  53714. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53715. /**
  53716. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53717. */
  53718. layerMask: number;
  53719. /**
  53720. * Define the id of the lens flare system in the scene.
  53721. * (equal to name by default)
  53722. */
  53723. id: string;
  53724. private _scene;
  53725. private _emitter;
  53726. private _vertexBuffers;
  53727. private _indexBuffer;
  53728. private _effect;
  53729. private _positionX;
  53730. private _positionY;
  53731. private _isEnabled;
  53732. /** @hidden */
  53733. static _SceneComponentInitialization: (scene: Scene) => void;
  53734. /**
  53735. * Instantiates a lens flare system.
  53736. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53737. * It is usually composed of several `lensFlare`.
  53738. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53739. * @param name Define the name of the lens flare system in the scene
  53740. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53741. * @param scene Define the scene the lens flare system belongs to
  53742. */
  53743. constructor(
  53744. /**
  53745. * Define the name of the lens flare system
  53746. */
  53747. name: string, emitter: any, scene: Scene);
  53748. /**
  53749. * Define if the lens flare system is enabled.
  53750. */
  53751. get isEnabled(): boolean;
  53752. set isEnabled(value: boolean);
  53753. /**
  53754. * Get the scene the effects belongs to.
  53755. * @returns the scene holding the lens flare system
  53756. */
  53757. getScene(): Scene;
  53758. /**
  53759. * Get the emitter of the lens flare system.
  53760. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53761. * @returns the emitter of the lens flare system
  53762. */
  53763. getEmitter(): any;
  53764. /**
  53765. * Set the emitter of the lens flare system.
  53766. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53767. * @param newEmitter Define the new emitter of the system
  53768. */
  53769. setEmitter(newEmitter: any): void;
  53770. /**
  53771. * Get the lens flare system emitter position.
  53772. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53773. * @returns the position
  53774. */
  53775. getEmitterPosition(): Vector3;
  53776. /**
  53777. * @hidden
  53778. */
  53779. computeEffectivePosition(globalViewport: Viewport): boolean;
  53780. /** @hidden */
  53781. _isVisible(): boolean;
  53782. /**
  53783. * @hidden
  53784. */
  53785. render(): boolean;
  53786. /**
  53787. * Dispose and release the lens flare with its associated resources.
  53788. */
  53789. dispose(): void;
  53790. /**
  53791. * Parse a lens flare system from a JSON repressentation
  53792. * @param parsedLensFlareSystem Define the JSON to parse
  53793. * @param scene Define the scene the parsed system should be instantiated in
  53794. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53795. * @returns the parsed system
  53796. */
  53797. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53798. /**
  53799. * Serialize the current Lens Flare System into a JSON representation.
  53800. * @returns the serialized JSON
  53801. */
  53802. serialize(): any;
  53803. }
  53804. }
  53805. declare module BABYLON {
  53806. /**
  53807. * This represents one of the lens effect in a `lensFlareSystem`.
  53808. * It controls one of the indiviual texture used in the effect.
  53809. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53810. */
  53811. export class LensFlare {
  53812. /**
  53813. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53814. */
  53815. size: number;
  53816. /**
  53817. * 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.
  53818. */
  53819. position: number;
  53820. /**
  53821. * Define the lens color.
  53822. */
  53823. color: Color3;
  53824. /**
  53825. * Define the lens texture.
  53826. */
  53827. texture: Nullable<Texture>;
  53828. /**
  53829. * Define the alpha mode to render this particular lens.
  53830. */
  53831. alphaMode: number;
  53832. private _system;
  53833. /**
  53834. * Creates a new Lens Flare.
  53835. * This represents one of the lens effect in a `lensFlareSystem`.
  53836. * It controls one of the indiviual texture used in the effect.
  53837. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53838. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53839. * @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.
  53840. * @param color Define the lens color
  53841. * @param imgUrl Define the lens texture url
  53842. * @param system Define the `lensFlareSystem` this flare is part of
  53843. * @returns The newly created Lens Flare
  53844. */
  53845. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53846. /**
  53847. * Instantiates a new Lens Flare.
  53848. * This represents one of the lens effect in a `lensFlareSystem`.
  53849. * It controls one of the indiviual texture used in the effect.
  53850. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53851. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53852. * @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.
  53853. * @param color Define the lens color
  53854. * @param imgUrl Define the lens texture url
  53855. * @param system Define the `lensFlareSystem` this flare is part of
  53856. */
  53857. constructor(
  53858. /**
  53859. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53860. */
  53861. size: number,
  53862. /**
  53863. * 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.
  53864. */
  53865. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53866. /**
  53867. * Dispose and release the lens flare with its associated resources.
  53868. */
  53869. dispose(): void;
  53870. }
  53871. }
  53872. declare module BABYLON {
  53873. interface AbstractScene {
  53874. /**
  53875. * The list of lens flare system added to the scene
  53876. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53877. */
  53878. lensFlareSystems: Array<LensFlareSystem>;
  53879. /**
  53880. * Removes the given lens flare system from this scene.
  53881. * @param toRemove The lens flare system to remove
  53882. * @returns The index of the removed lens flare system
  53883. */
  53884. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53885. /**
  53886. * Adds the given lens flare system to this scene
  53887. * @param newLensFlareSystem The lens flare system to add
  53888. */
  53889. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53890. /**
  53891. * Gets a lens flare system using its name
  53892. * @param name defines the name to look for
  53893. * @returns the lens flare system or null if not found
  53894. */
  53895. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53896. /**
  53897. * Gets a lens flare system using its id
  53898. * @param id defines the id to look for
  53899. * @returns the lens flare system or null if not found
  53900. */
  53901. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53902. }
  53903. /**
  53904. * Defines the lens flare scene component responsible to manage any lens flares
  53905. * in a given scene.
  53906. */
  53907. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53908. /**
  53909. * The component name helpfull to identify the component in the list of scene components.
  53910. */
  53911. readonly name: string;
  53912. /**
  53913. * The scene the component belongs to.
  53914. */
  53915. scene: Scene;
  53916. /**
  53917. * Creates a new instance of the component for the given scene
  53918. * @param scene Defines the scene to register the component in
  53919. */
  53920. constructor(scene: Scene);
  53921. /**
  53922. * Registers the component in a given scene
  53923. */
  53924. register(): void;
  53925. /**
  53926. * Rebuilds the elements related to this component in case of
  53927. * context lost for instance.
  53928. */
  53929. rebuild(): void;
  53930. /**
  53931. * Adds all the elements from the container to the scene
  53932. * @param container the container holding the elements
  53933. */
  53934. addFromContainer(container: AbstractScene): void;
  53935. /**
  53936. * Removes all the elements in the container from the scene
  53937. * @param container contains the elements to remove
  53938. * @param dispose if the removed element should be disposed (default: false)
  53939. */
  53940. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53941. /**
  53942. * Serializes the component data to the specified json object
  53943. * @param serializationObject The object to serialize to
  53944. */
  53945. serialize(serializationObject: any): void;
  53946. /**
  53947. * Disposes the component and the associated ressources.
  53948. */
  53949. dispose(): void;
  53950. private _draw;
  53951. }
  53952. }
  53953. declare module BABYLON {
  53954. /** @hidden */
  53955. export var depthPixelShader: {
  53956. name: string;
  53957. shader: string;
  53958. };
  53959. }
  53960. declare module BABYLON {
  53961. /** @hidden */
  53962. export var depthVertexShader: {
  53963. name: string;
  53964. shader: string;
  53965. };
  53966. }
  53967. declare module BABYLON {
  53968. /**
  53969. * This represents a depth renderer in Babylon.
  53970. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53971. */
  53972. export class DepthRenderer {
  53973. private _scene;
  53974. private _depthMap;
  53975. private _effect;
  53976. private readonly _storeNonLinearDepth;
  53977. private readonly _clearColor;
  53978. /** Get if the depth renderer is using packed depth or not */
  53979. readonly isPacked: boolean;
  53980. private _cachedDefines;
  53981. private _camera;
  53982. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  53983. enabled: boolean;
  53984. /**
  53985. * Specifiess that the depth renderer will only be used within
  53986. * the camera it is created for.
  53987. * This can help forcing its rendering during the camera processing.
  53988. */
  53989. useOnlyInActiveCamera: boolean;
  53990. /** @hidden */
  53991. static _SceneComponentInitialization: (scene: Scene) => void;
  53992. /**
  53993. * Instantiates a depth renderer
  53994. * @param scene The scene the renderer belongs to
  53995. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53996. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53997. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  53998. */
  53999. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54000. /**
  54001. * Creates the depth rendering effect and checks if the effect is ready.
  54002. * @param subMesh The submesh to be used to render the depth map of
  54003. * @param useInstances If multiple world instances should be used
  54004. * @returns if the depth renderer is ready to render the depth map
  54005. */
  54006. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54007. /**
  54008. * Gets the texture which the depth map will be written to.
  54009. * @returns The depth map texture
  54010. */
  54011. getDepthMap(): RenderTargetTexture;
  54012. /**
  54013. * Disposes of the depth renderer.
  54014. */
  54015. dispose(): void;
  54016. }
  54017. }
  54018. declare module BABYLON {
  54019. /** @hidden */
  54020. export var minmaxReduxPixelShader: {
  54021. name: string;
  54022. shader: string;
  54023. };
  54024. }
  54025. declare module BABYLON {
  54026. /**
  54027. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54028. * and maximum values from all values of the texture.
  54029. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54030. * The source values are read from the red channel of the texture.
  54031. */
  54032. export class MinMaxReducer {
  54033. /**
  54034. * Observable triggered when the computation has been performed
  54035. */
  54036. onAfterReductionPerformed: Observable<{
  54037. min: number;
  54038. max: number;
  54039. }>;
  54040. protected _camera: Camera;
  54041. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54042. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54043. protected _postProcessManager: PostProcessManager;
  54044. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54045. protected _forceFullscreenViewport: boolean;
  54046. /**
  54047. * Creates a min/max reducer
  54048. * @param camera The camera to use for the post processes
  54049. */
  54050. constructor(camera: Camera);
  54051. /**
  54052. * Gets the texture used to read the values from.
  54053. */
  54054. get sourceTexture(): Nullable<RenderTargetTexture>;
  54055. /**
  54056. * Sets the source texture to read the values from.
  54057. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54058. * because in such textures '1' value must not be taken into account to compute the maximum
  54059. * as this value is used to clear the texture.
  54060. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54061. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54062. * @param depthRedux Indicates if the texture is a depth texture or not
  54063. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54064. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54065. */
  54066. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54067. /**
  54068. * Defines the refresh rate of the computation.
  54069. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54070. */
  54071. get refreshRate(): number;
  54072. set refreshRate(value: number);
  54073. protected _activated: boolean;
  54074. /**
  54075. * Gets the activation status of the reducer
  54076. */
  54077. get activated(): boolean;
  54078. /**
  54079. * Activates the reduction computation.
  54080. * When activated, the observers registered in onAfterReductionPerformed are
  54081. * called after the compuation is performed
  54082. */
  54083. activate(): void;
  54084. /**
  54085. * Deactivates the reduction computation.
  54086. */
  54087. deactivate(): void;
  54088. /**
  54089. * Disposes the min/max reducer
  54090. * @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.
  54091. */
  54092. dispose(disposeAll?: boolean): void;
  54093. }
  54094. }
  54095. declare module BABYLON {
  54096. /**
  54097. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54098. */
  54099. export class DepthReducer extends MinMaxReducer {
  54100. private _depthRenderer;
  54101. private _depthRendererId;
  54102. /**
  54103. * Gets the depth renderer used for the computation.
  54104. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54105. */
  54106. get depthRenderer(): Nullable<DepthRenderer>;
  54107. /**
  54108. * Creates a depth reducer
  54109. * @param camera The camera used to render the depth texture
  54110. */
  54111. constructor(camera: Camera);
  54112. /**
  54113. * Sets the depth renderer to use to generate the depth map
  54114. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54115. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54116. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54117. */
  54118. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54119. /** @hidden */
  54120. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54121. /**
  54122. * Activates the reduction computation.
  54123. * When activated, the observers registered in onAfterReductionPerformed are
  54124. * called after the compuation is performed
  54125. */
  54126. activate(): void;
  54127. /**
  54128. * Deactivates the reduction computation.
  54129. */
  54130. deactivate(): void;
  54131. /**
  54132. * Disposes the depth reducer
  54133. * @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.
  54134. */
  54135. dispose(disposeAll?: boolean): void;
  54136. }
  54137. }
  54138. declare module BABYLON {
  54139. /**
  54140. * A CSM implementation allowing casting shadows on large scenes.
  54141. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54142. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54143. */
  54144. export class CascadedShadowGenerator extends ShadowGenerator {
  54145. private static readonly frustumCornersNDCSpace;
  54146. /**
  54147. * Name of the CSM class
  54148. */
  54149. static CLASSNAME: string;
  54150. /**
  54151. * Defines the default number of cascades used by the CSM.
  54152. */
  54153. static readonly DEFAULT_CASCADES_COUNT: number;
  54154. /**
  54155. * Defines the minimum number of cascades used by the CSM.
  54156. */
  54157. static readonly MIN_CASCADES_COUNT: number;
  54158. /**
  54159. * Defines the maximum number of cascades used by the CSM.
  54160. */
  54161. static readonly MAX_CASCADES_COUNT: number;
  54162. protected _validateFilter(filter: number): number;
  54163. /**
  54164. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54165. */
  54166. penumbraDarkness: number;
  54167. private _numCascades;
  54168. /**
  54169. * Gets or set the number of cascades used by the CSM.
  54170. */
  54171. get numCascades(): number;
  54172. set numCascades(value: number);
  54173. /**
  54174. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54175. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54176. */
  54177. stabilizeCascades: boolean;
  54178. private _freezeShadowCastersBoundingInfo;
  54179. private _freezeShadowCastersBoundingInfoObservable;
  54180. /**
  54181. * Enables or disables the shadow casters bounding info computation.
  54182. * If your shadow casters don't move, you can disable this feature.
  54183. * If it is enabled, the bounding box computation is done every frame.
  54184. */
  54185. get freezeShadowCastersBoundingInfo(): boolean;
  54186. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54187. private _scbiMin;
  54188. private _scbiMax;
  54189. protected _computeShadowCastersBoundingInfo(): void;
  54190. protected _shadowCastersBoundingInfo: BoundingInfo;
  54191. /**
  54192. * Gets or sets the shadow casters bounding info.
  54193. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54194. * so that the system won't overwrite the bounds you provide
  54195. */
  54196. get shadowCastersBoundingInfo(): BoundingInfo;
  54197. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54198. protected _breaksAreDirty: boolean;
  54199. protected _minDistance: number;
  54200. protected _maxDistance: number;
  54201. /**
  54202. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54203. *
  54204. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54205. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54206. * @param min minimal distance for the breaks (default to 0.)
  54207. * @param max maximal distance for the breaks (default to 1.)
  54208. */
  54209. setMinMaxDistance(min: number, max: number): void;
  54210. /** Gets the minimal distance used in the cascade break computation */
  54211. get minDistance(): number;
  54212. /** Gets the maximal distance used in the cascade break computation */
  54213. get maxDistance(): number;
  54214. /**
  54215. * Gets the class name of that object
  54216. * @returns "CascadedShadowGenerator"
  54217. */
  54218. getClassName(): string;
  54219. private _cascadeMinExtents;
  54220. private _cascadeMaxExtents;
  54221. /**
  54222. * Gets a cascade minimum extents
  54223. * @param cascadeIndex index of the cascade
  54224. * @returns the minimum cascade extents
  54225. */
  54226. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54227. /**
  54228. * Gets a cascade maximum extents
  54229. * @param cascadeIndex index of the cascade
  54230. * @returns the maximum cascade extents
  54231. */
  54232. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54233. private _cascades;
  54234. private _currentLayer;
  54235. private _viewSpaceFrustumsZ;
  54236. private _viewMatrices;
  54237. private _projectionMatrices;
  54238. private _transformMatrices;
  54239. private _transformMatricesAsArray;
  54240. private _frustumLengths;
  54241. private _lightSizeUVCorrection;
  54242. private _depthCorrection;
  54243. private _frustumCornersWorldSpace;
  54244. private _frustumCenter;
  54245. private _shadowCameraPos;
  54246. private _shadowMaxZ;
  54247. /**
  54248. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54249. * It defaults to camera.maxZ
  54250. */
  54251. get shadowMaxZ(): number;
  54252. /**
  54253. * Sets the shadow max z distance.
  54254. */
  54255. set shadowMaxZ(value: number);
  54256. protected _debug: boolean;
  54257. /**
  54258. * Gets or sets the debug flag.
  54259. * When enabled, the cascades are materialized by different colors on the screen.
  54260. */
  54261. get debug(): boolean;
  54262. set debug(dbg: boolean);
  54263. private _depthClamp;
  54264. /**
  54265. * Gets or sets the depth clamping value.
  54266. *
  54267. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54268. * to account for the shadow casters far away.
  54269. *
  54270. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54271. */
  54272. get depthClamp(): boolean;
  54273. set depthClamp(value: boolean);
  54274. private _cascadeBlendPercentage;
  54275. /**
  54276. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54277. * It defaults to 0.1 (10% blending).
  54278. */
  54279. get cascadeBlendPercentage(): number;
  54280. set cascadeBlendPercentage(value: number);
  54281. private _lambda;
  54282. /**
  54283. * Gets or set the lambda parameter.
  54284. * This parameter is used to split the camera frustum and create the cascades.
  54285. * 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.
  54286. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54287. */
  54288. get lambda(): number;
  54289. set lambda(value: number);
  54290. /**
  54291. * Gets the view matrix corresponding to a given cascade
  54292. * @param cascadeNum cascade to retrieve the view matrix from
  54293. * @returns the cascade view matrix
  54294. */
  54295. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54296. /**
  54297. * Gets the projection matrix corresponding to a given cascade
  54298. * @param cascadeNum cascade to retrieve the projection matrix from
  54299. * @returns the cascade projection matrix
  54300. */
  54301. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54302. /**
  54303. * Gets the transformation matrix corresponding to a given cascade
  54304. * @param cascadeNum cascade to retrieve the transformation matrix from
  54305. * @returns the cascade transformation matrix
  54306. */
  54307. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54308. private _depthRenderer;
  54309. /**
  54310. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54311. *
  54312. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54313. *
  54314. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54315. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54316. * @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
  54317. */
  54318. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54319. private _depthReducer;
  54320. private _autoCalcDepthBounds;
  54321. /**
  54322. * Gets or sets the autoCalcDepthBounds property.
  54323. *
  54324. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54325. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54326. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54327. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54328. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54329. */
  54330. get autoCalcDepthBounds(): boolean;
  54331. set autoCalcDepthBounds(value: boolean);
  54332. /**
  54333. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54334. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54335. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54336. * for setting the refresh rate on the renderer yourself!
  54337. */
  54338. get autoCalcDepthBoundsRefreshRate(): number;
  54339. set autoCalcDepthBoundsRefreshRate(value: number);
  54340. /**
  54341. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54342. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54343. * you change the camera near/far planes!
  54344. */
  54345. splitFrustum(): void;
  54346. private _splitFrustum;
  54347. private _computeMatrices;
  54348. private _computeFrustumInWorldSpace;
  54349. private _computeCascadeFrustum;
  54350. /** @hidden */
  54351. static _SceneComponentInitialization: (scene: Scene) => void;
  54352. /**
  54353. * Creates a Cascaded Shadow Generator object.
  54354. * A ShadowGenerator is the required tool to use the shadows.
  54355. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54356. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54357. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54358. * @param light The directional light object generating the shadows.
  54359. * @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.
  54360. */
  54361. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54362. protected _initializeGenerator(): void;
  54363. protected _createTargetRenderTexture(): void;
  54364. protected _initializeShadowMap(): void;
  54365. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54366. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54367. /**
  54368. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54369. * @param defines Defines of the material we want to update
  54370. * @param lightIndex Index of the light in the enabled light list of the material
  54371. */
  54372. prepareDefines(defines: any, lightIndex: number): void;
  54373. /**
  54374. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54375. * defined in the generator but impacting the effect).
  54376. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54377. * @param effect The effect we are binfing the information for
  54378. */
  54379. bindShadowLight(lightIndex: string, effect: Effect): void;
  54380. /**
  54381. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54382. * (eq to view projection * shadow projection matrices)
  54383. * @returns The transform matrix used to create the shadow map
  54384. */
  54385. getTransformMatrix(): Matrix;
  54386. /**
  54387. * Disposes the ShadowGenerator.
  54388. * Returns nothing.
  54389. */
  54390. dispose(): void;
  54391. /**
  54392. * Serializes the shadow generator setup to a json object.
  54393. * @returns The serialized JSON object
  54394. */
  54395. serialize(): any;
  54396. /**
  54397. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54398. * @param parsedShadowGenerator The JSON object to parse
  54399. * @param scene The scene to create the shadow map for
  54400. * @returns The parsed shadow generator
  54401. */
  54402. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54403. }
  54404. }
  54405. declare module BABYLON {
  54406. /**
  54407. * Defines the shadow generator component responsible to manage any shadow generators
  54408. * in a given scene.
  54409. */
  54410. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54411. /**
  54412. * The component name helpfull to identify the component in the list of scene components.
  54413. */
  54414. readonly name: string;
  54415. /**
  54416. * The scene the component belongs to.
  54417. */
  54418. scene: Scene;
  54419. /**
  54420. * Creates a new instance of the component for the given scene
  54421. * @param scene Defines the scene to register the component in
  54422. */
  54423. constructor(scene: Scene);
  54424. /**
  54425. * Registers the component in a given scene
  54426. */
  54427. register(): void;
  54428. /**
  54429. * Rebuilds the elements related to this component in case of
  54430. * context lost for instance.
  54431. */
  54432. rebuild(): void;
  54433. /**
  54434. * Serializes the component data to the specified json object
  54435. * @param serializationObject The object to serialize to
  54436. */
  54437. serialize(serializationObject: any): void;
  54438. /**
  54439. * Adds all the elements from the container to the scene
  54440. * @param container the container holding the elements
  54441. */
  54442. addFromContainer(container: AbstractScene): void;
  54443. /**
  54444. * Removes all the elements in the container from the scene
  54445. * @param container contains the elements to remove
  54446. * @param dispose if the removed element should be disposed (default: false)
  54447. */
  54448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54449. /**
  54450. * Rebuilds the elements related to this component in case of
  54451. * context lost for instance.
  54452. */
  54453. dispose(): void;
  54454. private _gatherRenderTargets;
  54455. }
  54456. }
  54457. declare module BABYLON {
  54458. /**
  54459. * A point light is a light defined by an unique point in world space.
  54460. * The light is emitted in every direction from this point.
  54461. * A good example of a point light is a standard light bulb.
  54462. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54463. */
  54464. export class PointLight extends ShadowLight {
  54465. private _shadowAngle;
  54466. /**
  54467. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54468. * This specifies what angle the shadow will use to be created.
  54469. *
  54470. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54471. */
  54472. get shadowAngle(): number;
  54473. /**
  54474. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54475. * This specifies what angle the shadow will use to be created.
  54476. *
  54477. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54478. */
  54479. set shadowAngle(value: number);
  54480. /**
  54481. * Gets the direction if it has been set.
  54482. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54483. */
  54484. get direction(): Vector3;
  54485. /**
  54486. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54487. */
  54488. set direction(value: Vector3);
  54489. /**
  54490. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54491. * A PointLight emits the light in every direction.
  54492. * It can cast shadows.
  54493. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54494. * ```javascript
  54495. * var pointLight = new PointLight("pl", camera.position, scene);
  54496. * ```
  54497. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54498. * @param name The light friendly name
  54499. * @param position The position of the point light in the scene
  54500. * @param scene The scene the lights belongs to
  54501. */
  54502. constructor(name: string, position: Vector3, scene: Scene);
  54503. /**
  54504. * Returns the string "PointLight"
  54505. * @returns the class name
  54506. */
  54507. getClassName(): string;
  54508. /**
  54509. * Returns the integer 0.
  54510. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54511. */
  54512. getTypeID(): number;
  54513. /**
  54514. * Specifies wether or not the shadowmap should be a cube texture.
  54515. * @returns true if the shadowmap needs to be a cube texture.
  54516. */
  54517. needCube(): boolean;
  54518. /**
  54519. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54520. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54521. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54522. */
  54523. getShadowDirection(faceIndex?: number): Vector3;
  54524. /**
  54525. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54526. * - fov = PI / 2
  54527. * - aspect ratio : 1.0
  54528. * - z-near and far equal to the active camera minZ and maxZ.
  54529. * Returns the PointLight.
  54530. */
  54531. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54532. protected _buildUniformLayout(): void;
  54533. /**
  54534. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54535. * @param effect The effect to update
  54536. * @param lightIndex The index of the light in the effect to update
  54537. * @returns The point light
  54538. */
  54539. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54540. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54541. /**
  54542. * Prepares the list of defines specific to the light type.
  54543. * @param defines the list of defines
  54544. * @param lightIndex defines the index of the light for the effect
  54545. */
  54546. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54547. }
  54548. }
  54549. declare module BABYLON {
  54550. /**
  54551. * Header information of HDR texture files.
  54552. */
  54553. export interface HDRInfo {
  54554. /**
  54555. * The height of the texture in pixels.
  54556. */
  54557. height: number;
  54558. /**
  54559. * The width of the texture in pixels.
  54560. */
  54561. width: number;
  54562. /**
  54563. * The index of the beginning of the data in the binary file.
  54564. */
  54565. dataPosition: number;
  54566. }
  54567. /**
  54568. * This groups tools to convert HDR texture to native colors array.
  54569. */
  54570. export class HDRTools {
  54571. private static Ldexp;
  54572. private static Rgbe2float;
  54573. private static readStringLine;
  54574. /**
  54575. * Reads header information from an RGBE texture stored in a native array.
  54576. * More information on this format are available here:
  54577. * https://en.wikipedia.org/wiki/RGBE_image_format
  54578. *
  54579. * @param uint8array The binary file stored in native array.
  54580. * @return The header information.
  54581. */
  54582. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54583. /**
  54584. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54585. * This RGBE texture needs to store the information as a panorama.
  54586. *
  54587. * More information on this format are available here:
  54588. * https://en.wikipedia.org/wiki/RGBE_image_format
  54589. *
  54590. * @param buffer The binary file stored in an array buffer.
  54591. * @param size The expected size of the extracted cubemap.
  54592. * @return The Cube Map information.
  54593. */
  54594. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54595. /**
  54596. * Returns the pixels data extracted from an RGBE texture.
  54597. * This pixels will be stored left to right up to down in the R G B order in one array.
  54598. *
  54599. * More information on this format are available here:
  54600. * https://en.wikipedia.org/wiki/RGBE_image_format
  54601. *
  54602. * @param uint8array The binary file stored in an array buffer.
  54603. * @param hdrInfo The header information of the file.
  54604. * @return The pixels data in RGB right to left up to down order.
  54605. */
  54606. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54607. private static RGBE_ReadPixels_RLE;
  54608. }
  54609. }
  54610. declare module BABYLON {
  54611. /**
  54612. * This represents a texture coming from an HDR input.
  54613. *
  54614. * The only supported format is currently panorama picture stored in RGBE format.
  54615. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54616. */
  54617. export class HDRCubeTexture extends BaseTexture {
  54618. private static _facesMapping;
  54619. private _generateHarmonics;
  54620. private _noMipmap;
  54621. private _textureMatrix;
  54622. private _size;
  54623. private _onLoad;
  54624. private _onError;
  54625. /**
  54626. * The texture URL.
  54627. */
  54628. url: string;
  54629. /**
  54630. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54631. */
  54632. coordinatesMode: number;
  54633. protected _isBlocking: boolean;
  54634. /**
  54635. * Sets wether or not the texture is blocking during loading.
  54636. */
  54637. set isBlocking(value: boolean);
  54638. /**
  54639. * Gets wether or not the texture is blocking during loading.
  54640. */
  54641. get isBlocking(): boolean;
  54642. protected _rotationY: number;
  54643. /**
  54644. * Sets texture matrix rotation angle around Y axis in radians.
  54645. */
  54646. set rotationY(value: number);
  54647. /**
  54648. * Gets texture matrix rotation angle around Y axis radians.
  54649. */
  54650. get rotationY(): number;
  54651. /**
  54652. * Gets or sets the center of the bounding box associated with the cube texture
  54653. * It must define where the camera used to render the texture was set
  54654. */
  54655. boundingBoxPosition: Vector3;
  54656. private _boundingBoxSize;
  54657. /**
  54658. * Gets or sets the size of the bounding box associated with the cube texture
  54659. * When defined, the cubemap will switch to local mode
  54660. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54661. * @example https://www.babylonjs-playground.com/#RNASML
  54662. */
  54663. set boundingBoxSize(value: Vector3);
  54664. get boundingBoxSize(): Vector3;
  54665. /**
  54666. * Instantiates an HDRTexture from the following parameters.
  54667. *
  54668. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54669. * @param scene The scene the texture will be used in
  54670. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54671. * @param noMipmap Forces to not generate the mipmap if true
  54672. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54673. * @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)
  54674. * @param reserved Reserved flag for internal use.
  54675. */
  54676. 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>);
  54677. /**
  54678. * Get the current class name of the texture useful for serialization or dynamic coding.
  54679. * @returns "HDRCubeTexture"
  54680. */
  54681. getClassName(): string;
  54682. /**
  54683. * Occurs when the file is raw .hdr file.
  54684. */
  54685. private loadTexture;
  54686. clone(): HDRCubeTexture;
  54687. delayLoad(): void;
  54688. /**
  54689. * Get the texture reflection matrix used to rotate/transform the reflection.
  54690. * @returns the reflection matrix
  54691. */
  54692. getReflectionTextureMatrix(): Matrix;
  54693. /**
  54694. * Set the texture reflection matrix used to rotate/transform the reflection.
  54695. * @param value Define the reflection matrix to set
  54696. */
  54697. setReflectionTextureMatrix(value: Matrix): void;
  54698. /**
  54699. * Parses a JSON representation of an HDR Texture in order to create the texture
  54700. * @param parsedTexture Define the JSON representation
  54701. * @param scene Define the scene the texture should be created in
  54702. * @param rootUrl Define the root url in case we need to load relative dependencies
  54703. * @returns the newly created texture after parsing
  54704. */
  54705. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54706. serialize(): any;
  54707. }
  54708. }
  54709. declare module BABYLON {
  54710. /**
  54711. * Class used to control physics engine
  54712. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54713. */
  54714. export class PhysicsEngine implements IPhysicsEngine {
  54715. private _physicsPlugin;
  54716. /**
  54717. * Global value used to control the smallest number supported by the simulation
  54718. */
  54719. static Epsilon: number;
  54720. private _impostors;
  54721. private _joints;
  54722. private _subTimeStep;
  54723. /**
  54724. * Gets the gravity vector used by the simulation
  54725. */
  54726. gravity: Vector3;
  54727. /**
  54728. * Factory used to create the default physics plugin.
  54729. * @returns The default physics plugin
  54730. */
  54731. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54732. /**
  54733. * Creates a new Physics Engine
  54734. * @param gravity defines the gravity vector used by the simulation
  54735. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54736. */
  54737. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54738. /**
  54739. * Sets the gravity vector used by the simulation
  54740. * @param gravity defines the gravity vector to use
  54741. */
  54742. setGravity(gravity: Vector3): void;
  54743. /**
  54744. * Set the time step of the physics engine.
  54745. * Default is 1/60.
  54746. * To slow it down, enter 1/600 for example.
  54747. * To speed it up, 1/30
  54748. * @param newTimeStep defines the new timestep to apply to this world.
  54749. */
  54750. setTimeStep(newTimeStep?: number): void;
  54751. /**
  54752. * Get the time step of the physics engine.
  54753. * @returns the current time step
  54754. */
  54755. getTimeStep(): number;
  54756. /**
  54757. * Set the sub time step of the physics engine.
  54758. * Default is 0 meaning there is no sub steps
  54759. * To increase physics resolution precision, set a small value (like 1 ms)
  54760. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54761. */
  54762. setSubTimeStep(subTimeStep?: number): void;
  54763. /**
  54764. * Get the sub time step of the physics engine.
  54765. * @returns the current sub time step
  54766. */
  54767. getSubTimeStep(): number;
  54768. /**
  54769. * Release all resources
  54770. */
  54771. dispose(): void;
  54772. /**
  54773. * Gets the name of the current physics plugin
  54774. * @returns the name of the plugin
  54775. */
  54776. getPhysicsPluginName(): string;
  54777. /**
  54778. * Adding a new impostor for the impostor tracking.
  54779. * This will be done by the impostor itself.
  54780. * @param impostor the impostor to add
  54781. */
  54782. addImpostor(impostor: PhysicsImpostor): void;
  54783. /**
  54784. * Remove an impostor from the engine.
  54785. * This impostor and its mesh will not longer be updated by the physics engine.
  54786. * @param impostor the impostor to remove
  54787. */
  54788. removeImpostor(impostor: PhysicsImpostor): void;
  54789. /**
  54790. * Add a joint to the physics engine
  54791. * @param mainImpostor defines the main impostor to which the joint is added.
  54792. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54793. * @param joint defines the joint that will connect both impostors.
  54794. */
  54795. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54796. /**
  54797. * Removes a joint from the simulation
  54798. * @param mainImpostor defines the impostor used with the joint
  54799. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54800. * @param joint defines the joint to remove
  54801. */
  54802. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54803. /**
  54804. * Called by the scene. No need to call it.
  54805. * @param delta defines the timespam between frames
  54806. */
  54807. _step(delta: number): void;
  54808. /**
  54809. * Gets the current plugin used to run the simulation
  54810. * @returns current plugin
  54811. */
  54812. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54813. /**
  54814. * Gets the list of physic impostors
  54815. * @returns an array of PhysicsImpostor
  54816. */
  54817. getImpostors(): Array<PhysicsImpostor>;
  54818. /**
  54819. * Gets the impostor for a physics enabled object
  54820. * @param object defines the object impersonated by the impostor
  54821. * @returns the PhysicsImpostor or null if not found
  54822. */
  54823. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54824. /**
  54825. * Gets the impostor for a physics body object
  54826. * @param body defines physics body used by the impostor
  54827. * @returns the PhysicsImpostor or null if not found
  54828. */
  54829. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54830. /**
  54831. * Does a raycast in the physics world
  54832. * @param from when should the ray start?
  54833. * @param to when should the ray end?
  54834. * @returns PhysicsRaycastResult
  54835. */
  54836. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54837. }
  54838. }
  54839. declare module BABYLON {
  54840. /** @hidden */
  54841. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54842. private _useDeltaForWorldStep;
  54843. world: any;
  54844. name: string;
  54845. private _physicsMaterials;
  54846. private _fixedTimeStep;
  54847. private _cannonRaycastResult;
  54848. private _raycastResult;
  54849. private _physicsBodysToRemoveAfterStep;
  54850. BJSCANNON: any;
  54851. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54852. setGravity(gravity: Vector3): void;
  54853. setTimeStep(timeStep: number): void;
  54854. getTimeStep(): number;
  54855. executeStep(delta: number): void;
  54856. private _removeMarkedPhysicsBodiesFromWorld;
  54857. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54858. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54859. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54860. private _processChildMeshes;
  54861. removePhysicsBody(impostor: PhysicsImpostor): void;
  54862. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54863. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54864. private _addMaterial;
  54865. private _checkWithEpsilon;
  54866. private _createShape;
  54867. private _createHeightmap;
  54868. private _minus90X;
  54869. private _plus90X;
  54870. private _tmpPosition;
  54871. private _tmpDeltaPosition;
  54872. private _tmpUnityRotation;
  54873. private _updatePhysicsBodyTransformation;
  54874. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54875. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54876. isSupported(): boolean;
  54877. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54878. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54879. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54880. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54881. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54882. getBodyMass(impostor: PhysicsImpostor): number;
  54883. getBodyFriction(impostor: PhysicsImpostor): number;
  54884. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54885. getBodyRestitution(impostor: PhysicsImpostor): number;
  54886. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54887. sleepBody(impostor: PhysicsImpostor): void;
  54888. wakeUpBody(impostor: PhysicsImpostor): void;
  54889. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54890. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54891. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54892. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54893. getRadius(impostor: PhysicsImpostor): number;
  54894. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54895. dispose(): void;
  54896. private _extendNamespace;
  54897. /**
  54898. * Does a raycast in the physics world
  54899. * @param from when should the ray start?
  54900. * @param to when should the ray end?
  54901. * @returns PhysicsRaycastResult
  54902. */
  54903. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54904. }
  54905. }
  54906. declare module BABYLON {
  54907. /** @hidden */
  54908. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54909. world: any;
  54910. name: string;
  54911. BJSOIMO: any;
  54912. private _raycastResult;
  54913. constructor(iterations?: number, oimoInjection?: any);
  54914. setGravity(gravity: Vector3): void;
  54915. setTimeStep(timeStep: number): void;
  54916. getTimeStep(): number;
  54917. private _tmpImpostorsArray;
  54918. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54919. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54920. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54921. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54922. private _tmpPositionVector;
  54923. removePhysicsBody(impostor: PhysicsImpostor): void;
  54924. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54925. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54926. isSupported(): boolean;
  54927. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54928. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54929. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54930. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54931. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54932. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54933. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54934. getBodyMass(impostor: PhysicsImpostor): number;
  54935. getBodyFriction(impostor: PhysicsImpostor): number;
  54936. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54937. getBodyRestitution(impostor: PhysicsImpostor): number;
  54938. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54939. sleepBody(impostor: PhysicsImpostor): void;
  54940. wakeUpBody(impostor: PhysicsImpostor): void;
  54941. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54942. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54943. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54944. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54945. getRadius(impostor: PhysicsImpostor): number;
  54946. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54947. dispose(): void;
  54948. /**
  54949. * Does a raycast in the physics world
  54950. * @param from when should the ray start?
  54951. * @param to when should the ray end?
  54952. * @returns PhysicsRaycastResult
  54953. */
  54954. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54955. }
  54956. }
  54957. declare module BABYLON {
  54958. /**
  54959. * Class containing static functions to help procedurally build meshes
  54960. */
  54961. export class RibbonBuilder {
  54962. /**
  54963. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54964. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54965. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54966. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54967. * * 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
  54968. * * 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
  54969. * * 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
  54970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54971. * * 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
  54972. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54973. * * 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
  54974. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54975. * * 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
  54976. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54978. * @param name defines the name of the mesh
  54979. * @param options defines the options used to create the mesh
  54980. * @param scene defines the hosting scene
  54981. * @returns the ribbon mesh
  54982. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54983. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54984. */
  54985. static CreateRibbon(name: string, options: {
  54986. pathArray: Vector3[][];
  54987. closeArray?: boolean;
  54988. closePath?: boolean;
  54989. offset?: number;
  54990. updatable?: boolean;
  54991. sideOrientation?: number;
  54992. frontUVs?: Vector4;
  54993. backUVs?: Vector4;
  54994. instance?: Mesh;
  54995. invertUV?: boolean;
  54996. uvs?: Vector2[];
  54997. colors?: Color4[];
  54998. }, scene?: Nullable<Scene>): Mesh;
  54999. }
  55000. }
  55001. declare module BABYLON {
  55002. /**
  55003. * Class containing static functions to help procedurally build meshes
  55004. */
  55005. export class ShapeBuilder {
  55006. /**
  55007. * 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.
  55008. * * 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.
  55009. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55010. * * 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.
  55011. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55012. * * 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
  55013. * * 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
  55014. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55016. * * 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
  55017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55019. * @param name defines the name of the mesh
  55020. * @param options defines the options used to create the mesh
  55021. * @param scene defines the hosting scene
  55022. * @returns the extruded shape mesh
  55023. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55024. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55025. */
  55026. static ExtrudeShape(name: string, options: {
  55027. shape: Vector3[];
  55028. path: Vector3[];
  55029. scale?: number;
  55030. rotation?: number;
  55031. cap?: number;
  55032. updatable?: boolean;
  55033. sideOrientation?: number;
  55034. frontUVs?: Vector4;
  55035. backUVs?: Vector4;
  55036. instance?: Mesh;
  55037. invertUV?: boolean;
  55038. }, scene?: Nullable<Scene>): Mesh;
  55039. /**
  55040. * Creates an custom extruded shape mesh.
  55041. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55042. * * 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.
  55043. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55044. * * 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
  55045. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55046. * * 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
  55047. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55048. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55049. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55050. * * 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
  55051. * * 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
  55052. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55054. * * 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
  55055. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55057. * @param name defines the name of the mesh
  55058. * @param options defines the options used to create the mesh
  55059. * @param scene defines the hosting scene
  55060. * @returns the custom extruded shape mesh
  55061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55064. */
  55065. static ExtrudeShapeCustom(name: string, options: {
  55066. shape: Vector3[];
  55067. path: Vector3[];
  55068. scaleFunction?: any;
  55069. rotationFunction?: any;
  55070. ribbonCloseArray?: boolean;
  55071. ribbonClosePath?: boolean;
  55072. cap?: number;
  55073. updatable?: boolean;
  55074. sideOrientation?: number;
  55075. frontUVs?: Vector4;
  55076. backUVs?: Vector4;
  55077. instance?: Mesh;
  55078. invertUV?: boolean;
  55079. }, scene?: Nullable<Scene>): Mesh;
  55080. private static _ExtrudeShapeGeneric;
  55081. }
  55082. }
  55083. declare module BABYLON {
  55084. /**
  55085. * AmmoJS Physics plugin
  55086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55087. * @see https://github.com/kripken/ammo.js/
  55088. */
  55089. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55090. private _useDeltaForWorldStep;
  55091. /**
  55092. * Reference to the Ammo library
  55093. */
  55094. bjsAMMO: any;
  55095. /**
  55096. * Created ammoJS world which physics bodies are added to
  55097. */
  55098. world: any;
  55099. /**
  55100. * Name of the plugin
  55101. */
  55102. name: string;
  55103. private _timeStep;
  55104. private _fixedTimeStep;
  55105. private _maxSteps;
  55106. private _tmpQuaternion;
  55107. private _tmpAmmoTransform;
  55108. private _tmpAmmoQuaternion;
  55109. private _tmpAmmoConcreteContactResultCallback;
  55110. private _collisionConfiguration;
  55111. private _dispatcher;
  55112. private _overlappingPairCache;
  55113. private _solver;
  55114. private _softBodySolver;
  55115. private _tmpAmmoVectorA;
  55116. private _tmpAmmoVectorB;
  55117. private _tmpAmmoVectorC;
  55118. private _tmpAmmoVectorD;
  55119. private _tmpContactCallbackResult;
  55120. private _tmpAmmoVectorRCA;
  55121. private _tmpAmmoVectorRCB;
  55122. private _raycastResult;
  55123. private static readonly DISABLE_COLLISION_FLAG;
  55124. private static readonly KINEMATIC_FLAG;
  55125. private static readonly DISABLE_DEACTIVATION_FLAG;
  55126. /**
  55127. * Initializes the ammoJS plugin
  55128. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55129. * @param ammoInjection can be used to inject your own ammo reference
  55130. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55131. */
  55132. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55133. /**
  55134. * Sets the gravity of the physics world (m/(s^2))
  55135. * @param gravity Gravity to set
  55136. */
  55137. setGravity(gravity: Vector3): void;
  55138. /**
  55139. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55140. * @param timeStep timestep to use in seconds
  55141. */
  55142. setTimeStep(timeStep: number): void;
  55143. /**
  55144. * 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)
  55145. * @param fixedTimeStep fixedTimeStep to use in seconds
  55146. */
  55147. setFixedTimeStep(fixedTimeStep: number): void;
  55148. /**
  55149. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55150. * @param maxSteps the maximum number of steps by the physics engine per frame
  55151. */
  55152. setMaxSteps(maxSteps: number): void;
  55153. /**
  55154. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55155. * @returns the current timestep in seconds
  55156. */
  55157. getTimeStep(): number;
  55158. /**
  55159. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55160. */
  55161. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55162. private _isImpostorInContact;
  55163. private _isImpostorPairInContact;
  55164. private _stepSimulation;
  55165. /**
  55166. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55167. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55168. * After the step the babylon meshes are set to the position of the physics imposters
  55169. * @param delta amount of time to step forward
  55170. * @param impostors array of imposters to update before/after the step
  55171. */
  55172. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55173. /**
  55174. * Update babylon mesh to match physics world object
  55175. * @param impostor imposter to match
  55176. */
  55177. private _afterSoftStep;
  55178. /**
  55179. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55180. * @param impostor imposter to match
  55181. */
  55182. private _ropeStep;
  55183. /**
  55184. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55185. * @param impostor imposter to match
  55186. */
  55187. private _softbodyOrClothStep;
  55188. private _tmpVector;
  55189. private _tmpMatrix;
  55190. /**
  55191. * Applies an impulse on the imposter
  55192. * @param impostor imposter to apply impulse to
  55193. * @param force amount of force to be applied to the imposter
  55194. * @param contactPoint the location to apply the impulse on the imposter
  55195. */
  55196. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55197. /**
  55198. * Applies a force on the imposter
  55199. * @param impostor imposter to apply force
  55200. * @param force amount of force to be applied to the imposter
  55201. * @param contactPoint the location to apply the force on the imposter
  55202. */
  55203. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55204. /**
  55205. * Creates a physics body using the plugin
  55206. * @param impostor the imposter to create the physics body on
  55207. */
  55208. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55209. /**
  55210. * Removes the physics body from the imposter and disposes of the body's memory
  55211. * @param impostor imposter to remove the physics body from
  55212. */
  55213. removePhysicsBody(impostor: PhysicsImpostor): void;
  55214. /**
  55215. * Generates a joint
  55216. * @param impostorJoint the imposter joint to create the joint with
  55217. */
  55218. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55219. /**
  55220. * Removes a joint
  55221. * @param impostorJoint the imposter joint to remove the joint from
  55222. */
  55223. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55224. private _addMeshVerts;
  55225. /**
  55226. * Initialise the soft body vertices to match its object's (mesh) vertices
  55227. * Softbody vertices (nodes) are in world space and to match this
  55228. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55229. * @param impostor to create the softbody for
  55230. */
  55231. private _softVertexData;
  55232. /**
  55233. * Create an impostor's soft body
  55234. * @param impostor to create the softbody for
  55235. */
  55236. private _createSoftbody;
  55237. /**
  55238. * Create cloth for an impostor
  55239. * @param impostor to create the softbody for
  55240. */
  55241. private _createCloth;
  55242. /**
  55243. * Create rope for an impostor
  55244. * @param impostor to create the softbody for
  55245. */
  55246. private _createRope;
  55247. /**
  55248. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55249. * @param impostor to create the custom physics shape for
  55250. */
  55251. private _createCustom;
  55252. private _addHullVerts;
  55253. private _createShape;
  55254. /**
  55255. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55256. * @param impostor imposter containing the physics body and babylon object
  55257. */
  55258. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55259. /**
  55260. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55261. * @param impostor imposter containing the physics body and babylon object
  55262. * @param newPosition new position
  55263. * @param newRotation new rotation
  55264. */
  55265. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55266. /**
  55267. * If this plugin is supported
  55268. * @returns true if its supported
  55269. */
  55270. isSupported(): boolean;
  55271. /**
  55272. * Sets the linear velocity of the physics body
  55273. * @param impostor imposter to set the velocity on
  55274. * @param velocity velocity to set
  55275. */
  55276. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55277. /**
  55278. * Sets the angular velocity of the physics body
  55279. * @param impostor imposter to set the velocity on
  55280. * @param velocity velocity to set
  55281. */
  55282. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55283. /**
  55284. * gets the linear velocity
  55285. * @param impostor imposter to get linear velocity from
  55286. * @returns linear velocity
  55287. */
  55288. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55289. /**
  55290. * gets the angular velocity
  55291. * @param impostor imposter to get angular velocity from
  55292. * @returns angular velocity
  55293. */
  55294. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55295. /**
  55296. * Sets the mass of physics body
  55297. * @param impostor imposter to set the mass on
  55298. * @param mass mass to set
  55299. */
  55300. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55301. /**
  55302. * Gets the mass of the physics body
  55303. * @param impostor imposter to get the mass from
  55304. * @returns mass
  55305. */
  55306. getBodyMass(impostor: PhysicsImpostor): number;
  55307. /**
  55308. * Gets friction of the impostor
  55309. * @param impostor impostor to get friction from
  55310. * @returns friction value
  55311. */
  55312. getBodyFriction(impostor: PhysicsImpostor): number;
  55313. /**
  55314. * Sets friction of the impostor
  55315. * @param impostor impostor to set friction on
  55316. * @param friction friction value
  55317. */
  55318. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55319. /**
  55320. * Gets restitution of the impostor
  55321. * @param impostor impostor to get restitution from
  55322. * @returns restitution value
  55323. */
  55324. getBodyRestitution(impostor: PhysicsImpostor): number;
  55325. /**
  55326. * Sets resitution of the impostor
  55327. * @param impostor impostor to set resitution on
  55328. * @param restitution resitution value
  55329. */
  55330. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55331. /**
  55332. * Gets pressure inside the impostor
  55333. * @param impostor impostor to get pressure from
  55334. * @returns pressure value
  55335. */
  55336. getBodyPressure(impostor: PhysicsImpostor): number;
  55337. /**
  55338. * Sets pressure inside a soft body impostor
  55339. * Cloth and rope must remain 0 pressure
  55340. * @param impostor impostor to set pressure on
  55341. * @param pressure pressure value
  55342. */
  55343. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55344. /**
  55345. * Gets stiffness of the impostor
  55346. * @param impostor impostor to get stiffness from
  55347. * @returns pressure value
  55348. */
  55349. getBodyStiffness(impostor: PhysicsImpostor): number;
  55350. /**
  55351. * Sets stiffness of the impostor
  55352. * @param impostor impostor to set stiffness on
  55353. * @param stiffness stiffness value from 0 to 1
  55354. */
  55355. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55356. /**
  55357. * Gets velocityIterations of the impostor
  55358. * @param impostor impostor to get velocity iterations from
  55359. * @returns velocityIterations value
  55360. */
  55361. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55362. /**
  55363. * Sets velocityIterations of the impostor
  55364. * @param impostor impostor to set velocity iterations on
  55365. * @param velocityIterations velocityIterations value
  55366. */
  55367. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55368. /**
  55369. * Gets positionIterations of the impostor
  55370. * @param impostor impostor to get position iterations from
  55371. * @returns positionIterations value
  55372. */
  55373. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55374. /**
  55375. * Sets positionIterations of the impostor
  55376. * @param impostor impostor to set position on
  55377. * @param positionIterations positionIterations value
  55378. */
  55379. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55380. /**
  55381. * Append an anchor to a cloth object
  55382. * @param impostor is the cloth impostor to add anchor to
  55383. * @param otherImpostor is the rigid impostor to anchor to
  55384. * @param width ratio across width from 0 to 1
  55385. * @param height ratio up height from 0 to 1
  55386. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55387. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55388. */
  55389. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55390. /**
  55391. * Append an hook to a rope object
  55392. * @param impostor is the rope impostor to add hook to
  55393. * @param otherImpostor is the rigid impostor to hook to
  55394. * @param length ratio along the rope from 0 to 1
  55395. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55396. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55397. */
  55398. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55399. /**
  55400. * Sleeps the physics body and stops it from being active
  55401. * @param impostor impostor to sleep
  55402. */
  55403. sleepBody(impostor: PhysicsImpostor): void;
  55404. /**
  55405. * Activates the physics body
  55406. * @param impostor impostor to activate
  55407. */
  55408. wakeUpBody(impostor: PhysicsImpostor): void;
  55409. /**
  55410. * Updates the distance parameters of the joint
  55411. * @param joint joint to update
  55412. * @param maxDistance maximum distance of the joint
  55413. * @param minDistance minimum distance of the joint
  55414. */
  55415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55416. /**
  55417. * Sets a motor on the joint
  55418. * @param joint joint to set motor on
  55419. * @param speed speed of the motor
  55420. * @param maxForce maximum force of the motor
  55421. * @param motorIndex index of the motor
  55422. */
  55423. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55424. /**
  55425. * Sets the motors limit
  55426. * @param joint joint to set limit on
  55427. * @param upperLimit upper limit
  55428. * @param lowerLimit lower limit
  55429. */
  55430. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55431. /**
  55432. * Syncs the position and rotation of a mesh with the impostor
  55433. * @param mesh mesh to sync
  55434. * @param impostor impostor to update the mesh with
  55435. */
  55436. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55437. /**
  55438. * Gets the radius of the impostor
  55439. * @param impostor impostor to get radius from
  55440. * @returns the radius
  55441. */
  55442. getRadius(impostor: PhysicsImpostor): number;
  55443. /**
  55444. * Gets the box size of the impostor
  55445. * @param impostor impostor to get box size from
  55446. * @param result the resulting box size
  55447. */
  55448. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55449. /**
  55450. * Disposes of the impostor
  55451. */
  55452. dispose(): void;
  55453. /**
  55454. * Does a raycast in the physics world
  55455. * @param from when should the ray start?
  55456. * @param to when should the ray end?
  55457. * @returns PhysicsRaycastResult
  55458. */
  55459. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55460. }
  55461. }
  55462. declare module BABYLON {
  55463. interface AbstractScene {
  55464. /**
  55465. * The list of reflection probes added to the scene
  55466. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55467. */
  55468. reflectionProbes: Array<ReflectionProbe>;
  55469. /**
  55470. * Removes the given reflection probe from this scene.
  55471. * @param toRemove The reflection probe to remove
  55472. * @returns The index of the removed reflection probe
  55473. */
  55474. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55475. /**
  55476. * Adds the given reflection probe to this scene.
  55477. * @param newReflectionProbe The reflection probe to add
  55478. */
  55479. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55480. }
  55481. /**
  55482. * Class used to generate realtime reflection / refraction cube textures
  55483. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55484. */
  55485. export class ReflectionProbe {
  55486. /** defines the name of the probe */
  55487. name: string;
  55488. private _scene;
  55489. private _renderTargetTexture;
  55490. private _projectionMatrix;
  55491. private _viewMatrix;
  55492. private _target;
  55493. private _add;
  55494. private _attachedMesh;
  55495. private _invertYAxis;
  55496. /** Gets or sets probe position (center of the cube map) */
  55497. position: Vector3;
  55498. /**
  55499. * Creates a new reflection probe
  55500. * @param name defines the name of the probe
  55501. * @param size defines the texture resolution (for each face)
  55502. * @param scene defines the hosting scene
  55503. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55504. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55505. */
  55506. constructor(
  55507. /** defines the name of the probe */
  55508. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55509. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55510. get samples(): number;
  55511. set samples(value: number);
  55512. /** Gets or sets the refresh rate to use (on every frame by default) */
  55513. get refreshRate(): number;
  55514. set refreshRate(value: number);
  55515. /**
  55516. * Gets the hosting scene
  55517. * @returns a Scene
  55518. */
  55519. getScene(): Scene;
  55520. /** Gets the internal CubeTexture used to render to */
  55521. get cubeTexture(): RenderTargetTexture;
  55522. /** Gets the list of meshes to render */
  55523. get renderList(): Nullable<AbstractMesh[]>;
  55524. /**
  55525. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55526. * @param mesh defines the mesh to attach to
  55527. */
  55528. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55529. /**
  55530. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55531. * @param renderingGroupId The rendering group id corresponding to its index
  55532. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55533. */
  55534. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55535. /**
  55536. * Clean all associated resources
  55537. */
  55538. dispose(): void;
  55539. /**
  55540. * Converts the reflection probe information to a readable string for debug purpose.
  55541. * @param fullDetails Supports for multiple levels of logging within scene loading
  55542. * @returns the human readable reflection probe info
  55543. */
  55544. toString(fullDetails?: boolean): string;
  55545. /**
  55546. * Get the class name of the relfection probe.
  55547. * @returns "ReflectionProbe"
  55548. */
  55549. getClassName(): string;
  55550. /**
  55551. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55552. * @returns The JSON representation of the texture
  55553. */
  55554. serialize(): any;
  55555. /**
  55556. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55557. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55558. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55559. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55560. * @returns The parsed reflection probe if successful
  55561. */
  55562. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55563. }
  55564. }
  55565. declare module BABYLON {
  55566. /** @hidden */
  55567. export var _BabylonLoaderRegistered: boolean;
  55568. /**
  55569. * Helps setting up some configuration for the babylon file loader.
  55570. */
  55571. export class BabylonFileLoaderConfiguration {
  55572. /**
  55573. * The loader does not allow injecting custom physix engine into the plugins.
  55574. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55575. * So you could set this variable to your engine import to make it work.
  55576. */
  55577. static LoaderInjectedPhysicsEngine: any;
  55578. }
  55579. }
  55580. declare module BABYLON {
  55581. /**
  55582. * The Physically based simple base material of BJS.
  55583. *
  55584. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55585. * It is used as the base class for both the specGloss and metalRough conventions.
  55586. */
  55587. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55588. /**
  55589. * Number of Simultaneous lights allowed on the material.
  55590. */
  55591. maxSimultaneousLights: number;
  55592. /**
  55593. * If sets to true, disables all the lights affecting the material.
  55594. */
  55595. disableLighting: boolean;
  55596. /**
  55597. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55598. */
  55599. environmentTexture: BaseTexture;
  55600. /**
  55601. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55602. */
  55603. invertNormalMapX: boolean;
  55604. /**
  55605. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55606. */
  55607. invertNormalMapY: boolean;
  55608. /**
  55609. * Normal map used in the model.
  55610. */
  55611. normalTexture: BaseTexture;
  55612. /**
  55613. * Emissivie color used to self-illuminate the model.
  55614. */
  55615. emissiveColor: Color3;
  55616. /**
  55617. * Emissivie texture used to self-illuminate the model.
  55618. */
  55619. emissiveTexture: BaseTexture;
  55620. /**
  55621. * Occlusion Channel Strenght.
  55622. */
  55623. occlusionStrength: number;
  55624. /**
  55625. * Occlusion Texture of the material (adding extra occlusion effects).
  55626. */
  55627. occlusionTexture: BaseTexture;
  55628. /**
  55629. * Defines the alpha limits in alpha test mode.
  55630. */
  55631. alphaCutOff: number;
  55632. /**
  55633. * Gets the current double sided mode.
  55634. */
  55635. get doubleSided(): boolean;
  55636. /**
  55637. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55638. */
  55639. set doubleSided(value: boolean);
  55640. /**
  55641. * Stores the pre-calculated light information of a mesh in a texture.
  55642. */
  55643. lightmapTexture: BaseTexture;
  55644. /**
  55645. * If true, the light map contains occlusion information instead of lighting info.
  55646. */
  55647. useLightmapAsShadowmap: boolean;
  55648. /**
  55649. * Instantiates a new PBRMaterial instance.
  55650. *
  55651. * @param name The material name
  55652. * @param scene The scene the material will be use in.
  55653. */
  55654. constructor(name: string, scene: Scene);
  55655. getClassName(): string;
  55656. }
  55657. }
  55658. declare module BABYLON {
  55659. /**
  55660. * The PBR material of BJS following the metal roughness convention.
  55661. *
  55662. * This fits to the PBR convention in the GLTF definition:
  55663. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55664. */
  55665. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55666. /**
  55667. * The base color has two different interpretations depending on the value of metalness.
  55668. * When the material is a metal, the base color is the specific measured reflectance value
  55669. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55670. * of the material.
  55671. */
  55672. baseColor: Color3;
  55673. /**
  55674. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55675. * well as opacity information in the alpha channel.
  55676. */
  55677. baseTexture: BaseTexture;
  55678. /**
  55679. * Specifies the metallic scalar value of the material.
  55680. * Can also be used to scale the metalness values of the metallic texture.
  55681. */
  55682. metallic: number;
  55683. /**
  55684. * Specifies the roughness scalar value of the material.
  55685. * Can also be used to scale the roughness values of the metallic texture.
  55686. */
  55687. roughness: number;
  55688. /**
  55689. * Texture containing both the metallic value in the B channel and the
  55690. * roughness value in the G channel to keep better precision.
  55691. */
  55692. metallicRoughnessTexture: BaseTexture;
  55693. /**
  55694. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55695. *
  55696. * @param name The material name
  55697. * @param scene The scene the material will be use in.
  55698. */
  55699. constructor(name: string, scene: Scene);
  55700. /**
  55701. * Return the currrent class name of the material.
  55702. */
  55703. getClassName(): string;
  55704. /**
  55705. * Makes a duplicate of the current material.
  55706. * @param name - name to use for the new material.
  55707. */
  55708. clone(name: string): PBRMetallicRoughnessMaterial;
  55709. /**
  55710. * Serialize the material to a parsable JSON object.
  55711. */
  55712. serialize(): any;
  55713. /**
  55714. * Parses a JSON object correponding to the serialize function.
  55715. */
  55716. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55717. }
  55718. }
  55719. declare module BABYLON {
  55720. /**
  55721. * The PBR material of BJS following the specular glossiness convention.
  55722. *
  55723. * This fits to the PBR convention in the GLTF definition:
  55724. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55725. */
  55726. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55727. /**
  55728. * Specifies the diffuse color of the material.
  55729. */
  55730. diffuseColor: Color3;
  55731. /**
  55732. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55733. * channel.
  55734. */
  55735. diffuseTexture: BaseTexture;
  55736. /**
  55737. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55738. */
  55739. specularColor: Color3;
  55740. /**
  55741. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55742. */
  55743. glossiness: number;
  55744. /**
  55745. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55746. */
  55747. specularGlossinessTexture: BaseTexture;
  55748. /**
  55749. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55750. *
  55751. * @param name The material name
  55752. * @param scene The scene the material will be use in.
  55753. */
  55754. constructor(name: string, scene: Scene);
  55755. /**
  55756. * Return the currrent class name of the material.
  55757. */
  55758. getClassName(): string;
  55759. /**
  55760. * Makes a duplicate of the current material.
  55761. * @param name - name to use for the new material.
  55762. */
  55763. clone(name: string): PBRSpecularGlossinessMaterial;
  55764. /**
  55765. * Serialize the material to a parsable JSON object.
  55766. */
  55767. serialize(): any;
  55768. /**
  55769. * Parses a JSON object correponding to the serialize function.
  55770. */
  55771. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55772. }
  55773. }
  55774. declare module BABYLON {
  55775. /**
  55776. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55777. * It can help converting any input color in a desired output one. This can then be used to create effects
  55778. * from sepia, black and white to sixties or futuristic rendering...
  55779. *
  55780. * The only supported format is currently 3dl.
  55781. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55782. */
  55783. export class ColorGradingTexture extends BaseTexture {
  55784. /**
  55785. * The current texture matrix. (will always be identity in color grading texture)
  55786. */
  55787. private _textureMatrix;
  55788. /**
  55789. * The texture URL.
  55790. */
  55791. url: string;
  55792. /**
  55793. * Empty line regex stored for GC.
  55794. */
  55795. private static _noneEmptyLineRegex;
  55796. private _engine;
  55797. /**
  55798. * Instantiates a ColorGradingTexture from the following parameters.
  55799. *
  55800. * @param url The location of the color gradind data (currently only supporting 3dl)
  55801. * @param scene The scene the texture will be used in
  55802. */
  55803. constructor(url: string, scene: Scene);
  55804. /**
  55805. * Returns the texture matrix used in most of the material.
  55806. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55807. */
  55808. getTextureMatrix(): Matrix;
  55809. /**
  55810. * Occurs when the file being loaded is a .3dl LUT file.
  55811. */
  55812. private load3dlTexture;
  55813. /**
  55814. * Starts the loading process of the texture.
  55815. */
  55816. private loadTexture;
  55817. /**
  55818. * Clones the color gradind texture.
  55819. */
  55820. clone(): ColorGradingTexture;
  55821. /**
  55822. * Called during delayed load for textures.
  55823. */
  55824. delayLoad(): void;
  55825. /**
  55826. * Parses a color grading texture serialized by Babylon.
  55827. * @param parsedTexture The texture information being parsedTexture
  55828. * @param scene The scene to load the texture in
  55829. * @param rootUrl The root url of the data assets to load
  55830. * @return A color gradind texture
  55831. */
  55832. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55833. /**
  55834. * Serializes the LUT texture to json format.
  55835. */
  55836. serialize(): any;
  55837. }
  55838. }
  55839. declare module BABYLON {
  55840. /**
  55841. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55842. */
  55843. export class EquiRectangularCubeTexture extends BaseTexture {
  55844. /** The six faces of the cube. */
  55845. private static _FacesMapping;
  55846. private _noMipmap;
  55847. private _onLoad;
  55848. private _onError;
  55849. /** The size of the cubemap. */
  55850. private _size;
  55851. /** The buffer of the image. */
  55852. private _buffer;
  55853. /** The width of the input image. */
  55854. private _width;
  55855. /** The height of the input image. */
  55856. private _height;
  55857. /** The URL to the image. */
  55858. url: string;
  55859. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55860. coordinatesMode: number;
  55861. /**
  55862. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55863. * @param url The location of the image
  55864. * @param scene The scene the texture will be used in
  55865. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55866. * @param noMipmap Forces to not generate the mipmap if true
  55867. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55868. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55869. * @param onLoad — defines a callback called when texture is loaded
  55870. * @param onError — defines a callback called if there is an error
  55871. */
  55872. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55873. /**
  55874. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55875. */
  55876. private loadImage;
  55877. /**
  55878. * Convert the image buffer into a cubemap and create a CubeTexture.
  55879. */
  55880. private loadTexture;
  55881. /**
  55882. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55883. * @param buffer The ArrayBuffer that should be converted.
  55884. * @returns The buffer as Float32Array.
  55885. */
  55886. private getFloat32ArrayFromArrayBuffer;
  55887. /**
  55888. * Get the current class name of the texture useful for serialization or dynamic coding.
  55889. * @returns "EquiRectangularCubeTexture"
  55890. */
  55891. getClassName(): string;
  55892. /**
  55893. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55894. * @returns A clone of the current EquiRectangularCubeTexture.
  55895. */
  55896. clone(): EquiRectangularCubeTexture;
  55897. }
  55898. }
  55899. declare module BABYLON {
  55900. /**
  55901. * Based on jsTGALoader - Javascript loader for TGA file
  55902. * By Vincent Thibault
  55903. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55904. */
  55905. export class TGATools {
  55906. private static _TYPE_INDEXED;
  55907. private static _TYPE_RGB;
  55908. private static _TYPE_GREY;
  55909. private static _TYPE_RLE_INDEXED;
  55910. private static _TYPE_RLE_RGB;
  55911. private static _TYPE_RLE_GREY;
  55912. private static _ORIGIN_MASK;
  55913. private static _ORIGIN_SHIFT;
  55914. private static _ORIGIN_BL;
  55915. private static _ORIGIN_BR;
  55916. private static _ORIGIN_UL;
  55917. private static _ORIGIN_UR;
  55918. /**
  55919. * Gets the header of a TGA file
  55920. * @param data defines the TGA data
  55921. * @returns the header
  55922. */
  55923. static GetTGAHeader(data: Uint8Array): any;
  55924. /**
  55925. * Uploads TGA content to a Babylon Texture
  55926. * @hidden
  55927. */
  55928. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55929. /** @hidden */
  55930. 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;
  55931. /** @hidden */
  55932. 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;
  55933. /** @hidden */
  55934. 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;
  55935. /** @hidden */
  55936. 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;
  55937. /** @hidden */
  55938. 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;
  55939. /** @hidden */
  55940. 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;
  55941. }
  55942. }
  55943. declare module BABYLON {
  55944. /**
  55945. * Implementation of the TGA Texture Loader.
  55946. * @hidden
  55947. */
  55948. export class _TGATextureLoader implements IInternalTextureLoader {
  55949. /**
  55950. * Defines wether the loader supports cascade loading the different faces.
  55951. */
  55952. readonly supportCascades: boolean;
  55953. /**
  55954. * This returns if the loader support the current file information.
  55955. * @param extension defines the file extension of the file being loaded
  55956. * @returns true if the loader can load the specified file
  55957. */
  55958. canLoad(extension: string): boolean;
  55959. /**
  55960. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55961. * @param data contains the texture data
  55962. * @param texture defines the BabylonJS internal texture
  55963. * @param createPolynomials will be true if polynomials have been requested
  55964. * @param onLoad defines the callback to trigger once the texture is ready
  55965. * @param onError defines the callback to trigger in case of error
  55966. */
  55967. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55968. /**
  55969. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55970. * @param data contains the texture data
  55971. * @param texture defines the BabylonJS internal texture
  55972. * @param callback defines the method to call once ready to upload
  55973. */
  55974. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55975. }
  55976. }
  55977. declare module BABYLON {
  55978. /**
  55979. * Info about the .basis files
  55980. */
  55981. class BasisFileInfo {
  55982. /**
  55983. * If the file has alpha
  55984. */
  55985. hasAlpha: boolean;
  55986. /**
  55987. * Info about each image of the basis file
  55988. */
  55989. images: Array<{
  55990. levels: Array<{
  55991. width: number;
  55992. height: number;
  55993. transcodedPixels: ArrayBufferView;
  55994. }>;
  55995. }>;
  55996. }
  55997. /**
  55998. * Result of transcoding a basis file
  55999. */
  56000. class TranscodeResult {
  56001. /**
  56002. * Info about the .basis file
  56003. */
  56004. fileInfo: BasisFileInfo;
  56005. /**
  56006. * Format to use when loading the file
  56007. */
  56008. format: number;
  56009. }
  56010. /**
  56011. * Configuration options for the Basis transcoder
  56012. */
  56013. export class BasisTranscodeConfiguration {
  56014. /**
  56015. * Supported compression formats used to determine the supported output format of the transcoder
  56016. */
  56017. supportedCompressionFormats?: {
  56018. /**
  56019. * etc1 compression format
  56020. */
  56021. etc1?: boolean;
  56022. /**
  56023. * s3tc compression format
  56024. */
  56025. s3tc?: boolean;
  56026. /**
  56027. * pvrtc compression format
  56028. */
  56029. pvrtc?: boolean;
  56030. /**
  56031. * etc2 compression format
  56032. */
  56033. etc2?: boolean;
  56034. };
  56035. /**
  56036. * If mipmap levels should be loaded for transcoded images (Default: true)
  56037. */
  56038. loadMipmapLevels?: boolean;
  56039. /**
  56040. * Index of a single image to load (Default: all images)
  56041. */
  56042. loadSingleImage?: number;
  56043. }
  56044. /**
  56045. * Used to load .Basis files
  56046. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56047. */
  56048. export class BasisTools {
  56049. private static _IgnoreSupportedFormats;
  56050. /**
  56051. * URL to use when loading the basis transcoder
  56052. */
  56053. static JSModuleURL: string;
  56054. /**
  56055. * URL to use when loading the wasm module for the transcoder
  56056. */
  56057. static WasmModuleURL: string;
  56058. /**
  56059. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56060. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56061. * @returns internal format corresponding to the Basis format
  56062. */
  56063. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56064. private static _WorkerPromise;
  56065. private static _Worker;
  56066. private static _actionId;
  56067. private static _CreateWorkerAsync;
  56068. /**
  56069. * Transcodes a loaded image file to compressed pixel data
  56070. * @param data image data to transcode
  56071. * @param config configuration options for the transcoding
  56072. * @returns a promise resulting in the transcoded image
  56073. */
  56074. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56075. /**
  56076. * Loads a texture from the transcode result
  56077. * @param texture texture load to
  56078. * @param transcodeResult the result of transcoding the basis file to load from
  56079. */
  56080. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56081. }
  56082. }
  56083. declare module BABYLON {
  56084. /**
  56085. * Loader for .basis file format
  56086. */
  56087. export class _BasisTextureLoader implements IInternalTextureLoader {
  56088. /**
  56089. * Defines whether the loader supports cascade loading the different faces.
  56090. */
  56091. readonly supportCascades: boolean;
  56092. /**
  56093. * This returns if the loader support the current file information.
  56094. * @param extension defines the file extension of the file being loaded
  56095. * @returns true if the loader can load the specified file
  56096. */
  56097. canLoad(extension: string): boolean;
  56098. /**
  56099. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56100. * @param data contains the texture data
  56101. * @param texture defines the BabylonJS internal texture
  56102. * @param createPolynomials will be true if polynomials have been requested
  56103. * @param onLoad defines the callback to trigger once the texture is ready
  56104. * @param onError defines the callback to trigger in case of error
  56105. */
  56106. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56107. /**
  56108. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56109. * @param data contains the texture data
  56110. * @param texture defines the BabylonJS internal texture
  56111. * @param callback defines the method to call once ready to upload
  56112. */
  56113. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56114. }
  56115. }
  56116. declare module BABYLON {
  56117. /**
  56118. * 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.
  56119. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56120. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56121. */
  56122. export class CustomProceduralTexture extends ProceduralTexture {
  56123. private _animate;
  56124. private _time;
  56125. private _config;
  56126. private _texturePath;
  56127. /**
  56128. * Instantiates a new Custom Procedural Texture.
  56129. * 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.
  56130. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56131. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56132. * @param name Define the name of the texture
  56133. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56134. * @param size Define the size of the texture to create
  56135. * @param scene Define the scene the texture belongs to
  56136. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56137. * @param generateMipMaps Define if the texture should creates mip maps or not
  56138. */
  56139. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56140. private _loadJson;
  56141. /**
  56142. * Is the texture ready to be used ? (rendered at least once)
  56143. * @returns true if ready, otherwise, false.
  56144. */
  56145. isReady(): boolean;
  56146. /**
  56147. * Render the texture to its associated render target.
  56148. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56149. */
  56150. render(useCameraPostProcess?: boolean): void;
  56151. /**
  56152. * Update the list of dependant textures samplers in the shader.
  56153. */
  56154. updateTextures(): void;
  56155. /**
  56156. * Update the uniform values of the procedural texture in the shader.
  56157. */
  56158. updateShaderUniforms(): void;
  56159. /**
  56160. * Define if the texture animates or not.
  56161. */
  56162. get animate(): boolean;
  56163. set animate(value: boolean);
  56164. }
  56165. }
  56166. declare module BABYLON {
  56167. /** @hidden */
  56168. export var noisePixelShader: {
  56169. name: string;
  56170. shader: string;
  56171. };
  56172. }
  56173. declare module BABYLON {
  56174. /**
  56175. * Class used to generate noise procedural textures
  56176. */
  56177. export class NoiseProceduralTexture extends ProceduralTexture {
  56178. private _time;
  56179. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56180. brightness: number;
  56181. /** Defines the number of octaves to process */
  56182. octaves: number;
  56183. /** Defines the level of persistence (0.8 by default) */
  56184. persistence: number;
  56185. /** Gets or sets animation speed factor (default is 1) */
  56186. animationSpeedFactor: number;
  56187. /**
  56188. * Creates a new NoiseProceduralTexture
  56189. * @param name defines the name fo the texture
  56190. * @param size defines the size of the texture (default is 256)
  56191. * @param scene defines the hosting scene
  56192. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56193. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56194. */
  56195. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56196. private _updateShaderUniforms;
  56197. protected _getDefines(): string;
  56198. /** Generate the current state of the procedural texture */
  56199. render(useCameraPostProcess?: boolean): void;
  56200. /**
  56201. * Serializes this noise procedural texture
  56202. * @returns a serialized noise procedural texture object
  56203. */
  56204. serialize(): any;
  56205. /**
  56206. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56207. * @param parsedTexture defines parsed texture data
  56208. * @param scene defines the current scene
  56209. * @param rootUrl defines the root URL containing noise procedural texture information
  56210. * @returns a parsed NoiseProceduralTexture
  56211. */
  56212. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56213. }
  56214. }
  56215. declare module BABYLON {
  56216. /**
  56217. * Raw cube texture where the raw buffers are passed in
  56218. */
  56219. export class RawCubeTexture extends CubeTexture {
  56220. /**
  56221. * Creates a cube texture where the raw buffers are passed in.
  56222. * @param scene defines the scene the texture is attached to
  56223. * @param data defines the array of data to use to create each face
  56224. * @param size defines the size of the textures
  56225. * @param format defines the format of the data
  56226. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56227. * @param generateMipMaps defines if the engine should generate the mip levels
  56228. * @param invertY defines if data must be stored with Y axis inverted
  56229. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56230. * @param compression defines the compression used (null by default)
  56231. */
  56232. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56233. /**
  56234. * Updates the raw cube texture.
  56235. * @param data defines the data to store
  56236. * @param format defines the data format
  56237. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56238. * @param invertY defines if data must be stored with Y axis inverted
  56239. * @param compression defines the compression used (null by default)
  56240. * @param level defines which level of the texture to update
  56241. */
  56242. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56243. /**
  56244. * Updates a raw cube texture with RGBD encoded data.
  56245. * @param data defines the array of data [mipmap][face] to use to create each face
  56246. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56247. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56248. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56249. * @returns a promsie that resolves when the operation is complete
  56250. */
  56251. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56252. /**
  56253. * Clones the raw cube texture.
  56254. * @return a new cube texture
  56255. */
  56256. clone(): CubeTexture;
  56257. /** @hidden */
  56258. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56259. }
  56260. }
  56261. declare module BABYLON {
  56262. /**
  56263. * Class used to store 3D textures containing user data
  56264. */
  56265. export class RawTexture3D extends Texture {
  56266. /** Gets or sets the texture format to use */
  56267. format: number;
  56268. private _engine;
  56269. /**
  56270. * Create a new RawTexture3D
  56271. * @param data defines the data of the texture
  56272. * @param width defines the width of the texture
  56273. * @param height defines the height of the texture
  56274. * @param depth defines the depth of the texture
  56275. * @param format defines the texture format to use
  56276. * @param scene defines the hosting scene
  56277. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56278. * @param invertY defines if texture must be stored with Y axis inverted
  56279. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56280. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56281. */
  56282. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56283. /** Gets or sets the texture format to use */
  56284. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56285. /**
  56286. * Update the texture with new data
  56287. * @param data defines the data to store in the texture
  56288. */
  56289. update(data: ArrayBufferView): void;
  56290. }
  56291. }
  56292. declare module BABYLON {
  56293. /**
  56294. * Class used to store 2D array textures containing user data
  56295. */
  56296. export class RawTexture2DArray extends Texture {
  56297. /** Gets or sets the texture format to use */
  56298. format: number;
  56299. private _engine;
  56300. /**
  56301. * Create a new RawTexture2DArray
  56302. * @param data defines the data of the texture
  56303. * @param width defines the width of the texture
  56304. * @param height defines the height of the texture
  56305. * @param depth defines the number of layers of the texture
  56306. * @param format defines the texture format to use
  56307. * @param scene defines the hosting scene
  56308. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56309. * @param invertY defines if texture must be stored with Y axis inverted
  56310. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56311. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56312. */
  56313. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56314. /** Gets or sets the texture format to use */
  56315. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56316. /**
  56317. * Update the texture with new data
  56318. * @param data defines the data to store in the texture
  56319. */
  56320. update(data: ArrayBufferView): void;
  56321. }
  56322. }
  56323. declare module BABYLON {
  56324. /**
  56325. * Creates a refraction texture used by refraction channel of the standard material.
  56326. * It is like a mirror but to see through a material.
  56327. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56328. */
  56329. export class RefractionTexture extends RenderTargetTexture {
  56330. /**
  56331. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56332. * 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.
  56333. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56334. */
  56335. refractionPlane: Plane;
  56336. /**
  56337. * Define how deep under the surface we should see.
  56338. */
  56339. depth: number;
  56340. /**
  56341. * Creates a refraction texture used by refraction channel of the standard material.
  56342. * It is like a mirror but to see through a material.
  56343. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56344. * @param name Define the texture name
  56345. * @param size Define the size of the underlying texture
  56346. * @param scene Define the scene the refraction belongs to
  56347. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56348. */
  56349. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56350. /**
  56351. * Clone the refraction texture.
  56352. * @returns the cloned texture
  56353. */
  56354. clone(): RefractionTexture;
  56355. /**
  56356. * Serialize the texture to a JSON representation you could use in Parse later on
  56357. * @returns the serialized JSON representation
  56358. */
  56359. serialize(): any;
  56360. }
  56361. }
  56362. declare module BABYLON {
  56363. /**
  56364. * Defines the options related to the creation of an HtmlElementTexture
  56365. */
  56366. export interface IHtmlElementTextureOptions {
  56367. /**
  56368. * Defines wether mip maps should be created or not.
  56369. */
  56370. generateMipMaps?: boolean;
  56371. /**
  56372. * Defines the sampling mode of the texture.
  56373. */
  56374. samplingMode?: number;
  56375. /**
  56376. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56377. */
  56378. engine: Nullable<ThinEngine>;
  56379. /**
  56380. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56381. */
  56382. scene: Nullable<Scene>;
  56383. }
  56384. /**
  56385. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56386. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56387. * is automatically managed.
  56388. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56389. * in your application.
  56390. *
  56391. * As the update is not automatic, you need to call them manually.
  56392. */
  56393. export class HtmlElementTexture extends BaseTexture {
  56394. /**
  56395. * The texture URL.
  56396. */
  56397. element: HTMLVideoElement | HTMLCanvasElement;
  56398. private static readonly DefaultOptions;
  56399. private _textureMatrix;
  56400. private _engine;
  56401. private _isVideo;
  56402. private _generateMipMaps;
  56403. private _samplingMode;
  56404. /**
  56405. * Instantiates a HtmlElementTexture from the following parameters.
  56406. *
  56407. * @param name Defines the name of the texture
  56408. * @param element Defines the video or canvas the texture is filled with
  56409. * @param options Defines the other none mandatory texture creation options
  56410. */
  56411. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56412. private _createInternalTexture;
  56413. /**
  56414. * Returns the texture matrix used in most of the material.
  56415. */
  56416. getTextureMatrix(): Matrix;
  56417. /**
  56418. * Updates the content of the texture.
  56419. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56420. */
  56421. update(invertY?: Nullable<boolean>): void;
  56422. }
  56423. }
  56424. declare module BABYLON {
  56425. /**
  56426. * Defines the basic options interface of a TexturePacker Frame
  56427. */
  56428. export interface ITexturePackerFrame {
  56429. /**
  56430. * The frame ID
  56431. */
  56432. id: number;
  56433. /**
  56434. * The frames Scale
  56435. */
  56436. scale: Vector2;
  56437. /**
  56438. * The Frames offset
  56439. */
  56440. offset: Vector2;
  56441. }
  56442. /**
  56443. * This is a support class for frame Data on texture packer sets.
  56444. */
  56445. export class TexturePackerFrame implements ITexturePackerFrame {
  56446. /**
  56447. * The frame ID
  56448. */
  56449. id: number;
  56450. /**
  56451. * The frames Scale
  56452. */
  56453. scale: Vector2;
  56454. /**
  56455. * The Frames offset
  56456. */
  56457. offset: Vector2;
  56458. /**
  56459. * Initializes a texture package frame.
  56460. * @param id The numerical frame identifier
  56461. * @param scale Scalar Vector2 for UV frame
  56462. * @param offset Vector2 for the frame position in UV units.
  56463. * @returns TexturePackerFrame
  56464. */
  56465. constructor(id: number, scale: Vector2, offset: Vector2);
  56466. }
  56467. }
  56468. declare module BABYLON {
  56469. /**
  56470. * Defines the basic options interface of a TexturePacker
  56471. */
  56472. export interface ITexturePackerOptions {
  56473. /**
  56474. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56475. */
  56476. map?: string[];
  56477. /**
  56478. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56479. */
  56480. uvsIn?: string;
  56481. /**
  56482. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56483. */
  56484. uvsOut?: string;
  56485. /**
  56486. * number representing the layout style. Defaults to LAYOUT_STRIP
  56487. */
  56488. layout?: number;
  56489. /**
  56490. * number of columns if using custom column count layout(2). This defaults to 4.
  56491. */
  56492. colnum?: number;
  56493. /**
  56494. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56495. */
  56496. updateInputMeshes?: boolean;
  56497. /**
  56498. * boolean flag to dispose all the source textures. Defaults to true.
  56499. */
  56500. disposeSources?: boolean;
  56501. /**
  56502. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56503. */
  56504. fillBlanks?: boolean;
  56505. /**
  56506. * string value representing the context fill style color. Defaults to 'black'.
  56507. */
  56508. customFillColor?: string;
  56509. /**
  56510. * Width and Height Value of each Frame in the TexturePacker Sets
  56511. */
  56512. frameSize?: number;
  56513. /**
  56514. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56515. */
  56516. paddingRatio?: number;
  56517. /**
  56518. * Number that declares the fill method for the padding gutter.
  56519. */
  56520. paddingMode?: number;
  56521. /**
  56522. * If in SUBUV_COLOR padding mode what color to use.
  56523. */
  56524. paddingColor?: Color3 | Color4;
  56525. }
  56526. /**
  56527. * Defines the basic interface of a TexturePacker JSON File
  56528. */
  56529. export interface ITexturePackerJSON {
  56530. /**
  56531. * The frame ID
  56532. */
  56533. name: string;
  56534. /**
  56535. * The base64 channel data
  56536. */
  56537. sets: any;
  56538. /**
  56539. * The options of the Packer
  56540. */
  56541. options: ITexturePackerOptions;
  56542. /**
  56543. * The frame data of the Packer
  56544. */
  56545. frames: Array<number>;
  56546. }
  56547. /**
  56548. * This is a support class that generates a series of packed texture sets.
  56549. * @see https://doc.babylonjs.com/babylon101/materials
  56550. */
  56551. export class TexturePacker {
  56552. /** Packer Layout Constant 0 */
  56553. static readonly LAYOUT_STRIP: number;
  56554. /** Packer Layout Constant 1 */
  56555. static readonly LAYOUT_POWER2: number;
  56556. /** Packer Layout Constant 2 */
  56557. static readonly LAYOUT_COLNUM: number;
  56558. /** Packer Layout Constant 0 */
  56559. static readonly SUBUV_WRAP: number;
  56560. /** Packer Layout Constant 1 */
  56561. static readonly SUBUV_EXTEND: number;
  56562. /** Packer Layout Constant 2 */
  56563. static readonly SUBUV_COLOR: number;
  56564. /** The Name of the Texture Package */
  56565. name: string;
  56566. /** The scene scope of the TexturePacker */
  56567. scene: Scene;
  56568. /** The Meshes to target */
  56569. meshes: AbstractMesh[];
  56570. /** Arguments passed with the Constructor */
  56571. options: ITexturePackerOptions;
  56572. /** The promise that is started upon initialization */
  56573. promise: Nullable<Promise<TexturePacker | string>>;
  56574. /** The Container object for the channel sets that are generated */
  56575. sets: object;
  56576. /** The Container array for the frames that are generated */
  56577. frames: TexturePackerFrame[];
  56578. /** The expected number of textures the system is parsing. */
  56579. private _expecting;
  56580. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56581. private _paddingValue;
  56582. /**
  56583. * Initializes a texture package series from an array of meshes or a single mesh.
  56584. * @param name The name of the package
  56585. * @param meshes The target meshes to compose the package from
  56586. * @param options The arguments that texture packer should follow while building.
  56587. * @param scene The scene which the textures are scoped to.
  56588. * @returns TexturePacker
  56589. */
  56590. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56591. /**
  56592. * Starts the package process
  56593. * @param resolve The promises resolution function
  56594. * @returns TexturePacker
  56595. */
  56596. private _createFrames;
  56597. /**
  56598. * Calculates the Size of the Channel Sets
  56599. * @returns Vector2
  56600. */
  56601. private _calculateSize;
  56602. /**
  56603. * Calculates the UV data for the frames.
  56604. * @param baseSize the base frameSize
  56605. * @param padding the base frame padding
  56606. * @param dtSize size of the Dynamic Texture for that channel
  56607. * @param dtUnits is 1/dtSize
  56608. * @param update flag to update the input meshes
  56609. */
  56610. private _calculateMeshUVFrames;
  56611. /**
  56612. * Calculates the frames Offset.
  56613. * @param index of the frame
  56614. * @returns Vector2
  56615. */
  56616. private _getFrameOffset;
  56617. /**
  56618. * Updates a Mesh to the frame data
  56619. * @param mesh that is the target
  56620. * @param frameID or the frame index
  56621. */
  56622. private _updateMeshUV;
  56623. /**
  56624. * Updates a Meshes materials to use the texture packer channels
  56625. * @param m is the mesh to target
  56626. * @param force all channels on the packer to be set.
  56627. */
  56628. private _updateTextureReferences;
  56629. /**
  56630. * Public method to set a Mesh to a frame
  56631. * @param m that is the target
  56632. * @param frameID or the frame index
  56633. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56634. */
  56635. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56636. /**
  56637. * Starts the async promise to compile the texture packer.
  56638. * @returns Promise<void>
  56639. */
  56640. processAsync(): Promise<void>;
  56641. /**
  56642. * Disposes all textures associated with this packer
  56643. */
  56644. dispose(): void;
  56645. /**
  56646. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56647. * @param imageType is the image type to use.
  56648. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56649. */
  56650. download(imageType?: string, quality?: number): void;
  56651. /**
  56652. * Public method to load a texturePacker JSON file.
  56653. * @param data of the JSON file in string format.
  56654. */
  56655. updateFromJSON(data: string): void;
  56656. }
  56657. }
  56658. declare module BABYLON {
  56659. /**
  56660. * Enum used to define the target of a block
  56661. */
  56662. export enum NodeMaterialBlockTargets {
  56663. /** Vertex shader */
  56664. Vertex = 1,
  56665. /** Fragment shader */
  56666. Fragment = 2,
  56667. /** Neutral */
  56668. Neutral = 4,
  56669. /** Vertex and Fragment */
  56670. VertexAndFragment = 3
  56671. }
  56672. }
  56673. declare module BABYLON {
  56674. /**
  56675. * Defines the kind of connection point for node based material
  56676. */
  56677. export enum NodeMaterialBlockConnectionPointTypes {
  56678. /** Float */
  56679. Float = 1,
  56680. /** Int */
  56681. Int = 2,
  56682. /** Vector2 */
  56683. Vector2 = 4,
  56684. /** Vector3 */
  56685. Vector3 = 8,
  56686. /** Vector4 */
  56687. Vector4 = 16,
  56688. /** Color3 */
  56689. Color3 = 32,
  56690. /** Color4 */
  56691. Color4 = 64,
  56692. /** Matrix */
  56693. Matrix = 128,
  56694. /** Detect type based on connection */
  56695. AutoDetect = 1024,
  56696. /** Output type that will be defined by input type */
  56697. BasedOnInput = 2048
  56698. }
  56699. }
  56700. declare module BABYLON {
  56701. /**
  56702. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56703. */
  56704. export enum NodeMaterialBlockConnectionPointMode {
  56705. /** Value is an uniform */
  56706. Uniform = 0,
  56707. /** Value is a mesh attribute */
  56708. Attribute = 1,
  56709. /** Value is a varying between vertex and fragment shaders */
  56710. Varying = 2,
  56711. /** Mode is undefined */
  56712. Undefined = 3
  56713. }
  56714. }
  56715. declare module BABYLON {
  56716. /**
  56717. * Enum used to define system values e.g. values automatically provided by the system
  56718. */
  56719. export enum NodeMaterialSystemValues {
  56720. /** World */
  56721. World = 1,
  56722. /** View */
  56723. View = 2,
  56724. /** Projection */
  56725. Projection = 3,
  56726. /** ViewProjection */
  56727. ViewProjection = 4,
  56728. /** WorldView */
  56729. WorldView = 5,
  56730. /** WorldViewProjection */
  56731. WorldViewProjection = 6,
  56732. /** CameraPosition */
  56733. CameraPosition = 7,
  56734. /** Fog Color */
  56735. FogColor = 8,
  56736. /** Delta time */
  56737. DeltaTime = 9
  56738. }
  56739. }
  56740. declare module BABYLON {
  56741. /**
  56742. * Root class for all node material optimizers
  56743. */
  56744. export class NodeMaterialOptimizer {
  56745. /**
  56746. * Function used to optimize a NodeMaterial graph
  56747. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56748. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56749. */
  56750. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56751. }
  56752. }
  56753. declare module BABYLON {
  56754. /**
  56755. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56756. */
  56757. export class TransformBlock extends NodeMaterialBlock {
  56758. /**
  56759. * Defines the value to use to complement W value to transform it to a Vector4
  56760. */
  56761. complementW: number;
  56762. /**
  56763. * Defines the value to use to complement z value to transform it to a Vector4
  56764. */
  56765. complementZ: number;
  56766. /**
  56767. * Creates a new TransformBlock
  56768. * @param name defines the block name
  56769. */
  56770. constructor(name: string);
  56771. /**
  56772. * Gets the current class name
  56773. * @returns the class name
  56774. */
  56775. getClassName(): string;
  56776. /**
  56777. * Gets the vector input
  56778. */
  56779. get vector(): NodeMaterialConnectionPoint;
  56780. /**
  56781. * Gets the output component
  56782. */
  56783. get output(): NodeMaterialConnectionPoint;
  56784. /**
  56785. * Gets the xyz output component
  56786. */
  56787. get xyz(): NodeMaterialConnectionPoint;
  56788. /**
  56789. * Gets the matrix transform input
  56790. */
  56791. get transform(): NodeMaterialConnectionPoint;
  56792. protected _buildBlock(state: NodeMaterialBuildState): this;
  56793. serialize(): any;
  56794. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56795. protected _dumpPropertiesCode(): string;
  56796. }
  56797. }
  56798. declare module BABYLON {
  56799. /**
  56800. * Block used to output the vertex position
  56801. */
  56802. export class VertexOutputBlock extends NodeMaterialBlock {
  56803. /**
  56804. * Creates a new VertexOutputBlock
  56805. * @param name defines the block name
  56806. */
  56807. constructor(name: string);
  56808. /**
  56809. * Gets the current class name
  56810. * @returns the class name
  56811. */
  56812. getClassName(): string;
  56813. /**
  56814. * Gets the vector input component
  56815. */
  56816. get vector(): NodeMaterialConnectionPoint;
  56817. protected _buildBlock(state: NodeMaterialBuildState): this;
  56818. }
  56819. }
  56820. declare module BABYLON {
  56821. /**
  56822. * Block used to output the final color
  56823. */
  56824. export class FragmentOutputBlock extends NodeMaterialBlock {
  56825. /**
  56826. * Create a new FragmentOutputBlock
  56827. * @param name defines the block name
  56828. */
  56829. constructor(name: string);
  56830. /**
  56831. * Gets the current class name
  56832. * @returns the class name
  56833. */
  56834. getClassName(): string;
  56835. /**
  56836. * Gets the rgba input component
  56837. */
  56838. get rgba(): NodeMaterialConnectionPoint;
  56839. /**
  56840. * Gets the rgb input component
  56841. */
  56842. get rgb(): NodeMaterialConnectionPoint;
  56843. /**
  56844. * Gets the a input component
  56845. */
  56846. get a(): NodeMaterialConnectionPoint;
  56847. protected _buildBlock(state: NodeMaterialBuildState): this;
  56848. }
  56849. }
  56850. declare module BABYLON {
  56851. /**
  56852. * Block used to read a reflection texture from a sampler
  56853. */
  56854. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56855. private _define3DName;
  56856. private _defineCubicName;
  56857. private _defineExplicitName;
  56858. private _defineProjectionName;
  56859. private _defineLocalCubicName;
  56860. private _defineSphericalName;
  56861. private _definePlanarName;
  56862. private _defineEquirectangularName;
  56863. private _defineMirroredEquirectangularFixedName;
  56864. private _defineEquirectangularFixedName;
  56865. private _defineSkyboxName;
  56866. private _cubeSamplerName;
  56867. private _2DSamplerName;
  56868. private _positionUVWName;
  56869. private _directionWName;
  56870. private _reflectionCoordsName;
  56871. private _reflection2DCoordsName;
  56872. private _reflectionColorName;
  56873. private _reflectionMatrixName;
  56874. /**
  56875. * Gets or sets the texture associated with the node
  56876. */
  56877. texture: Nullable<BaseTexture>;
  56878. /**
  56879. * Create a new TextureBlock
  56880. * @param name defines the block name
  56881. */
  56882. constructor(name: string);
  56883. /**
  56884. * Gets the current class name
  56885. * @returns the class name
  56886. */
  56887. getClassName(): string;
  56888. /**
  56889. * Gets the world position input component
  56890. */
  56891. get position(): NodeMaterialConnectionPoint;
  56892. /**
  56893. * Gets the world position input component
  56894. */
  56895. get worldPosition(): NodeMaterialConnectionPoint;
  56896. /**
  56897. * Gets the world normal input component
  56898. */
  56899. get worldNormal(): NodeMaterialConnectionPoint;
  56900. /**
  56901. * Gets the world input component
  56902. */
  56903. get world(): NodeMaterialConnectionPoint;
  56904. /**
  56905. * Gets the camera (or eye) position component
  56906. */
  56907. get cameraPosition(): NodeMaterialConnectionPoint;
  56908. /**
  56909. * Gets the view input component
  56910. */
  56911. get view(): NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the rgb output component
  56914. */
  56915. get rgb(): NodeMaterialConnectionPoint;
  56916. /**
  56917. * Gets the r output component
  56918. */
  56919. get r(): NodeMaterialConnectionPoint;
  56920. /**
  56921. * Gets the g output component
  56922. */
  56923. get g(): NodeMaterialConnectionPoint;
  56924. /**
  56925. * Gets the b output component
  56926. */
  56927. get b(): NodeMaterialConnectionPoint;
  56928. autoConfigure(material: NodeMaterial): void;
  56929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56930. isReady(): boolean;
  56931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56932. private _injectVertexCode;
  56933. private _writeOutput;
  56934. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56935. protected _dumpPropertiesCode(): string;
  56936. serialize(): any;
  56937. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56938. }
  56939. }
  56940. declare module BABYLON {
  56941. /**
  56942. * Interface used to configure the node material editor
  56943. */
  56944. export interface INodeMaterialEditorOptions {
  56945. /** Define the URl to load node editor script */
  56946. editorURL?: string;
  56947. }
  56948. /** @hidden */
  56949. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56950. NORMAL: boolean;
  56951. TANGENT: boolean;
  56952. UV1: boolean;
  56953. /** BONES */
  56954. NUM_BONE_INFLUENCERS: number;
  56955. BonesPerMesh: number;
  56956. BONETEXTURE: boolean;
  56957. /** MORPH TARGETS */
  56958. MORPHTARGETS: boolean;
  56959. MORPHTARGETS_NORMAL: boolean;
  56960. MORPHTARGETS_TANGENT: boolean;
  56961. MORPHTARGETS_UV: boolean;
  56962. NUM_MORPH_INFLUENCERS: number;
  56963. /** IMAGE PROCESSING */
  56964. IMAGEPROCESSING: boolean;
  56965. VIGNETTE: boolean;
  56966. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56967. VIGNETTEBLENDMODEOPAQUE: boolean;
  56968. TONEMAPPING: boolean;
  56969. TONEMAPPING_ACES: boolean;
  56970. CONTRAST: boolean;
  56971. EXPOSURE: boolean;
  56972. COLORCURVES: boolean;
  56973. COLORGRADING: boolean;
  56974. COLORGRADING3D: boolean;
  56975. SAMPLER3DGREENDEPTH: boolean;
  56976. SAMPLER3DBGRMAP: boolean;
  56977. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56978. /** MISC. */
  56979. BUMPDIRECTUV: number;
  56980. constructor();
  56981. setValue(name: string, value: boolean): void;
  56982. }
  56983. /**
  56984. * Class used to configure NodeMaterial
  56985. */
  56986. export interface INodeMaterialOptions {
  56987. /**
  56988. * Defines if blocks should emit comments
  56989. */
  56990. emitComments: boolean;
  56991. }
  56992. /**
  56993. * Class used to create a node based material built by assembling shader blocks
  56994. */
  56995. export class NodeMaterial extends PushMaterial {
  56996. private static _BuildIdGenerator;
  56997. private _options;
  56998. private _vertexCompilationState;
  56999. private _fragmentCompilationState;
  57000. private _sharedData;
  57001. private _buildId;
  57002. private _buildWasSuccessful;
  57003. private _cachedWorldViewMatrix;
  57004. private _cachedWorldViewProjectionMatrix;
  57005. private _optimizers;
  57006. private _animationFrame;
  57007. /** Define the Url to load node editor script */
  57008. static EditorURL: string;
  57009. /** Define the Url to load snippets */
  57010. static SnippetUrl: string;
  57011. private BJSNODEMATERIALEDITOR;
  57012. /** Get the inspector from bundle or global */
  57013. private _getGlobalNodeMaterialEditor;
  57014. /**
  57015. * Gets or sets data used by visual editor
  57016. * @see https://nme.babylonjs.com
  57017. */
  57018. editorData: any;
  57019. /**
  57020. * 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)
  57021. */
  57022. ignoreAlpha: boolean;
  57023. /**
  57024. * Defines the maximum number of lights that can be used in the material
  57025. */
  57026. maxSimultaneousLights: number;
  57027. /**
  57028. * Observable raised when the material is built
  57029. */
  57030. onBuildObservable: Observable<NodeMaterial>;
  57031. /**
  57032. * Gets or sets the root nodes of the material vertex shader
  57033. */
  57034. _vertexOutputNodes: NodeMaterialBlock[];
  57035. /**
  57036. * Gets or sets the root nodes of the material fragment (pixel) shader
  57037. */
  57038. _fragmentOutputNodes: NodeMaterialBlock[];
  57039. /** Gets or sets options to control the node material overall behavior */
  57040. get options(): INodeMaterialOptions;
  57041. set options(options: INodeMaterialOptions);
  57042. /**
  57043. * Default configuration related to image processing available in the standard Material.
  57044. */
  57045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57046. /**
  57047. * Gets the image processing configuration used either in this material.
  57048. */
  57049. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57050. /**
  57051. * Sets the Default image processing configuration used either in the this material.
  57052. *
  57053. * If sets to null, the scene one is in use.
  57054. */
  57055. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57056. /**
  57057. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57058. */
  57059. attachedBlocks: NodeMaterialBlock[];
  57060. /**
  57061. * Create a new node based material
  57062. * @param name defines the material name
  57063. * @param scene defines the hosting scene
  57064. * @param options defines creation option
  57065. */
  57066. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57067. /**
  57068. * Gets the current class name of the material e.g. "NodeMaterial"
  57069. * @returns the class name
  57070. */
  57071. getClassName(): string;
  57072. /**
  57073. * Keep track of the image processing observer to allow dispose and replace.
  57074. */
  57075. private _imageProcessingObserver;
  57076. /**
  57077. * Attaches a new image processing configuration to the Standard Material.
  57078. * @param configuration
  57079. */
  57080. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57081. /**
  57082. * Get a block by its name
  57083. * @param name defines the name of the block to retrieve
  57084. * @returns the required block or null if not found
  57085. */
  57086. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57087. /**
  57088. * Get a block by its name
  57089. * @param predicate defines the predicate used to find the good candidate
  57090. * @returns the required block or null if not found
  57091. */
  57092. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57093. /**
  57094. * Get an input block by its name
  57095. * @param predicate defines the predicate used to find the good candidate
  57096. * @returns the required input block or null if not found
  57097. */
  57098. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57099. /**
  57100. * Gets the list of input blocks attached to this material
  57101. * @returns an array of InputBlocks
  57102. */
  57103. getInputBlocks(): InputBlock[];
  57104. /**
  57105. * Adds a new optimizer to the list of optimizers
  57106. * @param optimizer defines the optimizers to add
  57107. * @returns the current material
  57108. */
  57109. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57110. /**
  57111. * Remove an optimizer from the list of optimizers
  57112. * @param optimizer defines the optimizers to remove
  57113. * @returns the current material
  57114. */
  57115. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57116. /**
  57117. * Add a new block to the list of output nodes
  57118. * @param node defines the node to add
  57119. * @returns the current material
  57120. */
  57121. addOutputNode(node: NodeMaterialBlock): this;
  57122. /**
  57123. * Remove a block from the list of root nodes
  57124. * @param node defines the node to remove
  57125. * @returns the current material
  57126. */
  57127. removeOutputNode(node: NodeMaterialBlock): this;
  57128. private _addVertexOutputNode;
  57129. private _removeVertexOutputNode;
  57130. private _addFragmentOutputNode;
  57131. private _removeFragmentOutputNode;
  57132. /**
  57133. * Specifies if the material will require alpha blending
  57134. * @returns a boolean specifying if alpha blending is needed
  57135. */
  57136. needAlphaBlending(): boolean;
  57137. /**
  57138. * Specifies if this material should be rendered in alpha test mode
  57139. * @returns a boolean specifying if an alpha test is needed.
  57140. */
  57141. needAlphaTesting(): boolean;
  57142. private _initializeBlock;
  57143. private _resetDualBlocks;
  57144. /**
  57145. * Remove a block from the current node material
  57146. * @param block defines the block to remove
  57147. */
  57148. removeBlock(block: NodeMaterialBlock): void;
  57149. /**
  57150. * Build the material and generates the inner effect
  57151. * @param verbose defines if the build should log activity
  57152. */
  57153. build(verbose?: boolean): void;
  57154. /**
  57155. * Runs an otpimization phase to try to improve the shader code
  57156. */
  57157. optimize(): void;
  57158. private _prepareDefinesForAttributes;
  57159. /**
  57160. * Get if the submesh is ready to be used and all its information available.
  57161. * Child classes can use it to update shaders
  57162. * @param mesh defines the mesh to check
  57163. * @param subMesh defines which submesh to check
  57164. * @param useInstances specifies that instances should be used
  57165. * @returns a boolean indicating that the submesh is ready or not
  57166. */
  57167. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57168. /**
  57169. * Get a string representing the shaders built by the current node graph
  57170. */
  57171. get compiledShaders(): string;
  57172. /**
  57173. * Binds the world matrix to the material
  57174. * @param world defines the world transformation matrix
  57175. */
  57176. bindOnlyWorldMatrix(world: Matrix): void;
  57177. /**
  57178. * Binds the submesh to this material by preparing the effect and shader to draw
  57179. * @param world defines the world transformation matrix
  57180. * @param mesh defines the mesh containing the submesh
  57181. * @param subMesh defines the submesh to bind the material to
  57182. */
  57183. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57184. /**
  57185. * Gets the active textures from the material
  57186. * @returns an array of textures
  57187. */
  57188. getActiveTextures(): BaseTexture[];
  57189. /**
  57190. * Gets the list of texture blocks
  57191. * @returns an array of texture blocks
  57192. */
  57193. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57194. /**
  57195. * Specifies if the material uses a texture
  57196. * @param texture defines the texture to check against the material
  57197. * @returns a boolean specifying if the material uses the texture
  57198. */
  57199. hasTexture(texture: BaseTexture): boolean;
  57200. /**
  57201. * Disposes the material
  57202. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57203. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57204. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57205. */
  57206. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57207. /** Creates the node editor window. */
  57208. private _createNodeEditor;
  57209. /**
  57210. * Launch the node material editor
  57211. * @param config Define the configuration of the editor
  57212. * @return a promise fulfilled when the node editor is visible
  57213. */
  57214. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57215. /**
  57216. * Clear the current material
  57217. */
  57218. clear(): void;
  57219. /**
  57220. * Clear the current material and set it to a default state
  57221. */
  57222. setToDefault(): void;
  57223. /**
  57224. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57225. * @param url defines the url to load from
  57226. * @returns a promise that will fullfil when the material is fully loaded
  57227. */
  57228. loadAsync(url: string): Promise<void>;
  57229. private _gatherBlocks;
  57230. /**
  57231. * Generate a string containing the code declaration required to create an equivalent of this material
  57232. * @returns a string
  57233. */
  57234. generateCode(): string;
  57235. /**
  57236. * Serializes this material in a JSON representation
  57237. * @returns the serialized material object
  57238. */
  57239. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57240. private _restoreConnections;
  57241. /**
  57242. * Clear the current graph and load a new one from a serialization object
  57243. * @param source defines the JSON representation of the material
  57244. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57245. */
  57246. loadFromSerialization(source: any, rootUrl?: string): void;
  57247. /**
  57248. * Creates a node material from parsed material data
  57249. * @param source defines the JSON representation of the material
  57250. * @param scene defines the hosting scene
  57251. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57252. * @returns a new node material
  57253. */
  57254. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57255. /**
  57256. * Creates a node material from a snippet saved in a remote file
  57257. * @param name defines the name of the material to create
  57258. * @param url defines the url to load from
  57259. * @param scene defines the hosting scene
  57260. * @returns a promise that will resolve to the new node material
  57261. */
  57262. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57263. /**
  57264. * Creates a node material from a snippet saved by the node material editor
  57265. * @param snippetId defines the snippet to load
  57266. * @param scene defines the hosting scene
  57267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57268. * @returns a promise that will resolve to the new node material
  57269. */
  57270. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57271. /**
  57272. * Creates a new node material set to default basic configuration
  57273. * @param name defines the name of the material
  57274. * @param scene defines the hosting scene
  57275. * @returns a new NodeMaterial
  57276. */
  57277. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57278. }
  57279. }
  57280. declare module BABYLON {
  57281. /**
  57282. * Block used to read a texture from a sampler
  57283. */
  57284. export class TextureBlock extends NodeMaterialBlock {
  57285. private _defineName;
  57286. private _linearDefineName;
  57287. private _tempTextureRead;
  57288. private _samplerName;
  57289. private _transformedUVName;
  57290. private _textureTransformName;
  57291. private _textureInfoName;
  57292. private _mainUVName;
  57293. private _mainUVDefineName;
  57294. /**
  57295. * Gets or sets the texture associated with the node
  57296. */
  57297. texture: Nullable<Texture>;
  57298. /**
  57299. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57300. */
  57301. convertToGammaSpace: boolean;
  57302. /**
  57303. * Create a new TextureBlock
  57304. * @param name defines the block name
  57305. */
  57306. constructor(name: string);
  57307. /**
  57308. * Gets the current class name
  57309. * @returns the class name
  57310. */
  57311. getClassName(): string;
  57312. /**
  57313. * Gets the uv input component
  57314. */
  57315. get uv(): NodeMaterialConnectionPoint;
  57316. /**
  57317. * Gets the rgba output component
  57318. */
  57319. get rgba(): NodeMaterialConnectionPoint;
  57320. /**
  57321. * Gets the rgb output component
  57322. */
  57323. get rgb(): NodeMaterialConnectionPoint;
  57324. /**
  57325. * Gets the r output component
  57326. */
  57327. get r(): NodeMaterialConnectionPoint;
  57328. /**
  57329. * Gets the g output component
  57330. */
  57331. get g(): NodeMaterialConnectionPoint;
  57332. /**
  57333. * Gets the b output component
  57334. */
  57335. get b(): NodeMaterialConnectionPoint;
  57336. /**
  57337. * Gets the a output component
  57338. */
  57339. get a(): NodeMaterialConnectionPoint;
  57340. get target(): NodeMaterialBlockTargets;
  57341. autoConfigure(material: NodeMaterial): void;
  57342. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57344. isReady(): boolean;
  57345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57346. private get _isMixed();
  57347. private _injectVertexCode;
  57348. private _writeTextureRead;
  57349. private _writeOutput;
  57350. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57351. protected _dumpPropertiesCode(): string;
  57352. serialize(): any;
  57353. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57354. }
  57355. }
  57356. declare module BABYLON {
  57357. /**
  57358. * Class used to store shared data between 2 NodeMaterialBuildState
  57359. */
  57360. export class NodeMaterialBuildStateSharedData {
  57361. /**
  57362. * Gets the list of emitted varyings
  57363. */
  57364. temps: string[];
  57365. /**
  57366. * Gets the list of emitted varyings
  57367. */
  57368. varyings: string[];
  57369. /**
  57370. * Gets the varying declaration string
  57371. */
  57372. varyingDeclaration: string;
  57373. /**
  57374. * Input blocks
  57375. */
  57376. inputBlocks: InputBlock[];
  57377. /**
  57378. * Input blocks
  57379. */
  57380. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57381. /**
  57382. * Bindable blocks (Blocks that need to set data to the effect)
  57383. */
  57384. bindableBlocks: NodeMaterialBlock[];
  57385. /**
  57386. * List of blocks that can provide a compilation fallback
  57387. */
  57388. blocksWithFallbacks: NodeMaterialBlock[];
  57389. /**
  57390. * List of blocks that can provide a define update
  57391. */
  57392. blocksWithDefines: NodeMaterialBlock[];
  57393. /**
  57394. * List of blocks that can provide a repeatable content
  57395. */
  57396. repeatableContentBlocks: NodeMaterialBlock[];
  57397. /**
  57398. * List of blocks that can provide a dynamic list of uniforms
  57399. */
  57400. dynamicUniformBlocks: NodeMaterialBlock[];
  57401. /**
  57402. * List of blocks that can block the isReady function for the material
  57403. */
  57404. blockingBlocks: NodeMaterialBlock[];
  57405. /**
  57406. * Gets the list of animated inputs
  57407. */
  57408. animatedInputs: InputBlock[];
  57409. /**
  57410. * Build Id used to avoid multiple recompilations
  57411. */
  57412. buildId: number;
  57413. /** List of emitted variables */
  57414. variableNames: {
  57415. [key: string]: number;
  57416. };
  57417. /** List of emitted defines */
  57418. defineNames: {
  57419. [key: string]: number;
  57420. };
  57421. /** Should emit comments? */
  57422. emitComments: boolean;
  57423. /** Emit build activity */
  57424. verbose: boolean;
  57425. /** Gets or sets the hosting scene */
  57426. scene: Scene;
  57427. /**
  57428. * Gets the compilation hints emitted at compilation time
  57429. */
  57430. hints: {
  57431. needWorldViewMatrix: boolean;
  57432. needWorldViewProjectionMatrix: boolean;
  57433. needAlphaBlending: boolean;
  57434. needAlphaTesting: boolean;
  57435. };
  57436. /**
  57437. * List of compilation checks
  57438. */
  57439. checks: {
  57440. emitVertex: boolean;
  57441. emitFragment: boolean;
  57442. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57443. };
  57444. /** Creates a new shared data */
  57445. constructor();
  57446. /**
  57447. * Emits console errors and exceptions if there is a failing check
  57448. */
  57449. emitErrors(): void;
  57450. }
  57451. }
  57452. declare module BABYLON {
  57453. /**
  57454. * Class used to store node based material build state
  57455. */
  57456. export class NodeMaterialBuildState {
  57457. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57458. supportUniformBuffers: boolean;
  57459. /**
  57460. * Gets the list of emitted attributes
  57461. */
  57462. attributes: string[];
  57463. /**
  57464. * Gets the list of emitted uniforms
  57465. */
  57466. uniforms: string[];
  57467. /**
  57468. * Gets the list of emitted constants
  57469. */
  57470. constants: string[];
  57471. /**
  57472. * Gets the list of emitted samplers
  57473. */
  57474. samplers: string[];
  57475. /**
  57476. * Gets the list of emitted functions
  57477. */
  57478. functions: {
  57479. [key: string]: string;
  57480. };
  57481. /**
  57482. * Gets the list of emitted extensions
  57483. */
  57484. extensions: {
  57485. [key: string]: string;
  57486. };
  57487. /**
  57488. * Gets the target of the compilation state
  57489. */
  57490. target: NodeMaterialBlockTargets;
  57491. /**
  57492. * Gets the list of emitted counters
  57493. */
  57494. counters: {
  57495. [key: string]: number;
  57496. };
  57497. /**
  57498. * Shared data between multiple NodeMaterialBuildState instances
  57499. */
  57500. sharedData: NodeMaterialBuildStateSharedData;
  57501. /** @hidden */
  57502. _vertexState: NodeMaterialBuildState;
  57503. /** @hidden */
  57504. _attributeDeclaration: string;
  57505. /** @hidden */
  57506. _uniformDeclaration: string;
  57507. /** @hidden */
  57508. _constantDeclaration: string;
  57509. /** @hidden */
  57510. _samplerDeclaration: string;
  57511. /** @hidden */
  57512. _varyingTransfer: string;
  57513. private _repeatableContentAnchorIndex;
  57514. /** @hidden */
  57515. _builtCompilationString: string;
  57516. /**
  57517. * Gets the emitted compilation strings
  57518. */
  57519. compilationString: string;
  57520. /**
  57521. * Finalize the compilation strings
  57522. * @param state defines the current compilation state
  57523. */
  57524. finalize(state: NodeMaterialBuildState): void;
  57525. /** @hidden */
  57526. get _repeatableContentAnchor(): string;
  57527. /** @hidden */
  57528. _getFreeVariableName(prefix: string): string;
  57529. /** @hidden */
  57530. _getFreeDefineName(prefix: string): string;
  57531. /** @hidden */
  57532. _excludeVariableName(name: string): void;
  57533. /** @hidden */
  57534. _emit2DSampler(name: string): void;
  57535. /** @hidden */
  57536. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57537. /** @hidden */
  57538. _emitExtension(name: string, extension: string): void;
  57539. /** @hidden */
  57540. _emitFunction(name: string, code: string, comments: string): void;
  57541. /** @hidden */
  57542. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57543. replaceStrings?: {
  57544. search: RegExp;
  57545. replace: string;
  57546. }[];
  57547. repeatKey?: string;
  57548. }): string;
  57549. /** @hidden */
  57550. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57551. repeatKey?: string;
  57552. removeAttributes?: boolean;
  57553. removeUniforms?: boolean;
  57554. removeVaryings?: boolean;
  57555. removeIfDef?: boolean;
  57556. replaceStrings?: {
  57557. search: RegExp;
  57558. replace: string;
  57559. }[];
  57560. }, storeKey?: string): void;
  57561. /** @hidden */
  57562. _registerTempVariable(name: string): boolean;
  57563. /** @hidden */
  57564. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57565. /** @hidden */
  57566. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57567. /** @hidden */
  57568. _emitFloat(value: number): string;
  57569. }
  57570. }
  57571. declare module BABYLON {
  57572. /**
  57573. * Defines a block that can be used inside a node based material
  57574. */
  57575. export class NodeMaterialBlock {
  57576. private _buildId;
  57577. private _buildTarget;
  57578. private _target;
  57579. private _isFinalMerger;
  57580. private _isInput;
  57581. protected _isUnique: boolean;
  57582. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57583. inputsAreExclusive: boolean;
  57584. /** @hidden */
  57585. _codeVariableName: string;
  57586. /** @hidden */
  57587. _inputs: NodeMaterialConnectionPoint[];
  57588. /** @hidden */
  57589. _outputs: NodeMaterialConnectionPoint[];
  57590. /** @hidden */
  57591. _preparationId: number;
  57592. /**
  57593. * Gets or sets the name of the block
  57594. */
  57595. name: string;
  57596. /**
  57597. * Gets or sets the unique id of the node
  57598. */
  57599. uniqueId: number;
  57600. /**
  57601. * Gets or sets the comments associated with this block
  57602. */
  57603. comments: string;
  57604. /**
  57605. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57606. */
  57607. get isUnique(): boolean;
  57608. /**
  57609. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57610. */
  57611. get isFinalMerger(): boolean;
  57612. /**
  57613. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57614. */
  57615. get isInput(): boolean;
  57616. /**
  57617. * Gets or sets the build Id
  57618. */
  57619. get buildId(): number;
  57620. set buildId(value: number);
  57621. /**
  57622. * Gets or sets the target of the block
  57623. */
  57624. get target(): NodeMaterialBlockTargets;
  57625. set target(value: NodeMaterialBlockTargets);
  57626. /**
  57627. * Gets the list of input points
  57628. */
  57629. get inputs(): NodeMaterialConnectionPoint[];
  57630. /** Gets the list of output points */
  57631. get outputs(): NodeMaterialConnectionPoint[];
  57632. /**
  57633. * Find an input by its name
  57634. * @param name defines the name of the input to look for
  57635. * @returns the input or null if not found
  57636. */
  57637. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57638. /**
  57639. * Find an output by its name
  57640. * @param name defines the name of the outputto look for
  57641. * @returns the output or null if not found
  57642. */
  57643. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57644. /**
  57645. * Creates a new NodeMaterialBlock
  57646. * @param name defines the block name
  57647. * @param target defines the target of that block (Vertex by default)
  57648. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57649. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57650. */
  57651. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57652. /**
  57653. * Initialize the block and prepare the context for build
  57654. * @param state defines the state that will be used for the build
  57655. */
  57656. initialize(state: NodeMaterialBuildState): void;
  57657. /**
  57658. * Bind data to effect. Will only be called for blocks with isBindable === true
  57659. * @param effect defines the effect to bind data to
  57660. * @param nodeMaterial defines the hosting NodeMaterial
  57661. * @param mesh defines the mesh that will be rendered
  57662. */
  57663. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57664. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57665. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57666. protected _writeFloat(value: number): string;
  57667. /**
  57668. * Gets the current class name e.g. "NodeMaterialBlock"
  57669. * @returns the class name
  57670. */
  57671. getClassName(): string;
  57672. /**
  57673. * Register a new input. Must be called inside a block constructor
  57674. * @param name defines the connection point name
  57675. * @param type defines the connection point type
  57676. * @param isOptional defines a boolean indicating that this input can be omitted
  57677. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57678. * @returns the current block
  57679. */
  57680. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57681. /**
  57682. * Register a new output. Must be called inside a block constructor
  57683. * @param name defines the connection point name
  57684. * @param type defines the connection point type
  57685. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57686. * @returns the current block
  57687. */
  57688. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57689. /**
  57690. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57691. * @param forOutput defines an optional connection point to check compatibility with
  57692. * @returns the first available input or null
  57693. */
  57694. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57695. /**
  57696. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57697. * @param forBlock defines an optional block to check compatibility with
  57698. * @returns the first available input or null
  57699. */
  57700. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57701. /**
  57702. * Gets the sibling of the given output
  57703. * @param current defines the current output
  57704. * @returns the next output in the list or null
  57705. */
  57706. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57707. /**
  57708. * Connect current block with another block
  57709. * @param other defines the block to connect with
  57710. * @param options define the various options to help pick the right connections
  57711. * @returns the current block
  57712. */
  57713. connectTo(other: NodeMaterialBlock, options?: {
  57714. input?: string;
  57715. output?: string;
  57716. outputSwizzle?: string;
  57717. }): this | undefined;
  57718. protected _buildBlock(state: NodeMaterialBuildState): void;
  57719. /**
  57720. * Add uniforms, samplers and uniform buffers at compilation time
  57721. * @param state defines the state to update
  57722. * @param nodeMaterial defines the node material requesting the update
  57723. * @param defines defines the material defines to update
  57724. * @param uniformBuffers defines the list of uniform buffer names
  57725. */
  57726. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57727. /**
  57728. * Add potential fallbacks if shader compilation fails
  57729. * @param mesh defines the mesh to be rendered
  57730. * @param fallbacks defines the current prioritized list of fallbacks
  57731. */
  57732. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57733. /**
  57734. * Initialize defines for shader compilation
  57735. * @param mesh defines the mesh to be rendered
  57736. * @param nodeMaterial defines the node material requesting the update
  57737. * @param defines defines the material defines to update
  57738. * @param useInstances specifies that instances should be used
  57739. */
  57740. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57741. /**
  57742. * Update defines for shader compilation
  57743. * @param mesh defines the mesh to be rendered
  57744. * @param nodeMaterial defines the node material requesting the update
  57745. * @param defines defines the material defines to update
  57746. * @param useInstances specifies that instances should be used
  57747. */
  57748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57749. /**
  57750. * Lets the block try to connect some inputs automatically
  57751. * @param material defines the hosting NodeMaterial
  57752. */
  57753. autoConfigure(material: NodeMaterial): void;
  57754. /**
  57755. * Function called when a block is declared as repeatable content generator
  57756. * @param vertexShaderState defines the current compilation state for the vertex shader
  57757. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57758. * @param mesh defines the mesh to be rendered
  57759. * @param defines defines the material defines to update
  57760. */
  57761. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57762. /**
  57763. * Checks if the block is ready
  57764. * @param mesh defines the mesh to be rendered
  57765. * @param nodeMaterial defines the node material requesting the update
  57766. * @param defines defines the material defines to update
  57767. * @param useInstances specifies that instances should be used
  57768. * @returns true if the block is ready
  57769. */
  57770. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57771. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57772. private _processBuild;
  57773. /**
  57774. * Compile the current node and generate the shader code
  57775. * @param state defines the current compilation state (uniforms, samplers, current string)
  57776. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57777. * @returns true if already built
  57778. */
  57779. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57780. protected _inputRename(name: string): string;
  57781. protected _outputRename(name: string): string;
  57782. protected _dumpPropertiesCode(): string;
  57783. /** @hidden */
  57784. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57785. /** @hidden */
  57786. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57787. /**
  57788. * Clone the current block to a new identical block
  57789. * @param scene defines the hosting scene
  57790. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57791. * @returns a copy of the current block
  57792. */
  57793. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57794. /**
  57795. * Serializes this block in a JSON representation
  57796. * @returns the serialized block object
  57797. */
  57798. serialize(): any;
  57799. /** @hidden */
  57800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57801. /**
  57802. * Release resources
  57803. */
  57804. dispose(): void;
  57805. }
  57806. }
  57807. declare module BABYLON {
  57808. /**
  57809. * Enum defining the type of animations supported by InputBlock
  57810. */
  57811. export enum AnimatedInputBlockTypes {
  57812. /** No animation */
  57813. None = 0,
  57814. /** Time based animation. Will only work for floats */
  57815. Time = 1
  57816. }
  57817. }
  57818. declare module BABYLON {
  57819. /**
  57820. * Block used to expose an input value
  57821. */
  57822. export class InputBlock extends NodeMaterialBlock {
  57823. private _mode;
  57824. private _associatedVariableName;
  57825. private _storedValue;
  57826. private _valueCallback;
  57827. private _type;
  57828. private _animationType;
  57829. /** Gets or set a value used to limit the range of float values */
  57830. min: number;
  57831. /** Gets or set a value used to limit the range of float values */
  57832. max: number;
  57833. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57834. isBoolean: boolean;
  57835. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57836. matrixMode: number;
  57837. /** @hidden */
  57838. _systemValue: Nullable<NodeMaterialSystemValues>;
  57839. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57840. visibleInInspector: boolean;
  57841. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57842. isConstant: boolean;
  57843. /** Gets or sets the group to use to display this block in the Inspector */
  57844. groupInInspector: string;
  57845. /** Gets an observable raised when the value is changed */
  57846. onValueChangedObservable: Observable<InputBlock>;
  57847. /**
  57848. * Gets or sets the connection point type (default is float)
  57849. */
  57850. get type(): NodeMaterialBlockConnectionPointTypes;
  57851. /**
  57852. * Creates a new InputBlock
  57853. * @param name defines the block name
  57854. * @param target defines the target of that block (Vertex by default)
  57855. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57856. */
  57857. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57858. /**
  57859. * Gets the output component
  57860. */
  57861. get output(): NodeMaterialConnectionPoint;
  57862. /**
  57863. * Set the source of this connection point to a vertex attribute
  57864. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57865. * @returns the current connection point
  57866. */
  57867. setAsAttribute(attributeName?: string): InputBlock;
  57868. /**
  57869. * Set the source of this connection point to a system value
  57870. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57871. * @returns the current connection point
  57872. */
  57873. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57874. /**
  57875. * Gets or sets the value of that point.
  57876. * Please note that this value will be ignored if valueCallback is defined
  57877. */
  57878. get value(): any;
  57879. set value(value: any);
  57880. /**
  57881. * Gets or sets a callback used to get the value of that point.
  57882. * Please note that setting this value will force the connection point to ignore the value property
  57883. */
  57884. get valueCallback(): () => any;
  57885. set valueCallback(value: () => any);
  57886. /**
  57887. * Gets or sets the associated variable name in the shader
  57888. */
  57889. get associatedVariableName(): string;
  57890. set associatedVariableName(value: string);
  57891. /** Gets or sets the type of animation applied to the input */
  57892. get animationType(): AnimatedInputBlockTypes;
  57893. set animationType(value: AnimatedInputBlockTypes);
  57894. /**
  57895. * Gets a boolean indicating that this connection point not defined yet
  57896. */
  57897. get isUndefined(): boolean;
  57898. /**
  57899. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57900. * In this case the connection point name must be the name of the uniform to use.
  57901. * Can only be set on inputs
  57902. */
  57903. get isUniform(): boolean;
  57904. set isUniform(value: boolean);
  57905. /**
  57906. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57907. * In this case the connection point name must be the name of the attribute to use
  57908. * Can only be set on inputs
  57909. */
  57910. get isAttribute(): boolean;
  57911. set isAttribute(value: boolean);
  57912. /**
  57913. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57914. * Can only be set on exit points
  57915. */
  57916. get isVarying(): boolean;
  57917. set isVarying(value: boolean);
  57918. /**
  57919. * Gets a boolean indicating that the current connection point is a system value
  57920. */
  57921. get isSystemValue(): boolean;
  57922. /**
  57923. * Gets or sets the current well known value or null if not defined as a system value
  57924. */
  57925. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57926. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57927. /**
  57928. * Gets the current class name
  57929. * @returns the class name
  57930. */
  57931. getClassName(): string;
  57932. /**
  57933. * Animate the input if animationType !== None
  57934. * @param scene defines the rendering scene
  57935. */
  57936. animate(scene: Scene): void;
  57937. private _emitDefine;
  57938. initialize(state: NodeMaterialBuildState): void;
  57939. /**
  57940. * Set the input block to its default value (based on its type)
  57941. */
  57942. setDefaultValue(): void;
  57943. private _emitConstant;
  57944. private _emit;
  57945. /** @hidden */
  57946. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57947. /** @hidden */
  57948. _transmit(effect: Effect, scene: Scene): void;
  57949. protected _buildBlock(state: NodeMaterialBuildState): void;
  57950. protected _dumpPropertiesCode(): string;
  57951. dispose(): void;
  57952. serialize(): any;
  57953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57954. }
  57955. }
  57956. declare module BABYLON {
  57957. /**
  57958. * Enum used to define the compatibility state between two connection points
  57959. */
  57960. export enum NodeMaterialConnectionPointCompatibilityStates {
  57961. /** Points are compatibles */
  57962. Compatible = 0,
  57963. /** Points are incompatible because of their types */
  57964. TypeIncompatible = 1,
  57965. /** Points are incompatible because of their targets (vertex vs fragment) */
  57966. TargetIncompatible = 2
  57967. }
  57968. /**
  57969. * Defines the direction of a connection point
  57970. */
  57971. export enum NodeMaterialConnectionPointDirection {
  57972. /** Input */
  57973. Input = 0,
  57974. /** Output */
  57975. Output = 1
  57976. }
  57977. /**
  57978. * Defines a connection point for a block
  57979. */
  57980. export class NodeMaterialConnectionPoint {
  57981. /** @hidden */
  57982. _ownerBlock: NodeMaterialBlock;
  57983. /** @hidden */
  57984. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57985. private _endpoints;
  57986. private _associatedVariableName;
  57987. private _direction;
  57988. /** @hidden */
  57989. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57990. /** @hidden */
  57991. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57992. private _type;
  57993. /** @hidden */
  57994. _enforceAssociatedVariableName: boolean;
  57995. /** Gets the direction of the point */
  57996. get direction(): NodeMaterialConnectionPointDirection;
  57997. /**
  57998. * Gets or sets the additional types supported by this connection point
  57999. */
  58000. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58001. /**
  58002. * Gets or sets the additional types excluded by this connection point
  58003. */
  58004. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58005. /**
  58006. * Observable triggered when this point is connected
  58007. */
  58008. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58009. /**
  58010. * Gets or sets the associated variable name in the shader
  58011. */
  58012. get associatedVariableName(): string;
  58013. set associatedVariableName(value: string);
  58014. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58015. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58016. /**
  58017. * Gets or sets the connection point type (default is float)
  58018. */
  58019. get type(): NodeMaterialBlockConnectionPointTypes;
  58020. set type(value: NodeMaterialBlockConnectionPointTypes);
  58021. /**
  58022. * Gets or sets the connection point name
  58023. */
  58024. name: string;
  58025. /**
  58026. * Gets or sets a boolean indicating that this connection point can be omitted
  58027. */
  58028. isOptional: boolean;
  58029. /**
  58030. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58031. */
  58032. define: string;
  58033. /** @hidden */
  58034. _prioritizeVertex: boolean;
  58035. private _target;
  58036. /** Gets or sets the target of that connection point */
  58037. get target(): NodeMaterialBlockTargets;
  58038. set target(value: NodeMaterialBlockTargets);
  58039. /**
  58040. * Gets a boolean indicating that the current point is connected
  58041. */
  58042. get isConnected(): boolean;
  58043. /**
  58044. * Gets a boolean indicating that the current point is connected to an input block
  58045. */
  58046. get isConnectedToInputBlock(): boolean;
  58047. /**
  58048. * Gets a the connected input block (if any)
  58049. */
  58050. get connectInputBlock(): Nullable<InputBlock>;
  58051. /** Get the other side of the connection (if any) */
  58052. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58053. /** Get the block that owns this connection point */
  58054. get ownerBlock(): NodeMaterialBlock;
  58055. /** Get the block connected on the other side of this connection (if any) */
  58056. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58057. /** Get the block connected on the endpoints of this connection (if any) */
  58058. get connectedBlocks(): Array<NodeMaterialBlock>;
  58059. /** Gets the list of connected endpoints */
  58060. get endpoints(): NodeMaterialConnectionPoint[];
  58061. /** Gets a boolean indicating if that output point is connected to at least one input */
  58062. get hasEndpoints(): boolean;
  58063. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58064. get isConnectedInVertexShader(): boolean;
  58065. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58066. get isConnectedInFragmentShader(): boolean;
  58067. /**
  58068. * Creates a new connection point
  58069. * @param name defines the connection point name
  58070. * @param ownerBlock defines the block hosting this connection point
  58071. * @param direction defines the direction of the connection point
  58072. */
  58073. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58074. /**
  58075. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58076. * @returns the class name
  58077. */
  58078. getClassName(): string;
  58079. /**
  58080. * Gets a boolean indicating if the current point can be connected to another point
  58081. * @param connectionPoint defines the other connection point
  58082. * @returns a boolean
  58083. */
  58084. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58085. /**
  58086. * Gets a number indicating if the current point can be connected to another point
  58087. * @param connectionPoint defines the other connection point
  58088. * @returns a number defining the compatibility state
  58089. */
  58090. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58091. /**
  58092. * Connect this point to another connection point
  58093. * @param connectionPoint defines the other connection point
  58094. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58095. * @returns the current connection point
  58096. */
  58097. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58098. /**
  58099. * Disconnect this point from one of his endpoint
  58100. * @param endpoint defines the other connection point
  58101. * @returns the current connection point
  58102. */
  58103. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58104. /**
  58105. * Serializes this point in a JSON representation
  58106. * @returns the serialized point object
  58107. */
  58108. serialize(): any;
  58109. /**
  58110. * Release resources
  58111. */
  58112. dispose(): void;
  58113. }
  58114. }
  58115. declare module BABYLON {
  58116. /**
  58117. * Block used to add support for vertex skinning (bones)
  58118. */
  58119. export class BonesBlock extends NodeMaterialBlock {
  58120. /**
  58121. * Creates a new BonesBlock
  58122. * @param name defines the block name
  58123. */
  58124. constructor(name: string);
  58125. /**
  58126. * Initialize the block and prepare the context for build
  58127. * @param state defines the state that will be used for the build
  58128. */
  58129. initialize(state: NodeMaterialBuildState): void;
  58130. /**
  58131. * Gets the current class name
  58132. * @returns the class name
  58133. */
  58134. getClassName(): string;
  58135. /**
  58136. * Gets the matrix indices input component
  58137. */
  58138. get matricesIndices(): NodeMaterialConnectionPoint;
  58139. /**
  58140. * Gets the matrix weights input component
  58141. */
  58142. get matricesWeights(): NodeMaterialConnectionPoint;
  58143. /**
  58144. * Gets the extra matrix indices input component
  58145. */
  58146. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58147. /**
  58148. * Gets the extra matrix weights input component
  58149. */
  58150. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58151. /**
  58152. * Gets the world input component
  58153. */
  58154. get world(): NodeMaterialConnectionPoint;
  58155. /**
  58156. * Gets the output component
  58157. */
  58158. get output(): NodeMaterialConnectionPoint;
  58159. autoConfigure(material: NodeMaterial): void;
  58160. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58161. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58163. protected _buildBlock(state: NodeMaterialBuildState): this;
  58164. }
  58165. }
  58166. declare module BABYLON {
  58167. /**
  58168. * Block used to add support for instances
  58169. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58170. */
  58171. export class InstancesBlock extends NodeMaterialBlock {
  58172. /**
  58173. * Creates a new InstancesBlock
  58174. * @param name defines the block name
  58175. */
  58176. constructor(name: string);
  58177. /**
  58178. * Gets the current class name
  58179. * @returns the class name
  58180. */
  58181. getClassName(): string;
  58182. /**
  58183. * Gets the first world row input component
  58184. */
  58185. get world0(): NodeMaterialConnectionPoint;
  58186. /**
  58187. * Gets the second world row input component
  58188. */
  58189. get world1(): NodeMaterialConnectionPoint;
  58190. /**
  58191. * Gets the third world row input component
  58192. */
  58193. get world2(): NodeMaterialConnectionPoint;
  58194. /**
  58195. * Gets the forth world row input component
  58196. */
  58197. get world3(): NodeMaterialConnectionPoint;
  58198. /**
  58199. * Gets the world input component
  58200. */
  58201. get world(): NodeMaterialConnectionPoint;
  58202. /**
  58203. * Gets the output component
  58204. */
  58205. get output(): NodeMaterialConnectionPoint;
  58206. /**
  58207. * Gets the isntanceID component
  58208. */
  58209. get instanceID(): NodeMaterialConnectionPoint;
  58210. autoConfigure(material: NodeMaterial): void;
  58211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58212. protected _buildBlock(state: NodeMaterialBuildState): this;
  58213. }
  58214. }
  58215. declare module BABYLON {
  58216. /**
  58217. * Block used to add morph targets support to vertex shader
  58218. */
  58219. export class MorphTargetsBlock extends NodeMaterialBlock {
  58220. private _repeatableContentAnchor;
  58221. /**
  58222. * Create a new MorphTargetsBlock
  58223. * @param name defines the block name
  58224. */
  58225. constructor(name: string);
  58226. /**
  58227. * Gets the current class name
  58228. * @returns the class name
  58229. */
  58230. getClassName(): string;
  58231. /**
  58232. * Gets the position input component
  58233. */
  58234. get position(): NodeMaterialConnectionPoint;
  58235. /**
  58236. * Gets the normal input component
  58237. */
  58238. get normal(): NodeMaterialConnectionPoint;
  58239. /**
  58240. * Gets the tangent input component
  58241. */
  58242. get tangent(): NodeMaterialConnectionPoint;
  58243. /**
  58244. * Gets the tangent input component
  58245. */
  58246. get uv(): NodeMaterialConnectionPoint;
  58247. /**
  58248. * Gets the position output component
  58249. */
  58250. get positionOutput(): NodeMaterialConnectionPoint;
  58251. /**
  58252. * Gets the normal output component
  58253. */
  58254. get normalOutput(): NodeMaterialConnectionPoint;
  58255. /**
  58256. * Gets the tangent output component
  58257. */
  58258. get tangentOutput(): NodeMaterialConnectionPoint;
  58259. /**
  58260. * Gets the tangent output component
  58261. */
  58262. get uvOutput(): NodeMaterialConnectionPoint;
  58263. initialize(state: NodeMaterialBuildState): void;
  58264. autoConfigure(material: NodeMaterial): void;
  58265. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58266. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58267. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58268. protected _buildBlock(state: NodeMaterialBuildState): this;
  58269. }
  58270. }
  58271. declare module BABYLON {
  58272. /**
  58273. * Block used to get data information from a light
  58274. */
  58275. export class LightInformationBlock extends NodeMaterialBlock {
  58276. private _lightDataUniformName;
  58277. private _lightColorUniformName;
  58278. private _lightTypeDefineName;
  58279. /**
  58280. * Gets or sets the light associated with this block
  58281. */
  58282. light: Nullable<Light>;
  58283. /**
  58284. * Creates a new LightInformationBlock
  58285. * @param name defines the block name
  58286. */
  58287. constructor(name: string);
  58288. /**
  58289. * Gets the current class name
  58290. * @returns the class name
  58291. */
  58292. getClassName(): string;
  58293. /**
  58294. * Gets the world position input component
  58295. */
  58296. get worldPosition(): NodeMaterialConnectionPoint;
  58297. /**
  58298. * Gets the direction output component
  58299. */
  58300. get direction(): NodeMaterialConnectionPoint;
  58301. /**
  58302. * Gets the direction output component
  58303. */
  58304. get color(): NodeMaterialConnectionPoint;
  58305. /**
  58306. * Gets the direction output component
  58307. */
  58308. get intensity(): NodeMaterialConnectionPoint;
  58309. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58310. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58311. protected _buildBlock(state: NodeMaterialBuildState): this;
  58312. serialize(): any;
  58313. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58314. }
  58315. }
  58316. declare module BABYLON {
  58317. /**
  58318. * Block used to add image processing support to fragment shader
  58319. */
  58320. export class ImageProcessingBlock extends NodeMaterialBlock {
  58321. /**
  58322. * Create a new ImageProcessingBlock
  58323. * @param name defines the block name
  58324. */
  58325. constructor(name: string);
  58326. /**
  58327. * Gets the current class name
  58328. * @returns the class name
  58329. */
  58330. getClassName(): string;
  58331. /**
  58332. * Gets the color input component
  58333. */
  58334. get color(): NodeMaterialConnectionPoint;
  58335. /**
  58336. * Gets the output component
  58337. */
  58338. get output(): NodeMaterialConnectionPoint;
  58339. /**
  58340. * Initialize the block and prepare the context for build
  58341. * @param state defines the state that will be used for the build
  58342. */
  58343. initialize(state: NodeMaterialBuildState): void;
  58344. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58346. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58347. protected _buildBlock(state: NodeMaterialBuildState): this;
  58348. }
  58349. }
  58350. declare module BABYLON {
  58351. /**
  58352. * Block used to pertub normals based on a normal map
  58353. */
  58354. export class PerturbNormalBlock extends NodeMaterialBlock {
  58355. private _tangentSpaceParameterName;
  58356. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58357. invertX: boolean;
  58358. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58359. invertY: boolean;
  58360. /**
  58361. * Create a new PerturbNormalBlock
  58362. * @param name defines the block name
  58363. */
  58364. constructor(name: string);
  58365. /**
  58366. * Gets the current class name
  58367. * @returns the class name
  58368. */
  58369. getClassName(): string;
  58370. /**
  58371. * Gets the world position input component
  58372. */
  58373. get worldPosition(): NodeMaterialConnectionPoint;
  58374. /**
  58375. * Gets the world normal input component
  58376. */
  58377. get worldNormal(): NodeMaterialConnectionPoint;
  58378. /**
  58379. * Gets the world tangent input component
  58380. */
  58381. get worldTangent(): NodeMaterialConnectionPoint;
  58382. /**
  58383. * Gets the uv input component
  58384. */
  58385. get uv(): NodeMaterialConnectionPoint;
  58386. /**
  58387. * Gets the normal map color input component
  58388. */
  58389. get normalMapColor(): NodeMaterialConnectionPoint;
  58390. /**
  58391. * Gets the strength input component
  58392. */
  58393. get strength(): NodeMaterialConnectionPoint;
  58394. /**
  58395. * Gets the output component
  58396. */
  58397. get output(): NodeMaterialConnectionPoint;
  58398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58399. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58400. autoConfigure(material: NodeMaterial): void;
  58401. protected _buildBlock(state: NodeMaterialBuildState): this;
  58402. protected _dumpPropertiesCode(): string;
  58403. serialize(): any;
  58404. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58405. }
  58406. }
  58407. declare module BABYLON {
  58408. /**
  58409. * Block used to discard a pixel if a value is smaller than a cutoff
  58410. */
  58411. export class DiscardBlock extends NodeMaterialBlock {
  58412. /**
  58413. * Create a new DiscardBlock
  58414. * @param name defines the block name
  58415. */
  58416. constructor(name: string);
  58417. /**
  58418. * Gets the current class name
  58419. * @returns the class name
  58420. */
  58421. getClassName(): string;
  58422. /**
  58423. * Gets the color input component
  58424. */
  58425. get value(): NodeMaterialConnectionPoint;
  58426. /**
  58427. * Gets the cutoff input component
  58428. */
  58429. get cutoff(): NodeMaterialConnectionPoint;
  58430. protected _buildBlock(state: NodeMaterialBuildState): this;
  58431. }
  58432. }
  58433. declare module BABYLON {
  58434. /**
  58435. * Block used to test if the fragment shader is front facing
  58436. */
  58437. export class FrontFacingBlock extends NodeMaterialBlock {
  58438. /**
  58439. * Creates a new FrontFacingBlock
  58440. * @param name defines the block name
  58441. */
  58442. constructor(name: string);
  58443. /**
  58444. * Gets the current class name
  58445. * @returns the class name
  58446. */
  58447. getClassName(): string;
  58448. /**
  58449. * Gets the output component
  58450. */
  58451. get output(): NodeMaterialConnectionPoint;
  58452. protected _buildBlock(state: NodeMaterialBuildState): this;
  58453. }
  58454. }
  58455. declare module BABYLON {
  58456. /**
  58457. * Block used to get the derivative value on x and y of a given input
  58458. */
  58459. export class DerivativeBlock extends NodeMaterialBlock {
  58460. /**
  58461. * Create a new DerivativeBlock
  58462. * @param name defines the block name
  58463. */
  58464. constructor(name: string);
  58465. /**
  58466. * Gets the current class name
  58467. * @returns the class name
  58468. */
  58469. getClassName(): string;
  58470. /**
  58471. * Gets the input component
  58472. */
  58473. get input(): NodeMaterialConnectionPoint;
  58474. /**
  58475. * Gets the derivative output on x
  58476. */
  58477. get dx(): NodeMaterialConnectionPoint;
  58478. /**
  58479. * Gets the derivative output on y
  58480. */
  58481. get dy(): NodeMaterialConnectionPoint;
  58482. protected _buildBlock(state: NodeMaterialBuildState): this;
  58483. }
  58484. }
  58485. declare module BABYLON {
  58486. /**
  58487. * Block used to add support for scene fog
  58488. */
  58489. export class FogBlock extends NodeMaterialBlock {
  58490. private _fogDistanceName;
  58491. private _fogParameters;
  58492. /**
  58493. * Create a new FogBlock
  58494. * @param name defines the block name
  58495. */
  58496. constructor(name: string);
  58497. /**
  58498. * Gets the current class name
  58499. * @returns the class name
  58500. */
  58501. getClassName(): string;
  58502. /**
  58503. * Gets the world position input component
  58504. */
  58505. get worldPosition(): NodeMaterialConnectionPoint;
  58506. /**
  58507. * Gets the view input component
  58508. */
  58509. get view(): NodeMaterialConnectionPoint;
  58510. /**
  58511. * Gets the color input component
  58512. */
  58513. get input(): NodeMaterialConnectionPoint;
  58514. /**
  58515. * Gets the fog color input component
  58516. */
  58517. get fogColor(): NodeMaterialConnectionPoint;
  58518. /**
  58519. * Gets the output component
  58520. */
  58521. get output(): NodeMaterialConnectionPoint;
  58522. autoConfigure(material: NodeMaterial): void;
  58523. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58524. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58525. protected _buildBlock(state: NodeMaterialBuildState): this;
  58526. }
  58527. }
  58528. declare module BABYLON {
  58529. /**
  58530. * Block used to add light in the fragment shader
  58531. */
  58532. export class LightBlock extends NodeMaterialBlock {
  58533. private _lightId;
  58534. /**
  58535. * Gets or sets the light associated with this block
  58536. */
  58537. light: Nullable<Light>;
  58538. /**
  58539. * Create a new LightBlock
  58540. * @param name defines the block name
  58541. */
  58542. constructor(name: string);
  58543. /**
  58544. * Gets the current class name
  58545. * @returns the class name
  58546. */
  58547. getClassName(): string;
  58548. /**
  58549. * Gets the world position input component
  58550. */
  58551. get worldPosition(): NodeMaterialConnectionPoint;
  58552. /**
  58553. * Gets the world normal input component
  58554. */
  58555. get worldNormal(): NodeMaterialConnectionPoint;
  58556. /**
  58557. * Gets the camera (or eye) position component
  58558. */
  58559. get cameraPosition(): NodeMaterialConnectionPoint;
  58560. /**
  58561. * Gets the glossiness component
  58562. */
  58563. get glossiness(): NodeMaterialConnectionPoint;
  58564. /**
  58565. * Gets the glossinness power component
  58566. */
  58567. get glossPower(): NodeMaterialConnectionPoint;
  58568. /**
  58569. * Gets the diffuse color component
  58570. */
  58571. get diffuseColor(): NodeMaterialConnectionPoint;
  58572. /**
  58573. * Gets the specular color component
  58574. */
  58575. get specularColor(): NodeMaterialConnectionPoint;
  58576. /**
  58577. * Gets the diffuse output component
  58578. */
  58579. get diffuseOutput(): NodeMaterialConnectionPoint;
  58580. /**
  58581. * Gets the specular output component
  58582. */
  58583. get specularOutput(): NodeMaterialConnectionPoint;
  58584. /**
  58585. * Gets the shadow output component
  58586. */
  58587. get shadow(): NodeMaterialConnectionPoint;
  58588. autoConfigure(material: NodeMaterial): void;
  58589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58590. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58591. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58592. private _injectVertexCode;
  58593. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58594. serialize(): any;
  58595. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58596. }
  58597. }
  58598. declare module BABYLON {
  58599. /**
  58600. * Block used to multiply 2 values
  58601. */
  58602. export class MultiplyBlock extends NodeMaterialBlock {
  58603. /**
  58604. * Creates a new MultiplyBlock
  58605. * @param name defines the block name
  58606. */
  58607. constructor(name: string);
  58608. /**
  58609. * Gets the current class name
  58610. * @returns the class name
  58611. */
  58612. getClassName(): string;
  58613. /**
  58614. * Gets the left operand input component
  58615. */
  58616. get left(): NodeMaterialConnectionPoint;
  58617. /**
  58618. * Gets the right operand input component
  58619. */
  58620. get right(): NodeMaterialConnectionPoint;
  58621. /**
  58622. * Gets the output component
  58623. */
  58624. get output(): NodeMaterialConnectionPoint;
  58625. protected _buildBlock(state: NodeMaterialBuildState): this;
  58626. }
  58627. }
  58628. declare module BABYLON {
  58629. /**
  58630. * Block used to add 2 vectors
  58631. */
  58632. export class AddBlock extends NodeMaterialBlock {
  58633. /**
  58634. * Creates a new AddBlock
  58635. * @param name defines the block name
  58636. */
  58637. constructor(name: string);
  58638. /**
  58639. * Gets the current class name
  58640. * @returns the class name
  58641. */
  58642. getClassName(): string;
  58643. /**
  58644. * Gets the left operand input component
  58645. */
  58646. get left(): NodeMaterialConnectionPoint;
  58647. /**
  58648. * Gets the right operand input component
  58649. */
  58650. get right(): NodeMaterialConnectionPoint;
  58651. /**
  58652. * Gets the output component
  58653. */
  58654. get output(): NodeMaterialConnectionPoint;
  58655. protected _buildBlock(state: NodeMaterialBuildState): this;
  58656. }
  58657. }
  58658. declare module BABYLON {
  58659. /**
  58660. * Block used to scale a vector by a float
  58661. */
  58662. export class ScaleBlock extends NodeMaterialBlock {
  58663. /**
  58664. * Creates a new ScaleBlock
  58665. * @param name defines the block name
  58666. */
  58667. constructor(name: string);
  58668. /**
  58669. * Gets the current class name
  58670. * @returns the class name
  58671. */
  58672. getClassName(): string;
  58673. /**
  58674. * Gets the input component
  58675. */
  58676. get input(): NodeMaterialConnectionPoint;
  58677. /**
  58678. * Gets the factor input component
  58679. */
  58680. get factor(): NodeMaterialConnectionPoint;
  58681. /**
  58682. * Gets the output component
  58683. */
  58684. get output(): NodeMaterialConnectionPoint;
  58685. protected _buildBlock(state: NodeMaterialBuildState): this;
  58686. }
  58687. }
  58688. declare module BABYLON {
  58689. /**
  58690. * Block used to clamp a float
  58691. */
  58692. export class ClampBlock extends NodeMaterialBlock {
  58693. /** Gets or sets the minimum range */
  58694. minimum: number;
  58695. /** Gets or sets the maximum range */
  58696. maximum: number;
  58697. /**
  58698. * Creates a new ClampBlock
  58699. * @param name defines the block name
  58700. */
  58701. constructor(name: string);
  58702. /**
  58703. * Gets the current class name
  58704. * @returns the class name
  58705. */
  58706. getClassName(): string;
  58707. /**
  58708. * Gets the value input component
  58709. */
  58710. get value(): NodeMaterialConnectionPoint;
  58711. /**
  58712. * Gets the output component
  58713. */
  58714. get output(): NodeMaterialConnectionPoint;
  58715. protected _buildBlock(state: NodeMaterialBuildState): this;
  58716. protected _dumpPropertiesCode(): string;
  58717. serialize(): any;
  58718. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58719. }
  58720. }
  58721. declare module BABYLON {
  58722. /**
  58723. * Block used to apply a cross product between 2 vectors
  58724. */
  58725. export class CrossBlock extends NodeMaterialBlock {
  58726. /**
  58727. * Creates a new CrossBlock
  58728. * @param name defines the block name
  58729. */
  58730. constructor(name: string);
  58731. /**
  58732. * Gets the current class name
  58733. * @returns the class name
  58734. */
  58735. getClassName(): string;
  58736. /**
  58737. * Gets the left operand input component
  58738. */
  58739. get left(): NodeMaterialConnectionPoint;
  58740. /**
  58741. * Gets the right operand input component
  58742. */
  58743. get right(): NodeMaterialConnectionPoint;
  58744. /**
  58745. * Gets the output component
  58746. */
  58747. get output(): NodeMaterialConnectionPoint;
  58748. protected _buildBlock(state: NodeMaterialBuildState): this;
  58749. }
  58750. }
  58751. declare module BABYLON {
  58752. /**
  58753. * Block used to apply a dot product between 2 vectors
  58754. */
  58755. export class DotBlock extends NodeMaterialBlock {
  58756. /**
  58757. * Creates a new DotBlock
  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 left operand input component
  58768. */
  58769. get left(): NodeMaterialConnectionPoint;
  58770. /**
  58771. * Gets the right operand input component
  58772. */
  58773. get right(): NodeMaterialConnectionPoint;
  58774. /**
  58775. * Gets the output component
  58776. */
  58777. get output(): NodeMaterialConnectionPoint;
  58778. protected _buildBlock(state: NodeMaterialBuildState): this;
  58779. }
  58780. }
  58781. declare module BABYLON {
  58782. /**
  58783. * Block used to remap a float from a range to a new one
  58784. */
  58785. export class RemapBlock extends NodeMaterialBlock {
  58786. /**
  58787. * Gets or sets the source range
  58788. */
  58789. sourceRange: Vector2;
  58790. /**
  58791. * Gets or sets the target range
  58792. */
  58793. targetRange: Vector2;
  58794. /**
  58795. * Creates a new RemapBlock
  58796. * @param name defines the block name
  58797. */
  58798. constructor(name: string);
  58799. /**
  58800. * Gets the current class name
  58801. * @returns the class name
  58802. */
  58803. getClassName(): string;
  58804. /**
  58805. * Gets the input component
  58806. */
  58807. get input(): NodeMaterialConnectionPoint;
  58808. /**
  58809. * Gets the source min input component
  58810. */
  58811. get sourceMin(): NodeMaterialConnectionPoint;
  58812. /**
  58813. * Gets the source max input component
  58814. */
  58815. get sourceMax(): NodeMaterialConnectionPoint;
  58816. /**
  58817. * Gets the target min input component
  58818. */
  58819. get targetMin(): NodeMaterialConnectionPoint;
  58820. /**
  58821. * Gets the target max input component
  58822. */
  58823. get targetMax(): NodeMaterialConnectionPoint;
  58824. /**
  58825. * Gets the output component
  58826. */
  58827. get output(): NodeMaterialConnectionPoint;
  58828. protected _buildBlock(state: NodeMaterialBuildState): this;
  58829. protected _dumpPropertiesCode(): string;
  58830. serialize(): any;
  58831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58832. }
  58833. }
  58834. declare module BABYLON {
  58835. /**
  58836. * Block used to normalize a vector
  58837. */
  58838. export class NormalizeBlock extends NodeMaterialBlock {
  58839. /**
  58840. * Creates a new NormalizeBlock
  58841. * @param name defines the block name
  58842. */
  58843. constructor(name: string);
  58844. /**
  58845. * Gets the current class name
  58846. * @returns the class name
  58847. */
  58848. getClassName(): string;
  58849. /**
  58850. * Gets the input component
  58851. */
  58852. get input(): NodeMaterialConnectionPoint;
  58853. /**
  58854. * Gets the output component
  58855. */
  58856. get output(): NodeMaterialConnectionPoint;
  58857. protected _buildBlock(state: NodeMaterialBuildState): this;
  58858. }
  58859. }
  58860. declare module BABYLON {
  58861. /**
  58862. * Operations supported by the Trigonometry block
  58863. */
  58864. export enum TrigonometryBlockOperations {
  58865. /** Cos */
  58866. Cos = 0,
  58867. /** Sin */
  58868. Sin = 1,
  58869. /** Abs */
  58870. Abs = 2,
  58871. /** Exp */
  58872. Exp = 3,
  58873. /** Exp2 */
  58874. Exp2 = 4,
  58875. /** Round */
  58876. Round = 5,
  58877. /** Floor */
  58878. Floor = 6,
  58879. /** Ceiling */
  58880. Ceiling = 7,
  58881. /** Square root */
  58882. Sqrt = 8,
  58883. /** Log */
  58884. Log = 9,
  58885. /** Tangent */
  58886. Tan = 10,
  58887. /** Arc tangent */
  58888. ArcTan = 11,
  58889. /** Arc cosinus */
  58890. ArcCos = 12,
  58891. /** Arc sinus */
  58892. ArcSin = 13,
  58893. /** Fraction */
  58894. Fract = 14,
  58895. /** Sign */
  58896. Sign = 15,
  58897. /** To radians (from degrees) */
  58898. Radians = 16,
  58899. /** To degrees (from radians) */
  58900. Degrees = 17
  58901. }
  58902. /**
  58903. * Block used to apply trigonometry operation to floats
  58904. */
  58905. export class TrigonometryBlock extends NodeMaterialBlock {
  58906. /**
  58907. * Gets or sets the operation applied by the block
  58908. */
  58909. operation: TrigonometryBlockOperations;
  58910. /**
  58911. * Creates a new TrigonometryBlock
  58912. * @param name defines the block name
  58913. */
  58914. constructor(name: string);
  58915. /**
  58916. * Gets the current class name
  58917. * @returns the class name
  58918. */
  58919. getClassName(): string;
  58920. /**
  58921. * Gets the input component
  58922. */
  58923. get input(): NodeMaterialConnectionPoint;
  58924. /**
  58925. * Gets the output component
  58926. */
  58927. get output(): NodeMaterialConnectionPoint;
  58928. protected _buildBlock(state: NodeMaterialBuildState): this;
  58929. serialize(): any;
  58930. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58931. protected _dumpPropertiesCode(): string;
  58932. }
  58933. }
  58934. declare module BABYLON {
  58935. /**
  58936. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58937. */
  58938. export class ColorMergerBlock extends NodeMaterialBlock {
  58939. /**
  58940. * Create a new ColorMergerBlock
  58941. * @param name defines the block name
  58942. */
  58943. constructor(name: string);
  58944. /**
  58945. * Gets the current class name
  58946. * @returns the class name
  58947. */
  58948. getClassName(): string;
  58949. /**
  58950. * Gets the rgb component (input)
  58951. */
  58952. get rgbIn(): NodeMaterialConnectionPoint;
  58953. /**
  58954. * Gets the r component (input)
  58955. */
  58956. get r(): NodeMaterialConnectionPoint;
  58957. /**
  58958. * Gets the g component (input)
  58959. */
  58960. get g(): NodeMaterialConnectionPoint;
  58961. /**
  58962. * Gets the b component (input)
  58963. */
  58964. get b(): NodeMaterialConnectionPoint;
  58965. /**
  58966. * Gets the a component (input)
  58967. */
  58968. get a(): NodeMaterialConnectionPoint;
  58969. /**
  58970. * Gets the rgba component (output)
  58971. */
  58972. get rgba(): NodeMaterialConnectionPoint;
  58973. /**
  58974. * Gets the rgb component (output)
  58975. */
  58976. get rgbOut(): NodeMaterialConnectionPoint;
  58977. /**
  58978. * Gets the rgb component (output)
  58979. * @deprecated Please use rgbOut instead.
  58980. */
  58981. get rgb(): NodeMaterialConnectionPoint;
  58982. protected _buildBlock(state: NodeMaterialBuildState): this;
  58983. }
  58984. }
  58985. declare module BABYLON {
  58986. /**
  58987. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58988. */
  58989. export class VectorMergerBlock extends NodeMaterialBlock {
  58990. /**
  58991. * Create a new VectorMergerBlock
  58992. * @param name defines the block name
  58993. */
  58994. constructor(name: string);
  58995. /**
  58996. * Gets the current class name
  58997. * @returns the class name
  58998. */
  58999. getClassName(): string;
  59000. /**
  59001. * Gets the xyz component (input)
  59002. */
  59003. get xyzIn(): NodeMaterialConnectionPoint;
  59004. /**
  59005. * Gets the xy component (input)
  59006. */
  59007. get xyIn(): NodeMaterialConnectionPoint;
  59008. /**
  59009. * Gets the x component (input)
  59010. */
  59011. get x(): NodeMaterialConnectionPoint;
  59012. /**
  59013. * Gets the y component (input)
  59014. */
  59015. get y(): NodeMaterialConnectionPoint;
  59016. /**
  59017. * Gets the z component (input)
  59018. */
  59019. get z(): NodeMaterialConnectionPoint;
  59020. /**
  59021. * Gets the w component (input)
  59022. */
  59023. get w(): NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the xyzw component (output)
  59026. */
  59027. get xyzw(): NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the xyz component (output)
  59030. */
  59031. get xyzOut(): NodeMaterialConnectionPoint;
  59032. /**
  59033. * Gets the xy component (output)
  59034. */
  59035. get xyOut(): NodeMaterialConnectionPoint;
  59036. /**
  59037. * Gets the xy component (output)
  59038. * @deprecated Please use xyOut instead.
  59039. */
  59040. get xy(): NodeMaterialConnectionPoint;
  59041. /**
  59042. * Gets the xyz component (output)
  59043. * @deprecated Please use xyzOut instead.
  59044. */
  59045. get xyz(): NodeMaterialConnectionPoint;
  59046. protected _buildBlock(state: NodeMaterialBuildState): this;
  59047. }
  59048. }
  59049. declare module BABYLON {
  59050. /**
  59051. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59052. */
  59053. export class ColorSplitterBlock extends NodeMaterialBlock {
  59054. /**
  59055. * Create a new ColorSplitterBlock
  59056. * @param name defines the block name
  59057. */
  59058. constructor(name: string);
  59059. /**
  59060. * Gets the current class name
  59061. * @returns the class name
  59062. */
  59063. getClassName(): string;
  59064. /**
  59065. * Gets the rgba component (input)
  59066. */
  59067. get rgba(): NodeMaterialConnectionPoint;
  59068. /**
  59069. * Gets the rgb component (input)
  59070. */
  59071. get rgbIn(): NodeMaterialConnectionPoint;
  59072. /**
  59073. * Gets the rgb component (output)
  59074. */
  59075. get rgbOut(): NodeMaterialConnectionPoint;
  59076. /**
  59077. * Gets the r component (output)
  59078. */
  59079. get r(): NodeMaterialConnectionPoint;
  59080. /**
  59081. * Gets the g component (output)
  59082. */
  59083. get g(): NodeMaterialConnectionPoint;
  59084. /**
  59085. * Gets the b component (output)
  59086. */
  59087. get b(): NodeMaterialConnectionPoint;
  59088. /**
  59089. * Gets the a component (output)
  59090. */
  59091. get a(): NodeMaterialConnectionPoint;
  59092. protected _inputRename(name: string): string;
  59093. protected _outputRename(name: string): string;
  59094. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59095. }
  59096. }
  59097. declare module BABYLON {
  59098. /**
  59099. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59100. */
  59101. export class VectorSplitterBlock extends NodeMaterialBlock {
  59102. /**
  59103. * Create a new VectorSplitterBlock
  59104. * @param name defines the block name
  59105. */
  59106. constructor(name: string);
  59107. /**
  59108. * Gets the current class name
  59109. * @returns the class name
  59110. */
  59111. getClassName(): string;
  59112. /**
  59113. * Gets the xyzw component (input)
  59114. */
  59115. get xyzw(): NodeMaterialConnectionPoint;
  59116. /**
  59117. * Gets the xyz component (input)
  59118. */
  59119. get xyzIn(): NodeMaterialConnectionPoint;
  59120. /**
  59121. * Gets the xy component (input)
  59122. */
  59123. get xyIn(): NodeMaterialConnectionPoint;
  59124. /**
  59125. * Gets the xyz component (output)
  59126. */
  59127. get xyzOut(): NodeMaterialConnectionPoint;
  59128. /**
  59129. * Gets the xy component (output)
  59130. */
  59131. get xyOut(): NodeMaterialConnectionPoint;
  59132. /**
  59133. * Gets the x component (output)
  59134. */
  59135. get x(): NodeMaterialConnectionPoint;
  59136. /**
  59137. * Gets the y component (output)
  59138. */
  59139. get y(): NodeMaterialConnectionPoint;
  59140. /**
  59141. * Gets the z component (output)
  59142. */
  59143. get z(): NodeMaterialConnectionPoint;
  59144. /**
  59145. * Gets the w component (output)
  59146. */
  59147. get w(): NodeMaterialConnectionPoint;
  59148. protected _inputRename(name: string): string;
  59149. protected _outputRename(name: string): string;
  59150. protected _buildBlock(state: NodeMaterialBuildState): this;
  59151. }
  59152. }
  59153. declare module BABYLON {
  59154. /**
  59155. * Block used to lerp between 2 values
  59156. */
  59157. export class LerpBlock extends NodeMaterialBlock {
  59158. /**
  59159. * Creates a new LerpBlock
  59160. * @param name defines the block name
  59161. */
  59162. constructor(name: string);
  59163. /**
  59164. * Gets the current class name
  59165. * @returns the class name
  59166. */
  59167. getClassName(): string;
  59168. /**
  59169. * Gets the left operand input component
  59170. */
  59171. get left(): NodeMaterialConnectionPoint;
  59172. /**
  59173. * Gets the right operand input component
  59174. */
  59175. get right(): NodeMaterialConnectionPoint;
  59176. /**
  59177. * Gets the gradient operand input component
  59178. */
  59179. get gradient(): NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the output component
  59182. */
  59183. get output(): NodeMaterialConnectionPoint;
  59184. protected _buildBlock(state: NodeMaterialBuildState): this;
  59185. }
  59186. }
  59187. declare module BABYLON {
  59188. /**
  59189. * Block used to divide 2 vectors
  59190. */
  59191. export class DivideBlock extends NodeMaterialBlock {
  59192. /**
  59193. * Creates a new DivideBlock
  59194. * @param name defines the block name
  59195. */
  59196. constructor(name: string);
  59197. /**
  59198. * Gets the current class name
  59199. * @returns the class name
  59200. */
  59201. getClassName(): string;
  59202. /**
  59203. * Gets the left operand input component
  59204. */
  59205. get left(): NodeMaterialConnectionPoint;
  59206. /**
  59207. * Gets the right operand input component
  59208. */
  59209. get right(): NodeMaterialConnectionPoint;
  59210. /**
  59211. * Gets the output component
  59212. */
  59213. get output(): NodeMaterialConnectionPoint;
  59214. protected _buildBlock(state: NodeMaterialBuildState): this;
  59215. }
  59216. }
  59217. declare module BABYLON {
  59218. /**
  59219. * Block used to subtract 2 vectors
  59220. */
  59221. export class SubtractBlock extends NodeMaterialBlock {
  59222. /**
  59223. * Creates a new SubtractBlock
  59224. * @param name defines the block name
  59225. */
  59226. constructor(name: string);
  59227. /**
  59228. * Gets the current class name
  59229. * @returns the class name
  59230. */
  59231. getClassName(): string;
  59232. /**
  59233. * Gets the left operand input component
  59234. */
  59235. get left(): NodeMaterialConnectionPoint;
  59236. /**
  59237. * Gets the right operand input component
  59238. */
  59239. get right(): NodeMaterialConnectionPoint;
  59240. /**
  59241. * Gets the output component
  59242. */
  59243. get output(): NodeMaterialConnectionPoint;
  59244. protected _buildBlock(state: NodeMaterialBuildState): this;
  59245. }
  59246. }
  59247. declare module BABYLON {
  59248. /**
  59249. * Block used to step a value
  59250. */
  59251. export class StepBlock extends NodeMaterialBlock {
  59252. /**
  59253. * Creates a new StepBlock
  59254. * @param name defines the block name
  59255. */
  59256. constructor(name: string);
  59257. /**
  59258. * Gets the current class name
  59259. * @returns the class name
  59260. */
  59261. getClassName(): string;
  59262. /**
  59263. * Gets the value operand input component
  59264. */
  59265. get value(): NodeMaterialConnectionPoint;
  59266. /**
  59267. * Gets the edge operand input component
  59268. */
  59269. get edge(): NodeMaterialConnectionPoint;
  59270. /**
  59271. * Gets the output component
  59272. */
  59273. get output(): NodeMaterialConnectionPoint;
  59274. protected _buildBlock(state: NodeMaterialBuildState): this;
  59275. }
  59276. }
  59277. declare module BABYLON {
  59278. /**
  59279. * Block used to get the opposite (1 - x) of a value
  59280. */
  59281. export class OneMinusBlock extends NodeMaterialBlock {
  59282. /**
  59283. * Creates a new OneMinusBlock
  59284. * @param name defines the block name
  59285. */
  59286. constructor(name: string);
  59287. /**
  59288. * Gets the current class name
  59289. * @returns the class name
  59290. */
  59291. getClassName(): string;
  59292. /**
  59293. * Gets the input component
  59294. */
  59295. get input(): NodeMaterialConnectionPoint;
  59296. /**
  59297. * Gets the output component
  59298. */
  59299. get output(): NodeMaterialConnectionPoint;
  59300. protected _buildBlock(state: NodeMaterialBuildState): this;
  59301. }
  59302. }
  59303. declare module BABYLON {
  59304. /**
  59305. * Block used to get the view direction
  59306. */
  59307. export class ViewDirectionBlock extends NodeMaterialBlock {
  59308. /**
  59309. * Creates a new ViewDirectionBlock
  59310. * @param name defines the block name
  59311. */
  59312. constructor(name: string);
  59313. /**
  59314. * Gets the current class name
  59315. * @returns the class name
  59316. */
  59317. getClassName(): string;
  59318. /**
  59319. * Gets the world position component
  59320. */
  59321. get worldPosition(): NodeMaterialConnectionPoint;
  59322. /**
  59323. * Gets the camera position component
  59324. */
  59325. get cameraPosition(): NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the output component
  59328. */
  59329. get output(): NodeMaterialConnectionPoint;
  59330. autoConfigure(material: NodeMaterial): void;
  59331. protected _buildBlock(state: NodeMaterialBuildState): this;
  59332. }
  59333. }
  59334. declare module BABYLON {
  59335. /**
  59336. * Block used to compute fresnel value
  59337. */
  59338. export class FresnelBlock extends NodeMaterialBlock {
  59339. /**
  59340. * Create a new FresnelBlock
  59341. * @param name defines the block name
  59342. */
  59343. constructor(name: string);
  59344. /**
  59345. * Gets the current class name
  59346. * @returns the class name
  59347. */
  59348. getClassName(): string;
  59349. /**
  59350. * Gets the world normal input component
  59351. */
  59352. get worldNormal(): NodeMaterialConnectionPoint;
  59353. /**
  59354. * Gets the view direction input component
  59355. */
  59356. get viewDirection(): NodeMaterialConnectionPoint;
  59357. /**
  59358. * Gets the bias input component
  59359. */
  59360. get bias(): NodeMaterialConnectionPoint;
  59361. /**
  59362. * Gets the camera (or eye) position component
  59363. */
  59364. get power(): NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the fresnel output component
  59367. */
  59368. get fresnel(): NodeMaterialConnectionPoint;
  59369. autoConfigure(material: NodeMaterial): void;
  59370. protected _buildBlock(state: NodeMaterialBuildState): this;
  59371. }
  59372. }
  59373. declare module BABYLON {
  59374. /**
  59375. * Block used to get the max of 2 values
  59376. */
  59377. export class MaxBlock extends NodeMaterialBlock {
  59378. /**
  59379. * Creates a new MaxBlock
  59380. * @param name defines the block name
  59381. */
  59382. constructor(name: string);
  59383. /**
  59384. * Gets the current class name
  59385. * @returns the class name
  59386. */
  59387. getClassName(): string;
  59388. /**
  59389. * Gets the left operand input component
  59390. */
  59391. get left(): NodeMaterialConnectionPoint;
  59392. /**
  59393. * Gets the right operand input component
  59394. */
  59395. get right(): NodeMaterialConnectionPoint;
  59396. /**
  59397. * Gets the output component
  59398. */
  59399. get output(): NodeMaterialConnectionPoint;
  59400. protected _buildBlock(state: NodeMaterialBuildState): this;
  59401. }
  59402. }
  59403. declare module BABYLON {
  59404. /**
  59405. * Block used to get the min of 2 values
  59406. */
  59407. export class MinBlock extends NodeMaterialBlock {
  59408. /**
  59409. * Creates a new MinBlock
  59410. * @param name defines the block name
  59411. */
  59412. constructor(name: string);
  59413. /**
  59414. * Gets the current class name
  59415. * @returns the class name
  59416. */
  59417. getClassName(): string;
  59418. /**
  59419. * Gets the left operand input component
  59420. */
  59421. get left(): NodeMaterialConnectionPoint;
  59422. /**
  59423. * Gets the right operand input component
  59424. */
  59425. get right(): NodeMaterialConnectionPoint;
  59426. /**
  59427. * Gets the output component
  59428. */
  59429. get output(): NodeMaterialConnectionPoint;
  59430. protected _buildBlock(state: NodeMaterialBuildState): this;
  59431. }
  59432. }
  59433. declare module BABYLON {
  59434. /**
  59435. * Block used to get the distance between 2 values
  59436. */
  59437. export class DistanceBlock extends NodeMaterialBlock {
  59438. /**
  59439. * Creates a new DistanceBlock
  59440. * @param name defines the block name
  59441. */
  59442. constructor(name: string);
  59443. /**
  59444. * Gets the current class name
  59445. * @returns the class name
  59446. */
  59447. getClassName(): string;
  59448. /**
  59449. * Gets the left operand input component
  59450. */
  59451. get left(): NodeMaterialConnectionPoint;
  59452. /**
  59453. * Gets the right operand input component
  59454. */
  59455. get right(): NodeMaterialConnectionPoint;
  59456. /**
  59457. * Gets the output component
  59458. */
  59459. get output(): NodeMaterialConnectionPoint;
  59460. protected _buildBlock(state: NodeMaterialBuildState): this;
  59461. }
  59462. }
  59463. declare module BABYLON {
  59464. /**
  59465. * Block used to get the length of a vector
  59466. */
  59467. export class LengthBlock extends NodeMaterialBlock {
  59468. /**
  59469. * Creates a new LengthBlock
  59470. * @param name defines the block name
  59471. */
  59472. constructor(name: string);
  59473. /**
  59474. * Gets the current class name
  59475. * @returns the class name
  59476. */
  59477. getClassName(): string;
  59478. /**
  59479. * Gets the value input component
  59480. */
  59481. get value(): NodeMaterialConnectionPoint;
  59482. /**
  59483. * Gets the output component
  59484. */
  59485. get output(): NodeMaterialConnectionPoint;
  59486. protected _buildBlock(state: NodeMaterialBuildState): this;
  59487. }
  59488. }
  59489. declare module BABYLON {
  59490. /**
  59491. * Block used to get negative version of a value (i.e. x * -1)
  59492. */
  59493. export class NegateBlock extends NodeMaterialBlock {
  59494. /**
  59495. * Creates a new NegateBlock
  59496. * @param name defines the block name
  59497. */
  59498. constructor(name: string);
  59499. /**
  59500. * Gets the current class name
  59501. * @returns the class name
  59502. */
  59503. getClassName(): string;
  59504. /**
  59505. * Gets the value input component
  59506. */
  59507. get value(): NodeMaterialConnectionPoint;
  59508. /**
  59509. * Gets the output component
  59510. */
  59511. get output(): NodeMaterialConnectionPoint;
  59512. protected _buildBlock(state: NodeMaterialBuildState): this;
  59513. }
  59514. }
  59515. declare module BABYLON {
  59516. /**
  59517. * Block used to get the value of the first parameter raised to the power of the second
  59518. */
  59519. export class PowBlock extends NodeMaterialBlock {
  59520. /**
  59521. * Creates a new PowBlock
  59522. * @param name defines the block name
  59523. */
  59524. constructor(name: string);
  59525. /**
  59526. * Gets the current class name
  59527. * @returns the class name
  59528. */
  59529. getClassName(): string;
  59530. /**
  59531. * Gets the value operand input component
  59532. */
  59533. get value(): NodeMaterialConnectionPoint;
  59534. /**
  59535. * Gets the power operand input component
  59536. */
  59537. get power(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the output component
  59540. */
  59541. get output(): NodeMaterialConnectionPoint;
  59542. protected _buildBlock(state: NodeMaterialBuildState): this;
  59543. }
  59544. }
  59545. declare module BABYLON {
  59546. /**
  59547. * Block used to get a random number
  59548. */
  59549. export class RandomNumberBlock extends NodeMaterialBlock {
  59550. /**
  59551. * Creates a new RandomNumberBlock
  59552. * @param name defines the block name
  59553. */
  59554. constructor(name: string);
  59555. /**
  59556. * Gets the current class name
  59557. * @returns the class name
  59558. */
  59559. getClassName(): string;
  59560. /**
  59561. * Gets the seed input component
  59562. */
  59563. get seed(): NodeMaterialConnectionPoint;
  59564. /**
  59565. * Gets the output component
  59566. */
  59567. get output(): NodeMaterialConnectionPoint;
  59568. protected _buildBlock(state: NodeMaterialBuildState): this;
  59569. }
  59570. }
  59571. declare module BABYLON {
  59572. /**
  59573. * Block used to compute arc tangent of 2 values
  59574. */
  59575. export class ArcTan2Block extends NodeMaterialBlock {
  59576. /**
  59577. * Creates a new ArcTan2Block
  59578. * @param name defines the block name
  59579. */
  59580. constructor(name: string);
  59581. /**
  59582. * Gets the current class name
  59583. * @returns the class name
  59584. */
  59585. getClassName(): string;
  59586. /**
  59587. * Gets the x operand input component
  59588. */
  59589. get x(): NodeMaterialConnectionPoint;
  59590. /**
  59591. * Gets the y operand input component
  59592. */
  59593. get y(): NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the output component
  59596. */
  59597. get output(): NodeMaterialConnectionPoint;
  59598. protected _buildBlock(state: NodeMaterialBuildState): this;
  59599. }
  59600. }
  59601. declare module BABYLON {
  59602. /**
  59603. * Block used to smooth step a value
  59604. */
  59605. export class SmoothStepBlock extends NodeMaterialBlock {
  59606. /**
  59607. * Creates a new SmoothStepBlock
  59608. * @param name defines the block name
  59609. */
  59610. constructor(name: string);
  59611. /**
  59612. * Gets the current class name
  59613. * @returns the class name
  59614. */
  59615. getClassName(): string;
  59616. /**
  59617. * Gets the value operand input component
  59618. */
  59619. get value(): NodeMaterialConnectionPoint;
  59620. /**
  59621. * Gets the first edge operand input component
  59622. */
  59623. get edge0(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the second edge operand input component
  59626. */
  59627. get edge1(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the output component
  59630. */
  59631. get output(): NodeMaterialConnectionPoint;
  59632. protected _buildBlock(state: NodeMaterialBuildState): this;
  59633. }
  59634. }
  59635. declare module BABYLON {
  59636. /**
  59637. * Block used to get the reciprocal (1 / x) of a value
  59638. */
  59639. export class ReciprocalBlock extends NodeMaterialBlock {
  59640. /**
  59641. * Creates a new ReciprocalBlock
  59642. * @param name defines the block name
  59643. */
  59644. constructor(name: string);
  59645. /**
  59646. * Gets the current class name
  59647. * @returns the class name
  59648. */
  59649. getClassName(): string;
  59650. /**
  59651. * Gets the input component
  59652. */
  59653. get input(): NodeMaterialConnectionPoint;
  59654. /**
  59655. * Gets the output component
  59656. */
  59657. get output(): NodeMaterialConnectionPoint;
  59658. protected _buildBlock(state: NodeMaterialBuildState): this;
  59659. }
  59660. }
  59661. declare module BABYLON {
  59662. /**
  59663. * Block used to replace a color by another one
  59664. */
  59665. export class ReplaceColorBlock extends NodeMaterialBlock {
  59666. /**
  59667. * Creates a new ReplaceColorBlock
  59668. * @param name defines the block name
  59669. */
  59670. constructor(name: string);
  59671. /**
  59672. * Gets the current class name
  59673. * @returns the class name
  59674. */
  59675. getClassName(): string;
  59676. /**
  59677. * Gets the value input component
  59678. */
  59679. get value(): NodeMaterialConnectionPoint;
  59680. /**
  59681. * Gets the reference input component
  59682. */
  59683. get reference(): NodeMaterialConnectionPoint;
  59684. /**
  59685. * Gets the distance input component
  59686. */
  59687. get distance(): NodeMaterialConnectionPoint;
  59688. /**
  59689. * Gets the replacement input component
  59690. */
  59691. get replacement(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the output component
  59694. */
  59695. get output(): NodeMaterialConnectionPoint;
  59696. protected _buildBlock(state: NodeMaterialBuildState): this;
  59697. }
  59698. }
  59699. declare module BABYLON {
  59700. /**
  59701. * Block used to posterize a value
  59702. * @see https://en.wikipedia.org/wiki/Posterization
  59703. */
  59704. export class PosterizeBlock extends NodeMaterialBlock {
  59705. /**
  59706. * Creates a new PosterizeBlock
  59707. * @param name defines the block name
  59708. */
  59709. constructor(name: string);
  59710. /**
  59711. * Gets the current class name
  59712. * @returns the class name
  59713. */
  59714. getClassName(): string;
  59715. /**
  59716. * Gets the value input component
  59717. */
  59718. get value(): NodeMaterialConnectionPoint;
  59719. /**
  59720. * Gets the steps input component
  59721. */
  59722. get steps(): NodeMaterialConnectionPoint;
  59723. /**
  59724. * Gets the output component
  59725. */
  59726. get output(): NodeMaterialConnectionPoint;
  59727. protected _buildBlock(state: NodeMaterialBuildState): this;
  59728. }
  59729. }
  59730. declare module BABYLON {
  59731. /**
  59732. * Operations supported by the Wave block
  59733. */
  59734. export enum WaveBlockKind {
  59735. /** SawTooth */
  59736. SawTooth = 0,
  59737. /** Square */
  59738. Square = 1,
  59739. /** Triangle */
  59740. Triangle = 2
  59741. }
  59742. /**
  59743. * Block used to apply wave operation to floats
  59744. */
  59745. export class WaveBlock extends NodeMaterialBlock {
  59746. /**
  59747. * Gets or sets the kibnd of wave to be applied by the block
  59748. */
  59749. kind: WaveBlockKind;
  59750. /**
  59751. * Creates a new WaveBlock
  59752. * @param name defines the block name
  59753. */
  59754. constructor(name: string);
  59755. /**
  59756. * Gets the current class name
  59757. * @returns the class name
  59758. */
  59759. getClassName(): string;
  59760. /**
  59761. * Gets the input component
  59762. */
  59763. get input(): NodeMaterialConnectionPoint;
  59764. /**
  59765. * Gets the output component
  59766. */
  59767. get output(): NodeMaterialConnectionPoint;
  59768. protected _buildBlock(state: NodeMaterialBuildState): this;
  59769. serialize(): any;
  59770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59771. }
  59772. }
  59773. declare module BABYLON {
  59774. /**
  59775. * Class used to store a color step for the GradientBlock
  59776. */
  59777. export class GradientBlockColorStep {
  59778. /**
  59779. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59780. */
  59781. step: number;
  59782. /**
  59783. * Gets or sets the color associated with this step
  59784. */
  59785. color: Color3;
  59786. /**
  59787. * Creates a new GradientBlockColorStep
  59788. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59789. * @param color defines the color associated with this step
  59790. */
  59791. constructor(
  59792. /**
  59793. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59794. */
  59795. step: number,
  59796. /**
  59797. * Gets or sets the color associated with this step
  59798. */
  59799. color: Color3);
  59800. }
  59801. /**
  59802. * Block used to return a color from a gradient based on an input value between 0 and 1
  59803. */
  59804. export class GradientBlock extends NodeMaterialBlock {
  59805. /**
  59806. * Gets or sets the list of color steps
  59807. */
  59808. colorSteps: GradientBlockColorStep[];
  59809. /**
  59810. * Creates a new GradientBlock
  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 gradient input component
  59821. */
  59822. get gradient(): NodeMaterialConnectionPoint;
  59823. /**
  59824. * Gets the output component
  59825. */
  59826. get output(): NodeMaterialConnectionPoint;
  59827. private _writeColorConstant;
  59828. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59829. serialize(): any;
  59830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59831. protected _dumpPropertiesCode(): string;
  59832. }
  59833. }
  59834. declare module BABYLON {
  59835. /**
  59836. * Block used to normalize lerp between 2 values
  59837. */
  59838. export class NLerpBlock extends NodeMaterialBlock {
  59839. /**
  59840. * Creates a new NLerpBlock
  59841. * @param name defines the block name
  59842. */
  59843. constructor(name: string);
  59844. /**
  59845. * Gets the current class name
  59846. * @returns the class name
  59847. */
  59848. getClassName(): string;
  59849. /**
  59850. * Gets the left operand input component
  59851. */
  59852. get left(): NodeMaterialConnectionPoint;
  59853. /**
  59854. * Gets the right operand input component
  59855. */
  59856. get right(): NodeMaterialConnectionPoint;
  59857. /**
  59858. * Gets the gradient operand input component
  59859. */
  59860. get gradient(): NodeMaterialConnectionPoint;
  59861. /**
  59862. * Gets the output component
  59863. */
  59864. get output(): NodeMaterialConnectionPoint;
  59865. protected _buildBlock(state: NodeMaterialBuildState): this;
  59866. }
  59867. }
  59868. declare module BABYLON {
  59869. /**
  59870. * block used to Generate a Worley Noise 3D Noise Pattern
  59871. */
  59872. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59873. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59874. manhattanDistance: boolean;
  59875. /**
  59876. * Creates a new WorleyNoise3DBlock
  59877. * @param name defines the block name
  59878. */
  59879. constructor(name: string);
  59880. /**
  59881. * Gets the current class name
  59882. * @returns the class name
  59883. */
  59884. getClassName(): string;
  59885. /**
  59886. * Gets the seed input component
  59887. */
  59888. get seed(): NodeMaterialConnectionPoint;
  59889. /**
  59890. * Gets the jitter input component
  59891. */
  59892. get jitter(): NodeMaterialConnectionPoint;
  59893. /**
  59894. * Gets the output component
  59895. */
  59896. get output(): NodeMaterialConnectionPoint;
  59897. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59898. /**
  59899. * Exposes the properties to the UI?
  59900. */
  59901. protected _dumpPropertiesCode(): string;
  59902. /**
  59903. * Exposes the properties to the Seralize?
  59904. */
  59905. serialize(): any;
  59906. /**
  59907. * Exposes the properties to the deseralize?
  59908. */
  59909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59910. }
  59911. }
  59912. declare module BABYLON {
  59913. /**
  59914. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59915. */
  59916. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59917. /**
  59918. * Creates a new SimplexPerlin3DBlock
  59919. * @param name defines the block name
  59920. */
  59921. constructor(name: string);
  59922. /**
  59923. * Gets the current class name
  59924. * @returns the class name
  59925. */
  59926. getClassName(): string;
  59927. /**
  59928. * Gets the seed operand input component
  59929. */
  59930. get seed(): NodeMaterialConnectionPoint;
  59931. /**
  59932. * Gets the output component
  59933. */
  59934. get output(): NodeMaterialConnectionPoint;
  59935. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59936. }
  59937. }
  59938. declare module BABYLON {
  59939. /**
  59940. * Block used to blend normals
  59941. */
  59942. export class NormalBlendBlock extends NodeMaterialBlock {
  59943. /**
  59944. * Creates a new NormalBlendBlock
  59945. * @param name defines the block name
  59946. */
  59947. constructor(name: string);
  59948. /**
  59949. * Gets the current class name
  59950. * @returns the class name
  59951. */
  59952. getClassName(): string;
  59953. /**
  59954. * Gets the first input component
  59955. */
  59956. get normalMap0(): NodeMaterialConnectionPoint;
  59957. /**
  59958. * Gets the second input component
  59959. */
  59960. get normalMap1(): NodeMaterialConnectionPoint;
  59961. /**
  59962. * Gets the output component
  59963. */
  59964. get output(): NodeMaterialConnectionPoint;
  59965. protected _buildBlock(state: NodeMaterialBuildState): this;
  59966. }
  59967. }
  59968. declare module BABYLON {
  59969. /**
  59970. * Block used to rotate a 2d vector by a given angle
  59971. */
  59972. export class Rotate2dBlock extends NodeMaterialBlock {
  59973. /**
  59974. * Creates a new Rotate2dBlock
  59975. * @param name defines the block name
  59976. */
  59977. constructor(name: string);
  59978. /**
  59979. * Gets the current class name
  59980. * @returns the class name
  59981. */
  59982. getClassName(): string;
  59983. /**
  59984. * Gets the input vector
  59985. */
  59986. get input(): NodeMaterialConnectionPoint;
  59987. /**
  59988. * Gets the input angle
  59989. */
  59990. get angle(): NodeMaterialConnectionPoint;
  59991. /**
  59992. * Gets the output component
  59993. */
  59994. get output(): NodeMaterialConnectionPoint;
  59995. autoConfigure(material: NodeMaterial): void;
  59996. protected _buildBlock(state: NodeMaterialBuildState): this;
  59997. }
  59998. }
  59999. declare module BABYLON {
  60000. /**
  60001. * Block used to get the reflected vector from a direction and a normal
  60002. */
  60003. export class ReflectBlock extends NodeMaterialBlock {
  60004. /**
  60005. * Creates a new ReflectBlock
  60006. * @param name defines the block name
  60007. */
  60008. constructor(name: string);
  60009. /**
  60010. * Gets the current class name
  60011. * @returns the class name
  60012. */
  60013. getClassName(): string;
  60014. /**
  60015. * Gets the incident component
  60016. */
  60017. get incident(): NodeMaterialConnectionPoint;
  60018. /**
  60019. * Gets the normal component
  60020. */
  60021. get normal(): NodeMaterialConnectionPoint;
  60022. /**
  60023. * Gets the output component
  60024. */
  60025. get output(): NodeMaterialConnectionPoint;
  60026. protected _buildBlock(state: NodeMaterialBuildState): this;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /**
  60031. * Block used to get the refracted vector from a direction and a normal
  60032. */
  60033. export class RefractBlock extends NodeMaterialBlock {
  60034. /**
  60035. * Creates a new RefractBlock
  60036. * @param name defines the block name
  60037. */
  60038. constructor(name: string);
  60039. /**
  60040. * Gets the current class name
  60041. * @returns the class name
  60042. */
  60043. getClassName(): string;
  60044. /**
  60045. * Gets the incident component
  60046. */
  60047. get incident(): NodeMaterialConnectionPoint;
  60048. /**
  60049. * Gets the normal component
  60050. */
  60051. get normal(): NodeMaterialConnectionPoint;
  60052. /**
  60053. * Gets the index of refraction component
  60054. */
  60055. get ior(): NodeMaterialConnectionPoint;
  60056. /**
  60057. * Gets the output component
  60058. */
  60059. get output(): NodeMaterialConnectionPoint;
  60060. protected _buildBlock(state: NodeMaterialBuildState): this;
  60061. }
  60062. }
  60063. declare module BABYLON {
  60064. /**
  60065. * Block used to desaturate a color
  60066. */
  60067. export class DesaturateBlock extends NodeMaterialBlock {
  60068. /**
  60069. * Creates a new DesaturateBlock
  60070. * @param name defines the block name
  60071. */
  60072. constructor(name: string);
  60073. /**
  60074. * Gets the current class name
  60075. * @returns the class name
  60076. */
  60077. getClassName(): string;
  60078. /**
  60079. * Gets the color operand input component
  60080. */
  60081. get color(): NodeMaterialConnectionPoint;
  60082. /**
  60083. * Gets the level operand input component
  60084. */
  60085. get level(): NodeMaterialConnectionPoint;
  60086. /**
  60087. * Gets the output component
  60088. */
  60089. get output(): NodeMaterialConnectionPoint;
  60090. protected _buildBlock(state: NodeMaterialBuildState): this;
  60091. }
  60092. }
  60093. declare module BABYLON {
  60094. /**
  60095. * Effect Render Options
  60096. */
  60097. export interface IEffectRendererOptions {
  60098. /**
  60099. * Defines the vertices positions.
  60100. */
  60101. positions?: number[];
  60102. /**
  60103. * Defines the indices.
  60104. */
  60105. indices?: number[];
  60106. }
  60107. /**
  60108. * Helper class to render one or more effects
  60109. */
  60110. export class EffectRenderer {
  60111. private engine;
  60112. private static _DefaultOptions;
  60113. private _vertexBuffers;
  60114. private _indexBuffer;
  60115. private _ringBufferIndex;
  60116. private _ringScreenBuffer;
  60117. private _fullscreenViewport;
  60118. private _getNextFrameBuffer;
  60119. /**
  60120. * Creates an effect renderer
  60121. * @param engine the engine to use for rendering
  60122. * @param options defines the options of the effect renderer
  60123. */
  60124. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60125. /**
  60126. * Sets the current viewport in normalized coordinates 0-1
  60127. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60128. */
  60129. setViewport(viewport?: Viewport): void;
  60130. /**
  60131. * Binds the embedded attributes buffer to the effect.
  60132. * @param effect Defines the effect to bind the attributes for
  60133. */
  60134. bindBuffers(effect: Effect): void;
  60135. /**
  60136. * Sets the current effect wrapper to use during draw.
  60137. * The effect needs to be ready before calling this api.
  60138. * This also sets the default full screen position attribute.
  60139. * @param effectWrapper Defines the effect to draw with
  60140. */
  60141. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60142. /**
  60143. * Draws a full screen quad.
  60144. */
  60145. draw(): void;
  60146. /**
  60147. * renders one or more effects to a specified texture
  60148. * @param effectWrappers list of effects to renderer
  60149. * @param outputTexture texture to draw to, if null it will render to the screen
  60150. */
  60151. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60152. /**
  60153. * Disposes of the effect renderer
  60154. */
  60155. dispose(): void;
  60156. }
  60157. /**
  60158. * Options to create an EffectWrapper
  60159. */
  60160. interface EffectWrapperCreationOptions {
  60161. /**
  60162. * Engine to use to create the effect
  60163. */
  60164. engine: ThinEngine;
  60165. /**
  60166. * Fragment shader for the effect
  60167. */
  60168. fragmentShader: string;
  60169. /**
  60170. * Vertex shader for the effect
  60171. */
  60172. vertexShader?: string;
  60173. /**
  60174. * Attributes to use in the shader
  60175. */
  60176. attributeNames?: Array<string>;
  60177. /**
  60178. * Uniforms to use in the shader
  60179. */
  60180. uniformNames?: Array<string>;
  60181. /**
  60182. * Texture sampler names to use in the shader
  60183. */
  60184. samplerNames?: Array<string>;
  60185. /**
  60186. * The friendly name of the effect displayed in Spector.
  60187. */
  60188. name?: string;
  60189. }
  60190. /**
  60191. * Wraps an effect to be used for rendering
  60192. */
  60193. export class EffectWrapper {
  60194. /**
  60195. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60196. */
  60197. onApplyObservable: Observable<{}>;
  60198. /**
  60199. * The underlying effect
  60200. */
  60201. effect: Effect;
  60202. /**
  60203. * Creates an effect to be renderer
  60204. * @param creationOptions options to create the effect
  60205. */
  60206. constructor(creationOptions: EffectWrapperCreationOptions);
  60207. /**
  60208. * Disposes of the effect wrapper
  60209. */
  60210. dispose(): void;
  60211. }
  60212. }
  60213. declare module BABYLON {
  60214. /**
  60215. * Helper class to push actions to a pool of workers.
  60216. */
  60217. export class WorkerPool implements IDisposable {
  60218. private _workerInfos;
  60219. private _pendingActions;
  60220. /**
  60221. * Constructor
  60222. * @param workers Array of workers to use for actions
  60223. */
  60224. constructor(workers: Array<Worker>);
  60225. /**
  60226. * Terminates all workers and clears any pending actions.
  60227. */
  60228. dispose(): void;
  60229. /**
  60230. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60231. * pended until a worker has completed its action.
  60232. * @param action The action to perform. Call onComplete when the action is complete.
  60233. */
  60234. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60235. private _execute;
  60236. }
  60237. }
  60238. declare module BABYLON {
  60239. /**
  60240. * Configuration for Draco compression
  60241. */
  60242. export interface IDracoCompressionConfiguration {
  60243. /**
  60244. * Configuration for the decoder.
  60245. */
  60246. decoder: {
  60247. /**
  60248. * The url to the WebAssembly module.
  60249. */
  60250. wasmUrl?: string;
  60251. /**
  60252. * The url to the WebAssembly binary.
  60253. */
  60254. wasmBinaryUrl?: string;
  60255. /**
  60256. * The url to the fallback JavaScript module.
  60257. */
  60258. fallbackUrl?: string;
  60259. };
  60260. }
  60261. /**
  60262. * Draco compression (https://google.github.io/draco/)
  60263. *
  60264. * This class wraps the Draco module.
  60265. *
  60266. * **Encoder**
  60267. *
  60268. * The encoder is not currently implemented.
  60269. *
  60270. * **Decoder**
  60271. *
  60272. * 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.
  60273. *
  60274. * To update the configuration, use the following code:
  60275. * ```javascript
  60276. * DracoCompression.Configuration = {
  60277. * decoder: {
  60278. * wasmUrl: "<url to the WebAssembly library>",
  60279. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60280. * fallbackUrl: "<url to the fallback JavaScript library>",
  60281. * }
  60282. * };
  60283. * ```
  60284. *
  60285. * 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.
  60286. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60287. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60288. *
  60289. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60290. * ```javascript
  60291. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60292. * ```
  60293. *
  60294. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60295. */
  60296. export class DracoCompression implements IDisposable {
  60297. private _workerPoolPromise?;
  60298. private _decoderModulePromise?;
  60299. /**
  60300. * The configuration. Defaults to the following urls:
  60301. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60302. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60303. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60304. */
  60305. static Configuration: IDracoCompressionConfiguration;
  60306. /**
  60307. * Returns true if the decoder configuration is available.
  60308. */
  60309. static get DecoderAvailable(): boolean;
  60310. /**
  60311. * Default number of workers to create when creating the draco compression object.
  60312. */
  60313. static DefaultNumWorkers: number;
  60314. private static GetDefaultNumWorkers;
  60315. private static _Default;
  60316. /**
  60317. * Default instance for the draco compression object.
  60318. */
  60319. static get Default(): DracoCompression;
  60320. /**
  60321. * Constructor
  60322. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60323. */
  60324. constructor(numWorkers?: number);
  60325. /**
  60326. * Stop all async operations and release resources.
  60327. */
  60328. dispose(): void;
  60329. /**
  60330. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60331. * @returns a promise that resolves when ready
  60332. */
  60333. whenReadyAsync(): Promise<void>;
  60334. /**
  60335. * Decode Draco compressed mesh data to vertex data.
  60336. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60337. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60338. * @returns A promise that resolves with the decoded vertex data
  60339. */
  60340. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60341. [kind: string]: number;
  60342. }): Promise<VertexData>;
  60343. }
  60344. }
  60345. declare module BABYLON {
  60346. /**
  60347. * Class for building Constructive Solid Geometry
  60348. */
  60349. export class CSG {
  60350. private polygons;
  60351. /**
  60352. * The world matrix
  60353. */
  60354. matrix: Matrix;
  60355. /**
  60356. * Stores the position
  60357. */
  60358. position: Vector3;
  60359. /**
  60360. * Stores the rotation
  60361. */
  60362. rotation: Vector3;
  60363. /**
  60364. * Stores the rotation quaternion
  60365. */
  60366. rotationQuaternion: Nullable<Quaternion>;
  60367. /**
  60368. * Stores the scaling vector
  60369. */
  60370. scaling: Vector3;
  60371. /**
  60372. * Convert the Mesh to CSG
  60373. * @param mesh The Mesh to convert to CSG
  60374. * @returns A new CSG from the Mesh
  60375. */
  60376. static FromMesh(mesh: Mesh): CSG;
  60377. /**
  60378. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60379. * @param polygons Polygons used to construct a CSG solid
  60380. */
  60381. private static FromPolygons;
  60382. /**
  60383. * Clones, or makes a deep copy, of the CSG
  60384. * @returns A new CSG
  60385. */
  60386. clone(): CSG;
  60387. /**
  60388. * Unions this CSG with another CSG
  60389. * @param csg The CSG to union against this CSG
  60390. * @returns The unioned CSG
  60391. */
  60392. union(csg: CSG): CSG;
  60393. /**
  60394. * Unions this CSG with another CSG in place
  60395. * @param csg The CSG to union against this CSG
  60396. */
  60397. unionInPlace(csg: CSG): void;
  60398. /**
  60399. * Subtracts this CSG with another CSG
  60400. * @param csg The CSG to subtract against this CSG
  60401. * @returns A new CSG
  60402. */
  60403. subtract(csg: CSG): CSG;
  60404. /**
  60405. * Subtracts this CSG with another CSG in place
  60406. * @param csg The CSG to subtact against this CSG
  60407. */
  60408. subtractInPlace(csg: CSG): void;
  60409. /**
  60410. * Intersect this CSG with another CSG
  60411. * @param csg The CSG to intersect against this CSG
  60412. * @returns A new CSG
  60413. */
  60414. intersect(csg: CSG): CSG;
  60415. /**
  60416. * Intersects this CSG with another CSG in place
  60417. * @param csg The CSG to intersect against this CSG
  60418. */
  60419. intersectInPlace(csg: CSG): void;
  60420. /**
  60421. * Return a new CSG solid with solid and empty space switched. This solid is
  60422. * not modified.
  60423. * @returns A new CSG solid with solid and empty space switched
  60424. */
  60425. inverse(): CSG;
  60426. /**
  60427. * Inverses the CSG in place
  60428. */
  60429. inverseInPlace(): void;
  60430. /**
  60431. * This is used to keep meshes transformations so they can be restored
  60432. * when we build back a Babylon Mesh
  60433. * NB : All CSG operations are performed in world coordinates
  60434. * @param csg The CSG to copy the transform attributes from
  60435. * @returns This CSG
  60436. */
  60437. copyTransformAttributes(csg: CSG): CSG;
  60438. /**
  60439. * Build Raw mesh from CSG
  60440. * Coordinates here are in world space
  60441. * @param name The name of the mesh geometry
  60442. * @param scene The Scene
  60443. * @param keepSubMeshes Specifies if the submeshes should be kept
  60444. * @returns A new Mesh
  60445. */
  60446. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60447. /**
  60448. * Build Mesh from CSG taking material and transforms into account
  60449. * @param name The name of the Mesh
  60450. * @param material The material of the Mesh
  60451. * @param scene The Scene
  60452. * @param keepSubMeshes Specifies if submeshes should be kept
  60453. * @returns The new Mesh
  60454. */
  60455. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60456. }
  60457. }
  60458. declare module BABYLON {
  60459. /**
  60460. * Class used to create a trail following a mesh
  60461. */
  60462. export class TrailMesh extends Mesh {
  60463. private _generator;
  60464. private _autoStart;
  60465. private _running;
  60466. private _diameter;
  60467. private _length;
  60468. private _sectionPolygonPointsCount;
  60469. private _sectionVectors;
  60470. private _sectionNormalVectors;
  60471. private _beforeRenderObserver;
  60472. /**
  60473. * @constructor
  60474. * @param name The value used by scene.getMeshByName() to do a lookup.
  60475. * @param generator The mesh or transform node to generate a trail.
  60476. * @param scene The scene to add this mesh to.
  60477. * @param diameter Diameter of trailing mesh. Default is 1.
  60478. * @param length Length of trailing mesh. Default is 60.
  60479. * @param autoStart Automatically start trailing mesh. Default true.
  60480. */
  60481. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60482. /**
  60483. * "TrailMesh"
  60484. * @returns "TrailMesh"
  60485. */
  60486. getClassName(): string;
  60487. private _createMesh;
  60488. /**
  60489. * Start trailing mesh.
  60490. */
  60491. start(): void;
  60492. /**
  60493. * Stop trailing mesh.
  60494. */
  60495. stop(): void;
  60496. /**
  60497. * Update trailing mesh geometry.
  60498. */
  60499. update(): void;
  60500. /**
  60501. * Returns a new TrailMesh object.
  60502. * @param name is a string, the name given to the new mesh
  60503. * @param newGenerator use new generator object for cloned trail mesh
  60504. * @returns a new mesh
  60505. */
  60506. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60507. /**
  60508. * Serializes this trail mesh
  60509. * @param serializationObject object to write serialization to
  60510. */
  60511. serialize(serializationObject: any): void;
  60512. /**
  60513. * Parses a serialized trail mesh
  60514. * @param parsedMesh the serialized mesh
  60515. * @param scene the scene to create the trail mesh in
  60516. * @returns the created trail mesh
  60517. */
  60518. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60519. }
  60520. }
  60521. declare module BABYLON {
  60522. /**
  60523. * Class containing static functions to help procedurally build meshes
  60524. */
  60525. export class TiledBoxBuilder {
  60526. /**
  60527. * Creates a box mesh
  60528. * 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)
  60529. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60531. * * 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
  60532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60533. * @param name defines the name of the mesh
  60534. * @param options defines the options used to create the mesh
  60535. * @param scene defines the hosting scene
  60536. * @returns the box mesh
  60537. */
  60538. static CreateTiledBox(name: string, options: {
  60539. pattern?: number;
  60540. width?: number;
  60541. height?: number;
  60542. depth?: number;
  60543. tileSize?: number;
  60544. tileWidth?: number;
  60545. tileHeight?: number;
  60546. alignHorizontal?: number;
  60547. alignVertical?: number;
  60548. faceUV?: Vector4[];
  60549. faceColors?: Color4[];
  60550. sideOrientation?: number;
  60551. updatable?: boolean;
  60552. }, scene?: Nullable<Scene>): Mesh;
  60553. }
  60554. }
  60555. declare module BABYLON {
  60556. /**
  60557. * Class containing static functions to help procedurally build meshes
  60558. */
  60559. export class TorusKnotBuilder {
  60560. /**
  60561. * Creates a torus knot mesh
  60562. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60563. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60564. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60565. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60567. * * 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
  60568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60569. * @param name defines the name of the mesh
  60570. * @param options defines the options used to create the mesh
  60571. * @param scene defines the hosting scene
  60572. * @returns the torus knot mesh
  60573. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60574. */
  60575. static CreateTorusKnot(name: string, options: {
  60576. radius?: number;
  60577. tube?: number;
  60578. radialSegments?: number;
  60579. tubularSegments?: number;
  60580. p?: number;
  60581. q?: number;
  60582. updatable?: boolean;
  60583. sideOrientation?: number;
  60584. frontUVs?: Vector4;
  60585. backUVs?: Vector4;
  60586. }, scene: any): Mesh;
  60587. }
  60588. }
  60589. declare module BABYLON {
  60590. /**
  60591. * Polygon
  60592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60593. */
  60594. export class Polygon {
  60595. /**
  60596. * Creates a rectangle
  60597. * @param xmin bottom X coord
  60598. * @param ymin bottom Y coord
  60599. * @param xmax top X coord
  60600. * @param ymax top Y coord
  60601. * @returns points that make the resulting rectation
  60602. */
  60603. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60604. /**
  60605. * Creates a circle
  60606. * @param radius radius of circle
  60607. * @param cx scale in x
  60608. * @param cy scale in y
  60609. * @param numberOfSides number of sides that make up the circle
  60610. * @returns points that make the resulting circle
  60611. */
  60612. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60613. /**
  60614. * Creates a polygon from input string
  60615. * @param input Input polygon data
  60616. * @returns the parsed points
  60617. */
  60618. static Parse(input: string): Vector2[];
  60619. /**
  60620. * Starts building a polygon from x and y coordinates
  60621. * @param x x coordinate
  60622. * @param y y coordinate
  60623. * @returns the started path2
  60624. */
  60625. static StartingAt(x: number, y: number): Path2;
  60626. }
  60627. /**
  60628. * Builds a polygon
  60629. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60630. */
  60631. export class PolygonMeshBuilder {
  60632. private _points;
  60633. private _outlinepoints;
  60634. private _holes;
  60635. private _name;
  60636. private _scene;
  60637. private _epoints;
  60638. private _eholes;
  60639. private _addToepoint;
  60640. /**
  60641. * Babylon reference to the earcut plugin.
  60642. */
  60643. bjsEarcut: any;
  60644. /**
  60645. * Creates a PolygonMeshBuilder
  60646. * @param name name of the builder
  60647. * @param contours Path of the polygon
  60648. * @param scene scene to add to when creating the mesh
  60649. * @param earcutInjection can be used to inject your own earcut reference
  60650. */
  60651. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60652. /**
  60653. * Adds a whole within the polygon
  60654. * @param hole Array of points defining the hole
  60655. * @returns this
  60656. */
  60657. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60658. /**
  60659. * Creates the polygon
  60660. * @param updatable If the mesh should be updatable
  60661. * @param depth The depth of the mesh created
  60662. * @returns the created mesh
  60663. */
  60664. build(updatable?: boolean, depth?: number): Mesh;
  60665. /**
  60666. * Creates the polygon
  60667. * @param depth The depth of the mesh created
  60668. * @returns the created VertexData
  60669. */
  60670. buildVertexData(depth?: number): VertexData;
  60671. /**
  60672. * Adds a side to the polygon
  60673. * @param positions points that make the polygon
  60674. * @param normals normals of the polygon
  60675. * @param uvs uvs of the polygon
  60676. * @param indices indices of the polygon
  60677. * @param bounds bounds of the polygon
  60678. * @param points points of the polygon
  60679. * @param depth depth of the polygon
  60680. * @param flip flip of the polygon
  60681. */
  60682. private addSide;
  60683. }
  60684. }
  60685. declare module BABYLON {
  60686. /**
  60687. * Class containing static functions to help procedurally build meshes
  60688. */
  60689. export class PolygonBuilder {
  60690. /**
  60691. * Creates a polygon mesh
  60692. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60693. * * 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
  60694. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60696. * * 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)
  60697. * * Remember you can only change the shape positions, not their number when updating a polygon
  60698. * @param name defines the name of the mesh
  60699. * @param options defines the options used to create the mesh
  60700. * @param scene defines the hosting scene
  60701. * @param earcutInjection can be used to inject your own earcut reference
  60702. * @returns the polygon mesh
  60703. */
  60704. static CreatePolygon(name: string, options: {
  60705. shape: Vector3[];
  60706. holes?: Vector3[][];
  60707. depth?: number;
  60708. faceUV?: Vector4[];
  60709. faceColors?: Color4[];
  60710. updatable?: boolean;
  60711. sideOrientation?: number;
  60712. frontUVs?: Vector4;
  60713. backUVs?: Vector4;
  60714. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60715. /**
  60716. * Creates an extruded polygon mesh, with depth in the Y direction.
  60717. * * 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)
  60718. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60719. * @param name defines the name of the mesh
  60720. * @param options defines the options used to create the mesh
  60721. * @param scene defines the hosting scene
  60722. * @param earcutInjection can be used to inject your own earcut reference
  60723. * @returns the polygon mesh
  60724. */
  60725. static ExtrudePolygon(name: string, options: {
  60726. shape: Vector3[];
  60727. holes?: Vector3[][];
  60728. depth?: number;
  60729. faceUV?: Vector4[];
  60730. faceColors?: Color4[];
  60731. updatable?: boolean;
  60732. sideOrientation?: number;
  60733. frontUVs?: Vector4;
  60734. backUVs?: Vector4;
  60735. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60736. }
  60737. }
  60738. declare module BABYLON {
  60739. /**
  60740. * Class containing static functions to help procedurally build meshes
  60741. */
  60742. export class LatheBuilder {
  60743. /**
  60744. * Creates lathe mesh.
  60745. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60746. * * 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
  60747. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60748. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60749. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60750. * * 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
  60751. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60752. * * 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
  60753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60754. * * 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
  60755. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the lathe mesh
  60761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60762. */
  60763. static CreateLathe(name: string, options: {
  60764. shape: Vector3[];
  60765. radius?: number;
  60766. tessellation?: number;
  60767. clip?: number;
  60768. arc?: number;
  60769. closed?: boolean;
  60770. updatable?: boolean;
  60771. sideOrientation?: number;
  60772. frontUVs?: Vector4;
  60773. backUVs?: Vector4;
  60774. cap?: number;
  60775. invertUV?: boolean;
  60776. }, scene?: Nullable<Scene>): Mesh;
  60777. }
  60778. }
  60779. declare module BABYLON {
  60780. /**
  60781. * Class containing static functions to help procedurally build meshes
  60782. */
  60783. export class TiledPlaneBuilder {
  60784. /**
  60785. * Creates a tiled plane mesh
  60786. * * The parameter `pattern` will, depending on value, do nothing or
  60787. * * * flip (reflect about central vertical) alternate tiles across and up
  60788. * * * flip every tile on alternate rows
  60789. * * * rotate (180 degs) alternate tiles across and up
  60790. * * * rotate every tile on alternate rows
  60791. * * * flip and rotate alternate tiles across and up
  60792. * * * flip and rotate every tile on alternate rows
  60793. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60794. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60795. * * 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
  60796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60797. * * 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)
  60798. * * 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)
  60799. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60800. * @param name defines the name of the mesh
  60801. * @param options defines the options used to create the mesh
  60802. * @param scene defines the hosting scene
  60803. * @returns the box mesh
  60804. */
  60805. static CreateTiledPlane(name: string, options: {
  60806. pattern?: number;
  60807. tileSize?: number;
  60808. tileWidth?: number;
  60809. tileHeight?: number;
  60810. size?: number;
  60811. width?: number;
  60812. height?: number;
  60813. alignHorizontal?: number;
  60814. alignVertical?: number;
  60815. sideOrientation?: number;
  60816. frontUVs?: Vector4;
  60817. backUVs?: Vector4;
  60818. updatable?: boolean;
  60819. }, scene?: Nullable<Scene>): Mesh;
  60820. }
  60821. }
  60822. declare module BABYLON {
  60823. /**
  60824. * Class containing static functions to help procedurally build meshes
  60825. */
  60826. export class TubeBuilder {
  60827. /**
  60828. * Creates a tube mesh.
  60829. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60830. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60831. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60832. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60833. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60834. * * 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)
  60835. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60836. * * 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
  60837. * * 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
  60838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60839. * * 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
  60840. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60842. * @param name defines the name of the mesh
  60843. * @param options defines the options used to create the mesh
  60844. * @param scene defines the hosting scene
  60845. * @returns the tube mesh
  60846. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60847. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60848. */
  60849. static CreateTube(name: string, options: {
  60850. path: Vector3[];
  60851. radius?: number;
  60852. tessellation?: number;
  60853. radiusFunction?: {
  60854. (i: number, distance: number): number;
  60855. };
  60856. cap?: number;
  60857. arc?: number;
  60858. updatable?: boolean;
  60859. sideOrientation?: number;
  60860. frontUVs?: Vector4;
  60861. backUVs?: Vector4;
  60862. instance?: Mesh;
  60863. invertUV?: boolean;
  60864. }, scene?: Nullable<Scene>): Mesh;
  60865. }
  60866. }
  60867. declare module BABYLON {
  60868. /**
  60869. * Class containing static functions to help procedurally build meshes
  60870. */
  60871. export class IcoSphereBuilder {
  60872. /**
  60873. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60874. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60875. * * 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`)
  60876. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60877. * * 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
  60878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60879. * * 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
  60880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60881. * @param name defines the name of the mesh
  60882. * @param options defines the options used to create the mesh
  60883. * @param scene defines the hosting scene
  60884. * @returns the icosahedron mesh
  60885. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60886. */
  60887. static CreateIcoSphere(name: string, options: {
  60888. radius?: number;
  60889. radiusX?: number;
  60890. radiusY?: number;
  60891. radiusZ?: number;
  60892. flat?: boolean;
  60893. subdivisions?: number;
  60894. sideOrientation?: number;
  60895. frontUVs?: Vector4;
  60896. backUVs?: Vector4;
  60897. updatable?: boolean;
  60898. }, scene?: Nullable<Scene>): Mesh;
  60899. }
  60900. }
  60901. declare module BABYLON {
  60902. /**
  60903. * Class containing static functions to help procedurally build meshes
  60904. */
  60905. export class DecalBuilder {
  60906. /**
  60907. * Creates a decal mesh.
  60908. * 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
  60909. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60910. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60911. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60912. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60913. * @param name defines the name of the mesh
  60914. * @param sourceMesh defines the mesh where the decal must be applied
  60915. * @param options defines the options used to create the mesh
  60916. * @param scene defines the hosting scene
  60917. * @returns the decal mesh
  60918. * @see https://doc.babylonjs.com/how_to/decals
  60919. */
  60920. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60921. position?: Vector3;
  60922. normal?: Vector3;
  60923. size?: Vector3;
  60924. angle?: number;
  60925. }): Mesh;
  60926. }
  60927. }
  60928. declare module BABYLON {
  60929. /**
  60930. * Class containing static functions to help procedurally build meshes
  60931. */
  60932. export class MeshBuilder {
  60933. /**
  60934. * Creates a box mesh
  60935. * * The parameter `size` sets the size (float) of each box side (default 1)
  60936. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60937. * * 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)
  60938. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60940. * * 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
  60941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60942. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60943. * @param name defines the name of the mesh
  60944. * @param options defines the options used to create the mesh
  60945. * @param scene defines the hosting scene
  60946. * @returns the box mesh
  60947. */
  60948. static CreateBox(name: string, options: {
  60949. size?: number;
  60950. width?: number;
  60951. height?: number;
  60952. depth?: number;
  60953. faceUV?: Vector4[];
  60954. faceColors?: Color4[];
  60955. sideOrientation?: number;
  60956. frontUVs?: Vector4;
  60957. backUVs?: Vector4;
  60958. updatable?: boolean;
  60959. }, scene?: Nullable<Scene>): Mesh;
  60960. /**
  60961. * Creates a tiled box mesh
  60962. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60964. * @param name defines the name of the mesh
  60965. * @param options defines the options used to create the mesh
  60966. * @param scene defines the hosting scene
  60967. * @returns the tiled box mesh
  60968. */
  60969. static CreateTiledBox(name: string, options: {
  60970. pattern?: number;
  60971. size?: number;
  60972. width?: number;
  60973. height?: number;
  60974. depth: number;
  60975. tileSize?: number;
  60976. tileWidth?: number;
  60977. tileHeight?: number;
  60978. faceUV?: Vector4[];
  60979. faceColors?: Color4[];
  60980. alignHorizontal?: number;
  60981. alignVertical?: number;
  60982. sideOrientation?: number;
  60983. updatable?: boolean;
  60984. }, scene?: Nullable<Scene>): Mesh;
  60985. /**
  60986. * Creates a sphere mesh
  60987. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60988. * * 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`)
  60989. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60990. * * 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
  60991. * * 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)
  60992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60993. * * 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
  60994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60995. * @param name defines the name of the mesh
  60996. * @param options defines the options used to create the mesh
  60997. * @param scene defines the hosting scene
  60998. * @returns the sphere mesh
  60999. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61000. */
  61001. static CreateSphere(name: string, options: {
  61002. segments?: number;
  61003. diameter?: number;
  61004. diameterX?: number;
  61005. diameterY?: number;
  61006. diameterZ?: number;
  61007. arc?: number;
  61008. slice?: number;
  61009. sideOrientation?: number;
  61010. frontUVs?: Vector4;
  61011. backUVs?: Vector4;
  61012. updatable?: boolean;
  61013. }, scene?: Nullable<Scene>): Mesh;
  61014. /**
  61015. * Creates a plane polygonal mesh. By default, this is a disc
  61016. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61017. * * 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
  61018. * * 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
  61019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61020. * * 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
  61021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61022. * @param name defines the name of the mesh
  61023. * @param options defines the options used to create the mesh
  61024. * @param scene defines the hosting scene
  61025. * @returns the plane polygonal mesh
  61026. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61027. */
  61028. static CreateDisc(name: string, options: {
  61029. radius?: number;
  61030. tessellation?: number;
  61031. arc?: number;
  61032. updatable?: boolean;
  61033. sideOrientation?: number;
  61034. frontUVs?: Vector4;
  61035. backUVs?: Vector4;
  61036. }, scene?: Nullable<Scene>): Mesh;
  61037. /**
  61038. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61039. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61040. * * 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`)
  61041. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61042. * * 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
  61043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61044. * * 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
  61045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61046. * @param name defines the name of the mesh
  61047. * @param options defines the options used to create the mesh
  61048. * @param scene defines the hosting scene
  61049. * @returns the icosahedron mesh
  61050. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61051. */
  61052. static CreateIcoSphere(name: string, options: {
  61053. radius?: number;
  61054. radiusX?: number;
  61055. radiusY?: number;
  61056. radiusZ?: number;
  61057. flat?: boolean;
  61058. subdivisions?: number;
  61059. sideOrientation?: number;
  61060. frontUVs?: Vector4;
  61061. backUVs?: Vector4;
  61062. updatable?: boolean;
  61063. }, scene?: Nullable<Scene>): Mesh;
  61064. /**
  61065. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61066. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61067. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61068. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61069. * * 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
  61070. * * 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
  61071. * * 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
  61072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61073. * * 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
  61074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61075. * * 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
  61076. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61077. * * 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
  61078. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61080. * @param name defines the name of the mesh
  61081. * @param options defines the options used to create the mesh
  61082. * @param scene defines the hosting scene
  61083. * @returns the ribbon mesh
  61084. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61085. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61086. */
  61087. static CreateRibbon(name: string, options: {
  61088. pathArray: Vector3[][];
  61089. closeArray?: boolean;
  61090. closePath?: boolean;
  61091. offset?: number;
  61092. updatable?: boolean;
  61093. sideOrientation?: number;
  61094. frontUVs?: Vector4;
  61095. backUVs?: Vector4;
  61096. instance?: Mesh;
  61097. invertUV?: boolean;
  61098. uvs?: Vector2[];
  61099. colors?: Color4[];
  61100. }, scene?: Nullable<Scene>): Mesh;
  61101. /**
  61102. * Creates a cylinder or a cone mesh
  61103. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61104. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61105. * * 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.
  61106. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61107. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61108. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61109. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61110. * * 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).
  61111. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61112. * * 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).
  61113. * * 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
  61114. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61115. * * 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
  61116. * * 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.
  61117. * * If `enclose` is false, a ring surface is one element.
  61118. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61119. * * 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
  61120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61121. * * 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
  61122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61123. * @param name defines the name of the mesh
  61124. * @param options defines the options used to create the mesh
  61125. * @param scene defines the hosting scene
  61126. * @returns the cylinder mesh
  61127. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61128. */
  61129. static CreateCylinder(name: string, options: {
  61130. height?: number;
  61131. diameterTop?: number;
  61132. diameterBottom?: number;
  61133. diameter?: number;
  61134. tessellation?: number;
  61135. subdivisions?: number;
  61136. arc?: number;
  61137. faceColors?: Color4[];
  61138. faceUV?: Vector4[];
  61139. updatable?: boolean;
  61140. hasRings?: boolean;
  61141. enclose?: boolean;
  61142. cap?: number;
  61143. sideOrientation?: number;
  61144. frontUVs?: Vector4;
  61145. backUVs?: Vector4;
  61146. }, scene?: Nullable<Scene>): Mesh;
  61147. /**
  61148. * Creates a torus mesh
  61149. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61150. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61151. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61153. * * 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
  61154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61155. * @param name defines the name of the mesh
  61156. * @param options defines the options used to create the mesh
  61157. * @param scene defines the hosting scene
  61158. * @returns the torus mesh
  61159. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61160. */
  61161. static CreateTorus(name: string, options: {
  61162. diameter?: number;
  61163. thickness?: number;
  61164. tessellation?: number;
  61165. updatable?: boolean;
  61166. sideOrientation?: number;
  61167. frontUVs?: Vector4;
  61168. backUVs?: Vector4;
  61169. }, scene?: Nullable<Scene>): Mesh;
  61170. /**
  61171. * Creates a torus knot mesh
  61172. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61173. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61174. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61175. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61177. * * 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
  61178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61179. * @param name defines the name of the mesh
  61180. * @param options defines the options used to create the mesh
  61181. * @param scene defines the hosting scene
  61182. * @returns the torus knot mesh
  61183. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61184. */
  61185. static CreateTorusKnot(name: string, options: {
  61186. radius?: number;
  61187. tube?: number;
  61188. radialSegments?: number;
  61189. tubularSegments?: number;
  61190. p?: number;
  61191. q?: number;
  61192. updatable?: boolean;
  61193. sideOrientation?: number;
  61194. frontUVs?: Vector4;
  61195. backUVs?: Vector4;
  61196. }, scene?: Nullable<Scene>): Mesh;
  61197. /**
  61198. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61199. * * 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
  61200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61201. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61202. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61203. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61205. * * 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
  61206. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61209. * @param name defines the name of the new line system
  61210. * @param options defines the options used to create the line system
  61211. * @param scene defines the hosting scene
  61212. * @returns a new line system mesh
  61213. */
  61214. static CreateLineSystem(name: string, options: {
  61215. lines: Vector3[][];
  61216. updatable?: boolean;
  61217. instance?: Nullable<LinesMesh>;
  61218. colors?: Nullable<Color4[][]>;
  61219. useVertexAlpha?: boolean;
  61220. }, scene: Nullable<Scene>): LinesMesh;
  61221. /**
  61222. * Creates a line mesh
  61223. * 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
  61224. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61225. * * The parameter `points` is an array successive Vector3
  61226. * * 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
  61227. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61228. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61229. * * When updating an instance, remember that only point positions can change, not the number of points
  61230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61232. * @param name defines the name of the new line system
  61233. * @param options defines the options used to create the line system
  61234. * @param scene defines the hosting scene
  61235. * @returns a new line mesh
  61236. */
  61237. static CreateLines(name: string, options: {
  61238. points: Vector3[];
  61239. updatable?: boolean;
  61240. instance?: Nullable<LinesMesh>;
  61241. colors?: Color4[];
  61242. useVertexAlpha?: boolean;
  61243. }, scene?: Nullable<Scene>): LinesMesh;
  61244. /**
  61245. * Creates a dashed line mesh
  61246. * * 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
  61247. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61248. * * The parameter `points` is an array successive Vector3
  61249. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61250. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61251. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61252. * * 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
  61253. * * When updating an instance, remember that only point positions can change, not the number of points
  61254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61255. * @param name defines the name of the mesh
  61256. * @param options defines the options used to create the mesh
  61257. * @param scene defines the hosting scene
  61258. * @returns the dashed line mesh
  61259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61260. */
  61261. static CreateDashedLines(name: string, options: {
  61262. points: Vector3[];
  61263. dashSize?: number;
  61264. gapSize?: number;
  61265. dashNb?: number;
  61266. updatable?: boolean;
  61267. instance?: LinesMesh;
  61268. }, scene?: Nullable<Scene>): LinesMesh;
  61269. /**
  61270. * 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.
  61271. * * 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.
  61272. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61273. * * 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.
  61274. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61275. * * 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
  61276. * * 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
  61277. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61279. * * 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
  61280. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61282. * @param name defines the name of the mesh
  61283. * @param options defines the options used to create the mesh
  61284. * @param scene defines the hosting scene
  61285. * @returns the extruded shape mesh
  61286. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61288. */
  61289. static ExtrudeShape(name: string, options: {
  61290. shape: Vector3[];
  61291. path: Vector3[];
  61292. scale?: number;
  61293. rotation?: number;
  61294. cap?: number;
  61295. updatable?: boolean;
  61296. sideOrientation?: number;
  61297. frontUVs?: Vector4;
  61298. backUVs?: Vector4;
  61299. instance?: Mesh;
  61300. invertUV?: boolean;
  61301. }, scene?: Nullable<Scene>): Mesh;
  61302. /**
  61303. * Creates an custom extruded shape mesh.
  61304. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61305. * * 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.
  61306. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61307. * * 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
  61308. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61309. * * 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
  61310. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61311. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61312. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61313. * * 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
  61314. * * 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
  61315. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61320. * @param name defines the name of the mesh
  61321. * @param options defines the options used to create the mesh
  61322. * @param scene defines the hosting scene
  61323. * @returns the custom extruded shape mesh
  61324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61327. */
  61328. static ExtrudeShapeCustom(name: string, options: {
  61329. shape: Vector3[];
  61330. path: Vector3[];
  61331. scaleFunction?: any;
  61332. rotationFunction?: any;
  61333. ribbonCloseArray?: boolean;
  61334. ribbonClosePath?: boolean;
  61335. cap?: number;
  61336. updatable?: boolean;
  61337. sideOrientation?: number;
  61338. frontUVs?: Vector4;
  61339. backUVs?: Vector4;
  61340. instance?: Mesh;
  61341. invertUV?: boolean;
  61342. }, scene?: Nullable<Scene>): Mesh;
  61343. /**
  61344. * Creates lathe mesh.
  61345. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61346. * * 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
  61347. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61348. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61349. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61350. * * 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
  61351. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61352. * * 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
  61353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61354. * * 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
  61355. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61357. * @param name defines the name of the mesh
  61358. * @param options defines the options used to create the mesh
  61359. * @param scene defines the hosting scene
  61360. * @returns the lathe mesh
  61361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61362. */
  61363. static CreateLathe(name: string, options: {
  61364. shape: Vector3[];
  61365. radius?: number;
  61366. tessellation?: number;
  61367. clip?: number;
  61368. arc?: number;
  61369. closed?: boolean;
  61370. updatable?: boolean;
  61371. sideOrientation?: number;
  61372. frontUVs?: Vector4;
  61373. backUVs?: Vector4;
  61374. cap?: number;
  61375. invertUV?: boolean;
  61376. }, scene?: Nullable<Scene>): Mesh;
  61377. /**
  61378. * Creates a tiled plane mesh
  61379. * * You can set a limited pattern arrangement with the tiles
  61380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61383. * @param name defines the name of the mesh
  61384. * @param options defines the options used to create the mesh
  61385. * @param scene defines the hosting scene
  61386. * @returns the plane mesh
  61387. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61388. */
  61389. static CreateTiledPlane(name: string, options: {
  61390. pattern?: number;
  61391. tileSize?: number;
  61392. tileWidth?: number;
  61393. tileHeight?: number;
  61394. size?: number;
  61395. width?: number;
  61396. height?: number;
  61397. alignHorizontal?: number;
  61398. alignVertical?: number;
  61399. sideOrientation?: number;
  61400. frontUVs?: Vector4;
  61401. backUVs?: Vector4;
  61402. updatable?: boolean;
  61403. }, scene?: Nullable<Scene>): Mesh;
  61404. /**
  61405. * Creates a plane mesh
  61406. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61407. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61408. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61410. * * 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
  61411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61412. * @param name defines the name of the mesh
  61413. * @param options defines the options used to create the mesh
  61414. * @param scene defines the hosting scene
  61415. * @returns the plane mesh
  61416. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61417. */
  61418. static CreatePlane(name: string, options: {
  61419. size?: number;
  61420. width?: number;
  61421. height?: number;
  61422. sideOrientation?: number;
  61423. frontUVs?: Vector4;
  61424. backUVs?: Vector4;
  61425. updatable?: boolean;
  61426. sourcePlane?: Plane;
  61427. }, scene?: Nullable<Scene>): Mesh;
  61428. /**
  61429. * Creates a ground mesh
  61430. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61431. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61433. * @param name defines the name of the mesh
  61434. * @param options defines the options used to create the mesh
  61435. * @param scene defines the hosting scene
  61436. * @returns the ground mesh
  61437. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61438. */
  61439. static CreateGround(name: string, options: {
  61440. width?: number;
  61441. height?: number;
  61442. subdivisions?: number;
  61443. subdivisionsX?: number;
  61444. subdivisionsY?: number;
  61445. updatable?: boolean;
  61446. }, scene?: Nullable<Scene>): Mesh;
  61447. /**
  61448. * Creates a tiled ground mesh
  61449. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61450. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61451. * * 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
  61452. * * 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
  61453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61454. * @param name defines the name of the mesh
  61455. * @param options defines the options used to create the mesh
  61456. * @param scene defines the hosting scene
  61457. * @returns the tiled ground mesh
  61458. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61459. */
  61460. static CreateTiledGround(name: string, options: {
  61461. xmin: number;
  61462. zmin: number;
  61463. xmax: number;
  61464. zmax: number;
  61465. subdivisions?: {
  61466. w: number;
  61467. h: number;
  61468. };
  61469. precision?: {
  61470. w: number;
  61471. h: number;
  61472. };
  61473. updatable?: boolean;
  61474. }, scene?: Nullable<Scene>): Mesh;
  61475. /**
  61476. * Creates a ground mesh from a height map
  61477. * * The parameter `url` sets the URL of the height map image resource.
  61478. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61479. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61480. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61481. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61482. * * 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.
  61483. * * 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).
  61484. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61486. * @param name defines the name of the mesh
  61487. * @param url defines the url to the height map
  61488. * @param options defines the options used to create the mesh
  61489. * @param scene defines the hosting scene
  61490. * @returns the ground mesh
  61491. * @see https://doc.babylonjs.com/babylon101/height_map
  61492. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61493. */
  61494. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61495. width?: number;
  61496. height?: number;
  61497. subdivisions?: number;
  61498. minHeight?: number;
  61499. maxHeight?: number;
  61500. colorFilter?: Color3;
  61501. alphaFilter?: number;
  61502. updatable?: boolean;
  61503. onReady?: (mesh: GroundMesh) => void;
  61504. }, scene?: Nullable<Scene>): GroundMesh;
  61505. /**
  61506. * Creates a polygon mesh
  61507. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61508. * * 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
  61509. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61511. * * 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)
  61512. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  61517. * @returns the polygon mesh
  61518. */
  61519. static CreatePolygon(name: string, options: {
  61520. shape: Vector3[];
  61521. holes?: Vector3[][];
  61522. depth?: number;
  61523. faceUV?: Vector4[];
  61524. faceColors?: Color4[];
  61525. updatable?: boolean;
  61526. sideOrientation?: number;
  61527. frontUVs?: Vector4;
  61528. backUVs?: Vector4;
  61529. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61530. /**
  61531. * Creates an extruded polygon mesh, with depth in the Y direction.
  61532. * * 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)
  61533. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61534. * @param name defines the name of the mesh
  61535. * @param options defines the options used to create the mesh
  61536. * @param scene defines the hosting scene
  61537. * @param earcutInjection can be used to inject your own earcut reference
  61538. * @returns the polygon mesh
  61539. */
  61540. static ExtrudePolygon(name: string, options: {
  61541. shape: Vector3[];
  61542. holes?: Vector3[][];
  61543. depth?: number;
  61544. faceUV?: Vector4[];
  61545. faceColors?: Color4[];
  61546. updatable?: boolean;
  61547. sideOrientation?: number;
  61548. frontUVs?: Vector4;
  61549. backUVs?: Vector4;
  61550. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61551. /**
  61552. * Creates a tube mesh.
  61553. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61554. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61555. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61556. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61557. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61558. * * 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)
  61559. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61560. * * 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
  61561. * * 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
  61562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61563. * * 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
  61564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61566. * @param name defines the name of the mesh
  61567. * @param options defines the options used to create the mesh
  61568. * @param scene defines the hosting scene
  61569. * @returns the tube mesh
  61570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61571. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61572. */
  61573. static CreateTube(name: string, options: {
  61574. path: Vector3[];
  61575. radius?: number;
  61576. tessellation?: number;
  61577. radiusFunction?: {
  61578. (i: number, distance: number): number;
  61579. };
  61580. cap?: number;
  61581. arc?: number;
  61582. updatable?: boolean;
  61583. sideOrientation?: number;
  61584. frontUVs?: Vector4;
  61585. backUVs?: Vector4;
  61586. instance?: Mesh;
  61587. invertUV?: boolean;
  61588. }, scene?: Nullable<Scene>): Mesh;
  61589. /**
  61590. * Creates a polyhedron mesh
  61591. * * 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
  61592. * * The parameter `size` (positive float, default 1) sets the polygon size
  61593. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61594. * * 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`
  61595. * * 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
  61596. * * 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)`)
  61597. * * 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
  61598. * * 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
  61599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61600. * * 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
  61601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61602. * @param name defines the name of the mesh
  61603. * @param options defines the options used to create the mesh
  61604. * @param scene defines the hosting scene
  61605. * @returns the polyhedron mesh
  61606. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61607. */
  61608. static CreatePolyhedron(name: string, options: {
  61609. type?: number;
  61610. size?: number;
  61611. sizeX?: number;
  61612. sizeY?: number;
  61613. sizeZ?: number;
  61614. custom?: any;
  61615. faceUV?: Vector4[];
  61616. faceColors?: Color4[];
  61617. flat?: boolean;
  61618. updatable?: boolean;
  61619. sideOrientation?: number;
  61620. frontUVs?: Vector4;
  61621. backUVs?: Vector4;
  61622. }, scene?: Nullable<Scene>): Mesh;
  61623. /**
  61624. * Creates a decal mesh.
  61625. * 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
  61626. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61627. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61628. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61629. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61630. * @param name defines the name of the mesh
  61631. * @param sourceMesh defines the mesh where the decal must be applied
  61632. * @param options defines the options used to create the mesh
  61633. * @param scene defines the hosting scene
  61634. * @returns the decal mesh
  61635. * @see https://doc.babylonjs.com/how_to/decals
  61636. */
  61637. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61638. position?: Vector3;
  61639. normal?: Vector3;
  61640. size?: Vector3;
  61641. angle?: number;
  61642. }): Mesh;
  61643. }
  61644. }
  61645. declare module BABYLON {
  61646. /**
  61647. * A simplifier interface for future simplification implementations
  61648. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61649. */
  61650. export interface ISimplifier {
  61651. /**
  61652. * Simplification of a given mesh according to the given settings.
  61653. * Since this requires computation, it is assumed that the function runs async.
  61654. * @param settings The settings of the simplification, including quality and distance
  61655. * @param successCallback A callback that will be called after the mesh was simplified.
  61656. * @param errorCallback in case of an error, this callback will be called. optional.
  61657. */
  61658. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61659. }
  61660. /**
  61661. * Expected simplification settings.
  61662. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61663. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61664. */
  61665. export interface ISimplificationSettings {
  61666. /**
  61667. * Gets or sets the expected quality
  61668. */
  61669. quality: number;
  61670. /**
  61671. * Gets or sets the distance when this optimized version should be used
  61672. */
  61673. distance: number;
  61674. /**
  61675. * Gets an already optimized mesh
  61676. */
  61677. optimizeMesh?: boolean;
  61678. }
  61679. /**
  61680. * Class used to specify simplification options
  61681. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61682. */
  61683. export class SimplificationSettings implements ISimplificationSettings {
  61684. /** expected quality */
  61685. quality: number;
  61686. /** distance when this optimized version should be used */
  61687. distance: number;
  61688. /** already optimized mesh */
  61689. optimizeMesh?: boolean | undefined;
  61690. /**
  61691. * Creates a SimplificationSettings
  61692. * @param quality expected quality
  61693. * @param distance distance when this optimized version should be used
  61694. * @param optimizeMesh already optimized mesh
  61695. */
  61696. constructor(
  61697. /** expected quality */
  61698. quality: number,
  61699. /** distance when this optimized version should be used */
  61700. distance: number,
  61701. /** already optimized mesh */
  61702. optimizeMesh?: boolean | undefined);
  61703. }
  61704. /**
  61705. * Interface used to define a simplification task
  61706. */
  61707. export interface ISimplificationTask {
  61708. /**
  61709. * Array of settings
  61710. */
  61711. settings: Array<ISimplificationSettings>;
  61712. /**
  61713. * Simplification type
  61714. */
  61715. simplificationType: SimplificationType;
  61716. /**
  61717. * Mesh to simplify
  61718. */
  61719. mesh: Mesh;
  61720. /**
  61721. * Callback called on success
  61722. */
  61723. successCallback?: () => void;
  61724. /**
  61725. * Defines if parallel processing can be used
  61726. */
  61727. parallelProcessing: boolean;
  61728. }
  61729. /**
  61730. * Queue used to order the simplification tasks
  61731. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61732. */
  61733. export class SimplificationQueue {
  61734. private _simplificationArray;
  61735. /**
  61736. * Gets a boolean indicating that the process is still running
  61737. */
  61738. running: boolean;
  61739. /**
  61740. * Creates a new queue
  61741. */
  61742. constructor();
  61743. /**
  61744. * Adds a new simplification task
  61745. * @param task defines a task to add
  61746. */
  61747. addTask(task: ISimplificationTask): void;
  61748. /**
  61749. * Execute next task
  61750. */
  61751. executeNext(): void;
  61752. /**
  61753. * Execute a simplification task
  61754. * @param task defines the task to run
  61755. */
  61756. runSimplification(task: ISimplificationTask): void;
  61757. private getSimplifier;
  61758. }
  61759. /**
  61760. * The implemented types of simplification
  61761. * At the moment only Quadratic Error Decimation is implemented
  61762. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61763. */
  61764. export enum SimplificationType {
  61765. /** Quadratic error decimation */
  61766. QUADRATIC = 0
  61767. }
  61768. }
  61769. declare module BABYLON {
  61770. interface Scene {
  61771. /** @hidden (Backing field) */
  61772. _simplificationQueue: SimplificationQueue;
  61773. /**
  61774. * Gets or sets the simplification queue attached to the scene
  61775. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61776. */
  61777. simplificationQueue: SimplificationQueue;
  61778. }
  61779. interface Mesh {
  61780. /**
  61781. * Simplify the mesh according to the given array of settings.
  61782. * Function will return immediately and will simplify async
  61783. * @param settings a collection of simplification settings
  61784. * @param parallelProcessing should all levels calculate parallel or one after the other
  61785. * @param simplificationType the type of simplification to run
  61786. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61787. * @returns the current mesh
  61788. */
  61789. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61790. }
  61791. /**
  61792. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61793. * created in a scene
  61794. */
  61795. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61796. /**
  61797. * The component name helpfull to identify the component in the list of scene components.
  61798. */
  61799. readonly name: string;
  61800. /**
  61801. * The scene the component belongs to.
  61802. */
  61803. scene: Scene;
  61804. /**
  61805. * Creates a new instance of the component for the given scene
  61806. * @param scene Defines the scene to register the component in
  61807. */
  61808. constructor(scene: Scene);
  61809. /**
  61810. * Registers the component in a given scene
  61811. */
  61812. register(): void;
  61813. /**
  61814. * Rebuilds the elements related to this component in case of
  61815. * context lost for instance.
  61816. */
  61817. rebuild(): void;
  61818. /**
  61819. * Disposes the component and the associated ressources
  61820. */
  61821. dispose(): void;
  61822. private _beforeCameraUpdate;
  61823. }
  61824. }
  61825. declare module BABYLON {
  61826. /**
  61827. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61828. */
  61829. export interface INavigationEnginePlugin {
  61830. /**
  61831. * plugin name
  61832. */
  61833. name: string;
  61834. /**
  61835. * Creates a navigation mesh
  61836. * @param meshes array of all the geometry used to compute the navigatio mesh
  61837. * @param parameters bunch of parameters used to filter geometry
  61838. */
  61839. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61840. /**
  61841. * Create a navigation mesh debug mesh
  61842. * @param scene is where the mesh will be added
  61843. * @returns debug display mesh
  61844. */
  61845. createDebugNavMesh(scene: Scene): Mesh;
  61846. /**
  61847. * Get a navigation mesh constrained position, closest to the parameter position
  61848. * @param position world position
  61849. * @returns the closest point to position constrained by the navigation mesh
  61850. */
  61851. getClosestPoint(position: Vector3): Vector3;
  61852. /**
  61853. * Get a navigation mesh constrained position, within a particular radius
  61854. * @param position world position
  61855. * @param maxRadius the maximum distance to the constrained world position
  61856. * @returns the closest point to position constrained by the navigation mesh
  61857. */
  61858. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61859. /**
  61860. * Compute the final position from a segment made of destination-position
  61861. * @param position world position
  61862. * @param destination world position
  61863. * @returns the resulting point along the navmesh
  61864. */
  61865. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61866. /**
  61867. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61868. * @param start world position
  61869. * @param end world position
  61870. * @returns array containing world position composing the path
  61871. */
  61872. computePath(start: Vector3, end: Vector3): Vector3[];
  61873. /**
  61874. * If this plugin is supported
  61875. * @returns true if plugin is supported
  61876. */
  61877. isSupported(): boolean;
  61878. /**
  61879. * Create a new Crowd so you can add agents
  61880. * @param maxAgents the maximum agent count in the crowd
  61881. * @param maxAgentRadius the maximum radius an agent can have
  61882. * @param scene to attach the crowd to
  61883. * @returns the crowd you can add agents to
  61884. */
  61885. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61886. /**
  61887. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61888. * The queries will try to find a solution within those bounds
  61889. * default is (1,1,1)
  61890. * @param extent x,y,z value that define the extent around the queries point of reference
  61891. */
  61892. setDefaultQueryExtent(extent: Vector3): void;
  61893. /**
  61894. * Get the Bounding box extent specified by setDefaultQueryExtent
  61895. * @returns the box extent values
  61896. */
  61897. getDefaultQueryExtent(): Vector3;
  61898. /**
  61899. * Release all resources
  61900. */
  61901. dispose(): void;
  61902. }
  61903. /**
  61904. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61905. */
  61906. export interface ICrowd {
  61907. /**
  61908. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61909. * You can attach anything to that node. The node position is updated in the scene update tick.
  61910. * @param pos world position that will be constrained by the navigation mesh
  61911. * @param parameters agent parameters
  61912. * @param transform hooked to the agent that will be update by the scene
  61913. * @returns agent index
  61914. */
  61915. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61916. /**
  61917. * Returns the agent position in world space
  61918. * @param index agent index returned by addAgent
  61919. * @returns world space position
  61920. */
  61921. getAgentPosition(index: number): Vector3;
  61922. /**
  61923. * Gets the agent velocity in world space
  61924. * @param index agent index returned by addAgent
  61925. * @returns world space velocity
  61926. */
  61927. getAgentVelocity(index: number): Vector3;
  61928. /**
  61929. * remove a particular agent previously created
  61930. * @param index agent index returned by addAgent
  61931. */
  61932. removeAgent(index: number): void;
  61933. /**
  61934. * get the list of all agents attached to this crowd
  61935. * @returns list of agent indices
  61936. */
  61937. getAgents(): number[];
  61938. /**
  61939. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61940. * @param deltaTime in seconds
  61941. */
  61942. update(deltaTime: number): void;
  61943. /**
  61944. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61945. * @param index agent index returned by addAgent
  61946. * @param destination targeted world position
  61947. */
  61948. agentGoto(index: number, destination: Vector3): void;
  61949. /**
  61950. * Teleport the agent to a new position
  61951. * @param index agent index returned by addAgent
  61952. * @param destination targeted world position
  61953. */
  61954. agentTeleport(index: number, destination: Vector3): void;
  61955. /**
  61956. * Update agent parameters
  61957. * @param index agent index returned by addAgent
  61958. * @param parameters agent parameters
  61959. */
  61960. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  61961. /**
  61962. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61963. * The queries will try to find a solution within those bounds
  61964. * default is (1,1,1)
  61965. * @param extent x,y,z value that define the extent around the queries point of reference
  61966. */
  61967. setDefaultQueryExtent(extent: Vector3): void;
  61968. /**
  61969. * Get the Bounding box extent specified by setDefaultQueryExtent
  61970. * @returns the box extent values
  61971. */
  61972. getDefaultQueryExtent(): Vector3;
  61973. /**
  61974. * Release all resources
  61975. */
  61976. dispose(): void;
  61977. }
  61978. /**
  61979. * Configures an agent
  61980. */
  61981. export interface IAgentParameters {
  61982. /**
  61983. * Agent radius. [Limit: >= 0]
  61984. */
  61985. radius: number;
  61986. /**
  61987. * Agent height. [Limit: > 0]
  61988. */
  61989. height: number;
  61990. /**
  61991. * Maximum allowed acceleration. [Limit: >= 0]
  61992. */
  61993. maxAcceleration: number;
  61994. /**
  61995. * Maximum allowed speed. [Limit: >= 0]
  61996. */
  61997. maxSpeed: number;
  61998. /**
  61999. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62000. */
  62001. collisionQueryRange: number;
  62002. /**
  62003. * The path visibility optimization range. [Limit: > 0]
  62004. */
  62005. pathOptimizationRange: number;
  62006. /**
  62007. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62008. */
  62009. separationWeight: number;
  62010. }
  62011. /**
  62012. * Configures the navigation mesh creation
  62013. */
  62014. export interface INavMeshParameters {
  62015. /**
  62016. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62017. */
  62018. cs: number;
  62019. /**
  62020. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62021. */
  62022. ch: number;
  62023. /**
  62024. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62025. */
  62026. walkableSlopeAngle: number;
  62027. /**
  62028. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62029. * be considered walkable. [Limit: >= 3] [Units: vx]
  62030. */
  62031. walkableHeight: number;
  62032. /**
  62033. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62034. */
  62035. walkableClimb: number;
  62036. /**
  62037. * The distance to erode/shrink the walkable area of the heightfield away from
  62038. * obstructions. [Limit: >=0] [Units: vx]
  62039. */
  62040. walkableRadius: number;
  62041. /**
  62042. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62043. */
  62044. maxEdgeLen: number;
  62045. /**
  62046. * The maximum distance a simplfied contour's border edges should deviate
  62047. * the original raw contour. [Limit: >=0] [Units: vx]
  62048. */
  62049. maxSimplificationError: number;
  62050. /**
  62051. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62052. */
  62053. minRegionArea: number;
  62054. /**
  62055. * Any regions with a span count smaller than this value will, if possible,
  62056. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62057. */
  62058. mergeRegionArea: number;
  62059. /**
  62060. * The maximum number of vertices allowed for polygons generated during the
  62061. * contour to polygon conversion process. [Limit: >= 3]
  62062. */
  62063. maxVertsPerPoly: number;
  62064. /**
  62065. * Sets the sampling distance to use when generating the detail mesh.
  62066. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62067. */
  62068. detailSampleDist: number;
  62069. /**
  62070. * The maximum distance the detail mesh surface should deviate from heightfield
  62071. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62072. */
  62073. detailSampleMaxError: number;
  62074. }
  62075. }
  62076. declare module BABYLON {
  62077. /**
  62078. * RecastJS navigation plugin
  62079. */
  62080. export class RecastJSPlugin implements INavigationEnginePlugin {
  62081. /**
  62082. * Reference to the Recast library
  62083. */
  62084. bjsRECAST: any;
  62085. /**
  62086. * plugin name
  62087. */
  62088. name: string;
  62089. /**
  62090. * the first navmesh created. We might extend this to support multiple navmeshes
  62091. */
  62092. navMesh: any;
  62093. /**
  62094. * Initializes the recastJS plugin
  62095. * @param recastInjection can be used to inject your own recast reference
  62096. */
  62097. constructor(recastInjection?: any);
  62098. /**
  62099. * Creates a navigation mesh
  62100. * @param meshes array of all the geometry used to compute the navigatio mesh
  62101. * @param parameters bunch of parameters used to filter geometry
  62102. */
  62103. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62104. /**
  62105. * Create a navigation mesh debug mesh
  62106. * @param scene is where the mesh will be added
  62107. * @returns debug display mesh
  62108. */
  62109. createDebugNavMesh(scene: Scene): Mesh;
  62110. /**
  62111. * Get a navigation mesh constrained position, closest to the parameter position
  62112. * @param position world position
  62113. * @returns the closest point to position constrained by the navigation mesh
  62114. */
  62115. getClosestPoint(position: Vector3): Vector3;
  62116. /**
  62117. * Get a navigation mesh constrained position, within a particular radius
  62118. * @param position world position
  62119. * @param maxRadius the maximum distance to the constrained world position
  62120. * @returns the closest point to position constrained by the navigation mesh
  62121. */
  62122. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62123. /**
  62124. * Compute the final position from a segment made of destination-position
  62125. * @param position world position
  62126. * @param destination world position
  62127. * @returns the resulting point along the navmesh
  62128. */
  62129. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62130. /**
  62131. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62132. * @param start world position
  62133. * @param end world position
  62134. * @returns array containing world position composing the path
  62135. */
  62136. computePath(start: Vector3, end: Vector3): Vector3[];
  62137. /**
  62138. * Create a new Crowd so you can add agents
  62139. * @param maxAgents the maximum agent count in the crowd
  62140. * @param maxAgentRadius the maximum radius an agent can have
  62141. * @param scene to attach the crowd to
  62142. * @returns the crowd you can add agents to
  62143. */
  62144. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62145. /**
  62146. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62147. * The queries will try to find a solution within those bounds
  62148. * default is (1,1,1)
  62149. * @param extent x,y,z value that define the extent around the queries point of reference
  62150. */
  62151. setDefaultQueryExtent(extent: Vector3): void;
  62152. /**
  62153. * Get the Bounding box extent specified by setDefaultQueryExtent
  62154. * @returns the box extent values
  62155. */
  62156. getDefaultQueryExtent(): Vector3;
  62157. /**
  62158. * Disposes
  62159. */
  62160. dispose(): void;
  62161. /**
  62162. * If this plugin is supported
  62163. * @returns true if plugin is supported
  62164. */
  62165. isSupported(): boolean;
  62166. }
  62167. /**
  62168. * Recast detour crowd implementation
  62169. */
  62170. export class RecastJSCrowd implements ICrowd {
  62171. /**
  62172. * Recast/detour plugin
  62173. */
  62174. bjsRECASTPlugin: RecastJSPlugin;
  62175. /**
  62176. * Link to the detour crowd
  62177. */
  62178. recastCrowd: any;
  62179. /**
  62180. * One transform per agent
  62181. */
  62182. transforms: TransformNode[];
  62183. /**
  62184. * All agents created
  62185. */
  62186. agents: number[];
  62187. /**
  62188. * Link to the scene is kept to unregister the crowd from the scene
  62189. */
  62190. private _scene;
  62191. /**
  62192. * Observer for crowd updates
  62193. */
  62194. private _onBeforeAnimationsObserver;
  62195. /**
  62196. * Constructor
  62197. * @param plugin recastJS plugin
  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. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62204. /**
  62205. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62206. * You can attach anything to that node. The node position is updated in the scene update tick.
  62207. * @param pos world position that will be constrained by the navigation mesh
  62208. * @param parameters agent parameters
  62209. * @param transform hooked to the agent that will be update by the scene
  62210. * @returns agent index
  62211. */
  62212. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62213. /**
  62214. * Returns the agent position in world space
  62215. * @param index agent index returned by addAgent
  62216. * @returns world space position
  62217. */
  62218. getAgentPosition(index: number): Vector3;
  62219. /**
  62220. * Returns the agent velocity in world space
  62221. * @param index agent index returned by addAgent
  62222. * @returns world space velocity
  62223. */
  62224. getAgentVelocity(index: number): Vector3;
  62225. /**
  62226. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62227. * @param index agent index returned by addAgent
  62228. * @param destination targeted world position
  62229. */
  62230. agentGoto(index: number, destination: Vector3): void;
  62231. /**
  62232. * Teleport the agent to a new position
  62233. * @param index agent index returned by addAgent
  62234. * @param destination targeted world position
  62235. */
  62236. agentTeleport(index: number, destination: Vector3): void;
  62237. /**
  62238. * Update agent parameters
  62239. * @param index agent index returned by addAgent
  62240. * @param parameters agent parameters
  62241. */
  62242. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62243. /**
  62244. * remove a particular agent previously created
  62245. * @param index agent index returned by addAgent
  62246. */
  62247. removeAgent(index: number): void;
  62248. /**
  62249. * get the list of all agents attached to this crowd
  62250. * @returns list of agent indices
  62251. */
  62252. getAgents(): number[];
  62253. /**
  62254. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62255. * @param deltaTime in seconds
  62256. */
  62257. update(deltaTime: number): void;
  62258. /**
  62259. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62260. * The queries will try to find a solution within those bounds
  62261. * default is (1,1,1)
  62262. * @param extent x,y,z value that define the extent around the queries point of reference
  62263. */
  62264. setDefaultQueryExtent(extent: Vector3): void;
  62265. /**
  62266. * Get the Bounding box extent specified by setDefaultQueryExtent
  62267. * @returns the box extent values
  62268. */
  62269. getDefaultQueryExtent(): Vector3;
  62270. /**
  62271. * Release all resources
  62272. */
  62273. dispose(): void;
  62274. }
  62275. }
  62276. declare module BABYLON {
  62277. /**
  62278. * Class used to enable access to IndexedDB
  62279. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62280. */
  62281. export class Database implements IOfflineProvider {
  62282. private _callbackManifestChecked;
  62283. private _currentSceneUrl;
  62284. private _db;
  62285. private _enableSceneOffline;
  62286. private _enableTexturesOffline;
  62287. private _manifestVersionFound;
  62288. private _mustUpdateRessources;
  62289. private _hasReachedQuota;
  62290. private _isSupported;
  62291. private _idbFactory;
  62292. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62293. private static IsUASupportingBlobStorage;
  62294. /**
  62295. * Gets a boolean indicating if Database storate is enabled (off by default)
  62296. */
  62297. static IDBStorageEnabled: boolean;
  62298. /**
  62299. * Gets a boolean indicating if scene must be saved in the database
  62300. */
  62301. get enableSceneOffline(): boolean;
  62302. /**
  62303. * Gets a boolean indicating if textures must be saved in the database
  62304. */
  62305. get enableTexturesOffline(): boolean;
  62306. /**
  62307. * Creates a new Database
  62308. * @param urlToScene defines the url to load the scene
  62309. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62310. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62311. */
  62312. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62313. private static _ParseURL;
  62314. private static _ReturnFullUrlLocation;
  62315. private _checkManifestFile;
  62316. /**
  62317. * Open the database and make it available
  62318. * @param successCallback defines the callback to call on success
  62319. * @param errorCallback defines the callback to call on error
  62320. */
  62321. open(successCallback: () => void, errorCallback: () => void): void;
  62322. /**
  62323. * Loads an image from the database
  62324. * @param url defines the url to load from
  62325. * @param image defines the target DOM image
  62326. */
  62327. loadImage(url: string, image: HTMLImageElement): void;
  62328. private _loadImageFromDBAsync;
  62329. private _saveImageIntoDBAsync;
  62330. private _checkVersionFromDB;
  62331. private _loadVersionFromDBAsync;
  62332. private _saveVersionIntoDBAsync;
  62333. /**
  62334. * Loads a file from database
  62335. * @param url defines the URL to load from
  62336. * @param sceneLoaded defines a callback to call on success
  62337. * @param progressCallBack defines a callback to call when progress changed
  62338. * @param errorCallback defines a callback to call on error
  62339. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62340. */
  62341. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62342. private _loadFileAsync;
  62343. private _saveFileAsync;
  62344. /**
  62345. * Validates if xhr data is correct
  62346. * @param xhr defines the request to validate
  62347. * @param dataType defines the expected data type
  62348. * @returns true if data is correct
  62349. */
  62350. private static _ValidateXHRData;
  62351. }
  62352. }
  62353. declare module BABYLON {
  62354. /** @hidden */
  62355. export var gpuUpdateParticlesPixelShader: {
  62356. name: string;
  62357. shader: string;
  62358. };
  62359. }
  62360. declare module BABYLON {
  62361. /** @hidden */
  62362. export var gpuUpdateParticlesVertexShader: {
  62363. name: string;
  62364. shader: string;
  62365. };
  62366. }
  62367. declare module BABYLON {
  62368. /** @hidden */
  62369. export var clipPlaneFragmentDeclaration2: {
  62370. name: string;
  62371. shader: string;
  62372. };
  62373. }
  62374. declare module BABYLON {
  62375. /** @hidden */
  62376. export var gpuRenderParticlesPixelShader: {
  62377. name: string;
  62378. shader: string;
  62379. };
  62380. }
  62381. declare module BABYLON {
  62382. /** @hidden */
  62383. export var clipPlaneVertexDeclaration2: {
  62384. name: string;
  62385. shader: string;
  62386. };
  62387. }
  62388. declare module BABYLON {
  62389. /** @hidden */
  62390. export var gpuRenderParticlesVertexShader: {
  62391. name: string;
  62392. shader: string;
  62393. };
  62394. }
  62395. declare module BABYLON {
  62396. /**
  62397. * This represents a GPU particle system in Babylon
  62398. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62399. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62400. */
  62401. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62402. /**
  62403. * The layer mask we are rendering the particles through.
  62404. */
  62405. layerMask: number;
  62406. private _capacity;
  62407. private _activeCount;
  62408. private _currentActiveCount;
  62409. private _accumulatedCount;
  62410. private _renderEffect;
  62411. private _updateEffect;
  62412. private _buffer0;
  62413. private _buffer1;
  62414. private _spriteBuffer;
  62415. private _updateVAO;
  62416. private _renderVAO;
  62417. private _targetIndex;
  62418. private _sourceBuffer;
  62419. private _targetBuffer;
  62420. private _engine;
  62421. private _currentRenderId;
  62422. private _started;
  62423. private _stopped;
  62424. private _timeDelta;
  62425. private _randomTexture;
  62426. private _randomTexture2;
  62427. private _attributesStrideSize;
  62428. private _updateEffectOptions;
  62429. private _randomTextureSize;
  62430. private _actualFrame;
  62431. private readonly _rawTextureWidth;
  62432. /**
  62433. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62434. */
  62435. static get IsSupported(): boolean;
  62436. /**
  62437. * An event triggered when the system is disposed.
  62438. */
  62439. onDisposeObservable: Observable<GPUParticleSystem>;
  62440. /**
  62441. * Gets the maximum number of particles active at the same time.
  62442. * @returns The max number of active particles.
  62443. */
  62444. getCapacity(): number;
  62445. /**
  62446. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62447. * to override the particles.
  62448. */
  62449. forceDepthWrite: boolean;
  62450. /**
  62451. * Gets or set the number of active particles
  62452. */
  62453. get activeParticleCount(): number;
  62454. set activeParticleCount(value: number);
  62455. private _preWarmDone;
  62456. /**
  62457. * Specifies if the particles are updated in emitter local space or world space.
  62458. * This is always false for GPU particles
  62459. */
  62460. get isLocal(): boolean;
  62461. set isLocal(value: boolean);
  62462. /**
  62463. * Is this system ready to be used/rendered
  62464. * @return true if the system is ready
  62465. */
  62466. isReady(): boolean;
  62467. /**
  62468. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62469. * @returns True if it has been started, otherwise false.
  62470. */
  62471. isStarted(): boolean;
  62472. /**
  62473. * Starts the particle system and begins to emit
  62474. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62475. */
  62476. start(delay?: number): void;
  62477. /**
  62478. * Stops the particle system.
  62479. */
  62480. stop(): void;
  62481. /**
  62482. * Remove all active particles
  62483. */
  62484. reset(): void;
  62485. /**
  62486. * Returns the string "GPUParticleSystem"
  62487. * @returns a string containing the class name
  62488. */
  62489. getClassName(): string;
  62490. private _colorGradientsTexture;
  62491. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62492. /**
  62493. * Adds a new color gradient
  62494. * @param gradient defines the gradient to use (between 0 and 1)
  62495. * @param color1 defines the color to affect to the specified gradient
  62496. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62497. * @returns the current particle system
  62498. */
  62499. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62500. /**
  62501. * Remove a specific color gradient
  62502. * @param gradient defines the gradient to remove
  62503. * @returns the current particle system
  62504. */
  62505. removeColorGradient(gradient: number): GPUParticleSystem;
  62506. private _angularSpeedGradientsTexture;
  62507. private _sizeGradientsTexture;
  62508. private _velocityGradientsTexture;
  62509. private _limitVelocityGradientsTexture;
  62510. private _dragGradientsTexture;
  62511. private _addFactorGradient;
  62512. /**
  62513. * Adds a new size gradient
  62514. * @param gradient defines the gradient to use (between 0 and 1)
  62515. * @param factor defines the size factor to affect to the specified gradient
  62516. * @returns the current particle system
  62517. */
  62518. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62519. /**
  62520. * Remove a specific size gradient
  62521. * @param gradient defines the gradient to remove
  62522. * @returns the current particle system
  62523. */
  62524. removeSizeGradient(gradient: number): GPUParticleSystem;
  62525. /**
  62526. * Adds a new angular speed gradient
  62527. * @param gradient defines the gradient to use (between 0 and 1)
  62528. * @param factor defines the angular speed to affect to the specified gradient
  62529. * @returns the current particle system
  62530. */
  62531. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62532. /**
  62533. * Remove a specific angular speed gradient
  62534. * @param gradient defines the gradient to remove
  62535. * @returns the current particle system
  62536. */
  62537. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62538. /**
  62539. * Adds a new velocity gradient
  62540. * @param gradient defines the gradient to use (between 0 and 1)
  62541. * @param factor defines the velocity to affect to the specified gradient
  62542. * @returns the current particle system
  62543. */
  62544. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62545. /**
  62546. * Remove a specific velocity gradient
  62547. * @param gradient defines the gradient to remove
  62548. * @returns the current particle system
  62549. */
  62550. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62551. /**
  62552. * Adds a new limit velocity gradient
  62553. * @param gradient defines the gradient to use (between 0 and 1)
  62554. * @param factor defines the limit velocity value to affect to the specified gradient
  62555. * @returns the current particle system
  62556. */
  62557. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62558. /**
  62559. * Remove a specific limit velocity gradient
  62560. * @param gradient defines the gradient to remove
  62561. * @returns the current particle system
  62562. */
  62563. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62564. /**
  62565. * Adds a new drag gradient
  62566. * @param gradient defines the gradient to use (between 0 and 1)
  62567. * @param factor defines the drag value to affect to the specified gradient
  62568. * @returns the current particle system
  62569. */
  62570. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62571. /**
  62572. * Remove a specific drag gradient
  62573. * @param gradient defines the gradient to remove
  62574. * @returns the current particle system
  62575. */
  62576. removeDragGradient(gradient: number): GPUParticleSystem;
  62577. /**
  62578. * Not supported by GPUParticleSystem
  62579. * @param gradient defines the gradient to use (between 0 and 1)
  62580. * @param factor defines the emit rate value to affect to the specified gradient
  62581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62582. * @returns the current particle system
  62583. */
  62584. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62585. /**
  62586. * Not supported by GPUParticleSystem
  62587. * @param gradient defines the gradient to remove
  62588. * @returns the current particle system
  62589. */
  62590. removeEmitRateGradient(gradient: number): IParticleSystem;
  62591. /**
  62592. * Not supported by GPUParticleSystem
  62593. * @param gradient defines the gradient to use (between 0 and 1)
  62594. * @param factor defines the start size value to affect to the specified gradient
  62595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62596. * @returns the current particle system
  62597. */
  62598. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62599. /**
  62600. * Not supported by GPUParticleSystem
  62601. * @param gradient defines the gradient to remove
  62602. * @returns the current particle system
  62603. */
  62604. removeStartSizeGradient(gradient: number): IParticleSystem;
  62605. /**
  62606. * Not supported by GPUParticleSystem
  62607. * @param gradient defines the gradient to use (between 0 and 1)
  62608. * @param min defines the color remap minimal range
  62609. * @param max defines the color remap maximal range
  62610. * @returns the current particle system
  62611. */
  62612. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62613. /**
  62614. * Not supported by GPUParticleSystem
  62615. * @param gradient defines the gradient to remove
  62616. * @returns the current particle system
  62617. */
  62618. removeColorRemapGradient(): IParticleSystem;
  62619. /**
  62620. * Not supported by GPUParticleSystem
  62621. * @param gradient defines the gradient to use (between 0 and 1)
  62622. * @param min defines the alpha remap minimal range
  62623. * @param max defines the alpha remap maximal range
  62624. * @returns the current particle system
  62625. */
  62626. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62627. /**
  62628. * Not supported by GPUParticleSystem
  62629. * @param gradient defines the gradient to remove
  62630. * @returns the current particle system
  62631. */
  62632. removeAlphaRemapGradient(): IParticleSystem;
  62633. /**
  62634. * Not supported by GPUParticleSystem
  62635. * @param gradient defines the gradient to use (between 0 and 1)
  62636. * @param color defines the color to affect to the specified gradient
  62637. * @returns the current particle system
  62638. */
  62639. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62640. /**
  62641. * Not supported by GPUParticleSystem
  62642. * @param gradient defines the gradient to remove
  62643. * @returns the current particle system
  62644. */
  62645. removeRampGradient(): IParticleSystem;
  62646. /**
  62647. * Not supported by GPUParticleSystem
  62648. * @returns the list of ramp gradients
  62649. */
  62650. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62651. /**
  62652. * Not supported by GPUParticleSystem
  62653. * Gets or sets a boolean indicating that ramp gradients must be used
  62654. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62655. */
  62656. get useRampGradients(): boolean;
  62657. set useRampGradients(value: boolean);
  62658. /**
  62659. * Not supported by GPUParticleSystem
  62660. * @param gradient defines the gradient to use (between 0 and 1)
  62661. * @param factor defines the life time factor to affect to the specified gradient
  62662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62663. * @returns the current particle system
  62664. */
  62665. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62666. /**
  62667. * Not supported by GPUParticleSystem
  62668. * @param gradient defines the gradient to remove
  62669. * @returns the current particle system
  62670. */
  62671. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62672. /**
  62673. * Instantiates a GPU particle system.
  62674. * 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.
  62675. * @param name The name of the particle system
  62676. * @param options The options used to create the system
  62677. * @param scene The scene the particle system belongs to
  62678. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62679. */
  62680. constructor(name: string, options: Partial<{
  62681. capacity: number;
  62682. randomTextureSize: number;
  62683. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62684. protected _reset(): void;
  62685. private _createUpdateVAO;
  62686. private _createRenderVAO;
  62687. private _initialize;
  62688. /** @hidden */
  62689. _recreateUpdateEffect(): void;
  62690. /** @hidden */
  62691. _recreateRenderEffect(): void;
  62692. /**
  62693. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62694. * @param preWarm defines if we are in the pre-warmimg phase
  62695. */
  62696. animate(preWarm?: boolean): void;
  62697. private _createFactorGradientTexture;
  62698. private _createSizeGradientTexture;
  62699. private _createAngularSpeedGradientTexture;
  62700. private _createVelocityGradientTexture;
  62701. private _createLimitVelocityGradientTexture;
  62702. private _createDragGradientTexture;
  62703. private _createColorGradientTexture;
  62704. /**
  62705. * Renders the particle system in its current state
  62706. * @param preWarm defines if the system should only update the particles but not render them
  62707. * @returns the current number of particles
  62708. */
  62709. render(preWarm?: boolean): number;
  62710. /**
  62711. * Rebuilds the particle system
  62712. */
  62713. rebuild(): void;
  62714. private _releaseBuffers;
  62715. private _releaseVAOs;
  62716. /**
  62717. * Disposes the particle system and free the associated resources
  62718. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62719. */
  62720. dispose(disposeTexture?: boolean): void;
  62721. /**
  62722. * Clones the particle system.
  62723. * @param name The name of the cloned object
  62724. * @param newEmitter The new emitter to use
  62725. * @returns the cloned particle system
  62726. */
  62727. clone(name: string, newEmitter: any): GPUParticleSystem;
  62728. /**
  62729. * Serializes the particle system to a JSON object.
  62730. * @returns the JSON object
  62731. */
  62732. serialize(): any;
  62733. /**
  62734. * Parses a JSON object to create a GPU particle system.
  62735. * @param parsedParticleSystem The JSON object to parse
  62736. * @param scene The scene to create the particle system in
  62737. * @param rootUrl The root url to use to load external dependencies like texture
  62738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62739. * @returns the parsed GPU particle system
  62740. */
  62741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62742. }
  62743. }
  62744. declare module BABYLON {
  62745. /**
  62746. * Represents a set of particle systems working together to create a specific effect
  62747. */
  62748. export class ParticleSystemSet implements IDisposable {
  62749. /**
  62750. * Gets or sets base Assets URL
  62751. */
  62752. static BaseAssetsUrl: string;
  62753. private _emitterCreationOptions;
  62754. private _emitterNode;
  62755. /**
  62756. * Gets the particle system list
  62757. */
  62758. systems: IParticleSystem[];
  62759. /**
  62760. * Gets the emitter node used with this set
  62761. */
  62762. get emitterNode(): Nullable<TransformNode>;
  62763. /**
  62764. * Creates a new emitter mesh as a sphere
  62765. * @param options defines the options used to create the sphere
  62766. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62767. * @param scene defines the hosting scene
  62768. */
  62769. setEmitterAsSphere(options: {
  62770. diameter: number;
  62771. segments: number;
  62772. color: Color3;
  62773. }, renderingGroupId: number, scene: Scene): void;
  62774. /**
  62775. * Starts all particle systems of the set
  62776. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62777. */
  62778. start(emitter?: AbstractMesh): void;
  62779. /**
  62780. * Release all associated resources
  62781. */
  62782. dispose(): void;
  62783. /**
  62784. * Serialize the set into a JSON compatible object
  62785. * @returns a JSON compatible representation of the set
  62786. */
  62787. serialize(): any;
  62788. /**
  62789. * Parse a new ParticleSystemSet from a serialized source
  62790. * @param data defines a JSON compatible representation of the set
  62791. * @param scene defines the hosting scene
  62792. * @param gpu defines if we want GPU particles or CPU particles
  62793. * @returns a new ParticleSystemSet
  62794. */
  62795. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62796. }
  62797. }
  62798. declare module BABYLON {
  62799. /**
  62800. * This class is made for on one-liner static method to help creating particle system set.
  62801. */
  62802. export class ParticleHelper {
  62803. /**
  62804. * Gets or sets base Assets URL
  62805. */
  62806. static BaseAssetsUrl: string;
  62807. /**
  62808. * Create a default particle system that you can tweak
  62809. * @param emitter defines the emitter to use
  62810. * @param capacity defines the system capacity (default is 500 particles)
  62811. * @param scene defines the hosting scene
  62812. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62813. * @returns the new Particle system
  62814. */
  62815. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62816. /**
  62817. * This is the main static method (one-liner) of this helper to create different particle systems
  62818. * @param type This string represents the type to the particle system to create
  62819. * @param scene The scene where the particle system should live
  62820. * @param gpu If the system will use gpu
  62821. * @returns the ParticleSystemSet created
  62822. */
  62823. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62824. /**
  62825. * Static function used to export a particle system to a ParticleSystemSet variable.
  62826. * Please note that the emitter shape is not exported
  62827. * @param systems defines the particle systems to export
  62828. * @returns the created particle system set
  62829. */
  62830. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62831. }
  62832. }
  62833. declare module BABYLON {
  62834. interface Engine {
  62835. /**
  62836. * Create an effect to use with particle systems.
  62837. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62838. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62839. * @param uniformsNames defines a list of attribute names
  62840. * @param samplers defines an array of string used to represent textures
  62841. * @param defines defines the string containing the defines to use to compile the shaders
  62842. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62843. * @param onCompiled defines a function to call when the effect creation is successful
  62844. * @param onError defines a function to call when the effect creation has failed
  62845. * @returns the new Effect
  62846. */
  62847. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62848. }
  62849. interface Mesh {
  62850. /**
  62851. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62852. * @returns an array of IParticleSystem
  62853. */
  62854. getEmittedParticleSystems(): IParticleSystem[];
  62855. /**
  62856. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62857. * @returns an array of IParticleSystem
  62858. */
  62859. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62860. }
  62861. /**
  62862. * @hidden
  62863. */
  62864. export var _IDoNeedToBeInTheBuild: number;
  62865. }
  62866. declare module BABYLON {
  62867. /** Defines the 4 color options */
  62868. export enum PointColor {
  62869. /** color value */
  62870. Color = 2,
  62871. /** uv value */
  62872. UV = 1,
  62873. /** random value */
  62874. Random = 0,
  62875. /** stated value */
  62876. Stated = 3
  62877. }
  62878. /**
  62879. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62880. * 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.
  62881. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62882. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62883. *
  62884. * Full documentation here : TO BE ENTERED
  62885. */
  62886. export class PointsCloudSystem implements IDisposable {
  62887. /**
  62888. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62889. * Example : var p = SPS.particles[i];
  62890. */
  62891. particles: CloudPoint[];
  62892. /**
  62893. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62894. */
  62895. nbParticles: number;
  62896. /**
  62897. * This a counter for your own usage. It's not set by any SPS functions.
  62898. */
  62899. counter: number;
  62900. /**
  62901. * The PCS name. This name is also given to the underlying mesh.
  62902. */
  62903. name: string;
  62904. /**
  62905. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62906. */
  62907. mesh: Mesh;
  62908. /**
  62909. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62910. * Please read :
  62911. */
  62912. vars: any;
  62913. /**
  62914. * @hidden
  62915. */
  62916. _size: number;
  62917. private _scene;
  62918. private _promises;
  62919. private _positions;
  62920. private _indices;
  62921. private _normals;
  62922. private _colors;
  62923. private _uvs;
  62924. private _indices32;
  62925. private _positions32;
  62926. private _colors32;
  62927. private _uvs32;
  62928. private _updatable;
  62929. private _isVisibilityBoxLocked;
  62930. private _alwaysVisible;
  62931. private _groups;
  62932. private _groupCounter;
  62933. private _computeParticleColor;
  62934. private _computeParticleTexture;
  62935. private _computeParticleRotation;
  62936. private _computeBoundingBox;
  62937. private _isReady;
  62938. /**
  62939. * Creates a PCS (Points Cloud System) object
  62940. * @param name (String) is the PCS name, this will be the underlying mesh name
  62941. * @param pointSize (number) is the size for each point
  62942. * @param scene (Scene) is the scene in which the PCS is added
  62943. * @param options defines the options of the PCS e.g.
  62944. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62945. */
  62946. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62947. updatable?: boolean;
  62948. });
  62949. /**
  62950. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62951. * If no points were added to the PCS, the returned mesh is just a single point.
  62952. * @returns a promise for the created mesh
  62953. */
  62954. buildMeshAsync(): Promise<Mesh>;
  62955. /**
  62956. * @hidden
  62957. */
  62958. private _buildMesh;
  62959. private _addParticle;
  62960. private _randomUnitVector;
  62961. private _getColorIndicesForCoord;
  62962. private _setPointsColorOrUV;
  62963. private _colorFromTexture;
  62964. private _calculateDensity;
  62965. /**
  62966. * Adds points to the PCS in random positions within a unit sphere
  62967. * @param nb (positive integer) the number of particles to be created from this model
  62968. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62969. * @returns the number of groups in the system
  62970. */
  62971. addPoints(nb: number, pointFunction?: any): number;
  62972. /**
  62973. * Adds points to the PCS from the surface of the model shape
  62974. * @param mesh is any Mesh object that will be used as a surface model for the points
  62975. * @param nb (positive integer) the number of particles to be created from this model
  62976. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62977. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62978. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62979. * @returns the number of groups in the system
  62980. */
  62981. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62982. /**
  62983. * Adds points to the PCS inside the model shape
  62984. * @param mesh is any Mesh object that will be used as a surface model for the points
  62985. * @param nb (positive integer) the number of particles to be created from this model
  62986. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62987. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62988. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62989. * @returns the number of groups in the system
  62990. */
  62991. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62992. /**
  62993. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62994. * This method calls `updateParticle()` for each particle of the SPS.
  62995. * For an animated SPS, it is usually called within the render loop.
  62996. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62997. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62998. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62999. * @returns the PCS.
  63000. */
  63001. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63002. /**
  63003. * Disposes the PCS.
  63004. */
  63005. dispose(): void;
  63006. /**
  63007. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63008. * doc :
  63009. * @returns the PCS.
  63010. */
  63011. refreshVisibleSize(): PointsCloudSystem;
  63012. /**
  63013. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63014. * @param size the size (float) of the visibility box
  63015. * note : this doesn't lock the PCS mesh bounding box.
  63016. * doc :
  63017. */
  63018. setVisibilityBox(size: number): void;
  63019. /**
  63020. * Gets whether the PCS is always visible or not
  63021. * doc :
  63022. */
  63023. get isAlwaysVisible(): boolean;
  63024. /**
  63025. * Sets the PCS as always visible or not
  63026. * doc :
  63027. */
  63028. set isAlwaysVisible(val: boolean);
  63029. /**
  63030. * Tells to `setParticles()` to compute the particle rotations or not
  63031. * Default value : false. The PCS is faster when it's set to false
  63032. * Note : particle rotations are only applied to parent particles
  63033. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63034. */
  63035. set computeParticleRotation(val: boolean);
  63036. /**
  63037. * Tells to `setParticles()` to compute the particle colors or not.
  63038. * Default value : true. The PCS is faster when it's set to false.
  63039. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63040. */
  63041. set computeParticleColor(val: boolean);
  63042. set computeParticleTexture(val: boolean);
  63043. /**
  63044. * Gets if `setParticles()` computes the particle colors or not.
  63045. * Default value : false. The PCS is faster when it's set to false.
  63046. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63047. */
  63048. get computeParticleColor(): boolean;
  63049. /**
  63050. * Gets if `setParticles()` computes the particle textures or not.
  63051. * Default value : false. The PCS is faster when it's set to false.
  63052. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63053. */
  63054. get computeParticleTexture(): boolean;
  63055. /**
  63056. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63057. */
  63058. set computeBoundingBox(val: boolean);
  63059. /**
  63060. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63061. */
  63062. get computeBoundingBox(): boolean;
  63063. /**
  63064. * This function does nothing. It may be overwritten to set all the particle first values.
  63065. * The PCS doesn't call this function, you may have to call it by your own.
  63066. * doc :
  63067. */
  63068. initParticles(): void;
  63069. /**
  63070. * This function does nothing. It may be overwritten to recycle a particle
  63071. * The PCS doesn't call this function, you can to call it
  63072. * doc :
  63073. * @param particle The particle to recycle
  63074. * @returns the recycled particle
  63075. */
  63076. recycleParticle(particle: CloudPoint): CloudPoint;
  63077. /**
  63078. * Updates a particle : this function should be overwritten by the user.
  63079. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63080. * doc :
  63081. * @example : just set a particle position or velocity and recycle conditions
  63082. * @param particle The particle to update
  63083. * @returns the updated particle
  63084. */
  63085. updateParticle(particle: CloudPoint): CloudPoint;
  63086. /**
  63087. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63088. * This does nothing and may be overwritten by the user.
  63089. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63090. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63091. * @param update the boolean update value actually passed to setParticles()
  63092. */
  63093. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63094. /**
  63095. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63096. * This will be passed three parameters.
  63097. * This does nothing and may be overwritten by the user.
  63098. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63099. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63100. * @param update the boolean update value actually passed to setParticles()
  63101. */
  63102. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63103. }
  63104. }
  63105. declare module BABYLON {
  63106. /**
  63107. * Represents one particle of a points cloud system.
  63108. */
  63109. export class CloudPoint {
  63110. /**
  63111. * particle global index
  63112. */
  63113. idx: number;
  63114. /**
  63115. * The color of the particle
  63116. */
  63117. color: Nullable<Color4>;
  63118. /**
  63119. * The world space position of the particle.
  63120. */
  63121. position: Vector3;
  63122. /**
  63123. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63124. */
  63125. rotation: Vector3;
  63126. /**
  63127. * The world space rotation quaternion of the particle.
  63128. */
  63129. rotationQuaternion: Nullable<Quaternion>;
  63130. /**
  63131. * The uv of the particle.
  63132. */
  63133. uv: Nullable<Vector2>;
  63134. /**
  63135. * The current speed of the particle.
  63136. */
  63137. velocity: Vector3;
  63138. /**
  63139. * The pivot point in the particle local space.
  63140. */
  63141. pivot: Vector3;
  63142. /**
  63143. * Must the particle be translated from its pivot point in its local space ?
  63144. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63145. * Default : false
  63146. */
  63147. translateFromPivot: boolean;
  63148. /**
  63149. * Index of this particle in the global "positions" array (Internal use)
  63150. * @hidden
  63151. */
  63152. _pos: number;
  63153. /**
  63154. * @hidden Index of this particle in the global "indices" array (Internal use)
  63155. */
  63156. _ind: number;
  63157. /**
  63158. * Group this particle belongs to
  63159. */
  63160. _group: PointsGroup;
  63161. /**
  63162. * Group id of this particle
  63163. */
  63164. groupId: number;
  63165. /**
  63166. * Index of the particle in its group id (Internal use)
  63167. */
  63168. idxInGroup: number;
  63169. /**
  63170. * @hidden Particle BoundingInfo object (Internal use)
  63171. */
  63172. _boundingInfo: BoundingInfo;
  63173. /**
  63174. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63175. */
  63176. _pcs: PointsCloudSystem;
  63177. /**
  63178. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63179. */
  63180. _stillInvisible: boolean;
  63181. /**
  63182. * @hidden Last computed particle rotation matrix
  63183. */
  63184. _rotationMatrix: number[];
  63185. /**
  63186. * Parent particle Id, if any.
  63187. * Default null.
  63188. */
  63189. parentId: Nullable<number>;
  63190. /**
  63191. * @hidden Internal global position in the PCS.
  63192. */
  63193. _globalPosition: Vector3;
  63194. /**
  63195. * Creates a Point Cloud object.
  63196. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63197. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63198. * @param group (PointsGroup) is the group the particle belongs to
  63199. * @param groupId (integer) is the group identifier in the PCS.
  63200. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63201. * @param pcs defines the PCS it is associated to
  63202. */
  63203. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63204. /**
  63205. * get point size
  63206. */
  63207. get size(): Vector3;
  63208. /**
  63209. * Set point size
  63210. */
  63211. set size(scale: Vector3);
  63212. /**
  63213. * Legacy support, changed quaternion to rotationQuaternion
  63214. */
  63215. get quaternion(): Nullable<Quaternion>;
  63216. /**
  63217. * Legacy support, changed quaternion to rotationQuaternion
  63218. */
  63219. set quaternion(q: Nullable<Quaternion>);
  63220. /**
  63221. * Returns a boolean. True if the particle intersects a mesh, else false
  63222. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63223. * @param target is the object (point or mesh) what the intersection is computed against
  63224. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63225. * @returns true if it intersects
  63226. */
  63227. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63228. /**
  63229. * get the rotation matrix of the particle
  63230. * @hidden
  63231. */
  63232. getRotationMatrix(m: Matrix): void;
  63233. }
  63234. /**
  63235. * Represents a group of points in a points cloud system
  63236. * * PCS internal tool, don't use it manually.
  63237. */
  63238. export class PointsGroup {
  63239. /**
  63240. * The group id
  63241. * @hidden
  63242. */
  63243. groupID: number;
  63244. /**
  63245. * image data for group (internal use)
  63246. * @hidden
  63247. */
  63248. _groupImageData: Nullable<ArrayBufferView>;
  63249. /**
  63250. * Image Width (internal use)
  63251. * @hidden
  63252. */
  63253. _groupImgWidth: number;
  63254. /**
  63255. * Image Height (internal use)
  63256. * @hidden
  63257. */
  63258. _groupImgHeight: number;
  63259. /**
  63260. * Custom position function (internal use)
  63261. * @hidden
  63262. */
  63263. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63264. /**
  63265. * density per facet for surface points
  63266. * @hidden
  63267. */
  63268. _groupDensity: number[];
  63269. /**
  63270. * Only when points are colored by texture carries pointer to texture list array
  63271. * @hidden
  63272. */
  63273. _textureNb: number;
  63274. /**
  63275. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63276. * PCS internal tool, don't use it manually.
  63277. * @hidden
  63278. */
  63279. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63280. }
  63281. }
  63282. declare module BABYLON {
  63283. interface Scene {
  63284. /** @hidden (Backing field) */
  63285. _physicsEngine: Nullable<IPhysicsEngine>;
  63286. /** @hidden */
  63287. _physicsTimeAccumulator: number;
  63288. /**
  63289. * Gets the current physics engine
  63290. * @returns a IPhysicsEngine or null if none attached
  63291. */
  63292. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63293. /**
  63294. * Enables physics to the current scene
  63295. * @param gravity defines the scene's gravity for the physics engine
  63296. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63297. * @return a boolean indicating if the physics engine was initialized
  63298. */
  63299. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63300. /**
  63301. * Disables and disposes the physics engine associated with the scene
  63302. */
  63303. disablePhysicsEngine(): void;
  63304. /**
  63305. * Gets a boolean indicating if there is an active physics engine
  63306. * @returns a boolean indicating if there is an active physics engine
  63307. */
  63308. isPhysicsEnabled(): boolean;
  63309. /**
  63310. * Deletes a physics compound impostor
  63311. * @param compound defines the compound to delete
  63312. */
  63313. deleteCompoundImpostor(compound: any): void;
  63314. /**
  63315. * An event triggered when physic simulation is about to be run
  63316. */
  63317. onBeforePhysicsObservable: Observable<Scene>;
  63318. /**
  63319. * An event triggered when physic simulation has been done
  63320. */
  63321. onAfterPhysicsObservable: Observable<Scene>;
  63322. }
  63323. interface AbstractMesh {
  63324. /** @hidden */
  63325. _physicsImpostor: Nullable<PhysicsImpostor>;
  63326. /**
  63327. * Gets or sets impostor used for physic simulation
  63328. * @see http://doc.babylonjs.com/features/physics_engine
  63329. */
  63330. physicsImpostor: Nullable<PhysicsImpostor>;
  63331. /**
  63332. * Gets the current physics impostor
  63333. * @see http://doc.babylonjs.com/features/physics_engine
  63334. * @returns a physics impostor or null
  63335. */
  63336. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63337. /** Apply a physic impulse to the mesh
  63338. * @param force defines the force to apply
  63339. * @param contactPoint defines where to apply the force
  63340. * @returns the current mesh
  63341. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63342. */
  63343. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63344. /**
  63345. * Creates a physic joint between two meshes
  63346. * @param otherMesh defines the other mesh to use
  63347. * @param pivot1 defines the pivot to use on this mesh
  63348. * @param pivot2 defines the pivot to use on the other mesh
  63349. * @param options defines additional options (can be plugin dependent)
  63350. * @returns the current mesh
  63351. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63352. */
  63353. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63354. /** @hidden */
  63355. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63356. }
  63357. /**
  63358. * Defines the physics engine scene component responsible to manage a physics engine
  63359. */
  63360. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63361. /**
  63362. * The component name helpful to identify the component in the list of scene components.
  63363. */
  63364. readonly name: string;
  63365. /**
  63366. * The scene the component belongs to.
  63367. */
  63368. scene: Scene;
  63369. /**
  63370. * Creates a new instance of the component for the given scene
  63371. * @param scene Defines the scene to register the component in
  63372. */
  63373. constructor(scene: Scene);
  63374. /**
  63375. * Registers the component in a given scene
  63376. */
  63377. register(): void;
  63378. /**
  63379. * Rebuilds the elements related to this component in case of
  63380. * context lost for instance.
  63381. */
  63382. rebuild(): void;
  63383. /**
  63384. * Disposes the component and the associated ressources
  63385. */
  63386. dispose(): void;
  63387. }
  63388. }
  63389. declare module BABYLON {
  63390. /**
  63391. * A helper for physics simulations
  63392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63393. */
  63394. export class PhysicsHelper {
  63395. private _scene;
  63396. private _physicsEngine;
  63397. /**
  63398. * Initializes the Physics helper
  63399. * @param scene Babylon.js scene
  63400. */
  63401. constructor(scene: Scene);
  63402. /**
  63403. * Applies a radial explosion impulse
  63404. * @param origin the origin of the explosion
  63405. * @param radiusOrEventOptions the radius or the options of radial explosion
  63406. * @param strength the explosion strength
  63407. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63408. * @returns A physics radial explosion event, or null
  63409. */
  63410. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63411. /**
  63412. * Applies a radial explosion force
  63413. * @param origin the origin of the explosion
  63414. * @param radiusOrEventOptions the radius or the options of radial explosion
  63415. * @param strength the explosion strength
  63416. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63417. * @returns A physics radial explosion event, or null
  63418. */
  63419. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63420. /**
  63421. * Creates a gravitational field
  63422. * @param origin the origin of the explosion
  63423. * @param radiusOrEventOptions the radius or the options of radial explosion
  63424. * @param strength the explosion strength
  63425. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63426. * @returns A physics gravitational field event, or null
  63427. */
  63428. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63429. /**
  63430. * Creates a physics updraft event
  63431. * @param origin the origin of the updraft
  63432. * @param radiusOrEventOptions the radius or the options of the updraft
  63433. * @param strength the strength of the updraft
  63434. * @param height the height of the updraft
  63435. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63436. * @returns A physics updraft event, or null
  63437. */
  63438. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63439. /**
  63440. * Creates a physics vortex event
  63441. * @param origin the of the vortex
  63442. * @param radiusOrEventOptions the radius or the options of the vortex
  63443. * @param strength the strength of the vortex
  63444. * @param height the height of the vortex
  63445. * @returns a Physics vortex event, or null
  63446. * A physics vortex event or null
  63447. */
  63448. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63449. }
  63450. /**
  63451. * Represents a physics radial explosion event
  63452. */
  63453. class PhysicsRadialExplosionEvent {
  63454. private _scene;
  63455. private _options;
  63456. private _sphere;
  63457. private _dataFetched;
  63458. /**
  63459. * Initializes a radial explosioin event
  63460. * @param _scene BabylonJS scene
  63461. * @param _options The options for the vortex event
  63462. */
  63463. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63464. /**
  63465. * Returns the data related to the radial explosion event (sphere).
  63466. * @returns The radial explosion event data
  63467. */
  63468. getData(): PhysicsRadialExplosionEventData;
  63469. /**
  63470. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63471. * @param impostor A physics imposter
  63472. * @param origin the origin of the explosion
  63473. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63474. */
  63475. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63476. /**
  63477. * Triggers affecterd impostors callbacks
  63478. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63479. */
  63480. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63481. /**
  63482. * Disposes the sphere.
  63483. * @param force Specifies if the sphere should be disposed by force
  63484. */
  63485. dispose(force?: boolean): void;
  63486. /*** Helpers ***/
  63487. private _prepareSphere;
  63488. private _intersectsWithSphere;
  63489. }
  63490. /**
  63491. * Represents a gravitational field event
  63492. */
  63493. class PhysicsGravitationalFieldEvent {
  63494. private _physicsHelper;
  63495. private _scene;
  63496. private _origin;
  63497. private _options;
  63498. private _tickCallback;
  63499. private _sphere;
  63500. private _dataFetched;
  63501. /**
  63502. * Initializes the physics gravitational field event
  63503. * @param _physicsHelper A physics helper
  63504. * @param _scene BabylonJS scene
  63505. * @param _origin The origin position of the gravitational field event
  63506. * @param _options The options for the vortex event
  63507. */
  63508. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63509. /**
  63510. * Returns the data related to the gravitational field event (sphere).
  63511. * @returns A gravitational field event
  63512. */
  63513. getData(): PhysicsGravitationalFieldEventData;
  63514. /**
  63515. * Enables the gravitational field.
  63516. */
  63517. enable(): void;
  63518. /**
  63519. * Disables the gravitational field.
  63520. */
  63521. disable(): void;
  63522. /**
  63523. * Disposes the sphere.
  63524. * @param force The force to dispose from the gravitational field event
  63525. */
  63526. dispose(force?: boolean): void;
  63527. private _tick;
  63528. }
  63529. /**
  63530. * Represents a physics updraft event
  63531. */
  63532. class PhysicsUpdraftEvent {
  63533. private _scene;
  63534. private _origin;
  63535. private _options;
  63536. private _physicsEngine;
  63537. private _originTop;
  63538. private _originDirection;
  63539. private _tickCallback;
  63540. private _cylinder;
  63541. private _cylinderPosition;
  63542. private _dataFetched;
  63543. /**
  63544. * Initializes the physics updraft event
  63545. * @param _scene BabylonJS scene
  63546. * @param _origin The origin position of the updraft
  63547. * @param _options The options for the updraft event
  63548. */
  63549. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63550. /**
  63551. * Returns the data related to the updraft event (cylinder).
  63552. * @returns A physics updraft event
  63553. */
  63554. getData(): PhysicsUpdraftEventData;
  63555. /**
  63556. * Enables the updraft.
  63557. */
  63558. enable(): void;
  63559. /**
  63560. * Disables the updraft.
  63561. */
  63562. disable(): void;
  63563. /**
  63564. * Disposes the cylinder.
  63565. * @param force Specifies if the updraft should be disposed by force
  63566. */
  63567. dispose(force?: boolean): void;
  63568. private getImpostorHitData;
  63569. private _tick;
  63570. /*** Helpers ***/
  63571. private _prepareCylinder;
  63572. private _intersectsWithCylinder;
  63573. }
  63574. /**
  63575. * Represents a physics vortex event
  63576. */
  63577. class PhysicsVortexEvent {
  63578. private _scene;
  63579. private _origin;
  63580. private _options;
  63581. private _physicsEngine;
  63582. private _originTop;
  63583. private _tickCallback;
  63584. private _cylinder;
  63585. private _cylinderPosition;
  63586. private _dataFetched;
  63587. /**
  63588. * Initializes the physics vortex event
  63589. * @param _scene The BabylonJS scene
  63590. * @param _origin The origin position of the vortex
  63591. * @param _options The options for the vortex event
  63592. */
  63593. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63594. /**
  63595. * Returns the data related to the vortex event (cylinder).
  63596. * @returns The physics vortex event data
  63597. */
  63598. getData(): PhysicsVortexEventData;
  63599. /**
  63600. * Enables the vortex.
  63601. */
  63602. enable(): void;
  63603. /**
  63604. * Disables the cortex.
  63605. */
  63606. disable(): void;
  63607. /**
  63608. * Disposes the sphere.
  63609. * @param force
  63610. */
  63611. dispose(force?: boolean): void;
  63612. private getImpostorHitData;
  63613. private _tick;
  63614. /*** Helpers ***/
  63615. private _prepareCylinder;
  63616. private _intersectsWithCylinder;
  63617. }
  63618. /**
  63619. * Options fot the radial explosion event
  63620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63621. */
  63622. export class PhysicsRadialExplosionEventOptions {
  63623. /**
  63624. * The radius of the sphere for the radial explosion.
  63625. */
  63626. radius: number;
  63627. /**
  63628. * The strenth of the explosion.
  63629. */
  63630. strength: number;
  63631. /**
  63632. * The strenght of the force in correspondence to the distance of the affected object
  63633. */
  63634. falloff: PhysicsRadialImpulseFalloff;
  63635. /**
  63636. * Sphere options for the radial explosion.
  63637. */
  63638. sphere: {
  63639. segments: number;
  63640. diameter: number;
  63641. };
  63642. /**
  63643. * Sphere options for the radial explosion.
  63644. */
  63645. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63646. }
  63647. /**
  63648. * Options fot the updraft event
  63649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63650. */
  63651. export class PhysicsUpdraftEventOptions {
  63652. /**
  63653. * The radius of the cylinder for the vortex
  63654. */
  63655. radius: number;
  63656. /**
  63657. * The strenth of the updraft.
  63658. */
  63659. strength: number;
  63660. /**
  63661. * The height of the cylinder for the updraft.
  63662. */
  63663. height: number;
  63664. /**
  63665. * The mode for the the updraft.
  63666. */
  63667. updraftMode: PhysicsUpdraftMode;
  63668. }
  63669. /**
  63670. * Options fot the vortex event
  63671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63672. */
  63673. export class PhysicsVortexEventOptions {
  63674. /**
  63675. * The radius of the cylinder for the vortex
  63676. */
  63677. radius: number;
  63678. /**
  63679. * The strenth of the vortex.
  63680. */
  63681. strength: number;
  63682. /**
  63683. * The height of the cylinder for the vortex.
  63684. */
  63685. height: number;
  63686. /**
  63687. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63688. */
  63689. centripetalForceThreshold: number;
  63690. /**
  63691. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63692. */
  63693. centripetalForceMultiplier: number;
  63694. /**
  63695. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63696. */
  63697. centrifugalForceMultiplier: number;
  63698. /**
  63699. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63700. */
  63701. updraftForceMultiplier: number;
  63702. }
  63703. /**
  63704. * The strenght of the force in correspondence to the distance of the affected object
  63705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63706. */
  63707. export enum PhysicsRadialImpulseFalloff {
  63708. /** Defines that impulse is constant in strength across it's whole radius */
  63709. Constant = 0,
  63710. /** Defines that impulse gets weaker if it's further from the origin */
  63711. Linear = 1
  63712. }
  63713. /**
  63714. * The strength of the force in correspondence to the distance of the affected object
  63715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63716. */
  63717. export enum PhysicsUpdraftMode {
  63718. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63719. Center = 0,
  63720. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63721. Perpendicular = 1
  63722. }
  63723. /**
  63724. * Interface for a physics hit data
  63725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63726. */
  63727. export interface PhysicsHitData {
  63728. /**
  63729. * The force applied at the contact point
  63730. */
  63731. force: Vector3;
  63732. /**
  63733. * The contact point
  63734. */
  63735. contactPoint: Vector3;
  63736. /**
  63737. * The distance from the origin to the contact point
  63738. */
  63739. distanceFromOrigin: number;
  63740. }
  63741. /**
  63742. * Interface for radial explosion event data
  63743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63744. */
  63745. export interface PhysicsRadialExplosionEventData {
  63746. /**
  63747. * A sphere used for the radial explosion event
  63748. */
  63749. sphere: Mesh;
  63750. }
  63751. /**
  63752. * Interface for gravitational field event data
  63753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63754. */
  63755. export interface PhysicsGravitationalFieldEventData {
  63756. /**
  63757. * A sphere mesh used for the gravitational field event
  63758. */
  63759. sphere: Mesh;
  63760. }
  63761. /**
  63762. * Interface for updraft event data
  63763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63764. */
  63765. export interface PhysicsUpdraftEventData {
  63766. /**
  63767. * A cylinder used for the updraft event
  63768. */
  63769. cylinder: Mesh;
  63770. }
  63771. /**
  63772. * Interface for vortex event data
  63773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63774. */
  63775. export interface PhysicsVortexEventData {
  63776. /**
  63777. * A cylinder used for the vortex event
  63778. */
  63779. cylinder: Mesh;
  63780. }
  63781. /**
  63782. * Interface for an affected physics impostor
  63783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63784. */
  63785. export interface PhysicsAffectedImpostorWithData {
  63786. /**
  63787. * The impostor affected by the effect
  63788. */
  63789. impostor: PhysicsImpostor;
  63790. /**
  63791. * The data about the hit/horce from the explosion
  63792. */
  63793. hitData: PhysicsHitData;
  63794. }
  63795. }
  63796. declare module BABYLON {
  63797. /** @hidden */
  63798. export var blackAndWhitePixelShader: {
  63799. name: string;
  63800. shader: string;
  63801. };
  63802. }
  63803. declare module BABYLON {
  63804. /**
  63805. * Post process used to render in black and white
  63806. */
  63807. export class BlackAndWhitePostProcess extends PostProcess {
  63808. /**
  63809. * Linear about to convert he result to black and white (default: 1)
  63810. */
  63811. degree: number;
  63812. /**
  63813. * Creates a black and white post process
  63814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63815. * @param name The name of the effect.
  63816. * @param options The required width/height ratio to downsize to before computing the render pass.
  63817. * @param camera The camera to apply the render pass to.
  63818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63819. * @param engine The engine which the post process will be applied. (default: current engine)
  63820. * @param reusable If the post process can be reused on the same frame. (default: false)
  63821. */
  63822. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63823. }
  63824. }
  63825. declare module BABYLON {
  63826. /**
  63827. * This represents a set of one or more post processes in Babylon.
  63828. * A post process can be used to apply a shader to a texture after it is rendered.
  63829. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63830. */
  63831. export class PostProcessRenderEffect {
  63832. private _postProcesses;
  63833. private _getPostProcesses;
  63834. private _singleInstance;
  63835. private _cameras;
  63836. private _indicesForCamera;
  63837. /**
  63838. * Name of the effect
  63839. * @hidden
  63840. */
  63841. _name: string;
  63842. /**
  63843. * Instantiates a post process render effect.
  63844. * A post process can be used to apply a shader to a texture after it is rendered.
  63845. * @param engine The engine the effect is tied to
  63846. * @param name The name of the effect
  63847. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63848. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63849. */
  63850. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63851. /**
  63852. * Checks if all the post processes in the effect are supported.
  63853. */
  63854. get isSupported(): boolean;
  63855. /**
  63856. * Updates the current state of the effect
  63857. * @hidden
  63858. */
  63859. _update(): void;
  63860. /**
  63861. * Attaches the effect on cameras
  63862. * @param cameras The camera to attach to.
  63863. * @hidden
  63864. */
  63865. _attachCameras(cameras: Camera): void;
  63866. /**
  63867. * Attaches the effect on cameras
  63868. * @param cameras The camera to attach to.
  63869. * @hidden
  63870. */
  63871. _attachCameras(cameras: Camera[]): void;
  63872. /**
  63873. * Detaches the effect on cameras
  63874. * @param cameras The camera to detatch from.
  63875. * @hidden
  63876. */
  63877. _detachCameras(cameras: Camera): void;
  63878. /**
  63879. * Detatches the effect on cameras
  63880. * @param cameras The camera to detatch from.
  63881. * @hidden
  63882. */
  63883. _detachCameras(cameras: Camera[]): void;
  63884. /**
  63885. * Enables the effect on given cameras
  63886. * @param cameras The camera to enable.
  63887. * @hidden
  63888. */
  63889. _enable(cameras: Camera): void;
  63890. /**
  63891. * Enables the effect on given cameras
  63892. * @param cameras The camera to enable.
  63893. * @hidden
  63894. */
  63895. _enable(cameras: Nullable<Camera[]>): void;
  63896. /**
  63897. * Disables the effect on the given cameras
  63898. * @param cameras The camera to disable.
  63899. * @hidden
  63900. */
  63901. _disable(cameras: Camera): void;
  63902. /**
  63903. * Disables the effect on the given cameras
  63904. * @param cameras The camera to disable.
  63905. * @hidden
  63906. */
  63907. _disable(cameras: Nullable<Camera[]>): void;
  63908. /**
  63909. * Gets a list of the post processes contained in the effect.
  63910. * @param camera The camera to get the post processes on.
  63911. * @returns The list of the post processes in the effect.
  63912. */
  63913. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63914. }
  63915. }
  63916. declare module BABYLON {
  63917. /** @hidden */
  63918. export var extractHighlightsPixelShader: {
  63919. name: string;
  63920. shader: string;
  63921. };
  63922. }
  63923. declare module BABYLON {
  63924. /**
  63925. * 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.
  63926. */
  63927. export class ExtractHighlightsPostProcess extends PostProcess {
  63928. /**
  63929. * The luminance threshold, pixels below this value will be set to black.
  63930. */
  63931. threshold: number;
  63932. /** @hidden */
  63933. _exposure: number;
  63934. /**
  63935. * Post process which has the input texture to be used when performing highlight extraction
  63936. * @hidden
  63937. */
  63938. _inputPostProcess: Nullable<PostProcess>;
  63939. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63940. }
  63941. }
  63942. declare module BABYLON {
  63943. /** @hidden */
  63944. export var bloomMergePixelShader: {
  63945. name: string;
  63946. shader: string;
  63947. };
  63948. }
  63949. declare module BABYLON {
  63950. /**
  63951. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63952. */
  63953. export class BloomMergePostProcess extends PostProcess {
  63954. /** Weight of the bloom to be added to the original input. */
  63955. weight: number;
  63956. /**
  63957. * Creates a new instance of @see BloomMergePostProcess
  63958. * @param name The name of the effect.
  63959. * @param originalFromInput Post process which's input will be used for the merge.
  63960. * @param blurred Blurred highlights post process which's output will be used.
  63961. * @param weight Weight of the bloom to be added to the original input.
  63962. * @param options The required width/height ratio to downsize to before computing the render pass.
  63963. * @param camera The camera to apply the render pass to.
  63964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63965. * @param engine The engine which the post process will be applied. (default: current engine)
  63966. * @param reusable If the post process can be reused on the same frame. (default: false)
  63967. * @param textureType Type of textures used when performing the post process. (default: 0)
  63968. * @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)
  63969. */
  63970. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63971. /** Weight of the bloom to be added to the original input. */
  63972. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63973. }
  63974. }
  63975. declare module BABYLON {
  63976. /**
  63977. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63978. */
  63979. export class BloomEffect extends PostProcessRenderEffect {
  63980. private bloomScale;
  63981. /**
  63982. * @hidden Internal
  63983. */
  63984. _effects: Array<PostProcess>;
  63985. /**
  63986. * @hidden Internal
  63987. */
  63988. _downscale: ExtractHighlightsPostProcess;
  63989. private _blurX;
  63990. private _blurY;
  63991. private _merge;
  63992. /**
  63993. * The luminance threshold to find bright areas of the image to bloom.
  63994. */
  63995. get threshold(): number;
  63996. set threshold(value: number);
  63997. /**
  63998. * The strength of the bloom.
  63999. */
  64000. get weight(): number;
  64001. set weight(value: number);
  64002. /**
  64003. * Specifies the size of the bloom blur kernel, relative to the final output size
  64004. */
  64005. get kernel(): number;
  64006. set kernel(value: number);
  64007. /**
  64008. * Creates a new instance of @see BloomEffect
  64009. * @param scene The scene the effect belongs to.
  64010. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64011. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64012. * @param bloomWeight The the strength of bloom.
  64013. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64014. * @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)
  64015. */
  64016. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64017. /**
  64018. * Disposes each of the internal effects for a given camera.
  64019. * @param camera The camera to dispose the effect on.
  64020. */
  64021. disposeEffects(camera: Camera): void;
  64022. /**
  64023. * @hidden Internal
  64024. */
  64025. _updateEffects(): void;
  64026. /**
  64027. * Internal
  64028. * @returns if all the contained post processes are ready.
  64029. * @hidden
  64030. */
  64031. _isReady(): boolean;
  64032. }
  64033. }
  64034. declare module BABYLON {
  64035. /** @hidden */
  64036. export var chromaticAberrationPixelShader: {
  64037. name: string;
  64038. shader: string;
  64039. };
  64040. }
  64041. declare module BABYLON {
  64042. /**
  64043. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64044. */
  64045. export class ChromaticAberrationPostProcess extends PostProcess {
  64046. /**
  64047. * The amount of seperation of rgb channels (default: 30)
  64048. */
  64049. aberrationAmount: number;
  64050. /**
  64051. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64052. */
  64053. radialIntensity: number;
  64054. /**
  64055. * 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))
  64056. */
  64057. direction: Vector2;
  64058. /**
  64059. * 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))
  64060. */
  64061. centerPosition: Vector2;
  64062. /**
  64063. * Creates a new instance ChromaticAberrationPostProcess
  64064. * @param name The name of the effect.
  64065. * @param screenWidth The width of the screen to apply the effect on.
  64066. * @param screenHeight The height of the screen to apply the effect on.
  64067. * @param options The required width/height ratio to downsize to before computing the render pass.
  64068. * @param camera The camera to apply the render pass to.
  64069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64070. * @param engine The engine which the post process will be applied. (default: current engine)
  64071. * @param reusable If the post process can be reused on the same frame. (default: false)
  64072. * @param textureType Type of textures used when performing the post process. (default: 0)
  64073. * @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)
  64074. */
  64075. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64076. }
  64077. }
  64078. declare module BABYLON {
  64079. /** @hidden */
  64080. export var circleOfConfusionPixelShader: {
  64081. name: string;
  64082. shader: string;
  64083. };
  64084. }
  64085. declare module BABYLON {
  64086. /**
  64087. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64088. */
  64089. export class CircleOfConfusionPostProcess extends PostProcess {
  64090. /**
  64091. * 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.
  64092. */
  64093. lensSize: number;
  64094. /**
  64095. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64096. */
  64097. fStop: number;
  64098. /**
  64099. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64100. */
  64101. focusDistance: number;
  64102. /**
  64103. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64104. */
  64105. focalLength: number;
  64106. private _depthTexture;
  64107. /**
  64108. * Creates a new instance CircleOfConfusionPostProcess
  64109. * @param name The name of the effect.
  64110. * @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.
  64111. * @param options The required width/height ratio to downsize to before computing the render pass.
  64112. * @param camera The camera to apply the render pass to.
  64113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64114. * @param engine The engine which the post process will be applied. (default: current engine)
  64115. * @param reusable If the post process can be reused on the same frame. (default: false)
  64116. * @param textureType Type of textures used when performing the post process. (default: 0)
  64117. * @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)
  64118. */
  64119. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64120. /**
  64121. * 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.
  64122. */
  64123. set depthTexture(value: RenderTargetTexture);
  64124. }
  64125. }
  64126. declare module BABYLON {
  64127. /** @hidden */
  64128. export var colorCorrectionPixelShader: {
  64129. name: string;
  64130. shader: string;
  64131. };
  64132. }
  64133. declare module BABYLON {
  64134. /**
  64135. *
  64136. * This post-process allows the modification of rendered colors by using
  64137. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64138. *
  64139. * The object needs to be provided an url to a texture containing the color
  64140. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64141. * Use an image editing software to tweak the LUT to match your needs.
  64142. *
  64143. * For an example of a color LUT, see here:
  64144. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64145. * For explanations on color grading, see here:
  64146. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64147. *
  64148. */
  64149. export class ColorCorrectionPostProcess extends PostProcess {
  64150. private _colorTableTexture;
  64151. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64152. }
  64153. }
  64154. declare module BABYLON {
  64155. /** @hidden */
  64156. export var convolutionPixelShader: {
  64157. name: string;
  64158. shader: string;
  64159. };
  64160. }
  64161. declare module BABYLON {
  64162. /**
  64163. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64164. * input texture to perform effects such as edge detection or sharpening
  64165. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64166. */
  64167. export class ConvolutionPostProcess extends PostProcess {
  64168. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64169. kernel: number[];
  64170. /**
  64171. * Creates a new instance ConvolutionPostProcess
  64172. * @param name The name of the effect.
  64173. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64174. * @param options The required width/height ratio to downsize to before computing the render pass.
  64175. * @param camera The camera to apply the render pass to.
  64176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64177. * @param engine The engine which the post process will be applied. (default: current engine)
  64178. * @param reusable If the post process can be reused on the same frame. (default: false)
  64179. * @param textureType Type of textures used when performing the post process. (default: 0)
  64180. */
  64181. constructor(name: string,
  64182. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64183. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64184. /**
  64185. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64186. */
  64187. static EdgeDetect0Kernel: number[];
  64188. /**
  64189. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64190. */
  64191. static EdgeDetect1Kernel: number[];
  64192. /**
  64193. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64194. */
  64195. static EdgeDetect2Kernel: number[];
  64196. /**
  64197. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64198. */
  64199. static SharpenKernel: number[];
  64200. /**
  64201. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64202. */
  64203. static EmbossKernel: number[];
  64204. /**
  64205. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64206. */
  64207. static GaussianKernel: number[];
  64208. }
  64209. }
  64210. declare module BABYLON {
  64211. /**
  64212. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64213. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64214. * based on samples that have a large difference in distance than the center pixel.
  64215. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64216. */
  64217. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64218. direction: Vector2;
  64219. /**
  64220. * Creates a new instance CircleOfConfusionPostProcess
  64221. * @param name The name of the effect.
  64222. * @param scene The scene the effect belongs to.
  64223. * @param direction The direction the blur should be applied.
  64224. * @param kernel The size of the kernel used to blur.
  64225. * @param options The required width/height ratio to downsize to before computing the render pass.
  64226. * @param camera The camera to apply the render pass to.
  64227. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64228. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  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. * @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)
  64234. */
  64235. 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);
  64236. }
  64237. }
  64238. declare module BABYLON {
  64239. /** @hidden */
  64240. export var depthOfFieldMergePixelShader: {
  64241. name: string;
  64242. shader: string;
  64243. };
  64244. }
  64245. declare module BABYLON {
  64246. /**
  64247. * Options to be set when merging outputs from the default pipeline.
  64248. */
  64249. export class DepthOfFieldMergePostProcessOptions {
  64250. /**
  64251. * The original image to merge on top of
  64252. */
  64253. originalFromInput: PostProcess;
  64254. /**
  64255. * Parameters to perform the merge of the depth of field effect
  64256. */
  64257. depthOfField?: {
  64258. circleOfConfusion: PostProcess;
  64259. blurSteps: Array<PostProcess>;
  64260. };
  64261. /**
  64262. * Parameters to perform the merge of bloom effect
  64263. */
  64264. bloom?: {
  64265. blurred: PostProcess;
  64266. weight: number;
  64267. };
  64268. }
  64269. /**
  64270. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64271. */
  64272. export class DepthOfFieldMergePostProcess extends PostProcess {
  64273. private blurSteps;
  64274. /**
  64275. * Creates a new instance of DepthOfFieldMergePostProcess
  64276. * @param name The name of the effect.
  64277. * @param originalFromInput Post process which's input will be used for the merge.
  64278. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64279. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64280. * @param options The required width/height ratio to downsize to before computing the render pass.
  64281. * @param camera The camera to apply the render pass to.
  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, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64289. /**
  64290. * Updates the effect with the current post process compile time values and recompiles the shader.
  64291. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64292. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64293. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64294. * @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
  64295. * @param onCompiled Called when the shader has been compiled.
  64296. * @param onError Called if there is an error when compiling a shader.
  64297. */
  64298. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64299. }
  64300. }
  64301. declare module BABYLON {
  64302. /**
  64303. * Specifies the level of max blur that should be applied when using the depth of field effect
  64304. */
  64305. export enum DepthOfFieldEffectBlurLevel {
  64306. /**
  64307. * Subtle blur
  64308. */
  64309. Low = 0,
  64310. /**
  64311. * Medium blur
  64312. */
  64313. Medium = 1,
  64314. /**
  64315. * Large blur
  64316. */
  64317. High = 2
  64318. }
  64319. /**
  64320. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64321. */
  64322. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64323. private _circleOfConfusion;
  64324. /**
  64325. * @hidden Internal, blurs from high to low
  64326. */
  64327. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64328. private _depthOfFieldBlurY;
  64329. private _dofMerge;
  64330. /**
  64331. * @hidden Internal post processes in depth of field effect
  64332. */
  64333. _effects: Array<PostProcess>;
  64334. /**
  64335. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64336. */
  64337. set focalLength(value: number);
  64338. get focalLength(): number;
  64339. /**
  64340. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64341. */
  64342. set fStop(value: number);
  64343. get fStop(): number;
  64344. /**
  64345. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64346. */
  64347. set focusDistance(value: number);
  64348. get focusDistance(): number;
  64349. /**
  64350. * 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.
  64351. */
  64352. set lensSize(value: number);
  64353. get lensSize(): number;
  64354. /**
  64355. * Creates a new instance DepthOfFieldEffect
  64356. * @param scene The scene the effect belongs to.
  64357. * @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.
  64358. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64359. * @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)
  64360. */
  64361. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64362. /**
  64363. * Get the current class name of the current effet
  64364. * @returns "DepthOfFieldEffect"
  64365. */
  64366. getClassName(): string;
  64367. /**
  64368. * 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.
  64369. */
  64370. set depthTexture(value: RenderTargetTexture);
  64371. /**
  64372. * Disposes each of the internal effects for a given camera.
  64373. * @param camera The camera to dispose the effect on.
  64374. */
  64375. disposeEffects(camera: Camera): void;
  64376. /**
  64377. * @hidden Internal
  64378. */
  64379. _updateEffects(): void;
  64380. /**
  64381. * Internal
  64382. * @returns if all the contained post processes are ready.
  64383. * @hidden
  64384. */
  64385. _isReady(): boolean;
  64386. }
  64387. }
  64388. declare module BABYLON {
  64389. /** @hidden */
  64390. export var displayPassPixelShader: {
  64391. name: string;
  64392. shader: string;
  64393. };
  64394. }
  64395. declare module BABYLON {
  64396. /**
  64397. * DisplayPassPostProcess which produces an output the same as it's input
  64398. */
  64399. export class DisplayPassPostProcess extends PostProcess {
  64400. /**
  64401. * Creates the DisplayPassPostProcess
  64402. * @param name The name of the effect.
  64403. * @param options The required width/height ratio to downsize to before computing the render pass.
  64404. * @param camera The camera to apply the render pass to.
  64405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64406. * @param engine The engine which the post process will be applied. (default: current engine)
  64407. * @param reusable If the post process can be reused on the same frame. (default: false)
  64408. */
  64409. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64410. }
  64411. }
  64412. declare module BABYLON {
  64413. /** @hidden */
  64414. export var filterPixelShader: {
  64415. name: string;
  64416. shader: string;
  64417. };
  64418. }
  64419. declare module BABYLON {
  64420. /**
  64421. * Applies a kernel filter to the image
  64422. */
  64423. export class FilterPostProcess extends PostProcess {
  64424. /** The matrix to be applied to the image */
  64425. kernelMatrix: Matrix;
  64426. /**
  64427. *
  64428. * @param name The name of the effect.
  64429. * @param kernelMatrix The matrix to be applied to the image
  64430. * @param options The required width/height ratio to downsize to before computing the render pass.
  64431. * @param camera The camera to apply the render pass to.
  64432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64433. * @param engine The engine which the post process will be applied. (default: current engine)
  64434. * @param reusable If the post process can be reused on the same frame. (default: false)
  64435. */
  64436. constructor(name: string,
  64437. /** The matrix to be applied to the image */
  64438. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64439. }
  64440. }
  64441. declare module BABYLON {
  64442. /** @hidden */
  64443. export var fxaaPixelShader: {
  64444. name: string;
  64445. shader: string;
  64446. };
  64447. }
  64448. declare module BABYLON {
  64449. /** @hidden */
  64450. export var fxaaVertexShader: {
  64451. name: string;
  64452. shader: string;
  64453. };
  64454. }
  64455. declare module BABYLON {
  64456. /**
  64457. * Fxaa post process
  64458. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64459. */
  64460. export class FxaaPostProcess extends PostProcess {
  64461. /** @hidden */
  64462. texelWidth: number;
  64463. /** @hidden */
  64464. texelHeight: number;
  64465. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64466. private _getDefines;
  64467. }
  64468. }
  64469. declare module BABYLON {
  64470. /** @hidden */
  64471. export var grainPixelShader: {
  64472. name: string;
  64473. shader: string;
  64474. };
  64475. }
  64476. declare module BABYLON {
  64477. /**
  64478. * The GrainPostProcess adds noise to the image at mid luminance levels
  64479. */
  64480. export class GrainPostProcess extends PostProcess {
  64481. /**
  64482. * The intensity of the grain added (default: 30)
  64483. */
  64484. intensity: number;
  64485. /**
  64486. * If the grain should be randomized on every frame
  64487. */
  64488. animated: boolean;
  64489. /**
  64490. * Creates a new instance of @see GrainPostProcess
  64491. * @param name The name of the effect.
  64492. * @param options The required width/height ratio to downsize to before computing the render pass.
  64493. * @param camera The camera to apply the render pass to.
  64494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64495. * @param engine The engine which the post process will be applied. (default: current engine)
  64496. * @param reusable If the post process can be reused on the same frame. (default: false)
  64497. * @param textureType Type of textures used when performing the post process. (default: 0)
  64498. * @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)
  64499. */
  64500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64501. }
  64502. }
  64503. declare module BABYLON {
  64504. /** @hidden */
  64505. export var highlightsPixelShader: {
  64506. name: string;
  64507. shader: string;
  64508. };
  64509. }
  64510. declare module BABYLON {
  64511. /**
  64512. * Extracts highlights from the image
  64513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64514. */
  64515. export class HighlightsPostProcess extends PostProcess {
  64516. /**
  64517. * Extracts highlights from the image
  64518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64519. * @param name The name of the effect.
  64520. * @param options The required width/height ratio to downsize to before computing the render pass.
  64521. * @param camera The camera to apply the render pass to.
  64522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64523. * @param engine The engine which the post process will be applied. (default: current engine)
  64524. * @param reusable If the post process can be reused on the same frame. (default: false)
  64525. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64526. */
  64527. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64528. }
  64529. }
  64530. declare module BABYLON {
  64531. /** @hidden */
  64532. export var mrtFragmentDeclaration: {
  64533. name: string;
  64534. shader: string;
  64535. };
  64536. }
  64537. declare module BABYLON {
  64538. /** @hidden */
  64539. export var geometryPixelShader: {
  64540. name: string;
  64541. shader: string;
  64542. };
  64543. }
  64544. declare module BABYLON {
  64545. /** @hidden */
  64546. export var geometryVertexShader: {
  64547. name: string;
  64548. shader: string;
  64549. };
  64550. }
  64551. declare module BABYLON {
  64552. /** @hidden */
  64553. interface ISavedTransformationMatrix {
  64554. world: Matrix;
  64555. viewProjection: Matrix;
  64556. }
  64557. /**
  64558. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64559. */
  64560. export class GeometryBufferRenderer {
  64561. /**
  64562. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64563. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64564. */
  64565. static readonly POSITION_TEXTURE_TYPE: number;
  64566. /**
  64567. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64568. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64569. */
  64570. static readonly VELOCITY_TEXTURE_TYPE: number;
  64571. /**
  64572. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64573. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64574. */
  64575. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64576. /**
  64577. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64578. * in order to compute objects velocities when enableVelocity is set to "true"
  64579. * @hidden
  64580. */
  64581. _previousTransformationMatrices: {
  64582. [index: number]: ISavedTransformationMatrix;
  64583. };
  64584. /**
  64585. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64586. * in order to compute objects velocities when enableVelocity is set to "true"
  64587. * @hidden
  64588. */
  64589. _previousBonesTransformationMatrices: {
  64590. [index: number]: Float32Array;
  64591. };
  64592. /**
  64593. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64594. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64595. */
  64596. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64597. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64598. renderTransparentMeshes: boolean;
  64599. private _scene;
  64600. private _multiRenderTarget;
  64601. private _ratio;
  64602. private _enablePosition;
  64603. private _enableVelocity;
  64604. private _enableReflectivity;
  64605. private _positionIndex;
  64606. private _velocityIndex;
  64607. private _reflectivityIndex;
  64608. protected _effect: Effect;
  64609. protected _cachedDefines: string;
  64610. /**
  64611. * Set the render list (meshes to be rendered) used in the G buffer.
  64612. */
  64613. set renderList(meshes: Mesh[]);
  64614. /**
  64615. * Gets wether or not G buffer are supported by the running hardware.
  64616. * This requires draw buffer supports
  64617. */
  64618. get isSupported(): boolean;
  64619. /**
  64620. * Returns the index of the given texture type in the G-Buffer textures array
  64621. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64622. * @returns the index of the given texture type in the G-Buffer textures array
  64623. */
  64624. getTextureIndex(textureType: number): number;
  64625. /**
  64626. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64627. */
  64628. get enablePosition(): boolean;
  64629. /**
  64630. * Sets whether or not objects positions are enabled for the G buffer.
  64631. */
  64632. set enablePosition(enable: boolean);
  64633. /**
  64634. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64635. */
  64636. get enableVelocity(): boolean;
  64637. /**
  64638. * Sets wether or not objects velocities are enabled for the G buffer.
  64639. */
  64640. set enableVelocity(enable: boolean);
  64641. /**
  64642. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64643. */
  64644. get enableReflectivity(): boolean;
  64645. /**
  64646. * Sets wether or not objects roughness are enabled for the G buffer.
  64647. */
  64648. set enableReflectivity(enable: boolean);
  64649. /**
  64650. * Gets the scene associated with the buffer.
  64651. */
  64652. get scene(): Scene;
  64653. /**
  64654. * Gets the ratio used by the buffer during its creation.
  64655. * How big is the buffer related to the main canvas.
  64656. */
  64657. get ratio(): number;
  64658. /** @hidden */
  64659. static _SceneComponentInitialization: (scene: Scene) => void;
  64660. /**
  64661. * Creates a new G Buffer for the scene
  64662. * @param scene The scene the buffer belongs to
  64663. * @param ratio How big is the buffer related to the main canvas.
  64664. */
  64665. constructor(scene: Scene, ratio?: number);
  64666. /**
  64667. * Checks wether everything is ready to render a submesh to the G buffer.
  64668. * @param subMesh the submesh to check readiness for
  64669. * @param useInstances is the mesh drawn using instance or not
  64670. * @returns true if ready otherwise false
  64671. */
  64672. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64673. /**
  64674. * Gets the current underlying G Buffer.
  64675. * @returns the buffer
  64676. */
  64677. getGBuffer(): MultiRenderTarget;
  64678. /**
  64679. * Gets the number of samples used to render the buffer (anti aliasing).
  64680. */
  64681. get samples(): number;
  64682. /**
  64683. * Sets the number of samples used to render the buffer (anti aliasing).
  64684. */
  64685. set samples(value: number);
  64686. /**
  64687. * Disposes the renderer and frees up associated resources.
  64688. */
  64689. dispose(): void;
  64690. protected _createRenderTargets(): void;
  64691. private _copyBonesTransformationMatrices;
  64692. }
  64693. }
  64694. declare module BABYLON {
  64695. interface Scene {
  64696. /** @hidden (Backing field) */
  64697. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64698. /**
  64699. * Gets or Sets the current geometry buffer associated to the scene.
  64700. */
  64701. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64702. /**
  64703. * Enables a GeometryBufferRender and associates it with the scene
  64704. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64705. * @returns the GeometryBufferRenderer
  64706. */
  64707. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64708. /**
  64709. * Disables the GeometryBufferRender associated with the scene
  64710. */
  64711. disableGeometryBufferRenderer(): void;
  64712. }
  64713. /**
  64714. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64715. * in several rendering techniques.
  64716. */
  64717. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64718. /**
  64719. * The component name helpful to identify the component in the list of scene components.
  64720. */
  64721. readonly name: string;
  64722. /**
  64723. * The scene the component belongs to.
  64724. */
  64725. scene: Scene;
  64726. /**
  64727. * Creates a new instance of the component for the given scene
  64728. * @param scene Defines the scene to register the component in
  64729. */
  64730. constructor(scene: Scene);
  64731. /**
  64732. * Registers the component in a given scene
  64733. */
  64734. register(): void;
  64735. /**
  64736. * Rebuilds the elements related to this component in case of
  64737. * context lost for instance.
  64738. */
  64739. rebuild(): void;
  64740. /**
  64741. * Disposes the component and the associated ressources
  64742. */
  64743. dispose(): void;
  64744. private _gatherRenderTargets;
  64745. }
  64746. }
  64747. declare module BABYLON {
  64748. /** @hidden */
  64749. export var motionBlurPixelShader: {
  64750. name: string;
  64751. shader: string;
  64752. };
  64753. }
  64754. declare module BABYLON {
  64755. /**
  64756. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64757. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64758. * As an example, all you have to do is to create the post-process:
  64759. * var mb = new BABYLON.MotionBlurPostProcess(
  64760. * 'mb', // The name of the effect.
  64761. * scene, // The scene containing the objects to blur according to their velocity.
  64762. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64763. * camera // The camera to apply the render pass to.
  64764. * );
  64765. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64766. */
  64767. export class MotionBlurPostProcess extends PostProcess {
  64768. /**
  64769. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64770. */
  64771. motionStrength: number;
  64772. /**
  64773. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64774. */
  64775. get motionBlurSamples(): number;
  64776. /**
  64777. * Sets the number of iterations to be used for motion blur quality
  64778. */
  64779. set motionBlurSamples(samples: number);
  64780. private _motionBlurSamples;
  64781. private _geometryBufferRenderer;
  64782. /**
  64783. * Creates a new instance MotionBlurPostProcess
  64784. * @param name The name of the effect.
  64785. * @param scene The scene containing the objects to blur according to their velocity.
  64786. * @param options The required width/height ratio to downsize to before computing the render pass.
  64787. * @param camera The camera to apply the render pass to.
  64788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64789. * @param engine The engine which the post process will be applied. (default: current engine)
  64790. * @param reusable If the post process can be reused on the same frame. (default: false)
  64791. * @param textureType Type of textures used when performing the post process. (default: 0)
  64792. * @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)
  64793. */
  64794. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64795. /**
  64796. * Excludes the given skinned mesh from computing bones velocities.
  64797. * 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.
  64798. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64799. */
  64800. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64801. /**
  64802. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64803. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64804. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64805. */
  64806. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64807. /**
  64808. * Disposes the post process.
  64809. * @param camera The camera to dispose the post process on.
  64810. */
  64811. dispose(camera?: Camera): void;
  64812. }
  64813. }
  64814. declare module BABYLON {
  64815. /** @hidden */
  64816. export var refractionPixelShader: {
  64817. name: string;
  64818. shader: string;
  64819. };
  64820. }
  64821. declare module BABYLON {
  64822. /**
  64823. * Post process which applies a refractin texture
  64824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64825. */
  64826. export class RefractionPostProcess extends PostProcess {
  64827. /** the base color of the refraction (used to taint the rendering) */
  64828. color: Color3;
  64829. /** simulated refraction depth */
  64830. depth: number;
  64831. /** the coefficient of the base color (0 to remove base color tainting) */
  64832. colorLevel: number;
  64833. private _refTexture;
  64834. private _ownRefractionTexture;
  64835. /**
  64836. * Gets or sets the refraction texture
  64837. * Please note that you are responsible for disposing the texture if you set it manually
  64838. */
  64839. get refractionTexture(): Texture;
  64840. set refractionTexture(value: Texture);
  64841. /**
  64842. * Initializes the RefractionPostProcess
  64843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64844. * @param name The name of the effect.
  64845. * @param refractionTextureUrl Url of the refraction texture to use
  64846. * @param color the base color of the refraction (used to taint the rendering)
  64847. * @param depth simulated refraction depth
  64848. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64849. * @param camera The camera to apply the render pass to.
  64850. * @param options The required width/height ratio to downsize to before computing the render pass.
  64851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64852. * @param engine The engine which the post process will be applied. (default: current engine)
  64853. * @param reusable If the post process can be reused on the same frame. (default: false)
  64854. */
  64855. constructor(name: string, refractionTextureUrl: string,
  64856. /** the base color of the refraction (used to taint the rendering) */
  64857. color: Color3,
  64858. /** simulated refraction depth */
  64859. depth: number,
  64860. /** the coefficient of the base color (0 to remove base color tainting) */
  64861. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64862. /**
  64863. * Disposes of the post process
  64864. * @param camera Camera to dispose post process on
  64865. */
  64866. dispose(camera: Camera): void;
  64867. }
  64868. }
  64869. declare module BABYLON {
  64870. /** @hidden */
  64871. export var sharpenPixelShader: {
  64872. name: string;
  64873. shader: string;
  64874. };
  64875. }
  64876. declare module BABYLON {
  64877. /**
  64878. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64879. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64880. */
  64881. export class SharpenPostProcess extends PostProcess {
  64882. /**
  64883. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64884. */
  64885. colorAmount: number;
  64886. /**
  64887. * How much sharpness should be applied (default: 0.3)
  64888. */
  64889. edgeAmount: number;
  64890. /**
  64891. * Creates a new instance ConvolutionPostProcess
  64892. * @param name The name of the effect.
  64893. * @param options The required width/height ratio to downsize to before computing the render pass.
  64894. * @param camera The camera to apply the render pass to.
  64895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64896. * @param engine The engine which the post process will be applied. (default: current engine)
  64897. * @param reusable If the post process can be reused on the same frame. (default: false)
  64898. * @param textureType Type of textures used when performing the post process. (default: 0)
  64899. * @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)
  64900. */
  64901. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64902. }
  64903. }
  64904. declare module BABYLON {
  64905. /**
  64906. * PostProcessRenderPipeline
  64907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64908. */
  64909. export class PostProcessRenderPipeline {
  64910. private engine;
  64911. private _renderEffects;
  64912. private _renderEffectsForIsolatedPass;
  64913. /**
  64914. * List of inspectable custom properties (used by the Inspector)
  64915. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64916. */
  64917. inspectableCustomProperties: IInspectable[];
  64918. /**
  64919. * @hidden
  64920. */
  64921. protected _cameras: Camera[];
  64922. /** @hidden */
  64923. _name: string;
  64924. /**
  64925. * Gets pipeline name
  64926. */
  64927. get name(): string;
  64928. /** Gets the list of attached cameras */
  64929. get cameras(): Camera[];
  64930. /**
  64931. * Initializes a PostProcessRenderPipeline
  64932. * @param engine engine to add the pipeline to
  64933. * @param name name of the pipeline
  64934. */
  64935. constructor(engine: Engine, name: string);
  64936. /**
  64937. * Gets the class name
  64938. * @returns "PostProcessRenderPipeline"
  64939. */
  64940. getClassName(): string;
  64941. /**
  64942. * If all the render effects in the pipeline are supported
  64943. */
  64944. get isSupported(): boolean;
  64945. /**
  64946. * Adds an effect to the pipeline
  64947. * @param renderEffect the effect to add
  64948. */
  64949. addEffect(renderEffect: PostProcessRenderEffect): void;
  64950. /** @hidden */
  64951. _rebuild(): void;
  64952. /** @hidden */
  64953. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64954. /** @hidden */
  64955. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64956. /** @hidden */
  64957. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64958. /** @hidden */
  64959. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64960. /** @hidden */
  64961. _attachCameras(cameras: Camera, unique: boolean): void;
  64962. /** @hidden */
  64963. _attachCameras(cameras: Camera[], unique: boolean): void;
  64964. /** @hidden */
  64965. _detachCameras(cameras: Camera): void;
  64966. /** @hidden */
  64967. _detachCameras(cameras: Nullable<Camera[]>): void;
  64968. /** @hidden */
  64969. _update(): void;
  64970. /** @hidden */
  64971. _reset(): void;
  64972. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64973. /**
  64974. * Disposes of the pipeline
  64975. */
  64976. dispose(): void;
  64977. }
  64978. }
  64979. declare module BABYLON {
  64980. /**
  64981. * PostProcessRenderPipelineManager class
  64982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64983. */
  64984. export class PostProcessRenderPipelineManager {
  64985. private _renderPipelines;
  64986. /**
  64987. * Initializes a PostProcessRenderPipelineManager
  64988. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64989. */
  64990. constructor();
  64991. /**
  64992. * Gets the list of supported render pipelines
  64993. */
  64994. get supportedPipelines(): PostProcessRenderPipeline[];
  64995. /**
  64996. * Adds a pipeline to the manager
  64997. * @param renderPipeline The pipeline to add
  64998. */
  64999. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65000. /**
  65001. * Attaches a camera to the pipeline
  65002. * @param renderPipelineName The name of the pipeline to attach to
  65003. * @param cameras the camera to attach
  65004. * @param unique if the camera can be attached multiple times to the pipeline
  65005. */
  65006. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65007. /**
  65008. * Detaches a camera from the pipeline
  65009. * @param renderPipelineName The name of the pipeline to detach from
  65010. * @param cameras the camera to detach
  65011. */
  65012. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65013. /**
  65014. * Enables an effect by name on a pipeline
  65015. * @param renderPipelineName the name of the pipeline to enable the effect in
  65016. * @param renderEffectName the name of the effect to enable
  65017. * @param cameras the cameras that the effect should be enabled on
  65018. */
  65019. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65020. /**
  65021. * Disables an effect by name on a pipeline
  65022. * @param renderPipelineName the name of the pipeline to disable the effect in
  65023. * @param renderEffectName the name of the effect to disable
  65024. * @param cameras the cameras that the effect should be disabled on
  65025. */
  65026. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65027. /**
  65028. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65029. */
  65030. update(): void;
  65031. /** @hidden */
  65032. _rebuild(): void;
  65033. /**
  65034. * Disposes of the manager and pipelines
  65035. */
  65036. dispose(): void;
  65037. }
  65038. }
  65039. declare module BABYLON {
  65040. interface Scene {
  65041. /** @hidden (Backing field) */
  65042. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65043. /**
  65044. * Gets the postprocess render pipeline manager
  65045. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65046. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65047. */
  65048. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65049. }
  65050. /**
  65051. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65052. */
  65053. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65054. /**
  65055. * The component name helpfull to identify the component in the list of scene components.
  65056. */
  65057. readonly name: string;
  65058. /**
  65059. * The scene the component belongs to.
  65060. */
  65061. scene: Scene;
  65062. /**
  65063. * Creates a new instance of the component for the given scene
  65064. * @param scene Defines the scene to register the component in
  65065. */
  65066. constructor(scene: Scene);
  65067. /**
  65068. * Registers the component in a given scene
  65069. */
  65070. register(): void;
  65071. /**
  65072. * Rebuilds the elements related to this component in case of
  65073. * context lost for instance.
  65074. */
  65075. rebuild(): void;
  65076. /**
  65077. * Disposes the component and the associated ressources
  65078. */
  65079. dispose(): void;
  65080. private _gatherRenderTargets;
  65081. }
  65082. }
  65083. declare module BABYLON {
  65084. /**
  65085. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65086. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65087. */
  65088. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65089. private _scene;
  65090. private _camerasToBeAttached;
  65091. /**
  65092. * ID of the sharpen post process,
  65093. */
  65094. private readonly SharpenPostProcessId;
  65095. /**
  65096. * @ignore
  65097. * ID of the image processing post process;
  65098. */
  65099. readonly ImageProcessingPostProcessId: string;
  65100. /**
  65101. * @ignore
  65102. * ID of the Fast Approximate Anti-Aliasing post process;
  65103. */
  65104. readonly FxaaPostProcessId: string;
  65105. /**
  65106. * ID of the chromatic aberration post process,
  65107. */
  65108. private readonly ChromaticAberrationPostProcessId;
  65109. /**
  65110. * ID of the grain post process
  65111. */
  65112. private readonly GrainPostProcessId;
  65113. /**
  65114. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65115. */
  65116. sharpen: SharpenPostProcess;
  65117. private _sharpenEffect;
  65118. private bloom;
  65119. /**
  65120. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65121. */
  65122. depthOfField: DepthOfFieldEffect;
  65123. /**
  65124. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65125. */
  65126. fxaa: FxaaPostProcess;
  65127. /**
  65128. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65129. */
  65130. imageProcessing: ImageProcessingPostProcess;
  65131. /**
  65132. * Chromatic aberration post process which will shift rgb colors in the image
  65133. */
  65134. chromaticAberration: ChromaticAberrationPostProcess;
  65135. private _chromaticAberrationEffect;
  65136. /**
  65137. * Grain post process which add noise to the image
  65138. */
  65139. grain: GrainPostProcess;
  65140. private _grainEffect;
  65141. /**
  65142. * Glow post process which adds a glow to emissive areas of the image
  65143. */
  65144. private _glowLayer;
  65145. /**
  65146. * Animations which can be used to tweak settings over a period of time
  65147. */
  65148. animations: Animation[];
  65149. private _imageProcessingConfigurationObserver;
  65150. private _sharpenEnabled;
  65151. private _bloomEnabled;
  65152. private _depthOfFieldEnabled;
  65153. private _depthOfFieldBlurLevel;
  65154. private _fxaaEnabled;
  65155. private _imageProcessingEnabled;
  65156. private _defaultPipelineTextureType;
  65157. private _bloomScale;
  65158. private _chromaticAberrationEnabled;
  65159. private _grainEnabled;
  65160. private _buildAllowed;
  65161. /**
  65162. * Gets active scene
  65163. */
  65164. get scene(): Scene;
  65165. /**
  65166. * Enable or disable the sharpen process from the pipeline
  65167. */
  65168. set sharpenEnabled(enabled: boolean);
  65169. get sharpenEnabled(): boolean;
  65170. private _resizeObserver;
  65171. private _hardwareScaleLevel;
  65172. private _bloomKernel;
  65173. /**
  65174. * Specifies the size of the bloom blur kernel, relative to the final output size
  65175. */
  65176. get bloomKernel(): number;
  65177. set bloomKernel(value: number);
  65178. /**
  65179. * Specifies the weight of the bloom in the final rendering
  65180. */
  65181. private _bloomWeight;
  65182. /**
  65183. * Specifies the luma threshold for the area that will be blurred by the bloom
  65184. */
  65185. private _bloomThreshold;
  65186. private _hdr;
  65187. /**
  65188. * The strength of the bloom.
  65189. */
  65190. set bloomWeight(value: number);
  65191. get bloomWeight(): number;
  65192. /**
  65193. * The strength of the bloom.
  65194. */
  65195. set bloomThreshold(value: number);
  65196. get bloomThreshold(): number;
  65197. /**
  65198. * The scale of the bloom, lower value will provide better performance.
  65199. */
  65200. set bloomScale(value: number);
  65201. get bloomScale(): number;
  65202. /**
  65203. * Enable or disable the bloom from the pipeline
  65204. */
  65205. set bloomEnabled(enabled: boolean);
  65206. get bloomEnabled(): boolean;
  65207. private _rebuildBloom;
  65208. /**
  65209. * If the depth of field is enabled.
  65210. */
  65211. get depthOfFieldEnabled(): boolean;
  65212. set depthOfFieldEnabled(enabled: boolean);
  65213. /**
  65214. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65215. */
  65216. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65217. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65218. /**
  65219. * If the anti aliasing is enabled.
  65220. */
  65221. set fxaaEnabled(enabled: boolean);
  65222. get fxaaEnabled(): boolean;
  65223. private _samples;
  65224. /**
  65225. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65226. */
  65227. set samples(sampleCount: number);
  65228. get samples(): number;
  65229. /**
  65230. * If image processing is enabled.
  65231. */
  65232. set imageProcessingEnabled(enabled: boolean);
  65233. get imageProcessingEnabled(): boolean;
  65234. /**
  65235. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65236. */
  65237. set glowLayerEnabled(enabled: boolean);
  65238. get glowLayerEnabled(): boolean;
  65239. /**
  65240. * Gets the glow layer (or null if not defined)
  65241. */
  65242. get glowLayer(): Nullable<GlowLayer>;
  65243. /**
  65244. * Enable or disable the chromaticAberration process from the pipeline
  65245. */
  65246. set chromaticAberrationEnabled(enabled: boolean);
  65247. get chromaticAberrationEnabled(): boolean;
  65248. /**
  65249. * Enable or disable the grain process from the pipeline
  65250. */
  65251. set grainEnabled(enabled: boolean);
  65252. get grainEnabled(): boolean;
  65253. /**
  65254. * @constructor
  65255. * @param name - The rendering pipeline name (default: "")
  65256. * @param hdr - If high dynamic range textures should be used (default: true)
  65257. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65258. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65259. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65260. */
  65261. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65262. /**
  65263. * Get the class name
  65264. * @returns "DefaultRenderingPipeline"
  65265. */
  65266. getClassName(): string;
  65267. /**
  65268. * Force the compilation of the entire pipeline.
  65269. */
  65270. prepare(): void;
  65271. private _hasCleared;
  65272. private _prevPostProcess;
  65273. private _prevPrevPostProcess;
  65274. private _setAutoClearAndTextureSharing;
  65275. private _depthOfFieldSceneObserver;
  65276. private _buildPipeline;
  65277. private _disposePostProcesses;
  65278. /**
  65279. * Adds a camera to the pipeline
  65280. * @param camera the camera to be added
  65281. */
  65282. addCamera(camera: Camera): void;
  65283. /**
  65284. * Removes a camera from the pipeline
  65285. * @param camera the camera to remove
  65286. */
  65287. removeCamera(camera: Camera): void;
  65288. /**
  65289. * Dispose of the pipeline and stop all post processes
  65290. */
  65291. dispose(): void;
  65292. /**
  65293. * Serialize the rendering pipeline (Used when exporting)
  65294. * @returns the serialized object
  65295. */
  65296. serialize(): any;
  65297. /**
  65298. * Parse the serialized pipeline
  65299. * @param source Source pipeline.
  65300. * @param scene The scene to load the pipeline to.
  65301. * @param rootUrl The URL of the serialized pipeline.
  65302. * @returns An instantiated pipeline from the serialized object.
  65303. */
  65304. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65305. }
  65306. }
  65307. declare module BABYLON {
  65308. /** @hidden */
  65309. export var lensHighlightsPixelShader: {
  65310. name: string;
  65311. shader: string;
  65312. };
  65313. }
  65314. declare module BABYLON {
  65315. /** @hidden */
  65316. export var depthOfFieldPixelShader: {
  65317. name: string;
  65318. shader: string;
  65319. };
  65320. }
  65321. declare module BABYLON {
  65322. /**
  65323. * BABYLON.JS Chromatic Aberration GLSL Shader
  65324. * Author: Olivier Guyot
  65325. * Separates very slightly R, G and B colors on the edges of the screen
  65326. * Inspired by Francois Tarlier & Martins Upitis
  65327. */
  65328. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65329. /**
  65330. * @ignore
  65331. * The chromatic aberration PostProcess id in the pipeline
  65332. */
  65333. LensChromaticAberrationEffect: string;
  65334. /**
  65335. * @ignore
  65336. * The highlights enhancing PostProcess id in the pipeline
  65337. */
  65338. HighlightsEnhancingEffect: string;
  65339. /**
  65340. * @ignore
  65341. * The depth-of-field PostProcess id in the pipeline
  65342. */
  65343. LensDepthOfFieldEffect: string;
  65344. private _scene;
  65345. private _depthTexture;
  65346. private _grainTexture;
  65347. private _chromaticAberrationPostProcess;
  65348. private _highlightsPostProcess;
  65349. private _depthOfFieldPostProcess;
  65350. private _edgeBlur;
  65351. private _grainAmount;
  65352. private _chromaticAberration;
  65353. private _distortion;
  65354. private _highlightsGain;
  65355. private _highlightsThreshold;
  65356. private _dofDistance;
  65357. private _dofAperture;
  65358. private _dofDarken;
  65359. private _dofPentagon;
  65360. private _blurNoise;
  65361. /**
  65362. * @constructor
  65363. *
  65364. * Effect parameters are as follow:
  65365. * {
  65366. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65367. * edge_blur: number; // from 0 to x (1 for realism)
  65368. * distortion: number; // from 0 to x (1 for realism)
  65369. * grain_amount: number; // from 0 to 1
  65370. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65371. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65372. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65373. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65374. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65375. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65376. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65377. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65378. * }
  65379. * Note: if an effect parameter is unset, effect is disabled
  65380. *
  65381. * @param name The rendering pipeline name
  65382. * @param parameters - An object containing all parameters (see above)
  65383. * @param scene The scene linked to this pipeline
  65384. * @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)
  65385. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65386. */
  65387. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65388. /**
  65389. * Get the class name
  65390. * @returns "LensRenderingPipeline"
  65391. */
  65392. getClassName(): string;
  65393. /**
  65394. * Gets associated scene
  65395. */
  65396. get scene(): Scene;
  65397. /**
  65398. * Gets or sets the edge blur
  65399. */
  65400. get edgeBlur(): number;
  65401. set edgeBlur(value: number);
  65402. /**
  65403. * Gets or sets the grain amount
  65404. */
  65405. get grainAmount(): number;
  65406. set grainAmount(value: number);
  65407. /**
  65408. * Gets or sets the chromatic aberration amount
  65409. */
  65410. get chromaticAberration(): number;
  65411. set chromaticAberration(value: number);
  65412. /**
  65413. * Gets or sets the depth of field aperture
  65414. */
  65415. get dofAperture(): number;
  65416. set dofAperture(value: number);
  65417. /**
  65418. * Gets or sets the edge distortion
  65419. */
  65420. get edgeDistortion(): number;
  65421. set edgeDistortion(value: number);
  65422. /**
  65423. * Gets or sets the depth of field distortion
  65424. */
  65425. get dofDistortion(): number;
  65426. set dofDistortion(value: number);
  65427. /**
  65428. * Gets or sets the darken out of focus amount
  65429. */
  65430. get darkenOutOfFocus(): number;
  65431. set darkenOutOfFocus(value: number);
  65432. /**
  65433. * Gets or sets a boolean indicating if blur noise is enabled
  65434. */
  65435. get blurNoise(): boolean;
  65436. set blurNoise(value: boolean);
  65437. /**
  65438. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65439. */
  65440. get pentagonBokeh(): boolean;
  65441. set pentagonBokeh(value: boolean);
  65442. /**
  65443. * Gets or sets the highlight grain amount
  65444. */
  65445. get highlightsGain(): number;
  65446. set highlightsGain(value: number);
  65447. /**
  65448. * Gets or sets the highlight threshold
  65449. */
  65450. get highlightsThreshold(): number;
  65451. set highlightsThreshold(value: number);
  65452. /**
  65453. * Sets the amount of blur at the edges
  65454. * @param amount blur amount
  65455. */
  65456. setEdgeBlur(amount: number): void;
  65457. /**
  65458. * Sets edge blur to 0
  65459. */
  65460. disableEdgeBlur(): void;
  65461. /**
  65462. * Sets the amout of grain
  65463. * @param amount Amount of grain
  65464. */
  65465. setGrainAmount(amount: number): void;
  65466. /**
  65467. * Set grain amount to 0
  65468. */
  65469. disableGrain(): void;
  65470. /**
  65471. * Sets the chromatic aberration amount
  65472. * @param amount amount of chromatic aberration
  65473. */
  65474. setChromaticAberration(amount: number): void;
  65475. /**
  65476. * Sets chromatic aberration amount to 0
  65477. */
  65478. disableChromaticAberration(): void;
  65479. /**
  65480. * Sets the EdgeDistortion amount
  65481. * @param amount amount of EdgeDistortion
  65482. */
  65483. setEdgeDistortion(amount: number): void;
  65484. /**
  65485. * Sets edge distortion to 0
  65486. */
  65487. disableEdgeDistortion(): void;
  65488. /**
  65489. * Sets the FocusDistance amount
  65490. * @param amount amount of FocusDistance
  65491. */
  65492. setFocusDistance(amount: number): void;
  65493. /**
  65494. * Disables depth of field
  65495. */
  65496. disableDepthOfField(): void;
  65497. /**
  65498. * Sets the Aperture amount
  65499. * @param amount amount of Aperture
  65500. */
  65501. setAperture(amount: number): void;
  65502. /**
  65503. * Sets the DarkenOutOfFocus amount
  65504. * @param amount amount of DarkenOutOfFocus
  65505. */
  65506. setDarkenOutOfFocus(amount: number): void;
  65507. private _pentagonBokehIsEnabled;
  65508. /**
  65509. * Creates a pentagon bokeh effect
  65510. */
  65511. enablePentagonBokeh(): void;
  65512. /**
  65513. * Disables the pentagon bokeh effect
  65514. */
  65515. disablePentagonBokeh(): void;
  65516. /**
  65517. * Enables noise blur
  65518. */
  65519. enableNoiseBlur(): void;
  65520. /**
  65521. * Disables noise blur
  65522. */
  65523. disableNoiseBlur(): void;
  65524. /**
  65525. * Sets the HighlightsGain amount
  65526. * @param amount amount of HighlightsGain
  65527. */
  65528. setHighlightsGain(amount: number): void;
  65529. /**
  65530. * Sets the HighlightsThreshold amount
  65531. * @param amount amount of HighlightsThreshold
  65532. */
  65533. setHighlightsThreshold(amount: number): void;
  65534. /**
  65535. * Disables highlights
  65536. */
  65537. disableHighlights(): void;
  65538. /**
  65539. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65540. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65541. */
  65542. dispose(disableDepthRender?: boolean): void;
  65543. private _createChromaticAberrationPostProcess;
  65544. private _createHighlightsPostProcess;
  65545. private _createDepthOfFieldPostProcess;
  65546. private _createGrainTexture;
  65547. }
  65548. }
  65549. declare module BABYLON {
  65550. /** @hidden */
  65551. export var ssao2PixelShader: {
  65552. name: string;
  65553. shader: string;
  65554. };
  65555. }
  65556. declare module BABYLON {
  65557. /** @hidden */
  65558. export var ssaoCombinePixelShader: {
  65559. name: string;
  65560. shader: string;
  65561. };
  65562. }
  65563. declare module BABYLON {
  65564. /**
  65565. * Render pipeline to produce ssao effect
  65566. */
  65567. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65568. /**
  65569. * @ignore
  65570. * The PassPostProcess id in the pipeline that contains the original scene color
  65571. */
  65572. SSAOOriginalSceneColorEffect: string;
  65573. /**
  65574. * @ignore
  65575. * The SSAO PostProcess id in the pipeline
  65576. */
  65577. SSAORenderEffect: string;
  65578. /**
  65579. * @ignore
  65580. * The horizontal blur PostProcess id in the pipeline
  65581. */
  65582. SSAOBlurHRenderEffect: string;
  65583. /**
  65584. * @ignore
  65585. * The vertical blur PostProcess id in the pipeline
  65586. */
  65587. SSAOBlurVRenderEffect: string;
  65588. /**
  65589. * @ignore
  65590. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65591. */
  65592. SSAOCombineRenderEffect: string;
  65593. /**
  65594. * The output strength of the SSAO post-process. Default value is 1.0.
  65595. */
  65596. totalStrength: number;
  65597. /**
  65598. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65599. */
  65600. maxZ: number;
  65601. /**
  65602. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65603. */
  65604. minZAspect: number;
  65605. private _samples;
  65606. /**
  65607. * Number of samples used for the SSAO calculations. Default value is 8
  65608. */
  65609. set samples(n: number);
  65610. get samples(): number;
  65611. private _textureSamples;
  65612. /**
  65613. * Number of samples to use for antialiasing
  65614. */
  65615. set textureSamples(n: number);
  65616. get textureSamples(): number;
  65617. /**
  65618. * Ratio object used for SSAO ratio and blur ratio
  65619. */
  65620. private _ratio;
  65621. /**
  65622. * Dynamically generated sphere sampler.
  65623. */
  65624. private _sampleSphere;
  65625. /**
  65626. * Blur filter offsets
  65627. */
  65628. private _samplerOffsets;
  65629. private _expensiveBlur;
  65630. /**
  65631. * If bilateral blur should be used
  65632. */
  65633. set expensiveBlur(b: boolean);
  65634. get expensiveBlur(): boolean;
  65635. /**
  65636. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65637. */
  65638. radius: number;
  65639. /**
  65640. * The base color of the SSAO post-process
  65641. * The final result is "base + ssao" between [0, 1]
  65642. */
  65643. base: number;
  65644. /**
  65645. * Support test.
  65646. */
  65647. static get IsSupported(): boolean;
  65648. private _scene;
  65649. private _depthTexture;
  65650. private _normalTexture;
  65651. private _randomTexture;
  65652. private _originalColorPostProcess;
  65653. private _ssaoPostProcess;
  65654. private _blurHPostProcess;
  65655. private _blurVPostProcess;
  65656. private _ssaoCombinePostProcess;
  65657. /**
  65658. * Gets active scene
  65659. */
  65660. get scene(): Scene;
  65661. /**
  65662. * @constructor
  65663. * @param name The rendering pipeline name
  65664. * @param scene The scene linked to this pipeline
  65665. * @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 }
  65666. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65667. */
  65668. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65669. /**
  65670. * Get the class name
  65671. * @returns "SSAO2RenderingPipeline"
  65672. */
  65673. getClassName(): string;
  65674. /**
  65675. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65676. */
  65677. dispose(disableGeometryBufferRenderer?: boolean): void;
  65678. private _createBlurPostProcess;
  65679. /** @hidden */
  65680. _rebuild(): void;
  65681. private _bits;
  65682. private _radicalInverse_VdC;
  65683. private _hammersley;
  65684. private _hemisphereSample_uniform;
  65685. private _generateHemisphere;
  65686. private _createSSAOPostProcess;
  65687. private _createSSAOCombinePostProcess;
  65688. private _createRandomTexture;
  65689. /**
  65690. * Serialize the rendering pipeline (Used when exporting)
  65691. * @returns the serialized object
  65692. */
  65693. serialize(): any;
  65694. /**
  65695. * Parse the serialized pipeline
  65696. * @param source Source pipeline.
  65697. * @param scene The scene to load the pipeline to.
  65698. * @param rootUrl The URL of the serialized pipeline.
  65699. * @returns An instantiated pipeline from the serialized object.
  65700. */
  65701. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65702. }
  65703. }
  65704. declare module BABYLON {
  65705. /** @hidden */
  65706. export var ssaoPixelShader: {
  65707. name: string;
  65708. shader: string;
  65709. };
  65710. }
  65711. declare module BABYLON {
  65712. /**
  65713. * Render pipeline to produce ssao effect
  65714. */
  65715. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65716. /**
  65717. * @ignore
  65718. * The PassPostProcess id in the pipeline that contains the original scene color
  65719. */
  65720. SSAOOriginalSceneColorEffect: string;
  65721. /**
  65722. * @ignore
  65723. * The SSAO PostProcess id in the pipeline
  65724. */
  65725. SSAORenderEffect: string;
  65726. /**
  65727. * @ignore
  65728. * The horizontal blur PostProcess id in the pipeline
  65729. */
  65730. SSAOBlurHRenderEffect: string;
  65731. /**
  65732. * @ignore
  65733. * The vertical blur PostProcess id in the pipeline
  65734. */
  65735. SSAOBlurVRenderEffect: string;
  65736. /**
  65737. * @ignore
  65738. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65739. */
  65740. SSAOCombineRenderEffect: string;
  65741. /**
  65742. * The output strength of the SSAO post-process. Default value is 1.0.
  65743. */
  65744. totalStrength: number;
  65745. /**
  65746. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65747. */
  65748. radius: number;
  65749. /**
  65750. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65751. * Must not be equal to fallOff and superior to fallOff.
  65752. * Default value is 0.0075
  65753. */
  65754. area: number;
  65755. /**
  65756. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65757. * Must not be equal to area and inferior to area.
  65758. * Default value is 0.000001
  65759. */
  65760. fallOff: number;
  65761. /**
  65762. * The base color of the SSAO post-process
  65763. * The final result is "base + ssao" between [0, 1]
  65764. */
  65765. base: number;
  65766. private _scene;
  65767. private _depthTexture;
  65768. private _randomTexture;
  65769. private _originalColorPostProcess;
  65770. private _ssaoPostProcess;
  65771. private _blurHPostProcess;
  65772. private _blurVPostProcess;
  65773. private _ssaoCombinePostProcess;
  65774. private _firstUpdate;
  65775. /**
  65776. * Gets active scene
  65777. */
  65778. get scene(): Scene;
  65779. /**
  65780. * @constructor
  65781. * @param name - The rendering pipeline name
  65782. * @param scene - The scene linked to this pipeline
  65783. * @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 }
  65784. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65785. */
  65786. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65787. /**
  65788. * Get the class name
  65789. * @returns "SSAORenderingPipeline"
  65790. */
  65791. getClassName(): string;
  65792. /**
  65793. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65794. */
  65795. dispose(disableDepthRender?: boolean): void;
  65796. private _createBlurPostProcess;
  65797. /** @hidden */
  65798. _rebuild(): void;
  65799. private _createSSAOPostProcess;
  65800. private _createSSAOCombinePostProcess;
  65801. private _createRandomTexture;
  65802. }
  65803. }
  65804. declare module BABYLON {
  65805. /** @hidden */
  65806. export var screenSpaceReflectionPixelShader: {
  65807. name: string;
  65808. shader: string;
  65809. };
  65810. }
  65811. declare module BABYLON {
  65812. /**
  65813. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65814. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65815. */
  65816. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65817. /**
  65818. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65819. */
  65820. threshold: number;
  65821. /**
  65822. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65823. */
  65824. strength: number;
  65825. /**
  65826. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65827. */
  65828. reflectionSpecularFalloffExponent: number;
  65829. /**
  65830. * 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]
  65831. */
  65832. step: number;
  65833. /**
  65834. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65835. */
  65836. roughnessFactor: number;
  65837. private _geometryBufferRenderer;
  65838. private _enableSmoothReflections;
  65839. private _reflectionSamples;
  65840. private _smoothSteps;
  65841. /**
  65842. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65843. * @param name The name of the effect.
  65844. * @param scene The scene containing the objects to calculate reflections.
  65845. * @param options The required width/height ratio to downsize to before computing the render pass.
  65846. * @param camera The camera to apply the render pass to.
  65847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65848. * @param engine The engine which the post process will be applied. (default: current engine)
  65849. * @param reusable If the post process can be reused on the same frame. (default: false)
  65850. * @param textureType Type of textures used when performing the post process. (default: 0)
  65851. * @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)
  65852. */
  65853. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65854. /**
  65855. * Gets wether or not smoothing reflections is enabled.
  65856. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65857. */
  65858. get enableSmoothReflections(): boolean;
  65859. /**
  65860. * Sets wether or not smoothing reflections is enabled.
  65861. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65862. */
  65863. set enableSmoothReflections(enabled: boolean);
  65864. /**
  65865. * Gets the number of samples taken while computing reflections. More samples count is high,
  65866. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65867. */
  65868. get reflectionSamples(): number;
  65869. /**
  65870. * Sets the number of samples taken while computing reflections. More samples count is high,
  65871. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65872. */
  65873. set reflectionSamples(samples: number);
  65874. /**
  65875. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65876. * more the post-process will require GPU power and can generate a drop in FPS.
  65877. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65878. */
  65879. get smoothSteps(): number;
  65880. set smoothSteps(steps: number);
  65881. private _updateEffectDefines;
  65882. }
  65883. }
  65884. declare module BABYLON {
  65885. /** @hidden */
  65886. export var standardPixelShader: {
  65887. name: string;
  65888. shader: string;
  65889. };
  65890. }
  65891. declare module BABYLON {
  65892. /**
  65893. * Standard rendering pipeline
  65894. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65895. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65896. */
  65897. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65898. /**
  65899. * Public members
  65900. */
  65901. /**
  65902. * Post-process which contains the original scene color before the pipeline applies all the effects
  65903. */
  65904. originalPostProcess: Nullable<PostProcess>;
  65905. /**
  65906. * Post-process used to down scale an image x4
  65907. */
  65908. downSampleX4PostProcess: Nullable<PostProcess>;
  65909. /**
  65910. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65911. */
  65912. brightPassPostProcess: Nullable<PostProcess>;
  65913. /**
  65914. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65915. */
  65916. blurHPostProcesses: PostProcess[];
  65917. /**
  65918. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65919. */
  65920. blurVPostProcesses: PostProcess[];
  65921. /**
  65922. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65923. */
  65924. textureAdderPostProcess: Nullable<PostProcess>;
  65925. /**
  65926. * Post-process used to create volumetric lighting effect
  65927. */
  65928. volumetricLightPostProcess: Nullable<PostProcess>;
  65929. /**
  65930. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65931. */
  65932. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65933. /**
  65934. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65935. */
  65936. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65937. /**
  65938. * Post-process used to merge the volumetric light effect and the real scene color
  65939. */
  65940. volumetricLightMergePostProces: Nullable<PostProcess>;
  65941. /**
  65942. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65943. */
  65944. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65945. /**
  65946. * Base post-process used to calculate the average luminance of the final image for HDR
  65947. */
  65948. luminancePostProcess: Nullable<PostProcess>;
  65949. /**
  65950. * Post-processes used to create down sample post-processes in order to get
  65951. * the average luminance of the final image for HDR
  65952. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65953. */
  65954. luminanceDownSamplePostProcesses: PostProcess[];
  65955. /**
  65956. * Post-process used to create a HDR effect (light adaptation)
  65957. */
  65958. hdrPostProcess: Nullable<PostProcess>;
  65959. /**
  65960. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65961. */
  65962. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65963. /**
  65964. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65965. */
  65966. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65967. /**
  65968. * Post-process used to merge the final HDR post-process and the real scene color
  65969. */
  65970. hdrFinalPostProcess: Nullable<PostProcess>;
  65971. /**
  65972. * Post-process used to create a lens flare effect
  65973. */
  65974. lensFlarePostProcess: Nullable<PostProcess>;
  65975. /**
  65976. * Post-process that merges the result of the lens flare post-process and the real scene color
  65977. */
  65978. lensFlareComposePostProcess: Nullable<PostProcess>;
  65979. /**
  65980. * Post-process used to create a motion blur effect
  65981. */
  65982. motionBlurPostProcess: Nullable<PostProcess>;
  65983. /**
  65984. * Post-process used to create a depth of field effect
  65985. */
  65986. depthOfFieldPostProcess: Nullable<PostProcess>;
  65987. /**
  65988. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65989. */
  65990. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65991. /**
  65992. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  65993. */
  65994. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  65995. /**
  65996. * Represents the brightness threshold in order to configure the illuminated surfaces
  65997. */
  65998. brightThreshold: number;
  65999. /**
  66000. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66001. */
  66002. blurWidth: number;
  66003. /**
  66004. * Sets if the blur for highlighted surfaces must be only horizontal
  66005. */
  66006. horizontalBlur: boolean;
  66007. /**
  66008. * Gets the overall exposure used by the pipeline
  66009. */
  66010. get exposure(): number;
  66011. /**
  66012. * Sets the overall exposure used by the pipeline
  66013. */
  66014. set exposure(value: number);
  66015. /**
  66016. * Texture used typically to simulate "dirty" on camera lens
  66017. */
  66018. lensTexture: Nullable<Texture>;
  66019. /**
  66020. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66021. */
  66022. volumetricLightCoefficient: number;
  66023. /**
  66024. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66025. */
  66026. volumetricLightPower: number;
  66027. /**
  66028. * Used the set the blur intensity to smooth the volumetric lights
  66029. */
  66030. volumetricLightBlurScale: number;
  66031. /**
  66032. * Light (spot or directional) used to generate the volumetric lights rays
  66033. * The source light must have a shadow generate so the pipeline can get its
  66034. * depth map
  66035. */
  66036. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66037. /**
  66038. * For eye adaptation, represents the minimum luminance the eye can see
  66039. */
  66040. hdrMinimumLuminance: number;
  66041. /**
  66042. * For eye adaptation, represents the decrease luminance speed
  66043. */
  66044. hdrDecreaseRate: number;
  66045. /**
  66046. * For eye adaptation, represents the increase luminance speed
  66047. */
  66048. hdrIncreaseRate: number;
  66049. /**
  66050. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66051. */
  66052. get hdrAutoExposure(): boolean;
  66053. /**
  66054. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66055. */
  66056. set hdrAutoExposure(value: boolean);
  66057. /**
  66058. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66059. */
  66060. lensColorTexture: Nullable<Texture>;
  66061. /**
  66062. * The overall strengh for the lens flare effect
  66063. */
  66064. lensFlareStrength: number;
  66065. /**
  66066. * Dispersion coefficient for lens flare ghosts
  66067. */
  66068. lensFlareGhostDispersal: number;
  66069. /**
  66070. * Main lens flare halo width
  66071. */
  66072. lensFlareHaloWidth: number;
  66073. /**
  66074. * Based on the lens distortion effect, defines how much the lens flare result
  66075. * is distorted
  66076. */
  66077. lensFlareDistortionStrength: number;
  66078. /**
  66079. * Configures the blur intensity used for for lens flare (halo)
  66080. */
  66081. lensFlareBlurWidth: number;
  66082. /**
  66083. * Lens star texture must be used to simulate rays on the flares and is available
  66084. * in the documentation
  66085. */
  66086. lensStarTexture: Nullable<Texture>;
  66087. /**
  66088. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66089. * flare effect by taking account of the dirt texture
  66090. */
  66091. lensFlareDirtTexture: Nullable<Texture>;
  66092. /**
  66093. * Represents the focal length for the depth of field effect
  66094. */
  66095. depthOfFieldDistance: number;
  66096. /**
  66097. * Represents the blur intensity for the blurred part of the depth of field effect
  66098. */
  66099. depthOfFieldBlurWidth: number;
  66100. /**
  66101. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66102. */
  66103. get motionStrength(): number;
  66104. /**
  66105. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66106. */
  66107. set motionStrength(strength: number);
  66108. /**
  66109. * Gets wether or not the motion blur post-process is object based or screen based.
  66110. */
  66111. get objectBasedMotionBlur(): boolean;
  66112. /**
  66113. * Sets wether or not the motion blur post-process should be object based or screen based
  66114. */
  66115. set objectBasedMotionBlur(value: boolean);
  66116. /**
  66117. * List of animations for the pipeline (IAnimatable implementation)
  66118. */
  66119. animations: Animation[];
  66120. /**
  66121. * Private members
  66122. */
  66123. private _scene;
  66124. private _currentDepthOfFieldSource;
  66125. private _basePostProcess;
  66126. private _fixedExposure;
  66127. private _currentExposure;
  66128. private _hdrAutoExposure;
  66129. private _hdrCurrentLuminance;
  66130. private _motionStrength;
  66131. private _isObjectBasedMotionBlur;
  66132. private _floatTextureType;
  66133. private _camerasToBeAttached;
  66134. private _ratio;
  66135. private _bloomEnabled;
  66136. private _depthOfFieldEnabled;
  66137. private _vlsEnabled;
  66138. private _lensFlareEnabled;
  66139. private _hdrEnabled;
  66140. private _motionBlurEnabled;
  66141. private _fxaaEnabled;
  66142. private _screenSpaceReflectionsEnabled;
  66143. private _motionBlurSamples;
  66144. private _volumetricLightStepsCount;
  66145. private _samples;
  66146. /**
  66147. * @ignore
  66148. * Specifies if the bloom pipeline is enabled
  66149. */
  66150. get BloomEnabled(): boolean;
  66151. set BloomEnabled(enabled: boolean);
  66152. /**
  66153. * @ignore
  66154. * Specifies if the depth of field pipeline is enabed
  66155. */
  66156. get DepthOfFieldEnabled(): boolean;
  66157. set DepthOfFieldEnabled(enabled: boolean);
  66158. /**
  66159. * @ignore
  66160. * Specifies if the lens flare pipeline is enabed
  66161. */
  66162. get LensFlareEnabled(): boolean;
  66163. set LensFlareEnabled(enabled: boolean);
  66164. /**
  66165. * @ignore
  66166. * Specifies if the HDR pipeline is enabled
  66167. */
  66168. get HDREnabled(): boolean;
  66169. set HDREnabled(enabled: boolean);
  66170. /**
  66171. * @ignore
  66172. * Specifies if the volumetric lights scattering effect is enabled
  66173. */
  66174. get VLSEnabled(): boolean;
  66175. set VLSEnabled(enabled: boolean);
  66176. /**
  66177. * @ignore
  66178. * Specifies if the motion blur effect is enabled
  66179. */
  66180. get MotionBlurEnabled(): boolean;
  66181. set MotionBlurEnabled(enabled: boolean);
  66182. /**
  66183. * Specifies if anti-aliasing is enabled
  66184. */
  66185. get fxaaEnabled(): boolean;
  66186. set fxaaEnabled(enabled: boolean);
  66187. /**
  66188. * Specifies if screen space reflections are enabled.
  66189. */
  66190. get screenSpaceReflectionsEnabled(): boolean;
  66191. set screenSpaceReflectionsEnabled(enabled: boolean);
  66192. /**
  66193. * Specifies the number of steps used to calculate the volumetric lights
  66194. * Typically in interval [50, 200]
  66195. */
  66196. get volumetricLightStepsCount(): number;
  66197. set volumetricLightStepsCount(count: number);
  66198. /**
  66199. * Specifies the number of samples used for the motion blur effect
  66200. * Typically in interval [16, 64]
  66201. */
  66202. get motionBlurSamples(): number;
  66203. set motionBlurSamples(samples: number);
  66204. /**
  66205. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66206. */
  66207. get samples(): number;
  66208. set samples(sampleCount: number);
  66209. /**
  66210. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66211. * @constructor
  66212. * @param name The rendering pipeline name
  66213. * @param scene The scene linked to this pipeline
  66214. * @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)
  66215. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66216. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66217. */
  66218. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66219. private _buildPipeline;
  66220. private _createDownSampleX4PostProcess;
  66221. private _createBrightPassPostProcess;
  66222. private _createBlurPostProcesses;
  66223. private _createTextureAdderPostProcess;
  66224. private _createVolumetricLightPostProcess;
  66225. private _createLuminancePostProcesses;
  66226. private _createHdrPostProcess;
  66227. private _createLensFlarePostProcess;
  66228. private _createDepthOfFieldPostProcess;
  66229. private _createMotionBlurPostProcess;
  66230. private _getDepthTexture;
  66231. private _disposePostProcesses;
  66232. /**
  66233. * Dispose of the pipeline and stop all post processes
  66234. */
  66235. dispose(): void;
  66236. /**
  66237. * Serialize the rendering pipeline (Used when exporting)
  66238. * @returns the serialized object
  66239. */
  66240. serialize(): any;
  66241. /**
  66242. * Parse the serialized pipeline
  66243. * @param source Source pipeline.
  66244. * @param scene The scene to load the pipeline to.
  66245. * @param rootUrl The URL of the serialized pipeline.
  66246. * @returns An instantiated pipeline from the serialized object.
  66247. */
  66248. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66249. /**
  66250. * Luminance steps
  66251. */
  66252. static LuminanceSteps: number;
  66253. }
  66254. }
  66255. declare module BABYLON {
  66256. /** @hidden */
  66257. export var tonemapPixelShader: {
  66258. name: string;
  66259. shader: string;
  66260. };
  66261. }
  66262. declare module BABYLON {
  66263. /** Defines operator used for tonemapping */
  66264. export enum TonemappingOperator {
  66265. /** Hable */
  66266. Hable = 0,
  66267. /** Reinhard */
  66268. Reinhard = 1,
  66269. /** HejiDawson */
  66270. HejiDawson = 2,
  66271. /** Photographic */
  66272. Photographic = 3
  66273. }
  66274. /**
  66275. * Defines a post process to apply tone mapping
  66276. */
  66277. export class TonemapPostProcess extends PostProcess {
  66278. private _operator;
  66279. /** Defines the required exposure adjustement */
  66280. exposureAdjustment: number;
  66281. /**
  66282. * Creates a new TonemapPostProcess
  66283. * @param name defines the name of the postprocess
  66284. * @param _operator defines the operator to use
  66285. * @param exposureAdjustment defines the required exposure adjustement
  66286. * @param camera defines the camera to use (can be null)
  66287. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66288. * @param engine defines the hosting engine (can be ignore if camera is set)
  66289. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66290. */
  66291. constructor(name: string, _operator: TonemappingOperator,
  66292. /** Defines the required exposure adjustement */
  66293. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66294. }
  66295. }
  66296. declare module BABYLON {
  66297. /** @hidden */
  66298. export var volumetricLightScatteringPixelShader: {
  66299. name: string;
  66300. shader: string;
  66301. };
  66302. }
  66303. declare module BABYLON {
  66304. /** @hidden */
  66305. export var volumetricLightScatteringPassVertexShader: {
  66306. name: string;
  66307. shader: string;
  66308. };
  66309. }
  66310. declare module BABYLON {
  66311. /** @hidden */
  66312. export var volumetricLightScatteringPassPixelShader: {
  66313. name: string;
  66314. shader: string;
  66315. };
  66316. }
  66317. declare module BABYLON {
  66318. /**
  66319. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66320. */
  66321. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66322. private _volumetricLightScatteringPass;
  66323. private _volumetricLightScatteringRTT;
  66324. private _viewPort;
  66325. private _screenCoordinates;
  66326. private _cachedDefines;
  66327. /**
  66328. * If not undefined, the mesh position is computed from the attached node position
  66329. */
  66330. attachedNode: {
  66331. position: Vector3;
  66332. };
  66333. /**
  66334. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66335. */
  66336. customMeshPosition: Vector3;
  66337. /**
  66338. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66339. */
  66340. useCustomMeshPosition: boolean;
  66341. /**
  66342. * If the post-process should inverse the light scattering direction
  66343. */
  66344. invert: boolean;
  66345. /**
  66346. * The internal mesh used by the post-process
  66347. */
  66348. mesh: Mesh;
  66349. /**
  66350. * @hidden
  66351. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66352. */
  66353. get useDiffuseColor(): boolean;
  66354. set useDiffuseColor(useDiffuseColor: boolean);
  66355. /**
  66356. * Array containing the excluded meshes not rendered in the internal pass
  66357. */
  66358. excludedMeshes: AbstractMesh[];
  66359. /**
  66360. * Controls the overall intensity of the post-process
  66361. */
  66362. exposure: number;
  66363. /**
  66364. * Dissipates each sample's contribution in range [0, 1]
  66365. */
  66366. decay: number;
  66367. /**
  66368. * Controls the overall intensity of each sample
  66369. */
  66370. weight: number;
  66371. /**
  66372. * Controls the density of each sample
  66373. */
  66374. density: number;
  66375. /**
  66376. * @constructor
  66377. * @param name The post-process name
  66378. * @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)
  66379. * @param camera The camera that the post-process will be attached to
  66380. * @param mesh The mesh used to create the light scattering
  66381. * @param samples The post-process quality, default 100
  66382. * @param samplingModeThe post-process filtering mode
  66383. * @param engine The babylon engine
  66384. * @param reusable If the post-process is reusable
  66385. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66386. */
  66387. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66388. /**
  66389. * Returns the string "VolumetricLightScatteringPostProcess"
  66390. * @returns "VolumetricLightScatteringPostProcess"
  66391. */
  66392. getClassName(): string;
  66393. private _isReady;
  66394. /**
  66395. * Sets the new light position for light scattering effect
  66396. * @param position The new custom light position
  66397. */
  66398. setCustomMeshPosition(position: Vector3): void;
  66399. /**
  66400. * Returns the light position for light scattering effect
  66401. * @return Vector3 The custom light position
  66402. */
  66403. getCustomMeshPosition(): Vector3;
  66404. /**
  66405. * Disposes the internal assets and detaches the post-process from the camera
  66406. */
  66407. dispose(camera: Camera): void;
  66408. /**
  66409. * Returns the render target texture used by the post-process
  66410. * @return the render target texture used by the post-process
  66411. */
  66412. getPass(): RenderTargetTexture;
  66413. private _meshExcluded;
  66414. private _createPass;
  66415. private _updateMeshScreenCoordinates;
  66416. /**
  66417. * Creates a default mesh for the Volumeric Light Scattering post-process
  66418. * @param name The mesh name
  66419. * @param scene The scene where to create the mesh
  66420. * @return the default mesh
  66421. */
  66422. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66423. }
  66424. }
  66425. declare module BABYLON {
  66426. interface Scene {
  66427. /** @hidden (Backing field) */
  66428. _boundingBoxRenderer: BoundingBoxRenderer;
  66429. /** @hidden (Backing field) */
  66430. _forceShowBoundingBoxes: boolean;
  66431. /**
  66432. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66433. */
  66434. forceShowBoundingBoxes: boolean;
  66435. /**
  66436. * Gets the bounding box renderer associated with the scene
  66437. * @returns a BoundingBoxRenderer
  66438. */
  66439. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66440. }
  66441. interface AbstractMesh {
  66442. /** @hidden (Backing field) */
  66443. _showBoundingBox: boolean;
  66444. /**
  66445. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66446. */
  66447. showBoundingBox: boolean;
  66448. }
  66449. /**
  66450. * Component responsible of rendering the bounding box of the meshes in a scene.
  66451. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66452. */
  66453. export class BoundingBoxRenderer implements ISceneComponent {
  66454. /**
  66455. * The component name helpfull to identify the component in the list of scene components.
  66456. */
  66457. readonly name: string;
  66458. /**
  66459. * The scene the component belongs to.
  66460. */
  66461. scene: Scene;
  66462. /**
  66463. * Color of the bounding box lines placed in front of an object
  66464. */
  66465. frontColor: Color3;
  66466. /**
  66467. * Color of the bounding box lines placed behind an object
  66468. */
  66469. backColor: Color3;
  66470. /**
  66471. * Defines if the renderer should show the back lines or not
  66472. */
  66473. showBackLines: boolean;
  66474. /**
  66475. * @hidden
  66476. */
  66477. renderList: SmartArray<BoundingBox>;
  66478. private _colorShader;
  66479. private _vertexBuffers;
  66480. private _indexBuffer;
  66481. private _fillIndexBuffer;
  66482. private _fillIndexData;
  66483. /**
  66484. * Instantiates a new bounding box renderer in a scene.
  66485. * @param scene the scene the renderer renders in
  66486. */
  66487. constructor(scene: Scene);
  66488. /**
  66489. * Registers the component in a given scene
  66490. */
  66491. register(): void;
  66492. private _evaluateSubMesh;
  66493. private _activeMesh;
  66494. private _prepareRessources;
  66495. private _createIndexBuffer;
  66496. /**
  66497. * Rebuilds the elements related to this component in case of
  66498. * context lost for instance.
  66499. */
  66500. rebuild(): void;
  66501. /**
  66502. * @hidden
  66503. */
  66504. reset(): void;
  66505. /**
  66506. * Render the bounding boxes of a specific rendering group
  66507. * @param renderingGroupId defines the rendering group to render
  66508. */
  66509. render(renderingGroupId: number): void;
  66510. /**
  66511. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66512. * @param mesh Define the mesh to render the occlusion bounding box for
  66513. */
  66514. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66515. /**
  66516. * Dispose and release the resources attached to this renderer.
  66517. */
  66518. dispose(): void;
  66519. }
  66520. }
  66521. declare module BABYLON {
  66522. interface Scene {
  66523. /** @hidden (Backing field) */
  66524. _depthRenderer: {
  66525. [id: string]: DepthRenderer;
  66526. };
  66527. /**
  66528. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66529. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66530. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66531. * @returns the created depth renderer
  66532. */
  66533. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66534. /**
  66535. * Disables a depth renderer for a given camera
  66536. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66537. */
  66538. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66539. }
  66540. /**
  66541. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66542. * in several rendering techniques.
  66543. */
  66544. export class DepthRendererSceneComponent implements ISceneComponent {
  66545. /**
  66546. * The component name helpfull to identify the component in the list of scene components.
  66547. */
  66548. readonly name: string;
  66549. /**
  66550. * The scene the component belongs to.
  66551. */
  66552. scene: Scene;
  66553. /**
  66554. * Creates a new instance of the component for the given scene
  66555. * @param scene Defines the scene to register the component in
  66556. */
  66557. constructor(scene: Scene);
  66558. /**
  66559. * Registers the component in a given scene
  66560. */
  66561. register(): void;
  66562. /**
  66563. * Rebuilds the elements related to this component in case of
  66564. * context lost for instance.
  66565. */
  66566. rebuild(): void;
  66567. /**
  66568. * Disposes the component and the associated ressources
  66569. */
  66570. dispose(): void;
  66571. private _gatherRenderTargets;
  66572. private _gatherActiveCameraRenderTargets;
  66573. }
  66574. }
  66575. declare module BABYLON {
  66576. /** @hidden */
  66577. export var outlinePixelShader: {
  66578. name: string;
  66579. shader: string;
  66580. };
  66581. }
  66582. declare module BABYLON {
  66583. /** @hidden */
  66584. export var outlineVertexShader: {
  66585. name: string;
  66586. shader: string;
  66587. };
  66588. }
  66589. declare module BABYLON {
  66590. interface Scene {
  66591. /** @hidden */
  66592. _outlineRenderer: OutlineRenderer;
  66593. /**
  66594. * Gets the outline renderer associated with the scene
  66595. * @returns a OutlineRenderer
  66596. */
  66597. getOutlineRenderer(): OutlineRenderer;
  66598. }
  66599. interface AbstractMesh {
  66600. /** @hidden (Backing field) */
  66601. _renderOutline: boolean;
  66602. /**
  66603. * Gets or sets a boolean indicating if the outline must be rendered as well
  66604. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66605. */
  66606. renderOutline: boolean;
  66607. /** @hidden (Backing field) */
  66608. _renderOverlay: boolean;
  66609. /**
  66610. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66611. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66612. */
  66613. renderOverlay: boolean;
  66614. }
  66615. /**
  66616. * This class is responsible to draw bothe outline/overlay of meshes.
  66617. * It should not be used directly but through the available method on mesh.
  66618. */
  66619. export class OutlineRenderer implements ISceneComponent {
  66620. /**
  66621. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66622. */
  66623. private static _StencilReference;
  66624. /**
  66625. * The name of the component. Each component must have a unique name.
  66626. */
  66627. name: string;
  66628. /**
  66629. * The scene the component belongs to.
  66630. */
  66631. scene: Scene;
  66632. /**
  66633. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66634. */
  66635. zOffset: number;
  66636. private _engine;
  66637. private _effect;
  66638. private _cachedDefines;
  66639. private _savedDepthWrite;
  66640. /**
  66641. * Instantiates a new outline renderer. (There could be only one per scene).
  66642. * @param scene Defines the scene it belongs to
  66643. */
  66644. constructor(scene: Scene);
  66645. /**
  66646. * Register the component to one instance of a scene.
  66647. */
  66648. register(): void;
  66649. /**
  66650. * Rebuilds the elements related to this component in case of
  66651. * context lost for instance.
  66652. */
  66653. rebuild(): void;
  66654. /**
  66655. * Disposes the component and the associated ressources.
  66656. */
  66657. dispose(): void;
  66658. /**
  66659. * Renders the outline in the canvas.
  66660. * @param subMesh Defines the sumesh to render
  66661. * @param batch Defines the batch of meshes in case of instances
  66662. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66663. */
  66664. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66665. /**
  66666. * Returns whether or not the outline renderer is ready for a given submesh.
  66667. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66668. * @param subMesh Defines the submesh to check readyness for
  66669. * @param useInstances Defines wheter wee are trying to render instances or not
  66670. * @returns true if ready otherwise false
  66671. */
  66672. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66673. private _beforeRenderingMesh;
  66674. private _afterRenderingMesh;
  66675. }
  66676. }
  66677. declare module BABYLON {
  66678. /**
  66679. * Defines the basic options interface of a Sprite Frame Source Size.
  66680. */
  66681. export interface ISpriteJSONSpriteSourceSize {
  66682. /**
  66683. * number of the original width of the Frame
  66684. */
  66685. w: number;
  66686. /**
  66687. * number of the original height of the Frame
  66688. */
  66689. h: number;
  66690. }
  66691. /**
  66692. * Defines the basic options interface of a Sprite Frame Data.
  66693. */
  66694. export interface ISpriteJSONSpriteFrameData {
  66695. /**
  66696. * number of the x offset of the Frame
  66697. */
  66698. x: number;
  66699. /**
  66700. * number of the y offset of the Frame
  66701. */
  66702. y: number;
  66703. /**
  66704. * number of the width of the Frame
  66705. */
  66706. w: number;
  66707. /**
  66708. * number of the height of the Frame
  66709. */
  66710. h: number;
  66711. }
  66712. /**
  66713. * Defines the basic options interface of a JSON Sprite.
  66714. */
  66715. export interface ISpriteJSONSprite {
  66716. /**
  66717. * string name of the Frame
  66718. */
  66719. filename: string;
  66720. /**
  66721. * ISpriteJSONSpriteFrame basic object of the frame data
  66722. */
  66723. frame: ISpriteJSONSpriteFrameData;
  66724. /**
  66725. * boolean to flag is the frame was rotated.
  66726. */
  66727. rotated: boolean;
  66728. /**
  66729. * boolean to flag is the frame was trimmed.
  66730. */
  66731. trimmed: boolean;
  66732. /**
  66733. * ISpriteJSONSpriteFrame basic object of the source data
  66734. */
  66735. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66736. /**
  66737. * ISpriteJSONSpriteFrame basic object of the source data
  66738. */
  66739. sourceSize: ISpriteJSONSpriteSourceSize;
  66740. }
  66741. /**
  66742. * Defines the basic options interface of a JSON atlas.
  66743. */
  66744. export interface ISpriteJSONAtlas {
  66745. /**
  66746. * Array of objects that contain the frame data.
  66747. */
  66748. frames: Array<ISpriteJSONSprite>;
  66749. /**
  66750. * object basic object containing the sprite meta data.
  66751. */
  66752. meta?: object;
  66753. }
  66754. }
  66755. declare module BABYLON {
  66756. /** @hidden */
  66757. export var spriteMapPixelShader: {
  66758. name: string;
  66759. shader: string;
  66760. };
  66761. }
  66762. declare module BABYLON {
  66763. /** @hidden */
  66764. export var spriteMapVertexShader: {
  66765. name: string;
  66766. shader: string;
  66767. };
  66768. }
  66769. declare module BABYLON {
  66770. /**
  66771. * Defines the basic options interface of a SpriteMap
  66772. */
  66773. export interface ISpriteMapOptions {
  66774. /**
  66775. * Vector2 of the number of cells in the grid.
  66776. */
  66777. stageSize?: Vector2;
  66778. /**
  66779. * Vector2 of the size of the output plane in World Units.
  66780. */
  66781. outputSize?: Vector2;
  66782. /**
  66783. * Vector3 of the position of the output plane in World Units.
  66784. */
  66785. outputPosition?: Vector3;
  66786. /**
  66787. * Vector3 of the rotation of the output plane.
  66788. */
  66789. outputRotation?: Vector3;
  66790. /**
  66791. * number of layers that the system will reserve in resources.
  66792. */
  66793. layerCount?: number;
  66794. /**
  66795. * number of max animation frames a single cell will reserve in resources.
  66796. */
  66797. maxAnimationFrames?: number;
  66798. /**
  66799. * number cell index of the base tile when the system compiles.
  66800. */
  66801. baseTile?: number;
  66802. /**
  66803. * boolean flip the sprite after its been repositioned by the framing data.
  66804. */
  66805. flipU?: boolean;
  66806. /**
  66807. * Vector3 scalar of the global RGB values of the SpriteMap.
  66808. */
  66809. colorMultiply?: Vector3;
  66810. }
  66811. /**
  66812. * Defines the IDisposable interface in order to be cleanable from resources.
  66813. */
  66814. export interface ISpriteMap extends IDisposable {
  66815. /**
  66816. * String name of the SpriteMap.
  66817. */
  66818. name: string;
  66819. /**
  66820. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66821. */
  66822. atlasJSON: ISpriteJSONAtlas;
  66823. /**
  66824. * Texture of the SpriteMap.
  66825. */
  66826. spriteSheet: Texture;
  66827. /**
  66828. * The parameters to initialize the SpriteMap with.
  66829. */
  66830. options: ISpriteMapOptions;
  66831. }
  66832. /**
  66833. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66834. */
  66835. export class SpriteMap implements ISpriteMap {
  66836. /** The Name of the spriteMap */
  66837. name: string;
  66838. /** The JSON file with the frame and meta data */
  66839. atlasJSON: ISpriteJSONAtlas;
  66840. /** The systems Sprite Sheet Texture */
  66841. spriteSheet: Texture;
  66842. /** Arguments passed with the Constructor */
  66843. options: ISpriteMapOptions;
  66844. /** Public Sprite Storage array, parsed from atlasJSON */
  66845. sprites: Array<ISpriteJSONSprite>;
  66846. /** Returns the Number of Sprites in the System */
  66847. get spriteCount(): number;
  66848. /** Returns the Position of Output Plane*/
  66849. get position(): Vector3;
  66850. /** Returns the Position of Output Plane*/
  66851. set position(v: Vector3);
  66852. /** Returns the Rotation of Output Plane*/
  66853. get rotation(): Vector3;
  66854. /** Returns the Rotation of Output Plane*/
  66855. set rotation(v: Vector3);
  66856. /** Sets the AnimationMap*/
  66857. get animationMap(): RawTexture;
  66858. /** Sets the AnimationMap*/
  66859. set animationMap(v: RawTexture);
  66860. /** Scene that the SpriteMap was created in */
  66861. private _scene;
  66862. /** Texture Buffer of Float32 that holds tile frame data*/
  66863. private _frameMap;
  66864. /** Texture Buffers of Float32 that holds tileMap data*/
  66865. private _tileMaps;
  66866. /** Texture Buffer of Float32 that holds Animation Data*/
  66867. private _animationMap;
  66868. /** Custom ShaderMaterial Central to the System*/
  66869. private _material;
  66870. /** Custom ShaderMaterial Central to the System*/
  66871. private _output;
  66872. /** Systems Time Ticker*/
  66873. private _time;
  66874. /**
  66875. * Creates a new SpriteMap
  66876. * @param name defines the SpriteMaps Name
  66877. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66878. * @param spriteSheet is the Texture that the Sprites are on.
  66879. * @param options a basic deployment configuration
  66880. * @param scene The Scene that the map is deployed on
  66881. */
  66882. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66883. /**
  66884. * Returns tileID location
  66885. * @returns Vector2 the cell position ID
  66886. */
  66887. getTileID(): Vector2;
  66888. /**
  66889. * Gets the UV location of the mouse over the SpriteMap.
  66890. * @returns Vector2 the UV position of the mouse interaction
  66891. */
  66892. getMousePosition(): Vector2;
  66893. /**
  66894. * Creates the "frame" texture Buffer
  66895. * -------------------------------------
  66896. * Structure of frames
  66897. * "filename": "Falling-Water-2.png",
  66898. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66899. * "rotated": true,
  66900. * "trimmed": true,
  66901. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66902. * "sourceSize": {"w":32,"h":32}
  66903. * @returns RawTexture of the frameMap
  66904. */
  66905. private _createFrameBuffer;
  66906. /**
  66907. * Creates the tileMap texture Buffer
  66908. * @param buffer normally and array of numbers, or a false to generate from scratch
  66909. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66910. * @returns RawTexture of the tileMap
  66911. */
  66912. private _createTileBuffer;
  66913. /**
  66914. * Modifies the data of the tileMaps
  66915. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66916. * @param pos is the iVector2 Coordinates of the Tile
  66917. * @param tile The SpriteIndex of the new Tile
  66918. */
  66919. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66920. /**
  66921. * Creates the animationMap texture Buffer
  66922. * @param buffer normally and array of numbers, or a false to generate from scratch
  66923. * @returns RawTexture of the animationMap
  66924. */
  66925. private _createTileAnimationBuffer;
  66926. /**
  66927. * Modifies the data of the animationMap
  66928. * @param cellID is the Index of the Sprite
  66929. * @param _frame is the target Animation frame
  66930. * @param toCell is the Target Index of the next frame of the animation
  66931. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66932. * @param speed is a global scalar of the time variable on the map.
  66933. */
  66934. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66935. /**
  66936. * Exports the .tilemaps file
  66937. */
  66938. saveTileMaps(): void;
  66939. /**
  66940. * Imports the .tilemaps file
  66941. * @param url of the .tilemaps file
  66942. */
  66943. loadTileMaps(url: string): void;
  66944. /**
  66945. * Release associated resources
  66946. */
  66947. dispose(): void;
  66948. }
  66949. }
  66950. declare module BABYLON {
  66951. /**
  66952. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66953. * @see http://doc.babylonjs.com/babylon101/sprites
  66954. */
  66955. export class SpritePackedManager extends SpriteManager {
  66956. /** defines the packed manager's name */
  66957. name: string;
  66958. /**
  66959. * Creates a new sprite manager from a packed sprite sheet
  66960. * @param name defines the manager's name
  66961. * @param imgUrl defines the sprite sheet url
  66962. * @param capacity defines the maximum allowed number of sprites
  66963. * @param scene defines the hosting scene
  66964. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66965. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66966. * @param samplingMode defines the smapling mode to use with spritesheet
  66967. * @param fromPacked set to true; do not alter
  66968. */
  66969. constructor(
  66970. /** defines the packed manager's name */
  66971. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66972. }
  66973. }
  66974. declare module BABYLON {
  66975. /**
  66976. * Defines the list of states available for a task inside a AssetsManager
  66977. */
  66978. export enum AssetTaskState {
  66979. /**
  66980. * Initialization
  66981. */
  66982. INIT = 0,
  66983. /**
  66984. * Running
  66985. */
  66986. RUNNING = 1,
  66987. /**
  66988. * Done
  66989. */
  66990. DONE = 2,
  66991. /**
  66992. * Error
  66993. */
  66994. ERROR = 3
  66995. }
  66996. /**
  66997. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66998. */
  66999. export abstract class AbstractAssetTask {
  67000. /**
  67001. * Task name
  67002. */ name: string;
  67003. /**
  67004. * Callback called when the task is successful
  67005. */
  67006. onSuccess: (task: any) => void;
  67007. /**
  67008. * Callback called when the task is not successful
  67009. */
  67010. onError: (task: any, message?: string, exception?: any) => void;
  67011. /**
  67012. * Creates a new AssetsManager
  67013. * @param name defines the name of the task
  67014. */
  67015. constructor(
  67016. /**
  67017. * Task name
  67018. */ name: string);
  67019. private _isCompleted;
  67020. private _taskState;
  67021. private _errorObject;
  67022. /**
  67023. * Get if the task is completed
  67024. */
  67025. get isCompleted(): boolean;
  67026. /**
  67027. * Gets the current state of the task
  67028. */
  67029. get taskState(): AssetTaskState;
  67030. /**
  67031. * Gets the current error object (if task is in error)
  67032. */
  67033. get errorObject(): {
  67034. message?: string;
  67035. exception?: any;
  67036. };
  67037. /**
  67038. * Internal only
  67039. * @hidden
  67040. */
  67041. _setErrorObject(message?: string, exception?: any): void;
  67042. /**
  67043. * Execute the current task
  67044. * @param scene defines the scene where you want your assets to be loaded
  67045. * @param onSuccess is a callback called when the task is successfully executed
  67046. * @param onError is a callback called if an error occurs
  67047. */
  67048. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67049. /**
  67050. * Execute the current task
  67051. * @param scene defines the scene where you want your assets to be loaded
  67052. * @param onSuccess is a callback called when the task is successfully executed
  67053. * @param onError is a callback called if an error occurs
  67054. */
  67055. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67056. /**
  67057. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67058. * This can be used with failed tasks that have the reason for failure fixed.
  67059. */
  67060. reset(): void;
  67061. private onErrorCallback;
  67062. private onDoneCallback;
  67063. }
  67064. /**
  67065. * Define the interface used by progress events raised during assets loading
  67066. */
  67067. export interface IAssetsProgressEvent {
  67068. /**
  67069. * Defines the number of remaining tasks to process
  67070. */
  67071. remainingCount: number;
  67072. /**
  67073. * Defines the total number of tasks
  67074. */
  67075. totalCount: number;
  67076. /**
  67077. * Defines the task that was just processed
  67078. */
  67079. task: AbstractAssetTask;
  67080. }
  67081. /**
  67082. * Class used to share progress information about assets loading
  67083. */
  67084. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67085. /**
  67086. * Defines the number of remaining tasks to process
  67087. */
  67088. remainingCount: number;
  67089. /**
  67090. * Defines the total number of tasks
  67091. */
  67092. totalCount: number;
  67093. /**
  67094. * Defines the task that was just processed
  67095. */
  67096. task: AbstractAssetTask;
  67097. /**
  67098. * Creates a AssetsProgressEvent
  67099. * @param remainingCount defines the number of remaining tasks to process
  67100. * @param totalCount defines the total number of tasks
  67101. * @param task defines the task that was just processed
  67102. */
  67103. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67104. }
  67105. /**
  67106. * Define a task used by AssetsManager to load meshes
  67107. */
  67108. export class MeshAssetTask extends AbstractAssetTask {
  67109. /**
  67110. * Defines the name of the task
  67111. */
  67112. name: string;
  67113. /**
  67114. * Defines the list of mesh's names you want to load
  67115. */
  67116. meshesNames: any;
  67117. /**
  67118. * Defines the root url to use as a base to load your meshes and associated resources
  67119. */
  67120. rootUrl: string;
  67121. /**
  67122. * Defines the filename of the scene to load from
  67123. */
  67124. sceneFilename: string;
  67125. /**
  67126. * Gets the list of loaded meshes
  67127. */
  67128. loadedMeshes: Array<AbstractMesh>;
  67129. /**
  67130. * Gets the list of loaded particle systems
  67131. */
  67132. loadedParticleSystems: Array<IParticleSystem>;
  67133. /**
  67134. * Gets the list of loaded skeletons
  67135. */
  67136. loadedSkeletons: Array<Skeleton>;
  67137. /**
  67138. * Gets the list of loaded animation groups
  67139. */
  67140. loadedAnimationGroups: Array<AnimationGroup>;
  67141. /**
  67142. * Callback called when the task is successful
  67143. */
  67144. onSuccess: (task: MeshAssetTask) => void;
  67145. /**
  67146. * Callback called when the task is successful
  67147. */
  67148. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67149. /**
  67150. * Creates a new MeshAssetTask
  67151. * @param name defines the name of the task
  67152. * @param meshesNames defines the list of mesh's names you want to load
  67153. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67154. * @param sceneFilename defines the filename of the scene to load from
  67155. */
  67156. constructor(
  67157. /**
  67158. * Defines the name of the task
  67159. */
  67160. name: string,
  67161. /**
  67162. * Defines the list of mesh's names you want to load
  67163. */
  67164. meshesNames: any,
  67165. /**
  67166. * Defines the root url to use as a base to load your meshes and associated resources
  67167. */
  67168. rootUrl: string,
  67169. /**
  67170. * Defines the filename of the scene to load from
  67171. */
  67172. sceneFilename: string);
  67173. /**
  67174. * Execute the current task
  67175. * @param scene defines the scene where you want your assets to be loaded
  67176. * @param onSuccess is a callback called when the task is successfully executed
  67177. * @param onError is a callback called if an error occurs
  67178. */
  67179. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67180. }
  67181. /**
  67182. * Define a task used by AssetsManager to load text content
  67183. */
  67184. export class TextFileAssetTask extends AbstractAssetTask {
  67185. /**
  67186. * Defines the name of the task
  67187. */
  67188. name: string;
  67189. /**
  67190. * Defines the location of the file to load
  67191. */
  67192. url: string;
  67193. /**
  67194. * Gets the loaded text string
  67195. */
  67196. text: string;
  67197. /**
  67198. * Callback called when the task is successful
  67199. */
  67200. onSuccess: (task: TextFileAssetTask) => void;
  67201. /**
  67202. * Callback called when the task is successful
  67203. */
  67204. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67205. /**
  67206. * Creates a new TextFileAssetTask object
  67207. * @param name defines the name of the task
  67208. * @param url defines the location of the file to load
  67209. */
  67210. constructor(
  67211. /**
  67212. * Defines the name of the task
  67213. */
  67214. name: string,
  67215. /**
  67216. * Defines the location of the file to load
  67217. */
  67218. url: string);
  67219. /**
  67220. * Execute the current task
  67221. * @param scene defines the scene where you want your assets to be loaded
  67222. * @param onSuccess is a callback called when the task is successfully executed
  67223. * @param onError is a callback called if an error occurs
  67224. */
  67225. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67226. }
  67227. /**
  67228. * Define a task used by AssetsManager to load binary data
  67229. */
  67230. export class BinaryFileAssetTask extends AbstractAssetTask {
  67231. /**
  67232. * Defines the name of the task
  67233. */
  67234. name: string;
  67235. /**
  67236. * Defines the location of the file to load
  67237. */
  67238. url: string;
  67239. /**
  67240. * Gets the lodaded data (as an array buffer)
  67241. */
  67242. data: ArrayBuffer;
  67243. /**
  67244. * Callback called when the task is successful
  67245. */
  67246. onSuccess: (task: BinaryFileAssetTask) => void;
  67247. /**
  67248. * Callback called when the task is successful
  67249. */
  67250. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67251. /**
  67252. * Creates a new BinaryFileAssetTask object
  67253. * @param name defines the name of the new task
  67254. * @param url defines the location of the file to load
  67255. */
  67256. constructor(
  67257. /**
  67258. * Defines the name of the task
  67259. */
  67260. name: string,
  67261. /**
  67262. * Defines the location of the file to load
  67263. */
  67264. url: string);
  67265. /**
  67266. * Execute the current task
  67267. * @param scene defines the scene where you want your assets to be loaded
  67268. * @param onSuccess is a callback called when the task is successfully executed
  67269. * @param onError is a callback called if an error occurs
  67270. */
  67271. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67272. }
  67273. /**
  67274. * Define a task used by AssetsManager to load images
  67275. */
  67276. export class ImageAssetTask extends AbstractAssetTask {
  67277. /**
  67278. * Defines the name of the task
  67279. */
  67280. name: string;
  67281. /**
  67282. * Defines the location of the image to load
  67283. */
  67284. url: string;
  67285. /**
  67286. * Gets the loaded images
  67287. */
  67288. image: HTMLImageElement;
  67289. /**
  67290. * Callback called when the task is successful
  67291. */
  67292. onSuccess: (task: ImageAssetTask) => void;
  67293. /**
  67294. * Callback called when the task is successful
  67295. */
  67296. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67297. /**
  67298. * Creates a new ImageAssetTask
  67299. * @param name defines the name of the task
  67300. * @param url defines the location of the image to load
  67301. */
  67302. constructor(
  67303. /**
  67304. * Defines the name of the task
  67305. */
  67306. name: string,
  67307. /**
  67308. * Defines the location of the image to load
  67309. */
  67310. url: string);
  67311. /**
  67312. * Execute the current task
  67313. * @param scene defines the scene where you want your assets to be loaded
  67314. * @param onSuccess is a callback called when the task is successfully executed
  67315. * @param onError is a callback called if an error occurs
  67316. */
  67317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67318. }
  67319. /**
  67320. * Defines the interface used by texture loading tasks
  67321. */
  67322. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67323. /**
  67324. * Gets the loaded texture
  67325. */
  67326. texture: TEX;
  67327. }
  67328. /**
  67329. * Define a task used by AssetsManager to load 2D textures
  67330. */
  67331. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67332. /**
  67333. * Defines the name of the task
  67334. */
  67335. name: string;
  67336. /**
  67337. * Defines the location of the file to load
  67338. */
  67339. url: string;
  67340. /**
  67341. * Defines if mipmap should not be generated (default is false)
  67342. */
  67343. noMipmap?: boolean | undefined;
  67344. /**
  67345. * Defines if texture must be inverted on Y axis (default is false)
  67346. */
  67347. invertY?: boolean | undefined;
  67348. /**
  67349. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67350. */
  67351. samplingMode: number;
  67352. /**
  67353. * Gets the loaded texture
  67354. */
  67355. texture: Texture;
  67356. /**
  67357. * Callback called when the task is successful
  67358. */
  67359. onSuccess: (task: TextureAssetTask) => void;
  67360. /**
  67361. * Callback called when the task is successful
  67362. */
  67363. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67364. /**
  67365. * Creates a new TextureAssetTask object
  67366. * @param name defines the name of the task
  67367. * @param url defines the location of the file to load
  67368. * @param noMipmap defines if mipmap should not be generated (default is false)
  67369. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67370. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67371. */
  67372. constructor(
  67373. /**
  67374. * Defines the name of the task
  67375. */
  67376. name: string,
  67377. /**
  67378. * Defines the location of the file to load
  67379. */
  67380. url: string,
  67381. /**
  67382. * Defines if mipmap should not be generated (default is false)
  67383. */
  67384. noMipmap?: boolean | undefined,
  67385. /**
  67386. * Defines if texture must be inverted on Y axis (default is false)
  67387. */
  67388. invertY?: boolean | undefined,
  67389. /**
  67390. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67391. */
  67392. samplingMode?: number);
  67393. /**
  67394. * Execute the current task
  67395. * @param scene defines the scene where you want your assets to be loaded
  67396. * @param onSuccess is a callback called when the task is successfully executed
  67397. * @param onError is a callback called if an error occurs
  67398. */
  67399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67400. }
  67401. /**
  67402. * Define a task used by AssetsManager to load cube textures
  67403. */
  67404. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67405. /**
  67406. * Defines the name of the task
  67407. */
  67408. name: string;
  67409. /**
  67410. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67411. */
  67412. url: string;
  67413. /**
  67414. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67415. */
  67416. extensions?: string[] | undefined;
  67417. /**
  67418. * Defines if mipmaps should not be generated (default is false)
  67419. */
  67420. noMipmap?: boolean | undefined;
  67421. /**
  67422. * Defines the explicit list of files (undefined by default)
  67423. */
  67424. files?: string[] | undefined;
  67425. /**
  67426. * Gets the loaded texture
  67427. */
  67428. texture: CubeTexture;
  67429. /**
  67430. * Callback called when the task is successful
  67431. */
  67432. onSuccess: (task: CubeTextureAssetTask) => void;
  67433. /**
  67434. * Callback called when the task is successful
  67435. */
  67436. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67437. /**
  67438. * Creates a new CubeTextureAssetTask
  67439. * @param name defines the name of the task
  67440. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67441. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67442. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67443. * @param files defines the explicit list of files (undefined by default)
  67444. */
  67445. constructor(
  67446. /**
  67447. * Defines the name of the task
  67448. */
  67449. name: string,
  67450. /**
  67451. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67452. */
  67453. url: string,
  67454. /**
  67455. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67456. */
  67457. extensions?: string[] | undefined,
  67458. /**
  67459. * Defines if mipmaps should not be generated (default is false)
  67460. */
  67461. noMipmap?: boolean | undefined,
  67462. /**
  67463. * Defines the explicit list of files (undefined by default)
  67464. */
  67465. files?: string[] | undefined);
  67466. /**
  67467. * Execute the current task
  67468. * @param scene defines the scene where you want your assets to be loaded
  67469. * @param onSuccess is a callback called when the task is successfully executed
  67470. * @param onError is a callback called if an error occurs
  67471. */
  67472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67473. }
  67474. /**
  67475. * Define a task used by AssetsManager to load HDR cube textures
  67476. */
  67477. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67478. /**
  67479. * Defines the name of the task
  67480. */
  67481. name: string;
  67482. /**
  67483. * Defines the location of the file to load
  67484. */
  67485. url: string;
  67486. /**
  67487. * Defines the desired size (the more it increases the longer the generation will be)
  67488. */
  67489. size: number;
  67490. /**
  67491. * Defines if mipmaps should not be generated (default is false)
  67492. */
  67493. noMipmap: boolean;
  67494. /**
  67495. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67496. */
  67497. generateHarmonics: boolean;
  67498. /**
  67499. * 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)
  67500. */
  67501. gammaSpace: boolean;
  67502. /**
  67503. * Internal Use Only
  67504. */
  67505. reserved: boolean;
  67506. /**
  67507. * Gets the loaded texture
  67508. */
  67509. texture: HDRCubeTexture;
  67510. /**
  67511. * Callback called when the task is successful
  67512. */
  67513. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67514. /**
  67515. * Callback called when the task is successful
  67516. */
  67517. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67518. /**
  67519. * Creates a new HDRCubeTextureAssetTask object
  67520. * @param name defines the name of the task
  67521. * @param url defines the location of the file to load
  67522. * @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.
  67523. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67524. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67525. * @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)
  67526. * @param reserved Internal use only
  67527. */
  67528. constructor(
  67529. /**
  67530. * Defines the name of the task
  67531. */
  67532. name: string,
  67533. /**
  67534. * Defines the location of the file to load
  67535. */
  67536. url: string,
  67537. /**
  67538. * Defines the desired size (the more it increases the longer the generation will be)
  67539. */
  67540. size: number,
  67541. /**
  67542. * Defines if mipmaps should not be generated (default is false)
  67543. */
  67544. noMipmap?: boolean,
  67545. /**
  67546. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67547. */
  67548. generateHarmonics?: boolean,
  67549. /**
  67550. * 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)
  67551. */
  67552. gammaSpace?: boolean,
  67553. /**
  67554. * Internal Use Only
  67555. */
  67556. reserved?: boolean);
  67557. /**
  67558. * Execute the current task
  67559. * @param scene defines the scene where you want your assets to be loaded
  67560. * @param onSuccess is a callback called when the task is successfully executed
  67561. * @param onError is a callback called if an error occurs
  67562. */
  67563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67564. }
  67565. /**
  67566. * Define a task used by AssetsManager to load Equirectangular cube textures
  67567. */
  67568. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67569. /**
  67570. * Defines the name of the task
  67571. */
  67572. name: string;
  67573. /**
  67574. * Defines the location of the file to load
  67575. */
  67576. url: string;
  67577. /**
  67578. * Defines the desired size (the more it increases the longer the generation will be)
  67579. */
  67580. size: number;
  67581. /**
  67582. * Defines if mipmaps should not be generated (default is false)
  67583. */
  67584. noMipmap: boolean;
  67585. /**
  67586. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67587. * but the standard material would require them in Gamma space) (default is true)
  67588. */
  67589. gammaSpace: boolean;
  67590. /**
  67591. * Gets the loaded texture
  67592. */
  67593. texture: EquiRectangularCubeTexture;
  67594. /**
  67595. * Callback called when the task is successful
  67596. */
  67597. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67598. /**
  67599. * Callback called when the task is successful
  67600. */
  67601. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67602. /**
  67603. * Creates a new EquiRectangularCubeTextureAssetTask object
  67604. * @param name defines the name of the task
  67605. * @param url defines the location of the file to load
  67606. * @param size defines the desired size (the more it increases the longer the generation will be)
  67607. * If the size is omitted this implies you are using a preprocessed cubemap.
  67608. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67609. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67610. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67611. * (default is true)
  67612. */
  67613. constructor(
  67614. /**
  67615. * Defines the name of the task
  67616. */
  67617. name: string,
  67618. /**
  67619. * Defines the location of the file to load
  67620. */
  67621. url: string,
  67622. /**
  67623. * Defines the desired size (the more it increases the longer the generation will be)
  67624. */
  67625. size: number,
  67626. /**
  67627. * Defines if mipmaps should not be generated (default is false)
  67628. */
  67629. noMipmap?: boolean,
  67630. /**
  67631. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67632. * but the standard material would require them in Gamma space) (default is true)
  67633. */
  67634. gammaSpace?: boolean);
  67635. /**
  67636. * Execute the current task
  67637. * @param scene defines the scene where you want your assets to be loaded
  67638. * @param onSuccess is a callback called when the task is successfully executed
  67639. * @param onError is a callback called if an error occurs
  67640. */
  67641. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67642. }
  67643. /**
  67644. * This class can be used to easily import assets into a scene
  67645. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67646. */
  67647. export class AssetsManager {
  67648. private _scene;
  67649. private _isLoading;
  67650. protected _tasks: AbstractAssetTask[];
  67651. protected _waitingTasksCount: number;
  67652. protected _totalTasksCount: number;
  67653. /**
  67654. * Callback called when all tasks are processed
  67655. */
  67656. onFinish: (tasks: AbstractAssetTask[]) => void;
  67657. /**
  67658. * Callback called when a task is successful
  67659. */
  67660. onTaskSuccess: (task: AbstractAssetTask) => void;
  67661. /**
  67662. * Callback called when a task had an error
  67663. */
  67664. onTaskError: (task: AbstractAssetTask) => void;
  67665. /**
  67666. * Callback called when a task is done (whatever the result is)
  67667. */
  67668. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67669. /**
  67670. * Observable called when all tasks are processed
  67671. */
  67672. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67673. /**
  67674. * Observable called when a task had an error
  67675. */
  67676. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67677. /**
  67678. * Observable called when all tasks were executed
  67679. */
  67680. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67681. /**
  67682. * Observable called when a task is done (whatever the result is)
  67683. */
  67684. onProgressObservable: Observable<IAssetsProgressEvent>;
  67685. /**
  67686. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67687. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67688. */
  67689. useDefaultLoadingScreen: boolean;
  67690. /**
  67691. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67692. * when all assets have been downloaded.
  67693. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67694. */
  67695. autoHideLoadingUI: boolean;
  67696. /**
  67697. * Creates a new AssetsManager
  67698. * @param scene defines the scene to work on
  67699. */
  67700. constructor(scene: Scene);
  67701. /**
  67702. * Add a MeshAssetTask to the list of active tasks
  67703. * @param taskName defines the name of the new task
  67704. * @param meshesNames defines the name of meshes to load
  67705. * @param rootUrl defines the root url to use to locate files
  67706. * @param sceneFilename defines the filename of the scene file
  67707. * @returns a new MeshAssetTask object
  67708. */
  67709. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67710. /**
  67711. * Add a TextFileAssetTask to the list of active tasks
  67712. * @param taskName defines the name of the new task
  67713. * @param url defines the url of the file to load
  67714. * @returns a new TextFileAssetTask object
  67715. */
  67716. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67717. /**
  67718. * Add a BinaryFileAssetTask to the list of active tasks
  67719. * @param taskName defines the name of the new task
  67720. * @param url defines the url of the file to load
  67721. * @returns a new BinaryFileAssetTask object
  67722. */
  67723. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67724. /**
  67725. * Add a ImageAssetTask to the list of active tasks
  67726. * @param taskName defines the name of the new task
  67727. * @param url defines the url of the file to load
  67728. * @returns a new ImageAssetTask object
  67729. */
  67730. addImageTask(taskName: string, url: string): ImageAssetTask;
  67731. /**
  67732. * Add a TextureAssetTask to the list of active tasks
  67733. * @param taskName defines the name of the new task
  67734. * @param url defines the url of the file to load
  67735. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67736. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67737. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67738. * @returns a new TextureAssetTask object
  67739. */
  67740. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67741. /**
  67742. * Add a CubeTextureAssetTask to the list of active tasks
  67743. * @param taskName defines the name of the new task
  67744. * @param url defines the url of the file to load
  67745. * @param extensions defines the extension to use to load the cube map (can be null)
  67746. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67747. * @param files defines the list of files to load (can be null)
  67748. * @returns a new CubeTextureAssetTask object
  67749. */
  67750. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67751. /**
  67752. *
  67753. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67754. * @param taskName defines the name of the new task
  67755. * @param url defines the url of the file to load
  67756. * @param size defines the size you want for the cubemap (can be null)
  67757. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67758. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67759. * @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)
  67760. * @param reserved Internal use only
  67761. * @returns a new HDRCubeTextureAssetTask object
  67762. */
  67763. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67764. /**
  67765. *
  67766. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67767. * @param taskName defines the name of the new task
  67768. * @param url defines the url of the file to load
  67769. * @param size defines the size you want for the cubemap (can be null)
  67770. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67771. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67772. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67773. * @returns a new EquiRectangularCubeTextureAssetTask object
  67774. */
  67775. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67776. /**
  67777. * Remove a task from the assets manager.
  67778. * @param task the task to remove
  67779. */
  67780. removeTask(task: AbstractAssetTask): void;
  67781. private _decreaseWaitingTasksCount;
  67782. private _runTask;
  67783. /**
  67784. * Reset the AssetsManager and remove all tasks
  67785. * @return the current instance of the AssetsManager
  67786. */
  67787. reset(): AssetsManager;
  67788. /**
  67789. * Start the loading process
  67790. * @return the current instance of the AssetsManager
  67791. */
  67792. load(): AssetsManager;
  67793. /**
  67794. * Start the loading process as an async operation
  67795. * @return a promise returning the list of failed tasks
  67796. */
  67797. loadAsync(): Promise<void>;
  67798. }
  67799. }
  67800. declare module BABYLON {
  67801. /**
  67802. * Wrapper class for promise with external resolve and reject.
  67803. */
  67804. export class Deferred<T> {
  67805. /**
  67806. * The promise associated with this deferred object.
  67807. */
  67808. readonly promise: Promise<T>;
  67809. private _resolve;
  67810. private _reject;
  67811. /**
  67812. * The resolve method of the promise associated with this deferred object.
  67813. */
  67814. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67815. /**
  67816. * The reject method of the promise associated with this deferred object.
  67817. */
  67818. get reject(): (reason?: any) => void;
  67819. /**
  67820. * Constructor for this deferred object.
  67821. */
  67822. constructor();
  67823. }
  67824. }
  67825. declare module BABYLON {
  67826. /**
  67827. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67828. */
  67829. export class MeshExploder {
  67830. private _centerMesh;
  67831. private _meshes;
  67832. private _meshesOrigins;
  67833. private _toCenterVectors;
  67834. private _scaledDirection;
  67835. private _newPosition;
  67836. private _centerPosition;
  67837. /**
  67838. * Explodes meshes from a center mesh.
  67839. * @param meshes The meshes to explode.
  67840. * @param centerMesh The mesh to be center of explosion.
  67841. */
  67842. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67843. private _setCenterMesh;
  67844. /**
  67845. * Get class name
  67846. * @returns "MeshExploder"
  67847. */
  67848. getClassName(): string;
  67849. /**
  67850. * "Exploded meshes"
  67851. * @returns Array of meshes with the centerMesh at index 0.
  67852. */
  67853. getMeshes(): Array<Mesh>;
  67854. /**
  67855. * Explodes meshes giving a specific direction
  67856. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67857. */
  67858. explode(direction?: number): void;
  67859. }
  67860. }
  67861. declare module BABYLON {
  67862. /**
  67863. * Class used to help managing file picking and drag'n'drop
  67864. */
  67865. export class FilesInput {
  67866. /**
  67867. * List of files ready to be loaded
  67868. */
  67869. static get FilesToLoad(): {
  67870. [key: string]: File;
  67871. };
  67872. /**
  67873. * Callback called when a file is processed
  67874. */
  67875. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67876. private _engine;
  67877. private _currentScene;
  67878. private _sceneLoadedCallback;
  67879. private _progressCallback;
  67880. private _additionalRenderLoopLogicCallback;
  67881. private _textureLoadingCallback;
  67882. private _startingProcessingFilesCallback;
  67883. private _onReloadCallback;
  67884. private _errorCallback;
  67885. private _elementToMonitor;
  67886. private _sceneFileToLoad;
  67887. private _filesToLoad;
  67888. /**
  67889. * Creates a new FilesInput
  67890. * @param engine defines the rendering engine
  67891. * @param scene defines the hosting scene
  67892. * @param sceneLoadedCallback callback called when scene is loaded
  67893. * @param progressCallback callback called to track progress
  67894. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67895. * @param textureLoadingCallback callback called when a texture is loading
  67896. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67897. * @param onReloadCallback callback called when a reload is requested
  67898. * @param errorCallback callback call if an error occurs
  67899. */
  67900. 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);
  67901. private _dragEnterHandler;
  67902. private _dragOverHandler;
  67903. private _dropHandler;
  67904. /**
  67905. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67906. * @param elementToMonitor defines the DOM element to track
  67907. */
  67908. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67909. /**
  67910. * Release all associated resources
  67911. */
  67912. dispose(): void;
  67913. private renderFunction;
  67914. private drag;
  67915. private drop;
  67916. private _traverseFolder;
  67917. private _processFiles;
  67918. /**
  67919. * Load files from a drop event
  67920. * @param event defines the drop event to use as source
  67921. */
  67922. loadFiles(event: any): void;
  67923. private _processReload;
  67924. /**
  67925. * Reload the current scene from the loaded files
  67926. */
  67927. reload(): void;
  67928. }
  67929. }
  67930. declare module BABYLON {
  67931. /**
  67932. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67934. */
  67935. export class SceneOptimization {
  67936. /**
  67937. * Defines the priority of this optimization (0 by default which means first in the list)
  67938. */
  67939. priority: number;
  67940. /**
  67941. * Gets a string describing the action executed by the current optimization
  67942. * @returns description string
  67943. */
  67944. getDescription(): string;
  67945. /**
  67946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67947. * @param scene defines the current scene where to apply this optimization
  67948. * @param optimizer defines the current optimizer
  67949. * @returns true if everything that can be done was applied
  67950. */
  67951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67952. /**
  67953. * Creates the SceneOptimization object
  67954. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67955. * @param desc defines the description associated with the optimization
  67956. */
  67957. constructor(
  67958. /**
  67959. * Defines the priority of this optimization (0 by default which means first in the list)
  67960. */
  67961. priority?: number);
  67962. }
  67963. /**
  67964. * Defines an optimization used to reduce the size of render target textures
  67965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67966. */
  67967. export class TextureOptimization extends SceneOptimization {
  67968. /**
  67969. * Defines the priority of this optimization (0 by default which means first in the list)
  67970. */
  67971. priority: number;
  67972. /**
  67973. * 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
  67974. */
  67975. maximumSize: number;
  67976. /**
  67977. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67978. */
  67979. step: number;
  67980. /**
  67981. * Gets a string describing the action executed by the current optimization
  67982. * @returns description string
  67983. */
  67984. getDescription(): string;
  67985. /**
  67986. * Creates the TextureOptimization object
  67987. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67988. * @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
  67989. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67990. */
  67991. constructor(
  67992. /**
  67993. * Defines the priority of this optimization (0 by default which means first in the list)
  67994. */
  67995. priority?: number,
  67996. /**
  67997. * 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
  67998. */
  67999. maximumSize?: number,
  68000. /**
  68001. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68002. */
  68003. step?: number);
  68004. /**
  68005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68006. * @param scene defines the current scene where to apply this optimization
  68007. * @param optimizer defines the current optimizer
  68008. * @returns true if everything that can be done was applied
  68009. */
  68010. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68011. }
  68012. /**
  68013. * Defines an optimization used to increase or decrease the rendering resolution
  68014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68015. */
  68016. export class HardwareScalingOptimization extends SceneOptimization {
  68017. /**
  68018. * Defines the priority of this optimization (0 by default which means first in the list)
  68019. */
  68020. priority: number;
  68021. /**
  68022. * Defines the maximum scale to use (2 by default)
  68023. */
  68024. maximumScale: number;
  68025. /**
  68026. * Defines the step to use between two passes (0.5 by default)
  68027. */
  68028. step: number;
  68029. private _currentScale;
  68030. private _directionOffset;
  68031. /**
  68032. * Gets a string describing the action executed by the current optimization
  68033. * @return description string
  68034. */
  68035. getDescription(): string;
  68036. /**
  68037. * Creates the HardwareScalingOptimization object
  68038. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68039. * @param maximumScale defines the maximum scale to use (2 by default)
  68040. * @param step defines the step to use between two passes (0.5 by default)
  68041. */
  68042. constructor(
  68043. /**
  68044. * Defines the priority of this optimization (0 by default which means first in the list)
  68045. */
  68046. priority?: number,
  68047. /**
  68048. * Defines the maximum scale to use (2 by default)
  68049. */
  68050. maximumScale?: number,
  68051. /**
  68052. * Defines the step to use between two passes (0.5 by default)
  68053. */
  68054. step?: number);
  68055. /**
  68056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68057. * @param scene defines the current scene where to apply this optimization
  68058. * @param optimizer defines the current optimizer
  68059. * @returns true if everything that can be done was applied
  68060. */
  68061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68062. }
  68063. /**
  68064. * Defines an optimization used to remove shadows
  68065. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68066. */
  68067. export class ShadowsOptimization extends SceneOptimization {
  68068. /**
  68069. * Gets a string describing the action executed by the current optimization
  68070. * @return description string
  68071. */
  68072. getDescription(): string;
  68073. /**
  68074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68075. * @param scene defines the current scene where to apply this optimization
  68076. * @param optimizer defines the current optimizer
  68077. * @returns true if everything that can be done was applied
  68078. */
  68079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68080. }
  68081. /**
  68082. * Defines an optimization used to turn post-processes off
  68083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68084. */
  68085. export class PostProcessesOptimization extends SceneOptimization {
  68086. /**
  68087. * Gets a string describing the action executed by the current optimization
  68088. * @return description string
  68089. */
  68090. getDescription(): string;
  68091. /**
  68092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68093. * @param scene defines the current scene where to apply this optimization
  68094. * @param optimizer defines the current optimizer
  68095. * @returns true if everything that can be done was applied
  68096. */
  68097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68098. }
  68099. /**
  68100. * Defines an optimization used to turn lens flares off
  68101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68102. */
  68103. export class LensFlaresOptimization extends SceneOptimization {
  68104. /**
  68105. * Gets a string describing the action executed by the current optimization
  68106. * @return description string
  68107. */
  68108. getDescription(): string;
  68109. /**
  68110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68111. * @param scene defines the current scene where to apply this optimization
  68112. * @param optimizer defines the current optimizer
  68113. * @returns true if everything that can be done was applied
  68114. */
  68115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68116. }
  68117. /**
  68118. * Defines an optimization based on user defined callback.
  68119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68120. */
  68121. export class CustomOptimization extends SceneOptimization {
  68122. /**
  68123. * Callback called to apply the custom optimization.
  68124. */
  68125. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68126. /**
  68127. * Callback called to get custom description
  68128. */
  68129. onGetDescription: () => string;
  68130. /**
  68131. * Gets a string describing the action executed by the current optimization
  68132. * @returns description string
  68133. */
  68134. getDescription(): string;
  68135. /**
  68136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68137. * @param scene defines the current scene where to apply this optimization
  68138. * @param optimizer defines the current optimizer
  68139. * @returns true if everything that can be done was applied
  68140. */
  68141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68142. }
  68143. /**
  68144. * Defines an optimization used to turn particles off
  68145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68146. */
  68147. export class ParticlesOptimization extends SceneOptimization {
  68148. /**
  68149. * Gets a string describing the action executed by the current optimization
  68150. * @return description string
  68151. */
  68152. getDescription(): string;
  68153. /**
  68154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68155. * @param scene defines the current scene where to apply this optimization
  68156. * @param optimizer defines the current optimizer
  68157. * @returns true if everything that can be done was applied
  68158. */
  68159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68160. }
  68161. /**
  68162. * Defines an optimization used to turn render targets off
  68163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68164. */
  68165. export class RenderTargetsOptimization extends SceneOptimization {
  68166. /**
  68167. * Gets a string describing the action executed by the current optimization
  68168. * @return description string
  68169. */
  68170. getDescription(): string;
  68171. /**
  68172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68173. * @param scene defines the current scene where to apply this optimization
  68174. * @param optimizer defines the current optimizer
  68175. * @returns true if everything that can be done was applied
  68176. */
  68177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68178. }
  68179. /**
  68180. * Defines an optimization used to merge meshes with compatible materials
  68181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68182. */
  68183. export class MergeMeshesOptimization extends SceneOptimization {
  68184. private static _UpdateSelectionTree;
  68185. /**
  68186. * Gets or sets a boolean which defines if optimization octree has to be updated
  68187. */
  68188. static get UpdateSelectionTree(): boolean;
  68189. /**
  68190. * Gets or sets a boolean which defines if optimization octree has to be updated
  68191. */
  68192. static set UpdateSelectionTree(value: boolean);
  68193. /**
  68194. * Gets a string describing the action executed by the current optimization
  68195. * @return description string
  68196. */
  68197. getDescription(): string;
  68198. private _canBeMerged;
  68199. /**
  68200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68201. * @param scene defines the current scene where to apply this optimization
  68202. * @param optimizer defines the current optimizer
  68203. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68204. * @returns true if everything that can be done was applied
  68205. */
  68206. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68207. }
  68208. /**
  68209. * Defines a list of options used by SceneOptimizer
  68210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68211. */
  68212. export class SceneOptimizerOptions {
  68213. /**
  68214. * Defines the target frame rate to reach (60 by default)
  68215. */
  68216. targetFrameRate: number;
  68217. /**
  68218. * Defines the interval between two checkes (2000ms by default)
  68219. */
  68220. trackerDuration: number;
  68221. /**
  68222. * Gets the list of optimizations to apply
  68223. */
  68224. optimizations: SceneOptimization[];
  68225. /**
  68226. * Creates a new list of options used by SceneOptimizer
  68227. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68228. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68229. */
  68230. constructor(
  68231. /**
  68232. * Defines the target frame rate to reach (60 by default)
  68233. */
  68234. targetFrameRate?: number,
  68235. /**
  68236. * Defines the interval between two checkes (2000ms by default)
  68237. */
  68238. trackerDuration?: number);
  68239. /**
  68240. * Add a new optimization
  68241. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68242. * @returns the current SceneOptimizerOptions
  68243. */
  68244. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68245. /**
  68246. * Add a new custom optimization
  68247. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68248. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68249. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68250. * @returns the current SceneOptimizerOptions
  68251. */
  68252. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68253. /**
  68254. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68255. * @param targetFrameRate defines the target frame rate (60 by default)
  68256. * @returns a SceneOptimizerOptions object
  68257. */
  68258. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68259. /**
  68260. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68261. * @param targetFrameRate defines the target frame rate (60 by default)
  68262. * @returns a SceneOptimizerOptions object
  68263. */
  68264. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68265. /**
  68266. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68267. * @param targetFrameRate defines the target frame rate (60 by default)
  68268. * @returns a SceneOptimizerOptions object
  68269. */
  68270. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68271. }
  68272. /**
  68273. * Class used to run optimizations in order to reach a target frame rate
  68274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68275. */
  68276. export class SceneOptimizer implements IDisposable {
  68277. private _isRunning;
  68278. private _options;
  68279. private _scene;
  68280. private _currentPriorityLevel;
  68281. private _targetFrameRate;
  68282. private _trackerDuration;
  68283. private _currentFrameRate;
  68284. private _sceneDisposeObserver;
  68285. private _improvementMode;
  68286. /**
  68287. * Defines an observable called when the optimizer reaches the target frame rate
  68288. */
  68289. onSuccessObservable: Observable<SceneOptimizer>;
  68290. /**
  68291. * Defines an observable called when the optimizer enables an optimization
  68292. */
  68293. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68294. /**
  68295. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68296. */
  68297. onFailureObservable: Observable<SceneOptimizer>;
  68298. /**
  68299. * Gets a boolean indicating if the optimizer is in improvement mode
  68300. */
  68301. get isInImprovementMode(): boolean;
  68302. /**
  68303. * Gets the current priority level (0 at start)
  68304. */
  68305. get currentPriorityLevel(): number;
  68306. /**
  68307. * Gets the current frame rate checked by the SceneOptimizer
  68308. */
  68309. get currentFrameRate(): number;
  68310. /**
  68311. * Gets or sets the current target frame rate (60 by default)
  68312. */
  68313. get targetFrameRate(): number;
  68314. /**
  68315. * Gets or sets the current target frame rate (60 by default)
  68316. */
  68317. set targetFrameRate(value: number);
  68318. /**
  68319. * Gets or sets the current interval between two checks (every 2000ms by default)
  68320. */
  68321. get trackerDuration(): number;
  68322. /**
  68323. * Gets or sets the current interval between two checks (every 2000ms by default)
  68324. */
  68325. set trackerDuration(value: number);
  68326. /**
  68327. * Gets the list of active optimizations
  68328. */
  68329. get optimizations(): SceneOptimization[];
  68330. /**
  68331. * Creates a new SceneOptimizer
  68332. * @param scene defines the scene to work on
  68333. * @param options defines the options to use with the SceneOptimizer
  68334. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68335. * @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)
  68336. */
  68337. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68338. /**
  68339. * Stops the current optimizer
  68340. */
  68341. stop(): void;
  68342. /**
  68343. * Reset the optimizer to initial step (current priority level = 0)
  68344. */
  68345. reset(): void;
  68346. /**
  68347. * Start the optimizer. By default it will try to reach a specific framerate
  68348. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68349. */
  68350. start(): void;
  68351. private _checkCurrentState;
  68352. /**
  68353. * Release all resources
  68354. */
  68355. dispose(): void;
  68356. /**
  68357. * Helper function to create a SceneOptimizer with one single line of code
  68358. * @param scene defines the scene to work on
  68359. * @param options defines the options to use with the SceneOptimizer
  68360. * @param onSuccess defines a callback to call on success
  68361. * @param onFailure defines a callback to call on failure
  68362. * @returns the new SceneOptimizer object
  68363. */
  68364. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68365. }
  68366. }
  68367. declare module BABYLON {
  68368. /**
  68369. * Class used to serialize a scene into a string
  68370. */
  68371. export class SceneSerializer {
  68372. /**
  68373. * Clear cache used by a previous serialization
  68374. */
  68375. static ClearCache(): void;
  68376. /**
  68377. * Serialize a scene into a JSON compatible object
  68378. * @param scene defines the scene to serialize
  68379. * @returns a JSON compatible object
  68380. */
  68381. static Serialize(scene: Scene): any;
  68382. /**
  68383. * Serialize a mesh into a JSON compatible object
  68384. * @param toSerialize defines the mesh to serialize
  68385. * @param withParents defines if parents must be serialized as well
  68386. * @param withChildren defines if children must be serialized as well
  68387. * @returns a JSON compatible object
  68388. */
  68389. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68390. }
  68391. }
  68392. declare module BABYLON {
  68393. /**
  68394. * Class used to host texture specific utilities
  68395. */
  68396. export class TextureTools {
  68397. /**
  68398. * Uses the GPU to create a copy texture rescaled at a given size
  68399. * @param texture Texture to copy from
  68400. * @param width defines the desired width
  68401. * @param height defines the desired height
  68402. * @param useBilinearMode defines if bilinear mode has to be used
  68403. * @return the generated texture
  68404. */
  68405. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68406. }
  68407. }
  68408. declare module BABYLON {
  68409. /**
  68410. * This represents the different options available for the video capture.
  68411. */
  68412. export interface VideoRecorderOptions {
  68413. /** Defines the mime type of the video. */
  68414. mimeType: string;
  68415. /** Defines the FPS the video should be recorded at. */
  68416. fps: number;
  68417. /** Defines the chunk size for the recording data. */
  68418. recordChunckSize: number;
  68419. /** The audio tracks to attach to the recording. */
  68420. audioTracks?: MediaStreamTrack[];
  68421. }
  68422. /**
  68423. * This can help with recording videos from BabylonJS.
  68424. * This is based on the available WebRTC functionalities of the browser.
  68425. *
  68426. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68427. */
  68428. export class VideoRecorder {
  68429. private static readonly _defaultOptions;
  68430. /**
  68431. * Returns whether or not the VideoRecorder is available in your browser.
  68432. * @param engine Defines the Babylon Engine.
  68433. * @returns true if supported otherwise false.
  68434. */
  68435. static IsSupported(engine: Engine): boolean;
  68436. private readonly _options;
  68437. private _canvas;
  68438. private _mediaRecorder;
  68439. private _recordedChunks;
  68440. private _fileName;
  68441. private _resolve;
  68442. private _reject;
  68443. /**
  68444. * True when a recording is already in progress.
  68445. */
  68446. get isRecording(): boolean;
  68447. /**
  68448. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68449. * @param engine Defines the BabylonJS Engine you wish to record.
  68450. * @param options Defines options that can be used to customize the capture.
  68451. */
  68452. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68453. /**
  68454. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68455. */
  68456. stopRecording(): void;
  68457. /**
  68458. * Starts recording the canvas for a max duration specified in parameters.
  68459. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68460. * If null no automatic download will start and you can rely on the promise to get the data back.
  68461. * @param maxDuration Defines the maximum recording time in seconds.
  68462. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68463. * @return A promise callback at the end of the recording with the video data in Blob.
  68464. */
  68465. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68466. /**
  68467. * Releases internal resources used during the recording.
  68468. */
  68469. dispose(): void;
  68470. private _handleDataAvailable;
  68471. private _handleError;
  68472. private _handleStop;
  68473. }
  68474. }
  68475. declare module BABYLON {
  68476. /**
  68477. * Class containing a set of static utilities functions for screenshots
  68478. */
  68479. export class ScreenshotTools {
  68480. /**
  68481. * Captures a screenshot of the current rendering
  68482. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68483. * @param engine defines the rendering engine
  68484. * @param camera defines the source camera
  68485. * @param size This parameter can be set to a single number or to an object with the
  68486. * following (optional) properties: precision, width, height. If a single number is passed,
  68487. * it will be used for both width and height. If an object is passed, the screenshot size
  68488. * will be derived from the parameters. The precision property is a multiplier allowing
  68489. * rendering at a higher or lower resolution
  68490. * @param successCallback defines the callback receives a single parameter which contains the
  68491. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68492. * src parameter of an <img> to display it
  68493. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68494. * Check your browser for supported MIME types
  68495. */
  68496. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68497. /**
  68498. * Captures a screenshot of the current rendering
  68499. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68500. * @param engine defines the rendering engine
  68501. * @param camera defines the source camera
  68502. * @param size This parameter can be set to a single number or to an object with the
  68503. * following (optional) properties: precision, width, height. If a single number is passed,
  68504. * it will be used for both width and height. If an object is passed, the screenshot size
  68505. * will be derived from the parameters. The precision property is a multiplier allowing
  68506. * rendering at a higher or lower resolution
  68507. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68508. * Check your browser for supported MIME types
  68509. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68510. * to the src parameter of an <img> to display it
  68511. */
  68512. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68513. /**
  68514. * Generates an image screenshot from the specified camera.
  68515. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68516. * @param engine The engine to use for rendering
  68517. * @param camera The camera to use for rendering
  68518. * @param size This parameter can be set to a single number or to an object with the
  68519. * following (optional) properties: precision, width, height. If a single number is passed,
  68520. * it will be used for both width and height. If an object is passed, the screenshot size
  68521. * will be derived from the parameters. The precision property is a multiplier allowing
  68522. * rendering at a higher or lower resolution
  68523. * @param successCallback The callback receives a single parameter which contains the
  68524. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68525. * src parameter of an <img> to display it
  68526. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68527. * Check your browser for supported MIME types
  68528. * @param samples Texture samples (default: 1)
  68529. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68530. * @param fileName A name for for the downloaded file.
  68531. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68532. */
  68533. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68534. /**
  68535. * Generates an image screenshot from the specified camera.
  68536. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68537. * @param engine The engine to use for rendering
  68538. * @param camera The camera to use for rendering
  68539. * @param size This parameter can be set to a single number or to an object with the
  68540. * following (optional) properties: precision, width, height. If a single number is passed,
  68541. * it will be used for both width and height. If an object is passed, the screenshot size
  68542. * will be derived from the parameters. The precision property is a multiplier allowing
  68543. * rendering at a higher or lower resolution
  68544. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68545. * Check your browser for supported MIME types
  68546. * @param samples Texture samples (default: 1)
  68547. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68548. * @param fileName A name for for the downloaded file.
  68549. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68550. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68551. * to the src parameter of an <img> to display it
  68552. */
  68553. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68554. /**
  68555. * Gets height and width for screenshot size
  68556. * @private
  68557. */
  68558. private static _getScreenshotSize;
  68559. }
  68560. }
  68561. declare module BABYLON {
  68562. /**
  68563. * Interface for a data buffer
  68564. */
  68565. export interface IDataBuffer {
  68566. /**
  68567. * Reads bytes from the data buffer.
  68568. * @param byteOffset The byte offset to read
  68569. * @param byteLength The byte length to read
  68570. * @returns A promise that resolves when the bytes are read
  68571. */
  68572. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68573. /**
  68574. * The byte length of the buffer.
  68575. */
  68576. readonly byteLength: number;
  68577. }
  68578. /**
  68579. * Utility class for reading from a data buffer
  68580. */
  68581. export class DataReader {
  68582. /**
  68583. * The data buffer associated with this data reader.
  68584. */
  68585. readonly buffer: IDataBuffer;
  68586. /**
  68587. * The current byte offset from the beginning of the data buffer.
  68588. */
  68589. byteOffset: number;
  68590. private _dataView;
  68591. private _dataByteOffset;
  68592. /**
  68593. * Constructor
  68594. * @param buffer The buffer to read
  68595. */
  68596. constructor(buffer: IDataBuffer);
  68597. /**
  68598. * Loads the given byte length.
  68599. * @param byteLength The byte length to load
  68600. * @returns A promise that resolves when the load is complete
  68601. */
  68602. loadAsync(byteLength: number): Promise<void>;
  68603. /**
  68604. * Read a unsigned 32-bit integer from the currently loaded data range.
  68605. * @returns The 32-bit integer read
  68606. */
  68607. readUint32(): number;
  68608. /**
  68609. * Read a byte array from the currently loaded data range.
  68610. * @param byteLength The byte length to read
  68611. * @returns The byte array read
  68612. */
  68613. readUint8Array(byteLength: number): Uint8Array;
  68614. /**
  68615. * Read a string from the currently loaded data range.
  68616. * @param byteLength The byte length to read
  68617. * @returns The string read
  68618. */
  68619. readString(byteLength: number): string;
  68620. /**
  68621. * Skips the given byte length the currently loaded data range.
  68622. * @param byteLength The byte length to skip
  68623. */
  68624. skipBytes(byteLength: number): void;
  68625. }
  68626. }
  68627. declare module BABYLON {
  68628. /**
  68629. * Options used for hit testing
  68630. */
  68631. export interface IWebXRHitTestOptions {
  68632. /**
  68633. * Only test when user interacted with the scene. Default - hit test every frame
  68634. */
  68635. testOnPointerDownOnly?: boolean;
  68636. /**
  68637. * The node to use to transform the local results to world coordinates
  68638. */
  68639. worldParentNode?: TransformNode;
  68640. }
  68641. /**
  68642. * Interface defining the babylon result of raycasting/hit-test
  68643. */
  68644. export interface IWebXRHitResult {
  68645. /**
  68646. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68647. */
  68648. transformationMatrix: Matrix;
  68649. /**
  68650. * The native hit test result
  68651. */
  68652. xrHitResult: XRHitResult;
  68653. }
  68654. /**
  68655. * The currently-working hit-test module.
  68656. * Hit test (or Ray-casting) is used to interact with the real world.
  68657. * For further information read here - https://github.com/immersive-web/hit-test
  68658. */
  68659. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68660. /**
  68661. * options to use when constructing this feature
  68662. */
  68663. readonly options: IWebXRHitTestOptions;
  68664. private _direction;
  68665. private _mat;
  68666. private _onSelectEnabled;
  68667. private _origin;
  68668. /**
  68669. * The module's name
  68670. */
  68671. static readonly Name: string;
  68672. /**
  68673. * The (Babylon) version of this module.
  68674. * This is an integer representing the implementation version.
  68675. * This number does not correspond to the WebXR specs version
  68676. */
  68677. static readonly Version: number;
  68678. /**
  68679. * Populated with the last native XR Hit Results
  68680. */
  68681. lastNativeXRHitResults: XRHitResult[];
  68682. /**
  68683. * Triggered when new babylon (transformed) hit test results are available
  68684. */
  68685. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68686. /**
  68687. * Creates a new instance of the (legacy version) hit test feature
  68688. * @param _xrSessionManager an instance of WebXRSessionManager
  68689. * @param options options to use when constructing this feature
  68690. */
  68691. constructor(_xrSessionManager: WebXRSessionManager,
  68692. /**
  68693. * options to use when constructing this feature
  68694. */
  68695. options?: IWebXRHitTestOptions);
  68696. /**
  68697. * execute a hit test with an XR Ray
  68698. *
  68699. * @param xrSession a native xrSession that will execute this hit test
  68700. * @param xrRay the ray (position and direction) to use for ray-casting
  68701. * @param referenceSpace native XR reference space to use for the hit-test
  68702. * @param filter filter function that will filter the results
  68703. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68704. */
  68705. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68706. /**
  68707. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68708. * @param event the (select) event to use to select with
  68709. * @param referenceSpace the reference space to use for this hit test
  68710. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68711. */
  68712. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68713. /**
  68714. * attach this feature
  68715. * Will usually be called by the features manager
  68716. *
  68717. * @returns true if successful.
  68718. */
  68719. attach(): boolean;
  68720. /**
  68721. * detach this feature.
  68722. * Will usually be called by the features manager
  68723. *
  68724. * @returns true if successful.
  68725. */
  68726. detach(): boolean;
  68727. /**
  68728. * Dispose this feature and all of the resources attached
  68729. */
  68730. dispose(): void;
  68731. protected _onXRFrame(frame: XRFrame): void;
  68732. private _onHitTestResults;
  68733. private _onSelect;
  68734. }
  68735. }
  68736. declare module BABYLON {
  68737. /**
  68738. * Options used in the plane detector module
  68739. */
  68740. export interface IWebXRPlaneDetectorOptions {
  68741. /**
  68742. * The node to use to transform the local results to world coordinates
  68743. */
  68744. worldParentNode?: TransformNode;
  68745. }
  68746. /**
  68747. * A babylon interface for a WebXR plane.
  68748. * A Plane is actually a polygon, built from N points in space
  68749. *
  68750. * Supported in chrome 79, not supported in canary 81 ATM
  68751. */
  68752. export interface IWebXRPlane {
  68753. /**
  68754. * a babylon-assigned ID for this polygon
  68755. */
  68756. id: number;
  68757. /**
  68758. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68759. */
  68760. polygonDefinition: Array<Vector3>;
  68761. /**
  68762. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68763. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68764. */
  68765. transformationMatrix: Matrix;
  68766. /**
  68767. * the native xr-plane object
  68768. */
  68769. xrPlane: XRPlane;
  68770. }
  68771. /**
  68772. * The plane detector is used to detect planes in the real world when in AR
  68773. * For more information see https://github.com/immersive-web/real-world-geometry/
  68774. */
  68775. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68776. private _options;
  68777. private _detectedPlanes;
  68778. private _enabled;
  68779. private _lastFrameDetected;
  68780. /**
  68781. * The module's name
  68782. */
  68783. static readonly Name: string;
  68784. /**
  68785. * The (Babylon) version of this module.
  68786. * This is an integer representing the implementation version.
  68787. * This number does not correspond to the WebXR specs version
  68788. */
  68789. static readonly Version: number;
  68790. /**
  68791. * Observers registered here will be executed when a new plane was added to the session
  68792. */
  68793. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68794. /**
  68795. * Observers registered here will be executed when a plane is no longer detected in the session
  68796. */
  68797. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68798. /**
  68799. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68800. * This can execute N times every frame
  68801. */
  68802. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68803. /**
  68804. * construct a new Plane Detector
  68805. * @param _xrSessionManager an instance of xr Session manager
  68806. * @param _options configuration to use when constructing this feature
  68807. */
  68808. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68809. /**
  68810. * Dispose this feature and all of the resources attached
  68811. */
  68812. dispose(): void;
  68813. protected _onXRFrame(frame: XRFrame): void;
  68814. private _init;
  68815. private _updatePlaneWithXRPlane;
  68816. /**
  68817. * avoiding using Array.find for global support.
  68818. * @param xrPlane the plane to find in the array
  68819. */
  68820. private findIndexInPlaneArray;
  68821. }
  68822. }
  68823. declare module BABYLON {
  68824. /**
  68825. * Configuration options of the anchor system
  68826. */
  68827. export interface IWebXRAnchorSystemOptions {
  68828. /**
  68829. * Should a new anchor be added every time a select event is triggered
  68830. */
  68831. addAnchorOnSelect?: boolean;
  68832. /**
  68833. * should the anchor system use plane detection.
  68834. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68835. */
  68836. usePlaneDetection?: boolean;
  68837. /**
  68838. * a node that will be used to convert local to world coordinates
  68839. */
  68840. worldParentNode?: TransformNode;
  68841. }
  68842. /**
  68843. * A babylon container for an XR Anchor
  68844. */
  68845. export interface IWebXRAnchor {
  68846. /**
  68847. * A babylon-assigned ID for this anchor
  68848. */
  68849. id: number;
  68850. /**
  68851. * Transformation matrix to apply to an object attached to this anchor
  68852. */
  68853. transformationMatrix: Matrix;
  68854. /**
  68855. * The native anchor object
  68856. */
  68857. xrAnchor: XRAnchor;
  68858. }
  68859. /**
  68860. * An implementation of the anchor system of WebXR.
  68861. * Note that the current documented implementation is not available in any browser. Future implementations
  68862. * will use the frame to create an anchor and not the session or a detected plane
  68863. * For further information see https://github.com/immersive-web/anchors/
  68864. */
  68865. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68866. private _options;
  68867. private _enabled;
  68868. private _hitTestModule;
  68869. private _lastFrameDetected;
  68870. private _onSelect;
  68871. private _planeDetector;
  68872. private _trackedAnchors;
  68873. /**
  68874. * The module's name
  68875. */
  68876. static readonly Name: string;
  68877. /**
  68878. * The (Babylon) version of this module.
  68879. * This is an integer representing the implementation version.
  68880. * This number does not correspond to the WebXR specs version
  68881. */
  68882. static readonly Version: number;
  68883. /**
  68884. * Observers registered here will be executed when a new anchor was added to the session
  68885. */
  68886. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  68887. /**
  68888. * Observers registered here will be executed when an anchor was removed from the session
  68889. */
  68890. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  68891. /**
  68892. * Observers registered here will be executed when an existing anchor updates
  68893. * This can execute N times every frame
  68894. */
  68895. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  68896. /**
  68897. * constructs a new anchor system
  68898. * @param _xrSessionManager an instance of WebXRSessionManager
  68899. * @param _options configuration object for this feature
  68900. */
  68901. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  68902. /**
  68903. * Add anchor at a specific XR point.
  68904. *
  68905. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  68906. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  68907. * @returns a promise the fulfills when the anchor was created
  68908. */
  68909. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  68910. /**
  68911. * attach this feature
  68912. * Will usually be called by the features manager
  68913. *
  68914. * @returns true if successful.
  68915. */
  68916. attach(): boolean;
  68917. /**
  68918. * detach this feature.
  68919. * Will usually be called by the features manager
  68920. *
  68921. * @returns true if successful.
  68922. */
  68923. detach(): boolean;
  68924. /**
  68925. * Dispose this feature and all of the resources attached
  68926. */
  68927. dispose(): void;
  68928. /**
  68929. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  68930. * @param hitTestModule the hit-test module to use.
  68931. */
  68932. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  68933. /**
  68934. * set the plane detector to use in order to create anchors from frames
  68935. * @param planeDetector the plane-detector module to use
  68936. * @param enable enable plane-anchors. default is true
  68937. */
  68938. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  68939. protected _onXRFrame(frame: XRFrame): void;
  68940. /**
  68941. * avoiding using Array.find for global support.
  68942. * @param xrAnchor the plane to find in the array
  68943. */
  68944. private _findIndexInAnchorArray;
  68945. private _updateAnchorWithXRFrame;
  68946. }
  68947. }
  68948. declare module BABYLON {
  68949. /**
  68950. * Options interface for the background remover plugin
  68951. */
  68952. export interface IWebXRBackgroundRemoverOptions {
  68953. /**
  68954. * Further background meshes to disable when entering AR
  68955. */
  68956. backgroundMeshes?: AbstractMesh[];
  68957. /**
  68958. * flags to configure the removal of the environment helper.
  68959. * If not set, the entire background will be removed. If set, flags should be set as well.
  68960. */
  68961. environmentHelperRemovalFlags?: {
  68962. /**
  68963. * Should the skybox be removed (default false)
  68964. */
  68965. skyBox?: boolean;
  68966. /**
  68967. * Should the ground be removed (default false)
  68968. */
  68969. ground?: boolean;
  68970. };
  68971. /**
  68972. * don't disable the environment helper
  68973. */
  68974. ignoreEnvironmentHelper?: boolean;
  68975. }
  68976. /**
  68977. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  68978. */
  68979. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  68980. /**
  68981. * read-only options to be used in this module
  68982. */
  68983. readonly options: IWebXRBackgroundRemoverOptions;
  68984. /**
  68985. * The module's name
  68986. */
  68987. static readonly Name: string;
  68988. /**
  68989. * The (Babylon) version of this module.
  68990. * This is an integer representing the implementation version.
  68991. * This number does not correspond to the WebXR specs version
  68992. */
  68993. static readonly Version: number;
  68994. /**
  68995. * registered observers will be triggered when the background state changes
  68996. */
  68997. onBackgroundStateChangedObservable: Observable<boolean>;
  68998. /**
  68999. * constructs a new background remover module
  69000. * @param _xrSessionManager the session manager for this module
  69001. * @param options read-only options to be used in this module
  69002. */
  69003. constructor(_xrSessionManager: WebXRSessionManager,
  69004. /**
  69005. * read-only options to be used in this module
  69006. */
  69007. options?: IWebXRBackgroundRemoverOptions);
  69008. /**
  69009. * attach this feature
  69010. * Will usually be called by the features manager
  69011. *
  69012. * @returns true if successful.
  69013. */
  69014. attach(): boolean;
  69015. /**
  69016. * detach this feature.
  69017. * Will usually be called by the features manager
  69018. *
  69019. * @returns true if successful.
  69020. */
  69021. detach(): boolean;
  69022. /**
  69023. * Dispose this feature and all of the resources attached
  69024. */
  69025. dispose(): void;
  69026. protected _onXRFrame(_xrFrame: XRFrame): void;
  69027. private _setBackgroundState;
  69028. }
  69029. }
  69030. declare module BABYLON {
  69031. /**
  69032. * Options for the controller physics feature
  69033. */
  69034. export class IWebXRControllerPhysicsOptions {
  69035. /**
  69036. * Should the headset get its own impostor
  69037. */
  69038. enableHeadsetImpostor?: boolean;
  69039. /**
  69040. * Optional parameters for the headset impostor
  69041. */
  69042. headsetImpostorParams?: {
  69043. /**
  69044. * The type of impostor to create. Default is sphere
  69045. */
  69046. impostorType: number;
  69047. /**
  69048. * the size of the impostor. Defaults to 10cm
  69049. */
  69050. impostorSize?: number | {
  69051. width: number;
  69052. height: number;
  69053. depth: number;
  69054. };
  69055. /**
  69056. * Friction definitions
  69057. */
  69058. friction?: number;
  69059. /**
  69060. * Restitution
  69061. */
  69062. restitution?: number;
  69063. };
  69064. /**
  69065. * The physics properties of the future impostors
  69066. */
  69067. physicsProperties?: {
  69068. /**
  69069. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69070. * Note that this requires a physics engine that supports mesh impostors!
  69071. */
  69072. useControllerMesh?: boolean;
  69073. /**
  69074. * The type of impostor to create. Default is sphere
  69075. */
  69076. impostorType?: number;
  69077. /**
  69078. * the size of the impostor. Defaults to 10cm
  69079. */
  69080. impostorSize?: number | {
  69081. width: number;
  69082. height: number;
  69083. depth: number;
  69084. };
  69085. /**
  69086. * Friction definitions
  69087. */
  69088. friction?: number;
  69089. /**
  69090. * Restitution
  69091. */
  69092. restitution?: number;
  69093. };
  69094. /**
  69095. * the xr input to use with this pointer selection
  69096. */
  69097. xrInput: WebXRInput;
  69098. }
  69099. /**
  69100. * Add physics impostor to your webxr controllers,
  69101. * including naive calculation of their linear and angular velocity
  69102. */
  69103. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69104. private readonly _options;
  69105. private _attachController;
  69106. private _controllers;
  69107. private _debugMode;
  69108. private _delta;
  69109. private _headsetImpostor?;
  69110. private _headsetMesh?;
  69111. private _lastTimestamp;
  69112. private _tmpQuaternion;
  69113. private _tmpVector;
  69114. /**
  69115. * The module's name
  69116. */
  69117. static readonly Name: string;
  69118. /**
  69119. * The (Babylon) version of this module.
  69120. * This is an integer representing the implementation version.
  69121. * This number does not correspond to the webxr specs version
  69122. */
  69123. static readonly Version: number;
  69124. /**
  69125. * Construct a new Controller Physics Feature
  69126. * @param _xrSessionManager the corresponding xr session manager
  69127. * @param _options options to create this feature with
  69128. */
  69129. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69130. /**
  69131. * @hidden
  69132. * enable debugging - will show console outputs and the impostor mesh
  69133. */
  69134. _enablePhysicsDebug(): void;
  69135. /**
  69136. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69137. * @param xrController the controller to add
  69138. */
  69139. addController(xrController: WebXRInputSource): void;
  69140. /**
  69141. * attach this feature
  69142. * Will usually be called by the features manager
  69143. *
  69144. * @returns true if successful.
  69145. */
  69146. attach(): boolean;
  69147. /**
  69148. * detach this feature.
  69149. * Will usually be called by the features manager
  69150. *
  69151. * @returns true if successful.
  69152. */
  69153. detach(): boolean;
  69154. /**
  69155. * Get the headset impostor, if enabled
  69156. * @returns the impostor
  69157. */
  69158. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69159. /**
  69160. * Get the physics impostor of a specific controller.
  69161. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69162. * @param controller the controller or the controller id of which to get the impostor
  69163. * @returns the impostor or null
  69164. */
  69165. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69166. /**
  69167. * Update the physics properties provided in the constructor
  69168. * @param newProperties the new properties object
  69169. */
  69170. setPhysicsProperties(newProperties: {
  69171. impostorType?: number;
  69172. impostorSize?: number | {
  69173. width: number;
  69174. height: number;
  69175. depth: number;
  69176. };
  69177. friction?: number;
  69178. restitution?: number;
  69179. }): void;
  69180. protected _onXRFrame(_xrFrame: any): void;
  69181. private _detachController;
  69182. }
  69183. }
  69184. declare module BABYLON {
  69185. /**
  69186. * The motion controller class for all microsoft mixed reality controllers
  69187. */
  69188. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69189. protected readonly _mapping: {
  69190. defaultButton: {
  69191. "valueNodeName": string;
  69192. "unpressedNodeName": string;
  69193. "pressedNodeName": string;
  69194. };
  69195. defaultAxis: {
  69196. "valueNodeName": string;
  69197. "minNodeName": string;
  69198. "maxNodeName": string;
  69199. };
  69200. buttons: {
  69201. "xr-standard-trigger": {
  69202. "rootNodeName": string;
  69203. "componentProperty": string;
  69204. "states": string[];
  69205. };
  69206. "xr-standard-squeeze": {
  69207. "rootNodeName": string;
  69208. "componentProperty": string;
  69209. "states": string[];
  69210. };
  69211. "xr-standard-touchpad": {
  69212. "rootNodeName": string;
  69213. "labelAnchorNodeName": string;
  69214. "touchPointNodeName": string;
  69215. };
  69216. "xr-standard-thumbstick": {
  69217. "rootNodeName": string;
  69218. "componentProperty": string;
  69219. "states": string[];
  69220. };
  69221. };
  69222. axes: {
  69223. "xr-standard-touchpad": {
  69224. "x-axis": {
  69225. "rootNodeName": string;
  69226. };
  69227. "y-axis": {
  69228. "rootNodeName": string;
  69229. };
  69230. };
  69231. "xr-standard-thumbstick": {
  69232. "x-axis": {
  69233. "rootNodeName": string;
  69234. };
  69235. "y-axis": {
  69236. "rootNodeName": string;
  69237. };
  69238. };
  69239. };
  69240. };
  69241. /**
  69242. * The base url used to load the left and right controller models
  69243. */
  69244. static MODEL_BASE_URL: string;
  69245. /**
  69246. * The name of the left controller model file
  69247. */
  69248. static MODEL_LEFT_FILENAME: string;
  69249. /**
  69250. * The name of the right controller model file
  69251. */
  69252. static MODEL_RIGHT_FILENAME: string;
  69253. profileId: string;
  69254. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69255. protected _getFilenameAndPath(): {
  69256. filename: string;
  69257. path: string;
  69258. };
  69259. protected _getModelLoadingConstraints(): boolean;
  69260. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69261. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69262. protected _updateModel(): void;
  69263. }
  69264. }
  69265. declare module BABYLON {
  69266. /**
  69267. * The motion controller class for oculus touch (quest, rift).
  69268. * This class supports legacy mapping as well the standard xr mapping
  69269. */
  69270. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69271. private _forceLegacyControllers;
  69272. private _modelRootNode;
  69273. /**
  69274. * The base url used to load the left and right controller models
  69275. */
  69276. static MODEL_BASE_URL: string;
  69277. /**
  69278. * The name of the left controller model file
  69279. */
  69280. static MODEL_LEFT_FILENAME: string;
  69281. /**
  69282. * The name of the right controller model file
  69283. */
  69284. static MODEL_RIGHT_FILENAME: string;
  69285. /**
  69286. * Base Url for the Quest controller model.
  69287. */
  69288. static QUEST_MODEL_BASE_URL: string;
  69289. profileId: string;
  69290. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69291. protected _getFilenameAndPath(): {
  69292. filename: string;
  69293. path: string;
  69294. };
  69295. protected _getModelLoadingConstraints(): boolean;
  69296. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69297. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69298. protected _updateModel(): void;
  69299. /**
  69300. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69301. * between the touch and touch 2.
  69302. */
  69303. private _isQuest;
  69304. }
  69305. }
  69306. declare module BABYLON {
  69307. /**
  69308. * The motion controller class for the standard HTC-Vive controllers
  69309. */
  69310. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69311. private _modelRootNode;
  69312. /**
  69313. * The base url used to load the left and right controller models
  69314. */
  69315. static MODEL_BASE_URL: string;
  69316. /**
  69317. * File name for the controller model.
  69318. */
  69319. static MODEL_FILENAME: string;
  69320. profileId: string;
  69321. /**
  69322. * Create a new Vive motion controller object
  69323. * @param scene the scene to use to create this controller
  69324. * @param gamepadObject the corresponding gamepad object
  69325. * @param handness the handness of the controller
  69326. */
  69327. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69328. protected _getFilenameAndPath(): {
  69329. filename: string;
  69330. path: string;
  69331. };
  69332. protected _getModelLoadingConstraints(): boolean;
  69333. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69334. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69335. protected _updateModel(): void;
  69336. }
  69337. }
  69338. declare module BABYLON {
  69339. /**
  69340. * A cursor which tracks a point on a path
  69341. */
  69342. export class PathCursor {
  69343. private path;
  69344. /**
  69345. * Stores path cursor callbacks for when an onchange event is triggered
  69346. */
  69347. private _onchange;
  69348. /**
  69349. * The value of the path cursor
  69350. */
  69351. value: number;
  69352. /**
  69353. * The animation array of the path cursor
  69354. */
  69355. animations: Animation[];
  69356. /**
  69357. * Initializes the path cursor
  69358. * @param path The path to track
  69359. */
  69360. constructor(path: Path2);
  69361. /**
  69362. * Gets the cursor point on the path
  69363. * @returns A point on the path cursor at the cursor location
  69364. */
  69365. getPoint(): Vector3;
  69366. /**
  69367. * Moves the cursor ahead by the step amount
  69368. * @param step The amount to move the cursor forward
  69369. * @returns This path cursor
  69370. */
  69371. moveAhead(step?: number): PathCursor;
  69372. /**
  69373. * Moves the cursor behind by the step amount
  69374. * @param step The amount to move the cursor back
  69375. * @returns This path cursor
  69376. */
  69377. moveBack(step?: number): PathCursor;
  69378. /**
  69379. * Moves the cursor by the step amount
  69380. * If the step amount is greater than one, an exception is thrown
  69381. * @param step The amount to move the cursor
  69382. * @returns This path cursor
  69383. */
  69384. move(step: number): PathCursor;
  69385. /**
  69386. * Ensures that the value is limited between zero and one
  69387. * @returns This path cursor
  69388. */
  69389. private ensureLimits;
  69390. /**
  69391. * Runs onchange callbacks on change (used by the animation engine)
  69392. * @returns This path cursor
  69393. */
  69394. private raiseOnChange;
  69395. /**
  69396. * Executes a function on change
  69397. * @param f A path cursor onchange callback
  69398. * @returns This path cursor
  69399. */
  69400. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69401. }
  69402. }
  69403. declare module BABYLON {
  69404. /** @hidden */
  69405. export var blurPixelShader: {
  69406. name: string;
  69407. shader: string;
  69408. };
  69409. }
  69410. declare module BABYLON {
  69411. /** @hidden */
  69412. export var pointCloudVertexDeclaration: {
  69413. name: string;
  69414. shader: string;
  69415. };
  69416. }
  69417. // Mixins
  69418. interface Window {
  69419. mozIndexedDB: IDBFactory;
  69420. webkitIndexedDB: IDBFactory;
  69421. msIndexedDB: IDBFactory;
  69422. webkitURL: typeof URL;
  69423. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69424. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69425. WebGLRenderingContext: WebGLRenderingContext;
  69426. MSGesture: MSGesture;
  69427. CANNON: any;
  69428. AudioContext: AudioContext;
  69429. webkitAudioContext: AudioContext;
  69430. PointerEvent: any;
  69431. Math: Math;
  69432. Uint8Array: Uint8ArrayConstructor;
  69433. Float32Array: Float32ArrayConstructor;
  69434. mozURL: typeof URL;
  69435. msURL: typeof URL;
  69436. VRFrameData: any; // WebVR, from specs 1.1
  69437. DracoDecoderModule: any;
  69438. setImmediate(handler: (...args: any[]) => void): number;
  69439. }
  69440. interface HTMLCanvasElement {
  69441. requestPointerLock(): void;
  69442. msRequestPointerLock?(): void;
  69443. mozRequestPointerLock?(): void;
  69444. webkitRequestPointerLock?(): void;
  69445. /** Track wether a record is in progress */
  69446. isRecording: boolean;
  69447. /** Capture Stream method defined by some browsers */
  69448. captureStream(fps?: number): MediaStream;
  69449. }
  69450. interface CanvasRenderingContext2D {
  69451. msImageSmoothingEnabled: boolean;
  69452. }
  69453. interface MouseEvent {
  69454. mozMovementX: number;
  69455. mozMovementY: number;
  69456. webkitMovementX: number;
  69457. webkitMovementY: number;
  69458. msMovementX: number;
  69459. msMovementY: number;
  69460. }
  69461. interface Navigator {
  69462. mozGetVRDevices: (any: any) => any;
  69463. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69464. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69465. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69466. webkitGetGamepads(): Gamepad[];
  69467. msGetGamepads(): Gamepad[];
  69468. webkitGamepads(): Gamepad[];
  69469. }
  69470. interface HTMLVideoElement {
  69471. mozSrcObject: any;
  69472. }
  69473. interface Math {
  69474. fround(x: number): number;
  69475. imul(a: number, b: number): number;
  69476. }
  69477. interface WebGLRenderingContext {
  69478. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69479. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69480. vertexAttribDivisor(index: number, divisor: number): void;
  69481. createVertexArray(): any;
  69482. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69483. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69484. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69485. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69486. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69487. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69488. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69489. // Queries
  69490. createQuery(): WebGLQuery;
  69491. deleteQuery(query: WebGLQuery): void;
  69492. beginQuery(target: number, query: WebGLQuery): void;
  69493. endQuery(target: number): void;
  69494. getQueryParameter(query: WebGLQuery, pname: number): any;
  69495. getQuery(target: number, pname: number): any;
  69496. MAX_SAMPLES: number;
  69497. RGBA8: number;
  69498. READ_FRAMEBUFFER: number;
  69499. DRAW_FRAMEBUFFER: number;
  69500. UNIFORM_BUFFER: number;
  69501. HALF_FLOAT_OES: number;
  69502. RGBA16F: number;
  69503. RGBA32F: number;
  69504. R32F: number;
  69505. RG32F: number;
  69506. RGB32F: number;
  69507. R16F: number;
  69508. RG16F: number;
  69509. RGB16F: number;
  69510. RED: number;
  69511. RG: number;
  69512. R8: number;
  69513. RG8: number;
  69514. UNSIGNED_INT_24_8: number;
  69515. DEPTH24_STENCIL8: number;
  69516. MIN: number;
  69517. MAX: number;
  69518. /* Multiple Render Targets */
  69519. drawBuffers(buffers: number[]): void;
  69520. readBuffer(src: number): void;
  69521. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69522. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69523. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69524. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69525. // Occlusion Query
  69526. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69527. ANY_SAMPLES_PASSED: number;
  69528. QUERY_RESULT_AVAILABLE: number;
  69529. QUERY_RESULT: number;
  69530. }
  69531. interface WebGLProgram {
  69532. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69533. }
  69534. interface EXT_disjoint_timer_query {
  69535. QUERY_COUNTER_BITS_EXT: number;
  69536. TIME_ELAPSED_EXT: number;
  69537. TIMESTAMP_EXT: number;
  69538. GPU_DISJOINT_EXT: number;
  69539. QUERY_RESULT_EXT: number;
  69540. QUERY_RESULT_AVAILABLE_EXT: number;
  69541. queryCounterEXT(query: WebGLQuery, target: number): void;
  69542. createQueryEXT(): WebGLQuery;
  69543. beginQueryEXT(target: number, query: WebGLQuery): void;
  69544. endQueryEXT(target: number): void;
  69545. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69546. deleteQueryEXT(query: WebGLQuery): void;
  69547. }
  69548. interface WebGLUniformLocation {
  69549. _currentState: any;
  69550. }
  69551. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69552. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69553. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69554. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69555. interface WebGLRenderingContext {
  69556. readonly RASTERIZER_DISCARD: number;
  69557. readonly DEPTH_COMPONENT24: number;
  69558. readonly TEXTURE_3D: number;
  69559. readonly TEXTURE_2D_ARRAY: number;
  69560. readonly TEXTURE_COMPARE_FUNC: number;
  69561. readonly TEXTURE_COMPARE_MODE: number;
  69562. readonly COMPARE_REF_TO_TEXTURE: number;
  69563. readonly TEXTURE_WRAP_R: number;
  69564. readonly HALF_FLOAT: number;
  69565. readonly RGB8: number;
  69566. readonly RED_INTEGER: number;
  69567. readonly RG_INTEGER: number;
  69568. readonly RGB_INTEGER: number;
  69569. readonly RGBA_INTEGER: number;
  69570. readonly R8_SNORM: number;
  69571. readonly RG8_SNORM: number;
  69572. readonly RGB8_SNORM: number;
  69573. readonly RGBA8_SNORM: number;
  69574. readonly R8I: number;
  69575. readonly RG8I: number;
  69576. readonly RGB8I: number;
  69577. readonly RGBA8I: number;
  69578. readonly R8UI: number;
  69579. readonly RG8UI: number;
  69580. readonly RGB8UI: number;
  69581. readonly RGBA8UI: number;
  69582. readonly R16I: number;
  69583. readonly RG16I: number;
  69584. readonly RGB16I: number;
  69585. readonly RGBA16I: number;
  69586. readonly R16UI: number;
  69587. readonly RG16UI: number;
  69588. readonly RGB16UI: number;
  69589. readonly RGBA16UI: number;
  69590. readonly R32I: number;
  69591. readonly RG32I: number;
  69592. readonly RGB32I: number;
  69593. readonly RGBA32I: number;
  69594. readonly R32UI: number;
  69595. readonly RG32UI: number;
  69596. readonly RGB32UI: number;
  69597. readonly RGBA32UI: number;
  69598. readonly RGB10_A2UI: number;
  69599. readonly R11F_G11F_B10F: number;
  69600. readonly RGB9_E5: number;
  69601. readonly RGB10_A2: number;
  69602. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69603. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69604. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69605. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69606. readonly DEPTH_COMPONENT32F: number;
  69607. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69608. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69609. 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;
  69610. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69611. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69612. readonly TRANSFORM_FEEDBACK: number;
  69613. readonly INTERLEAVED_ATTRIBS: number;
  69614. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69615. createTransformFeedback(): WebGLTransformFeedback;
  69616. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69617. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69618. beginTransformFeedback(primitiveMode: number): void;
  69619. endTransformFeedback(): void;
  69620. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69621. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69622. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69623. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69624. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69625. }
  69626. interface ImageBitmap {
  69627. readonly width: number;
  69628. readonly height: number;
  69629. close(): void;
  69630. }
  69631. interface WebGLQuery extends WebGLObject {
  69632. }
  69633. declare var WebGLQuery: {
  69634. prototype: WebGLQuery;
  69635. new(): WebGLQuery;
  69636. };
  69637. interface WebGLSampler extends WebGLObject {
  69638. }
  69639. declare var WebGLSampler: {
  69640. prototype: WebGLSampler;
  69641. new(): WebGLSampler;
  69642. };
  69643. interface WebGLSync extends WebGLObject {
  69644. }
  69645. declare var WebGLSync: {
  69646. prototype: WebGLSync;
  69647. new(): WebGLSync;
  69648. };
  69649. interface WebGLTransformFeedback extends WebGLObject {
  69650. }
  69651. declare var WebGLTransformFeedback: {
  69652. prototype: WebGLTransformFeedback;
  69653. new(): WebGLTransformFeedback;
  69654. };
  69655. interface WebGLVertexArrayObject extends WebGLObject {
  69656. }
  69657. declare var WebGLVertexArrayObject: {
  69658. prototype: WebGLVertexArrayObject;
  69659. new(): WebGLVertexArrayObject;
  69660. };
  69661. // Type definitions for WebVR API
  69662. // Project: https://w3c.github.io/webvr/
  69663. // Definitions by: six a <https://github.com/lostfictions>
  69664. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69665. interface VRDisplay extends EventTarget {
  69666. /**
  69667. * Dictionary of capabilities describing the VRDisplay.
  69668. */
  69669. readonly capabilities: VRDisplayCapabilities;
  69670. /**
  69671. * z-depth defining the far plane of the eye view frustum
  69672. * enables mapping of values in the render target depth
  69673. * attachment to scene coordinates. Initially set to 10000.0.
  69674. */
  69675. depthFar: number;
  69676. /**
  69677. * z-depth defining the near plane of the eye view frustum
  69678. * enables mapping of values in the render target depth
  69679. * attachment to scene coordinates. Initially set to 0.01.
  69680. */
  69681. depthNear: number;
  69682. /**
  69683. * An identifier for this distinct VRDisplay. Used as an
  69684. * association point in the Gamepad API.
  69685. */
  69686. readonly displayId: number;
  69687. /**
  69688. * A display name, a user-readable name identifying it.
  69689. */
  69690. readonly displayName: string;
  69691. readonly isConnected: boolean;
  69692. readonly isPresenting: boolean;
  69693. /**
  69694. * If this VRDisplay supports room-scale experiences, the optional
  69695. * stage attribute contains details on the room-scale parameters.
  69696. */
  69697. readonly stageParameters: VRStageParameters | null;
  69698. /**
  69699. * Passing the value returned by `requestAnimationFrame` to
  69700. * `cancelAnimationFrame` will unregister the callback.
  69701. * @param handle Define the hanle of the request to cancel
  69702. */
  69703. cancelAnimationFrame(handle: number): void;
  69704. /**
  69705. * Stops presenting to the VRDisplay.
  69706. * @returns a promise to know when it stopped
  69707. */
  69708. exitPresent(): Promise<void>;
  69709. /**
  69710. * Return the current VREyeParameters for the given eye.
  69711. * @param whichEye Define the eye we want the parameter for
  69712. * @returns the eye parameters
  69713. */
  69714. getEyeParameters(whichEye: string): VREyeParameters;
  69715. /**
  69716. * Populates the passed VRFrameData with the information required to render
  69717. * the current frame.
  69718. * @param frameData Define the data structure to populate
  69719. * @returns true if ok otherwise false
  69720. */
  69721. getFrameData(frameData: VRFrameData): boolean;
  69722. /**
  69723. * Get the layers currently being presented.
  69724. * @returns the list of VR layers
  69725. */
  69726. getLayers(): VRLayer[];
  69727. /**
  69728. * Return a VRPose containing the future predicted pose of the VRDisplay
  69729. * when the current frame will be presented. The value returned will not
  69730. * change until JavaScript has returned control to the browser.
  69731. *
  69732. * The VRPose will contain the position, orientation, velocity,
  69733. * and acceleration of each of these properties.
  69734. * @returns the pose object
  69735. */
  69736. getPose(): VRPose;
  69737. /**
  69738. * Return the current instantaneous pose of the VRDisplay, with no
  69739. * prediction applied.
  69740. * @returns the current instantaneous pose
  69741. */
  69742. getImmediatePose(): VRPose;
  69743. /**
  69744. * The callback passed to `requestAnimationFrame` will be called
  69745. * any time a new frame should be rendered. When the VRDisplay is
  69746. * presenting the callback will be called at the native refresh
  69747. * rate of the HMD. When not presenting this function acts
  69748. * identically to how window.requestAnimationFrame acts. Content should
  69749. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69750. * asynchronously from other displays and at differing refresh rates.
  69751. * @param callback Define the eaction to run next frame
  69752. * @returns the request handle it
  69753. */
  69754. requestAnimationFrame(callback: FrameRequestCallback): number;
  69755. /**
  69756. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69757. * Repeat calls while already presenting will update the VRLayers being displayed.
  69758. * @param layers Define the list of layer to present
  69759. * @returns a promise to know when the request has been fulfilled
  69760. */
  69761. requestPresent(layers: VRLayer[]): Promise<void>;
  69762. /**
  69763. * Reset the pose for this display, treating its current position and
  69764. * orientation as the "origin/zero" values. VRPose.position,
  69765. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69766. * updated when calling resetPose(). This should be called in only
  69767. * sitting-space experiences.
  69768. */
  69769. resetPose(): void;
  69770. /**
  69771. * The VRLayer provided to the VRDisplay will be captured and presented
  69772. * in the HMD. Calling this function has the same effect on the source
  69773. * canvas as any other operation that uses its source image, and canvases
  69774. * created without preserveDrawingBuffer set to true will be cleared.
  69775. * @param pose Define the pose to submit
  69776. */
  69777. submitFrame(pose?: VRPose): void;
  69778. }
  69779. declare var VRDisplay: {
  69780. prototype: VRDisplay;
  69781. new(): VRDisplay;
  69782. };
  69783. interface VRLayer {
  69784. leftBounds?: number[] | Float32Array | null;
  69785. rightBounds?: number[] | Float32Array | null;
  69786. source?: HTMLCanvasElement | null;
  69787. }
  69788. interface VRDisplayCapabilities {
  69789. readonly canPresent: boolean;
  69790. readonly hasExternalDisplay: boolean;
  69791. readonly hasOrientation: boolean;
  69792. readonly hasPosition: boolean;
  69793. readonly maxLayers: number;
  69794. }
  69795. interface VREyeParameters {
  69796. /** @deprecated */
  69797. readonly fieldOfView: VRFieldOfView;
  69798. readonly offset: Float32Array;
  69799. readonly renderHeight: number;
  69800. readonly renderWidth: number;
  69801. }
  69802. interface VRFieldOfView {
  69803. readonly downDegrees: number;
  69804. readonly leftDegrees: number;
  69805. readonly rightDegrees: number;
  69806. readonly upDegrees: number;
  69807. }
  69808. interface VRFrameData {
  69809. readonly leftProjectionMatrix: Float32Array;
  69810. readonly leftViewMatrix: Float32Array;
  69811. readonly pose: VRPose;
  69812. readonly rightProjectionMatrix: Float32Array;
  69813. readonly rightViewMatrix: Float32Array;
  69814. readonly timestamp: number;
  69815. }
  69816. interface VRPose {
  69817. readonly angularAcceleration: Float32Array | null;
  69818. readonly angularVelocity: Float32Array | null;
  69819. readonly linearAcceleration: Float32Array | null;
  69820. readonly linearVelocity: Float32Array | null;
  69821. readonly orientation: Float32Array | null;
  69822. readonly position: Float32Array | null;
  69823. readonly timestamp: number;
  69824. }
  69825. interface VRStageParameters {
  69826. sittingToStandingTransform?: Float32Array;
  69827. sizeX?: number;
  69828. sizeY?: number;
  69829. }
  69830. interface Navigator {
  69831. getVRDisplays(): Promise<VRDisplay[]>;
  69832. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69833. }
  69834. interface Window {
  69835. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69836. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69837. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69838. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69839. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69840. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69841. }
  69842. interface Gamepad {
  69843. readonly displayId: number;
  69844. }
  69845. type XRSessionMode =
  69846. | "inline"
  69847. | "immersive-vr"
  69848. | "immersive-ar";
  69849. type XRReferenceSpaceType =
  69850. | "viewer"
  69851. | "local"
  69852. | "local-floor"
  69853. | "bounded-floor"
  69854. | "unbounded";
  69855. type XREnvironmentBlendMode =
  69856. | "opaque"
  69857. | "additive"
  69858. | "alpha-blend";
  69859. type XRVisibilityState =
  69860. | "visible"
  69861. | "visible-blurred"
  69862. | "hidden";
  69863. type XRHandedness =
  69864. | "none"
  69865. | "left"
  69866. | "right";
  69867. type XRTargetRayMode =
  69868. | "gaze"
  69869. | "tracked-pointer"
  69870. | "screen";
  69871. type XREye =
  69872. | "none"
  69873. | "left"
  69874. | "right";
  69875. interface XRSpace extends EventTarget {
  69876. }
  69877. interface XRRenderState {
  69878. depthNear?: number;
  69879. depthFar?: number;
  69880. inlineVerticalFieldOfView?: number;
  69881. baseLayer?: XRWebGLLayer;
  69882. }
  69883. interface XRInputSource {
  69884. handedness: XRHandedness;
  69885. targetRayMode: XRTargetRayMode;
  69886. targetRaySpace: XRSpace;
  69887. gripSpace: XRSpace | undefined;
  69888. gamepad: Gamepad | undefined;
  69889. profiles: Array<string>;
  69890. }
  69891. interface XRSessionInit {
  69892. optionalFeatures?: XRReferenceSpaceType[];
  69893. requiredFeatures?: XRReferenceSpaceType[];
  69894. }
  69895. interface XRSession extends XRAnchorCreator {
  69896. addEventListener: Function;
  69897. removeEventListener: Function;
  69898. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69899. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69900. requestAnimationFrame: Function;
  69901. end(): Promise<void>;
  69902. renderState: XRRenderState;
  69903. inputSources: Array<XRInputSource>;
  69904. // AR hit test
  69905. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69906. updateWorldTrackingState(options: {
  69907. planeDetectionState?: { enabled: boolean; }
  69908. }): void;
  69909. }
  69910. interface XRReferenceSpace extends XRSpace {
  69911. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69912. onreset: any;
  69913. }
  69914. type XRPlaneSet = Set<XRPlane>;
  69915. type XRAnchorSet = Set<XRAnchor>;
  69916. interface XRFrame {
  69917. session: XRSession;
  69918. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69919. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69920. // Anchors
  69921. trackedAnchors?: XRAnchorSet;
  69922. // Planes
  69923. worldInformation: {
  69924. detectedPlanes?: XRPlaneSet;
  69925. };
  69926. }
  69927. interface XRViewerPose extends XRPose {
  69928. views: Array<XRView>;
  69929. }
  69930. interface XRPose {
  69931. transform: XRRigidTransform;
  69932. emulatedPosition: boolean;
  69933. }
  69934. interface XRWebGLLayerOptions {
  69935. antialias?: boolean;
  69936. depth?: boolean;
  69937. stencil?: boolean;
  69938. alpha?: boolean;
  69939. multiview?: boolean;
  69940. framebufferScaleFactor?: number;
  69941. }
  69942. declare var XRWebGLLayer: {
  69943. prototype: XRWebGLLayer;
  69944. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69945. };
  69946. interface XRWebGLLayer {
  69947. framebuffer: WebGLFramebuffer;
  69948. framebufferWidth: number;
  69949. framebufferHeight: number;
  69950. getViewport: Function;
  69951. }
  69952. declare class XRRigidTransform {
  69953. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69954. position: DOMPointReadOnly;
  69955. orientation: DOMPointReadOnly;
  69956. matrix: Float32Array;
  69957. inverse: XRRigidTransform;
  69958. }
  69959. interface XRView {
  69960. eye: XREye;
  69961. projectionMatrix: Float32Array;
  69962. transform: XRRigidTransform;
  69963. }
  69964. interface XRInputSourceChangeEvent {
  69965. session: XRSession;
  69966. removed: Array<XRInputSource>;
  69967. added: Array<XRInputSource>;
  69968. }
  69969. interface XRInputSourceEvent extends Event {
  69970. readonly frame: XRFrame;
  69971. readonly inputSource: XRInputSource;
  69972. }
  69973. // Experimental(er) features
  69974. declare class XRRay {
  69975. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69976. origin: DOMPointReadOnly;
  69977. direction: DOMPointReadOnly;
  69978. matrix: Float32Array;
  69979. }
  69980. interface XRHitResult {
  69981. hitMatrix: Float32Array;
  69982. }
  69983. interface XRAnchor {
  69984. // remove?
  69985. id?: string;
  69986. anchorSpace: XRSpace;
  69987. lastChangedTime: number;
  69988. detach(): void;
  69989. }
  69990. interface XRPlane extends XRAnchorCreator {
  69991. orientation: "Horizontal" | "Vertical";
  69992. planeSpace: XRSpace;
  69993. polygon: Array<DOMPointReadOnly>;
  69994. lastChangedTime: number;
  69995. }
  69996. interface XRAnchorCreator {
  69997. // AR Anchors
  69998. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69999. }
  70000. /**
  70001. * @ignore
  70002. */
  70003. declare module BABYLON.GLTF2.Exporter {
  70004. }
  70005. /**
  70006. * @ignore
  70007. */
  70008. declare module BABYLON.GLTF1 {
  70009. }
  70010. declare module BABYLON.GUI {
  70011. /**
  70012. * Class used to specific a value and its associated unit
  70013. */
  70014. export class ValueAndUnit {
  70015. /** defines the unit to store */
  70016. unit: number;
  70017. /** defines a boolean indicating if the value can be negative */
  70018. negativeValueAllowed: boolean;
  70019. private _value;
  70020. private _originalUnit;
  70021. /**
  70022. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70023. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70024. */
  70025. ignoreAdaptiveScaling: boolean;
  70026. /**
  70027. * Creates a new ValueAndUnit
  70028. * @param value defines the value to store
  70029. * @param unit defines the unit to store
  70030. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70031. */
  70032. constructor(value: number,
  70033. /** defines the unit to store */
  70034. unit?: number,
  70035. /** defines a boolean indicating if the value can be negative */
  70036. negativeValueAllowed?: boolean);
  70037. /** Gets a boolean indicating if the value is a percentage */
  70038. get isPercentage(): boolean;
  70039. /** Gets a boolean indicating if the value is store as pixel */
  70040. get isPixel(): boolean;
  70041. /** Gets direct internal value */
  70042. get internalValue(): number;
  70043. /**
  70044. * Gets value as pixel
  70045. * @param host defines the root host
  70046. * @param refValue defines the reference value for percentages
  70047. * @returns the value as pixel
  70048. */
  70049. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70050. /**
  70051. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70052. * @param value defines the value to store
  70053. * @param unit defines the unit to store
  70054. * @returns the current ValueAndUnit
  70055. */
  70056. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70057. /**
  70058. * Gets the value accordingly to its unit
  70059. * @param host defines the root host
  70060. * @returns the value
  70061. */
  70062. getValue(host: AdvancedDynamicTexture): number;
  70063. /**
  70064. * Gets a string representation of the value
  70065. * @param host defines the root host
  70066. * @param decimals defines an optional number of decimals to display
  70067. * @returns a string
  70068. */
  70069. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70070. /**
  70071. * Store a value parsed from a string
  70072. * @param source defines the source string
  70073. * @returns true if the value was successfully parsed
  70074. */
  70075. fromString(source: string | number): boolean;
  70076. private static _Regex;
  70077. private static _UNITMODE_PERCENTAGE;
  70078. private static _UNITMODE_PIXEL;
  70079. /** UNITMODE_PERCENTAGE */
  70080. static get UNITMODE_PERCENTAGE(): number;
  70081. /** UNITMODE_PIXEL */
  70082. static get UNITMODE_PIXEL(): number;
  70083. }
  70084. }
  70085. declare module BABYLON.GUI {
  70086. /**
  70087. * Define a style used by control to automatically setup properties based on a template.
  70088. * Only support font related properties so far
  70089. */
  70090. export class Style implements BABYLON.IDisposable {
  70091. private _fontFamily;
  70092. private _fontStyle;
  70093. private _fontWeight;
  70094. /** @hidden */
  70095. _host: AdvancedDynamicTexture;
  70096. /** @hidden */
  70097. _fontSize: ValueAndUnit;
  70098. /**
  70099. * BABYLON.Observable raised when the style values are changed
  70100. */
  70101. onChangedObservable: BABYLON.Observable<Style>;
  70102. /**
  70103. * Creates a new style object
  70104. * @param host defines the AdvancedDynamicTexture which hosts this style
  70105. */
  70106. constructor(host: AdvancedDynamicTexture);
  70107. /**
  70108. * Gets or sets the font size
  70109. */
  70110. get fontSize(): string | number;
  70111. set fontSize(value: string | number);
  70112. /**
  70113. * Gets or sets the font family
  70114. */
  70115. get fontFamily(): string;
  70116. set fontFamily(value: string);
  70117. /**
  70118. * Gets or sets the font style
  70119. */
  70120. get fontStyle(): string;
  70121. set fontStyle(value: string);
  70122. /** Gets or sets font weight */
  70123. get fontWeight(): string;
  70124. set fontWeight(value: string);
  70125. /** Dispose all associated resources */
  70126. dispose(): void;
  70127. }
  70128. }
  70129. declare module BABYLON.GUI {
  70130. /**
  70131. * Class used to transport BABYLON.Vector2 information for pointer events
  70132. */
  70133. export class Vector2WithInfo extends BABYLON.Vector2 {
  70134. /** defines the current mouse button index */
  70135. buttonIndex: number;
  70136. /**
  70137. * Creates a new Vector2WithInfo
  70138. * @param source defines the vector2 data to transport
  70139. * @param buttonIndex defines the current mouse button index
  70140. */
  70141. constructor(source: BABYLON.Vector2,
  70142. /** defines the current mouse button index */
  70143. buttonIndex?: number);
  70144. }
  70145. /** Class used to provide 2D matrix features */
  70146. export class Matrix2D {
  70147. /** Gets the internal array of 6 floats used to store matrix data */
  70148. m: Float32Array;
  70149. /**
  70150. * Creates a new matrix
  70151. * @param m00 defines value for (0, 0)
  70152. * @param m01 defines value for (0, 1)
  70153. * @param m10 defines value for (1, 0)
  70154. * @param m11 defines value for (1, 1)
  70155. * @param m20 defines value for (2, 0)
  70156. * @param m21 defines value for (2, 1)
  70157. */
  70158. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70159. /**
  70160. * Fills the matrix from direct values
  70161. * @param m00 defines value for (0, 0)
  70162. * @param m01 defines value for (0, 1)
  70163. * @param m10 defines value for (1, 0)
  70164. * @param m11 defines value for (1, 1)
  70165. * @param m20 defines value for (2, 0)
  70166. * @param m21 defines value for (2, 1)
  70167. * @returns the current modified matrix
  70168. */
  70169. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70170. /**
  70171. * Gets matrix determinant
  70172. * @returns the determinant
  70173. */
  70174. determinant(): number;
  70175. /**
  70176. * Inverses the matrix and stores it in a target matrix
  70177. * @param result defines the target matrix
  70178. * @returns the current matrix
  70179. */
  70180. invertToRef(result: Matrix2D): Matrix2D;
  70181. /**
  70182. * Multiplies the current matrix with another one
  70183. * @param other defines the second operand
  70184. * @param result defines the target matrix
  70185. * @returns the current matrix
  70186. */
  70187. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70188. /**
  70189. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70190. * @param x defines the x coordinate to transform
  70191. * @param y defines the x coordinate to transform
  70192. * @param result defines the target vector2
  70193. * @returns the current matrix
  70194. */
  70195. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70196. /**
  70197. * Creates an identity matrix
  70198. * @returns a new matrix
  70199. */
  70200. static Identity(): Matrix2D;
  70201. /**
  70202. * Creates a translation matrix and stores it in a target matrix
  70203. * @param x defines the x coordinate of the translation
  70204. * @param y defines the y coordinate of the translation
  70205. * @param result defines the target matrix
  70206. */
  70207. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70208. /**
  70209. * Creates a scaling matrix and stores it in a target matrix
  70210. * @param x defines the x coordinate of the scaling
  70211. * @param y defines the y coordinate of the scaling
  70212. * @param result defines the target matrix
  70213. */
  70214. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70215. /**
  70216. * Creates a rotation matrix and stores it in a target matrix
  70217. * @param angle defines the rotation angle
  70218. * @param result defines the target matrix
  70219. */
  70220. static RotationToRef(angle: number, result: Matrix2D): void;
  70221. private static _TempPreTranslationMatrix;
  70222. private static _TempPostTranslationMatrix;
  70223. private static _TempRotationMatrix;
  70224. private static _TempScalingMatrix;
  70225. private static _TempCompose0;
  70226. private static _TempCompose1;
  70227. private static _TempCompose2;
  70228. /**
  70229. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70230. * @param tx defines the x coordinate of the translation
  70231. * @param ty defines the y coordinate of the translation
  70232. * @param angle defines the rotation angle
  70233. * @param scaleX defines the x coordinate of the scaling
  70234. * @param scaleY defines the y coordinate of the scaling
  70235. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70236. * @param result defines the target matrix
  70237. */
  70238. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70239. }
  70240. }
  70241. declare module BABYLON.GUI {
  70242. /**
  70243. * Class used to store 2D control sizes
  70244. */
  70245. export class Measure {
  70246. /** defines left coordinate */
  70247. left: number;
  70248. /** defines top coordinate */
  70249. top: number;
  70250. /** defines width dimension */
  70251. width: number;
  70252. /** defines height dimension */
  70253. height: number;
  70254. /**
  70255. * Creates a new measure
  70256. * @param left defines left coordinate
  70257. * @param top defines top coordinate
  70258. * @param width defines width dimension
  70259. * @param height defines height dimension
  70260. */
  70261. constructor(
  70262. /** defines left coordinate */
  70263. left: number,
  70264. /** defines top coordinate */
  70265. top: number,
  70266. /** defines width dimension */
  70267. width: number,
  70268. /** defines height dimension */
  70269. height: number);
  70270. /**
  70271. * Copy from another measure
  70272. * @param other defines the other measure to copy from
  70273. */
  70274. copyFrom(other: Measure): void;
  70275. /**
  70276. * Copy from a group of 4 floats
  70277. * @param left defines left coordinate
  70278. * @param top defines top coordinate
  70279. * @param width defines width dimension
  70280. * @param height defines height dimension
  70281. */
  70282. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70283. /**
  70284. * Computes the axis aligned bounding box measure for two given measures
  70285. * @param a Input measure
  70286. * @param b Input measure
  70287. * @param result the resulting bounding measure
  70288. */
  70289. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70290. /**
  70291. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70292. * @param transform the matrix to transform the measure before computing the AABB
  70293. * @param result the resulting AABB
  70294. */
  70295. transformToRef(transform: Matrix2D, result: Measure): void;
  70296. /**
  70297. * Check equality between this measure and another one
  70298. * @param other defines the other measures
  70299. * @returns true if both measures are equals
  70300. */
  70301. isEqualsTo(other: Measure): boolean;
  70302. /**
  70303. * Creates an empty measure
  70304. * @returns a new measure
  70305. */
  70306. static Empty(): Measure;
  70307. }
  70308. }
  70309. declare module BABYLON.GUI {
  70310. /**
  70311. * Interface used to define a control that can receive focus
  70312. */
  70313. export interface IFocusableControl {
  70314. /**
  70315. * Function called when the control receives the focus
  70316. */
  70317. onFocus(): void;
  70318. /**
  70319. * Function called when the control loses the focus
  70320. */
  70321. onBlur(): void;
  70322. /**
  70323. * Function called to let the control handle keyboard events
  70324. * @param evt defines the current keyboard event
  70325. */
  70326. processKeyboard(evt: KeyboardEvent): void;
  70327. /**
  70328. * Function called to get the list of controls that should not steal the focus from this control
  70329. * @returns an array of controls
  70330. */
  70331. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70332. }
  70333. /**
  70334. * Class used to create texture to support 2D GUI elements
  70335. * @see http://doc.babylonjs.com/how_to/gui
  70336. */
  70337. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70338. private _isDirty;
  70339. private _renderObserver;
  70340. private _resizeObserver;
  70341. private _preKeyboardObserver;
  70342. private _pointerMoveObserver;
  70343. private _pointerObserver;
  70344. private _canvasPointerOutObserver;
  70345. private _background;
  70346. /** @hidden */
  70347. _rootContainer: Container;
  70348. /** @hidden */
  70349. _lastPickedControl: Control;
  70350. /** @hidden */
  70351. _lastControlOver: {
  70352. [pointerId: number]: Control;
  70353. };
  70354. /** @hidden */
  70355. _lastControlDown: {
  70356. [pointerId: number]: Control;
  70357. };
  70358. /** @hidden */
  70359. _capturingControl: {
  70360. [pointerId: number]: Control;
  70361. };
  70362. /** @hidden */
  70363. _shouldBlockPointer: boolean;
  70364. /** @hidden */
  70365. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70366. /** @hidden */
  70367. _linkedControls: Control[];
  70368. private _isFullscreen;
  70369. private _fullscreenViewport;
  70370. private _idealWidth;
  70371. private _idealHeight;
  70372. private _useSmallestIdeal;
  70373. private _renderAtIdealSize;
  70374. private _focusedControl;
  70375. private _blockNextFocusCheck;
  70376. private _renderScale;
  70377. private _rootElement;
  70378. private _cursorChanged;
  70379. private _defaultMousePointerId;
  70380. /** @hidden */
  70381. _numLayoutCalls: number;
  70382. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70383. get numLayoutCalls(): number;
  70384. /** @hidden */
  70385. _numRenderCalls: number;
  70386. /** Gets the number of render calls made the last time the ADT has been rendered */
  70387. get numRenderCalls(): number;
  70388. /**
  70389. * Define type to string to ensure compatibility across browsers
  70390. * Safari doesn't support DataTransfer constructor
  70391. */
  70392. private _clipboardData;
  70393. /**
  70394. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70395. */
  70396. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70397. /**
  70398. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70399. */
  70400. onControlPickedObservable: BABYLON.Observable<Control>;
  70401. /**
  70402. * BABYLON.Observable event triggered before layout is evaluated
  70403. */
  70404. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70405. /**
  70406. * BABYLON.Observable event triggered after the layout was evaluated
  70407. */
  70408. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70409. /**
  70410. * BABYLON.Observable event triggered before the texture is rendered
  70411. */
  70412. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70413. /**
  70414. * BABYLON.Observable event triggered after the texture was rendered
  70415. */
  70416. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70417. /**
  70418. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70419. */
  70420. premulAlpha: boolean;
  70421. /**
  70422. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70423. * Useful when you want more antialiasing
  70424. */
  70425. get renderScale(): number;
  70426. set renderScale(value: number);
  70427. /** Gets or sets the background color */
  70428. get background(): string;
  70429. set background(value: string);
  70430. /**
  70431. * Gets or sets the ideal width used to design controls.
  70432. * The GUI will then rescale everything accordingly
  70433. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70434. */
  70435. get idealWidth(): number;
  70436. set idealWidth(value: number);
  70437. /**
  70438. * Gets or sets the ideal height used to design controls.
  70439. * The GUI will then rescale everything accordingly
  70440. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70441. */
  70442. get idealHeight(): number;
  70443. set idealHeight(value: number);
  70444. /**
  70445. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70446. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70447. */
  70448. get useSmallestIdeal(): boolean;
  70449. set useSmallestIdeal(value: boolean);
  70450. /**
  70451. * Gets or sets a boolean indicating if adaptive scaling must be used
  70452. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70453. */
  70454. get renderAtIdealSize(): boolean;
  70455. set renderAtIdealSize(value: boolean);
  70456. /**
  70457. * Gets the ratio used when in "ideal mode"
  70458. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70459. * */
  70460. get idealRatio(): number;
  70461. /**
  70462. * Gets the underlying layer used to render the texture when in fullscreen mode
  70463. */
  70464. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70465. /**
  70466. * Gets the root container control
  70467. */
  70468. get rootContainer(): Container;
  70469. /**
  70470. * Returns an array containing the root container.
  70471. * This is mostly used to let the Inspector introspects the ADT
  70472. * @returns an array containing the rootContainer
  70473. */
  70474. getChildren(): Array<Container>;
  70475. /**
  70476. * Will return all controls that are inside this texture
  70477. * @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
  70478. * @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
  70479. * @return all child controls
  70480. */
  70481. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70482. /**
  70483. * Gets or sets the current focused control
  70484. */
  70485. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70486. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70487. /**
  70488. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70489. */
  70490. get isForeground(): boolean;
  70491. set isForeground(value: boolean);
  70492. /**
  70493. * Gets or set information about clipboardData
  70494. */
  70495. get clipboardData(): string;
  70496. set clipboardData(value: string);
  70497. /**
  70498. * Creates a new AdvancedDynamicTexture
  70499. * @param name defines the name of the texture
  70500. * @param width defines the width of the texture
  70501. * @param height defines the height of the texture
  70502. * @param scene defines the hosting scene
  70503. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70504. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70505. */
  70506. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70507. /**
  70508. * Get the current class name of the texture useful for serialization or dynamic coding.
  70509. * @returns "AdvancedDynamicTexture"
  70510. */
  70511. getClassName(): string;
  70512. /**
  70513. * Function used to execute a function on all controls
  70514. * @param func defines the function to execute
  70515. * @param container defines the container where controls belong. If null the root container will be used
  70516. */
  70517. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70518. private _useInvalidateRectOptimization;
  70519. /**
  70520. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70521. */
  70522. get useInvalidateRectOptimization(): boolean;
  70523. set useInvalidateRectOptimization(value: boolean);
  70524. private _invalidatedRectangle;
  70525. /**
  70526. * Invalidates a rectangle area on the gui texture
  70527. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70528. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70529. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70530. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70531. */
  70532. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70533. /**
  70534. * Marks the texture as dirty forcing a complete update
  70535. */
  70536. markAsDirty(): void;
  70537. /**
  70538. * Helper function used to create a new style
  70539. * @returns a new style
  70540. * @see http://doc.babylonjs.com/how_to/gui#styles
  70541. */
  70542. createStyle(): Style;
  70543. /**
  70544. * Adds a new control to the root container
  70545. * @param control defines the control to add
  70546. * @returns the current texture
  70547. */
  70548. addControl(control: Control): AdvancedDynamicTexture;
  70549. /**
  70550. * Removes a control from the root container
  70551. * @param control defines the control to remove
  70552. * @returns the current texture
  70553. */
  70554. removeControl(control: Control): AdvancedDynamicTexture;
  70555. /**
  70556. * Release all resources
  70557. */
  70558. dispose(): void;
  70559. private _onResize;
  70560. /** @hidden */
  70561. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70562. /**
  70563. * Get screen coordinates for a vector3
  70564. * @param position defines the position to project
  70565. * @param worldMatrix defines the world matrix to use
  70566. * @returns the projected position
  70567. */
  70568. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70569. private _checkUpdate;
  70570. private _clearMeasure;
  70571. private _render;
  70572. /** @hidden */
  70573. _changeCursor(cursor: string): void;
  70574. /** @hidden */
  70575. _registerLastControlDown(control: Control, pointerId: number): void;
  70576. private _doPicking;
  70577. /** @hidden */
  70578. _cleanControlAfterRemovalFromList(list: {
  70579. [pointerId: number]: Control;
  70580. }, control: Control): void;
  70581. /** @hidden */
  70582. _cleanControlAfterRemoval(control: Control): void;
  70583. /** Attach to all scene events required to support pointer events */
  70584. attach(): void;
  70585. /** @hidden */
  70586. private onClipboardCopy;
  70587. /** @hidden */
  70588. private onClipboardCut;
  70589. /** @hidden */
  70590. private onClipboardPaste;
  70591. /**
  70592. * Register the clipboard Events onto the canvas
  70593. */
  70594. registerClipboardEvents(): void;
  70595. /**
  70596. * Unregister the clipboard Events from the canvas
  70597. */
  70598. unRegisterClipboardEvents(): void;
  70599. /**
  70600. * Connect the texture to a hosting mesh to enable interactions
  70601. * @param mesh defines the mesh to attach to
  70602. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70603. */
  70604. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70605. /**
  70606. * Move the focus to a specific control
  70607. * @param control defines the control which will receive the focus
  70608. */
  70609. moveFocusToControl(control: IFocusableControl): void;
  70610. private _manageFocus;
  70611. private _attachToOnPointerOut;
  70612. /**
  70613. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70614. * @param mesh defines the mesh which will receive the texture
  70615. * @param width defines the texture width (1024 by default)
  70616. * @param height defines the texture height (1024 by default)
  70617. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70618. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70619. * @returns a new AdvancedDynamicTexture
  70620. */
  70621. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70622. /**
  70623. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70624. * In this mode the texture will rely on a layer for its rendering.
  70625. * This allows it to be treated like any other layer.
  70626. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70627. * LayerMask is set through advancedTexture.layer.layerMask
  70628. * @param name defines name for the texture
  70629. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70630. * @param scene defines the hsoting scene
  70631. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70632. * @returns a new AdvancedDynamicTexture
  70633. */
  70634. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70635. }
  70636. }
  70637. declare module BABYLON.GUI {
  70638. /**
  70639. * Root class used for all 2D controls
  70640. * @see http://doc.babylonjs.com/how_to/gui#controls
  70641. */
  70642. export class Control {
  70643. /** defines the name of the control */
  70644. name?: string | undefined;
  70645. /**
  70646. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70647. */
  70648. static AllowAlphaInheritance: boolean;
  70649. private _alpha;
  70650. private _alphaSet;
  70651. private _zIndex;
  70652. /** @hidden */
  70653. _host: AdvancedDynamicTexture;
  70654. /** Gets or sets the control parent */
  70655. parent: BABYLON.Nullable<Container>;
  70656. /** @hidden */
  70657. _currentMeasure: Measure;
  70658. private _fontFamily;
  70659. private _fontStyle;
  70660. private _fontWeight;
  70661. private _fontSize;
  70662. private _font;
  70663. /** @hidden */
  70664. _width: ValueAndUnit;
  70665. /** @hidden */
  70666. _height: ValueAndUnit;
  70667. /** @hidden */
  70668. protected _fontOffset: {
  70669. ascent: number;
  70670. height: number;
  70671. descent: number;
  70672. };
  70673. private _color;
  70674. private _style;
  70675. private _styleObserver;
  70676. /** @hidden */
  70677. protected _horizontalAlignment: number;
  70678. /** @hidden */
  70679. protected _verticalAlignment: number;
  70680. /** @hidden */
  70681. protected _isDirty: boolean;
  70682. /** @hidden */
  70683. protected _wasDirty: boolean;
  70684. /** @hidden */
  70685. _tempParentMeasure: Measure;
  70686. /** @hidden */
  70687. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70688. /** @hidden */
  70689. protected _cachedParentMeasure: Measure;
  70690. private _paddingLeft;
  70691. private _paddingRight;
  70692. private _paddingTop;
  70693. private _paddingBottom;
  70694. /** @hidden */
  70695. _left: ValueAndUnit;
  70696. /** @hidden */
  70697. _top: ValueAndUnit;
  70698. private _scaleX;
  70699. private _scaleY;
  70700. private _rotation;
  70701. private _transformCenterX;
  70702. private _transformCenterY;
  70703. /** @hidden */
  70704. _transformMatrix: Matrix2D;
  70705. /** @hidden */
  70706. protected _invertTransformMatrix: Matrix2D;
  70707. /** @hidden */
  70708. protected _transformedPosition: BABYLON.Vector2;
  70709. private _isMatrixDirty;
  70710. private _cachedOffsetX;
  70711. private _cachedOffsetY;
  70712. private _isVisible;
  70713. private _isHighlighted;
  70714. /** @hidden */
  70715. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70716. private _fontSet;
  70717. private _dummyVector2;
  70718. private _downCount;
  70719. private _enterCount;
  70720. private _doNotRender;
  70721. private _downPointerIds;
  70722. protected _isEnabled: boolean;
  70723. protected _disabledColor: string;
  70724. protected _disabledColorItem: string;
  70725. /** @hidden */
  70726. protected _rebuildLayout: boolean;
  70727. /** @hidden */
  70728. _customData: any;
  70729. /** @hidden */
  70730. _isClipped: boolean;
  70731. /** @hidden */
  70732. _automaticSize: boolean;
  70733. /** @hidden */
  70734. _tag: any;
  70735. /**
  70736. * 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
  70737. */
  70738. uniqueId: number;
  70739. /**
  70740. * Gets or sets an object used to store user defined information for the node
  70741. */
  70742. metadata: any;
  70743. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70744. isHitTestVisible: boolean;
  70745. /** Gets or sets a boolean indicating if the control can block pointer events */
  70746. isPointerBlocker: boolean;
  70747. /** Gets or sets a boolean indicating if the control can be focusable */
  70748. isFocusInvisible: boolean;
  70749. /**
  70750. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70751. * 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
  70752. */
  70753. clipChildren: boolean;
  70754. /**
  70755. * Gets or sets a boolean indicating that control content must be clipped
  70756. * 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
  70757. */
  70758. clipContent: boolean;
  70759. /**
  70760. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70761. */
  70762. useBitmapCache: boolean;
  70763. private _cacheData;
  70764. private _shadowOffsetX;
  70765. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70766. get shadowOffsetX(): number;
  70767. set shadowOffsetX(value: number);
  70768. private _shadowOffsetY;
  70769. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70770. get shadowOffsetY(): number;
  70771. set shadowOffsetY(value: number);
  70772. private _shadowBlur;
  70773. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70774. get shadowBlur(): number;
  70775. set shadowBlur(value: number);
  70776. private _shadowColor;
  70777. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70778. get shadowColor(): string;
  70779. set shadowColor(value: string);
  70780. /** Gets or sets the cursor to use when the control is hovered */
  70781. hoverCursor: string;
  70782. /** @hidden */
  70783. protected _linkOffsetX: ValueAndUnit;
  70784. /** @hidden */
  70785. protected _linkOffsetY: ValueAndUnit;
  70786. /** Gets the control type name */
  70787. get typeName(): string;
  70788. /**
  70789. * Get the current class name of the control.
  70790. * @returns current class name
  70791. */
  70792. getClassName(): string;
  70793. /**
  70794. * An event triggered when pointer wheel is scrolled
  70795. */
  70796. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  70797. /**
  70798. * An event triggered when the pointer move over the control.
  70799. */
  70800. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70801. /**
  70802. * An event triggered when the pointer move out of the control.
  70803. */
  70804. onPointerOutObservable: BABYLON.Observable<Control>;
  70805. /**
  70806. * An event triggered when the pointer taps the control
  70807. */
  70808. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70809. /**
  70810. * An event triggered when pointer up
  70811. */
  70812. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70813. /**
  70814. * An event triggered when a control is clicked on
  70815. */
  70816. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70817. /**
  70818. * An event triggered when pointer enters the control
  70819. */
  70820. onPointerEnterObservable: BABYLON.Observable<Control>;
  70821. /**
  70822. * An event triggered when the control is marked as dirty
  70823. */
  70824. onDirtyObservable: BABYLON.Observable<Control>;
  70825. /**
  70826. * An event triggered before drawing the control
  70827. */
  70828. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70829. /**
  70830. * An event triggered after the control was drawn
  70831. */
  70832. onAfterDrawObservable: BABYLON.Observable<Control>;
  70833. /**
  70834. * Get the hosting AdvancedDynamicTexture
  70835. */
  70836. get host(): AdvancedDynamicTexture;
  70837. /** Gets or set information about font offsets (used to render and align text) */
  70838. get fontOffset(): {
  70839. ascent: number;
  70840. height: number;
  70841. descent: number;
  70842. };
  70843. set fontOffset(offset: {
  70844. ascent: number;
  70845. height: number;
  70846. descent: number;
  70847. });
  70848. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70849. get alpha(): number;
  70850. set alpha(value: number);
  70851. /**
  70852. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70853. */
  70854. get isHighlighted(): boolean;
  70855. set isHighlighted(value: boolean);
  70856. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70857. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70858. */
  70859. get scaleX(): number;
  70860. set scaleX(value: number);
  70861. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70862. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70863. */
  70864. get scaleY(): number;
  70865. set scaleY(value: number);
  70866. /** Gets or sets the rotation angle (0 by default)
  70867. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70868. */
  70869. get rotation(): number;
  70870. set rotation(value: number);
  70871. /** Gets or sets the transformation center on Y axis (0 by default)
  70872. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70873. */
  70874. get transformCenterY(): number;
  70875. set transformCenterY(value: number);
  70876. /** Gets or sets the transformation center on X axis (0 by default)
  70877. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70878. */
  70879. get transformCenterX(): number;
  70880. set transformCenterX(value: number);
  70881. /**
  70882. * Gets or sets the horizontal alignment
  70883. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70884. */
  70885. get horizontalAlignment(): number;
  70886. set horizontalAlignment(value: number);
  70887. /**
  70888. * Gets or sets the vertical alignment
  70889. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70890. */
  70891. get verticalAlignment(): number;
  70892. set verticalAlignment(value: number);
  70893. /**
  70894. * Gets or sets control width
  70895. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70896. */
  70897. get width(): string | number;
  70898. set width(value: string | number);
  70899. /**
  70900. * Gets or sets the control width in pixel
  70901. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70902. */
  70903. get widthInPixels(): number;
  70904. set widthInPixels(value: number);
  70905. /**
  70906. * Gets or sets control height
  70907. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70908. */
  70909. get height(): string | number;
  70910. set height(value: string | number);
  70911. /**
  70912. * Gets or sets control height in pixel
  70913. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70914. */
  70915. get heightInPixels(): number;
  70916. set heightInPixels(value: number);
  70917. /** Gets or set font family */
  70918. get fontFamily(): string;
  70919. set fontFamily(value: string);
  70920. /** Gets or sets font style */
  70921. get fontStyle(): string;
  70922. set fontStyle(value: string);
  70923. /** Gets or sets font weight */
  70924. get fontWeight(): string;
  70925. set fontWeight(value: string);
  70926. /**
  70927. * Gets or sets style
  70928. * @see http://doc.babylonjs.com/how_to/gui#styles
  70929. */
  70930. get style(): BABYLON.Nullable<Style>;
  70931. set style(value: BABYLON.Nullable<Style>);
  70932. /** @hidden */
  70933. get _isFontSizeInPercentage(): boolean;
  70934. /** Gets or sets font size in pixels */
  70935. get fontSizeInPixels(): number;
  70936. set fontSizeInPixels(value: number);
  70937. /** Gets or sets font size */
  70938. get fontSize(): string | number;
  70939. set fontSize(value: string | number);
  70940. /** Gets or sets foreground color */
  70941. get color(): string;
  70942. set color(value: string);
  70943. /** Gets or sets z index which is used to reorder controls on the z axis */
  70944. get zIndex(): number;
  70945. set zIndex(value: number);
  70946. /** Gets or sets a boolean indicating if the control can be rendered */
  70947. get notRenderable(): boolean;
  70948. set notRenderable(value: boolean);
  70949. /** Gets or sets a boolean indicating if the control is visible */
  70950. get isVisible(): boolean;
  70951. set isVisible(value: boolean);
  70952. /** Gets a boolean indicating that the control needs to update its rendering */
  70953. get isDirty(): boolean;
  70954. /**
  70955. * Gets the current linked mesh (or null if none)
  70956. */
  70957. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70958. /**
  70959. * Gets or sets a value indicating the padding to use on the left of the control
  70960. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70961. */
  70962. get paddingLeft(): string | number;
  70963. set paddingLeft(value: string | number);
  70964. /**
  70965. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70966. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70967. */
  70968. get paddingLeftInPixels(): number;
  70969. set paddingLeftInPixels(value: number);
  70970. /**
  70971. * Gets or sets a value indicating the padding to use on the right of the control
  70972. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70973. */
  70974. get paddingRight(): string | number;
  70975. set paddingRight(value: string | number);
  70976. /**
  70977. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70978. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70979. */
  70980. get paddingRightInPixels(): number;
  70981. set paddingRightInPixels(value: number);
  70982. /**
  70983. * Gets or sets a value indicating the padding to use on the top of the control
  70984. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70985. */
  70986. get paddingTop(): string | number;
  70987. set paddingTop(value: string | number);
  70988. /**
  70989. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70990. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70991. */
  70992. get paddingTopInPixels(): number;
  70993. set paddingTopInPixels(value: number);
  70994. /**
  70995. * Gets or sets a value indicating the padding to use on the bottom of the control
  70996. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70997. */
  70998. get paddingBottom(): string | number;
  70999. set paddingBottom(value: string | number);
  71000. /**
  71001. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71002. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71003. */
  71004. get paddingBottomInPixels(): number;
  71005. set paddingBottomInPixels(value: number);
  71006. /**
  71007. * Gets or sets a value indicating the left coordinate of the control
  71008. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71009. */
  71010. get left(): string | number;
  71011. set left(value: string | number);
  71012. /**
  71013. * Gets or sets a value indicating the left coordinate in pixels of the control
  71014. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71015. */
  71016. get leftInPixels(): number;
  71017. set leftInPixels(value: number);
  71018. /**
  71019. * Gets or sets a value indicating the top coordinate of the control
  71020. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71021. */
  71022. get top(): string | number;
  71023. set top(value: string | number);
  71024. /**
  71025. * Gets or sets a value indicating the top coordinate in pixels of the control
  71026. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71027. */
  71028. get topInPixels(): number;
  71029. set topInPixels(value: number);
  71030. /**
  71031. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71032. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71033. */
  71034. get linkOffsetX(): string | number;
  71035. set linkOffsetX(value: string | number);
  71036. /**
  71037. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71038. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71039. */
  71040. get linkOffsetXInPixels(): number;
  71041. set linkOffsetXInPixels(value: number);
  71042. /**
  71043. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71044. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71045. */
  71046. get linkOffsetY(): string | number;
  71047. set linkOffsetY(value: string | number);
  71048. /**
  71049. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71050. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71051. */
  71052. get linkOffsetYInPixels(): number;
  71053. set linkOffsetYInPixels(value: number);
  71054. /** Gets the center coordinate on X axis */
  71055. get centerX(): number;
  71056. /** Gets the center coordinate on Y axis */
  71057. get centerY(): number;
  71058. /** Gets or sets if control is Enabled*/
  71059. get isEnabled(): boolean;
  71060. set isEnabled(value: boolean);
  71061. /** Gets or sets background color of control if it's disabled*/
  71062. get disabledColor(): string;
  71063. set disabledColor(value: string);
  71064. /** Gets or sets front color of control if it's disabled*/
  71065. get disabledColorItem(): string;
  71066. set disabledColorItem(value: string);
  71067. /**
  71068. * Creates a new control
  71069. * @param name defines the name of the control
  71070. */
  71071. constructor(
  71072. /** defines the name of the control */
  71073. name?: string | undefined);
  71074. /** @hidden */
  71075. protected _getTypeName(): string;
  71076. /**
  71077. * Gets the first ascendant in the hierarchy of the given type
  71078. * @param className defines the required type
  71079. * @returns the ascendant or null if not found
  71080. */
  71081. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71082. /** @hidden */
  71083. _resetFontCache(): void;
  71084. /**
  71085. * Determines if a container is an ascendant of the current control
  71086. * @param container defines the container to look for
  71087. * @returns true if the container is one of the ascendant of the control
  71088. */
  71089. isAscendant(container: Control): boolean;
  71090. /**
  71091. * Gets coordinates in local control space
  71092. * @param globalCoordinates defines the coordinates to transform
  71093. * @returns the new coordinates in local space
  71094. */
  71095. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71096. /**
  71097. * Gets coordinates in local control space
  71098. * @param globalCoordinates defines the coordinates to transform
  71099. * @param result defines the target vector2 where to store the result
  71100. * @returns the current control
  71101. */
  71102. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71103. /**
  71104. * Gets coordinates in parent local control space
  71105. * @param globalCoordinates defines the coordinates to transform
  71106. * @returns the new coordinates in parent local space
  71107. */
  71108. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71109. /**
  71110. * Move the current control to a vector3 position projected onto the screen.
  71111. * @param position defines the target position
  71112. * @param scene defines the hosting scene
  71113. */
  71114. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71115. /**
  71116. * Will store all controls that have this control as ascendant in a given array
  71117. * @param results defines the array where to store the descendants
  71118. * @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
  71119. * @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
  71120. */
  71121. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71122. /**
  71123. * Will return all controls that have this control as ascendant
  71124. * @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
  71125. * @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
  71126. * @return all child controls
  71127. */
  71128. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71129. /**
  71130. * Link current control with a target mesh
  71131. * @param mesh defines the mesh to link with
  71132. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71133. */
  71134. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71135. /** @hidden */
  71136. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71137. /** @hidden */
  71138. _offsetLeft(offset: number): void;
  71139. /** @hidden */
  71140. _offsetTop(offset: number): void;
  71141. /** @hidden */
  71142. _markMatrixAsDirty(): void;
  71143. /** @hidden */
  71144. _flagDescendantsAsMatrixDirty(): void;
  71145. /** @hidden */
  71146. _intersectsRect(rect: Measure): boolean;
  71147. /** @hidden */
  71148. protected invalidateRect(): void;
  71149. /** @hidden */
  71150. _markAsDirty(force?: boolean): void;
  71151. /** @hidden */
  71152. _markAllAsDirty(): void;
  71153. /** @hidden */
  71154. _link(host: AdvancedDynamicTexture): void;
  71155. /** @hidden */
  71156. protected _transform(context?: CanvasRenderingContext2D): void;
  71157. /** @hidden */
  71158. _renderHighlight(context: CanvasRenderingContext2D): void;
  71159. /** @hidden */
  71160. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71161. /** @hidden */
  71162. protected _applyStates(context: CanvasRenderingContext2D): void;
  71163. /** @hidden */
  71164. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71165. /** @hidden */
  71166. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71167. protected _evaluateClippingState(parentMeasure: Measure): void;
  71168. /** @hidden */
  71169. _measure(): void;
  71170. /** @hidden */
  71171. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71172. /** @hidden */
  71173. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71174. /** @hidden */
  71175. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71176. /** @hidden */
  71177. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71178. private static _ClipMeasure;
  71179. private _tmpMeasureA;
  71180. private _clip;
  71181. /** @hidden */
  71182. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71183. /** @hidden */
  71184. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71185. /**
  71186. * Tests if a given coordinates belong to the current control
  71187. * @param x defines x coordinate to test
  71188. * @param y defines y coordinate to test
  71189. * @returns true if the coordinates are inside the control
  71190. */
  71191. contains(x: number, y: number): boolean;
  71192. /** @hidden */
  71193. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71194. /** @hidden */
  71195. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71196. /** @hidden */
  71197. _onPointerEnter(target: Control): boolean;
  71198. /** @hidden */
  71199. _onPointerOut(target: Control, force?: boolean): void;
  71200. /** @hidden */
  71201. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71202. /** @hidden */
  71203. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71204. /** @hidden */
  71205. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71206. /** @hidden */
  71207. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  71208. /** @hidden */
  71209. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71210. private _prepareFont;
  71211. /** Releases associated resources */
  71212. dispose(): void;
  71213. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71214. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71215. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71216. private static _VERTICAL_ALIGNMENT_TOP;
  71217. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71218. private static _VERTICAL_ALIGNMENT_CENTER;
  71219. /** HORIZONTAL_ALIGNMENT_LEFT */
  71220. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71221. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71222. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71223. /** HORIZONTAL_ALIGNMENT_CENTER */
  71224. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71225. /** VERTICAL_ALIGNMENT_TOP */
  71226. static get VERTICAL_ALIGNMENT_TOP(): number;
  71227. /** VERTICAL_ALIGNMENT_BOTTOM */
  71228. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71229. /** VERTICAL_ALIGNMENT_CENTER */
  71230. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71231. private static _FontHeightSizes;
  71232. /** @hidden */
  71233. static _GetFontOffset(font: string): {
  71234. ascent: number;
  71235. height: number;
  71236. descent: number;
  71237. };
  71238. /**
  71239. * Creates a stack panel that can be used to render headers
  71240. * @param control defines the control to associate with the header
  71241. * @param text defines the text of the header
  71242. * @param size defines the size of the header
  71243. * @param options defines options used to configure the header
  71244. * @returns a new StackPanel
  71245. * @ignore
  71246. * @hidden
  71247. */
  71248. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71249. isHorizontal: boolean;
  71250. controlFirst: boolean;
  71251. }) => any;
  71252. /** @hidden */
  71253. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71254. }
  71255. }
  71256. declare module BABYLON.GUI {
  71257. /**
  71258. * Root class for 2D containers
  71259. * @see http://doc.babylonjs.com/how_to/gui#containers
  71260. */
  71261. export class Container extends Control {
  71262. name?: string | undefined;
  71263. /** @hidden */
  71264. _children: Control[];
  71265. /** @hidden */
  71266. protected _measureForChildren: Measure;
  71267. /** @hidden */
  71268. protected _background: string;
  71269. /** @hidden */
  71270. protected _adaptWidthToChildren: boolean;
  71271. /** @hidden */
  71272. protected _adaptHeightToChildren: boolean;
  71273. /**
  71274. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71275. */
  71276. logLayoutCycleErrors: boolean;
  71277. /**
  71278. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71279. */
  71280. maxLayoutCycle: number;
  71281. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71282. get adaptHeightToChildren(): boolean;
  71283. set adaptHeightToChildren(value: boolean);
  71284. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71285. get adaptWidthToChildren(): boolean;
  71286. set adaptWidthToChildren(value: boolean);
  71287. /** Gets or sets background color */
  71288. get background(): string;
  71289. set background(value: string);
  71290. /** Gets the list of children */
  71291. get children(): Control[];
  71292. /**
  71293. * Creates a new Container
  71294. * @param name defines the name of the container
  71295. */
  71296. constructor(name?: string | undefined);
  71297. protected _getTypeName(): string;
  71298. _flagDescendantsAsMatrixDirty(): void;
  71299. /**
  71300. * Gets a child using its name
  71301. * @param name defines the child name to look for
  71302. * @returns the child control if found
  71303. */
  71304. getChildByName(name: string): BABYLON.Nullable<Control>;
  71305. /**
  71306. * Gets a child using its type and its name
  71307. * @param name defines the child name to look for
  71308. * @param type defines the child type to look for
  71309. * @returns the child control if found
  71310. */
  71311. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71312. /**
  71313. * Search for a specific control in children
  71314. * @param control defines the control to look for
  71315. * @returns true if the control is in child list
  71316. */
  71317. containsControl(control: Control): boolean;
  71318. /**
  71319. * Adds a new control to the current container
  71320. * @param control defines the control to add
  71321. * @returns the current container
  71322. */
  71323. addControl(control: BABYLON.Nullable<Control>): Container;
  71324. /**
  71325. * Removes all controls from the current container
  71326. * @returns the current container
  71327. */
  71328. clearControls(): Container;
  71329. /**
  71330. * Removes a control from the current container
  71331. * @param control defines the control to remove
  71332. * @returns the current container
  71333. */
  71334. removeControl(control: Control): Container;
  71335. /** @hidden */
  71336. _reOrderControl(control: Control): void;
  71337. /** @hidden */
  71338. _offsetLeft(offset: number): void;
  71339. /** @hidden */
  71340. _offsetTop(offset: number): void;
  71341. /** @hidden */
  71342. _markAllAsDirty(): void;
  71343. /** @hidden */
  71344. protected _localDraw(context: CanvasRenderingContext2D): void;
  71345. /** @hidden */
  71346. _link(host: AdvancedDynamicTexture): void;
  71347. /** @hidden */
  71348. protected _beforeLayout(): void;
  71349. /** @hidden */
  71350. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71351. /** @hidden */
  71352. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71353. protected _postMeasure(): void;
  71354. /** @hidden */
  71355. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71356. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71357. /** @hidden */
  71358. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71359. /** @hidden */
  71360. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71361. /** Releases associated resources */
  71362. dispose(): void;
  71363. }
  71364. }
  71365. declare module BABYLON.GUI {
  71366. /** Class used to create rectangle container */
  71367. export class Rectangle extends Container {
  71368. name?: string | undefined;
  71369. private _thickness;
  71370. private _cornerRadius;
  71371. /** Gets or sets border thickness */
  71372. get thickness(): number;
  71373. set thickness(value: number);
  71374. /** Gets or sets the corner radius angle */
  71375. get cornerRadius(): number;
  71376. set cornerRadius(value: number);
  71377. /**
  71378. * Creates a new Rectangle
  71379. * @param name defines the control name
  71380. */
  71381. constructor(name?: string | undefined);
  71382. protected _getTypeName(): string;
  71383. protected _localDraw(context: CanvasRenderingContext2D): void;
  71384. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71385. private _drawRoundedRect;
  71386. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71387. }
  71388. }
  71389. declare module BABYLON.GUI {
  71390. /**
  71391. * Enum that determines the text-wrapping mode to use.
  71392. */
  71393. export enum TextWrapping {
  71394. /**
  71395. * Clip the text when it's larger than Control.width; this is the default mode.
  71396. */
  71397. Clip = 0,
  71398. /**
  71399. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71400. */
  71401. WordWrap = 1,
  71402. /**
  71403. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71404. */
  71405. Ellipsis = 2
  71406. }
  71407. /**
  71408. * Class used to create text block control
  71409. */
  71410. export class TextBlock extends Control {
  71411. /**
  71412. * Defines the name of the control
  71413. */
  71414. name?: string | undefined;
  71415. private _text;
  71416. private _textWrapping;
  71417. private _textHorizontalAlignment;
  71418. private _textVerticalAlignment;
  71419. private _lines;
  71420. private _resizeToFit;
  71421. private _lineSpacing;
  71422. private _outlineWidth;
  71423. private _outlineColor;
  71424. /**
  71425. * An event triggered after the text is changed
  71426. */
  71427. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71428. /**
  71429. * An event triggered after the text was broken up into lines
  71430. */
  71431. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71432. /**
  71433. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71434. */
  71435. get lines(): any[];
  71436. /**
  71437. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71438. */
  71439. get resizeToFit(): boolean;
  71440. /**
  71441. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71442. */
  71443. set resizeToFit(value: boolean);
  71444. /**
  71445. * Gets or sets a boolean indicating if text must be wrapped
  71446. */
  71447. get textWrapping(): TextWrapping | boolean;
  71448. /**
  71449. * Gets or sets a boolean indicating if text must be wrapped
  71450. */
  71451. set textWrapping(value: TextWrapping | boolean);
  71452. /**
  71453. * Gets or sets text to display
  71454. */
  71455. get text(): string;
  71456. /**
  71457. * Gets or sets text to display
  71458. */
  71459. set text(value: string);
  71460. /**
  71461. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71462. */
  71463. get textHorizontalAlignment(): number;
  71464. /**
  71465. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71466. */
  71467. set textHorizontalAlignment(value: number);
  71468. /**
  71469. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71470. */
  71471. get textVerticalAlignment(): number;
  71472. /**
  71473. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71474. */
  71475. set textVerticalAlignment(value: number);
  71476. /**
  71477. * Gets or sets line spacing value
  71478. */
  71479. set lineSpacing(value: string | number);
  71480. /**
  71481. * Gets or sets line spacing value
  71482. */
  71483. get lineSpacing(): string | number;
  71484. /**
  71485. * Gets or sets outlineWidth of the text to display
  71486. */
  71487. get outlineWidth(): number;
  71488. /**
  71489. * Gets or sets outlineWidth of the text to display
  71490. */
  71491. set outlineWidth(value: number);
  71492. /**
  71493. * Gets or sets outlineColor of the text to display
  71494. */
  71495. get outlineColor(): string;
  71496. /**
  71497. * Gets or sets outlineColor of the text to display
  71498. */
  71499. set outlineColor(value: string);
  71500. /**
  71501. * Creates a new TextBlock object
  71502. * @param name defines the name of the control
  71503. * @param text defines the text to display (emptry string by default)
  71504. */
  71505. constructor(
  71506. /**
  71507. * Defines the name of the control
  71508. */
  71509. name?: string | undefined, text?: string);
  71510. protected _getTypeName(): string;
  71511. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71512. private _drawText;
  71513. /** @hidden */
  71514. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71515. protected _applyStates(context: CanvasRenderingContext2D): void;
  71516. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71517. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71518. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71519. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71520. protected _renderLines(context: CanvasRenderingContext2D): void;
  71521. /**
  71522. * Given a width constraint applied on the text block, find the expected height
  71523. * @returns expected height
  71524. */
  71525. computeExpectedHeight(): number;
  71526. dispose(): void;
  71527. }
  71528. }
  71529. declare module BABYLON.GUI {
  71530. /**
  71531. * Class used to create 2D images
  71532. */
  71533. export class Image extends Control {
  71534. name?: string | undefined;
  71535. private _workingCanvas;
  71536. private _domImage;
  71537. private _imageWidth;
  71538. private _imageHeight;
  71539. private _loaded;
  71540. private _stretch;
  71541. private _source;
  71542. private _autoScale;
  71543. private _sourceLeft;
  71544. private _sourceTop;
  71545. private _sourceWidth;
  71546. private _sourceHeight;
  71547. private _svgAttributesComputationCompleted;
  71548. private _isSVG;
  71549. private _cellWidth;
  71550. private _cellHeight;
  71551. private _cellId;
  71552. private _populateNinePatchSlicesFromImage;
  71553. private _sliceLeft;
  71554. private _sliceRight;
  71555. private _sliceTop;
  71556. private _sliceBottom;
  71557. private _detectPointerOnOpaqueOnly;
  71558. /**
  71559. * BABYLON.Observable notified when the content is loaded
  71560. */
  71561. onImageLoadedObservable: BABYLON.Observable<Image>;
  71562. /**
  71563. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71564. */
  71565. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71566. /**
  71567. * Gets a boolean indicating that the content is loaded
  71568. */
  71569. get isLoaded(): boolean;
  71570. /**
  71571. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71572. */
  71573. get populateNinePatchSlicesFromImage(): boolean;
  71574. set populateNinePatchSlicesFromImage(value: boolean);
  71575. /**
  71576. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71577. * Beware using this as this will comsume more memory as the image has to be stored twice
  71578. */
  71579. get detectPointerOnOpaqueOnly(): boolean;
  71580. set detectPointerOnOpaqueOnly(value: boolean);
  71581. /**
  71582. * Gets or sets the left value for slicing (9-patch)
  71583. */
  71584. get sliceLeft(): number;
  71585. set sliceLeft(value: number);
  71586. /**
  71587. * Gets or sets the right value for slicing (9-patch)
  71588. */
  71589. get sliceRight(): number;
  71590. set sliceRight(value: number);
  71591. /**
  71592. * Gets or sets the top value for slicing (9-patch)
  71593. */
  71594. get sliceTop(): number;
  71595. set sliceTop(value: number);
  71596. /**
  71597. * Gets or sets the bottom value for slicing (9-patch)
  71598. */
  71599. get sliceBottom(): number;
  71600. set sliceBottom(value: number);
  71601. /**
  71602. * Gets or sets the left coordinate in the source image
  71603. */
  71604. get sourceLeft(): number;
  71605. set sourceLeft(value: number);
  71606. /**
  71607. * Gets or sets the top coordinate in the source image
  71608. */
  71609. get sourceTop(): number;
  71610. set sourceTop(value: number);
  71611. /**
  71612. * Gets or sets the width to capture in the source image
  71613. */
  71614. get sourceWidth(): number;
  71615. set sourceWidth(value: number);
  71616. /**
  71617. * Gets or sets the height to capture in the source image
  71618. */
  71619. get sourceHeight(): number;
  71620. set sourceHeight(value: number);
  71621. /** Indicates if the format of the image is SVG */
  71622. get isSVG(): boolean;
  71623. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71624. get svgAttributesComputationCompleted(): boolean;
  71625. /**
  71626. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71627. * @see http://doc.babylonjs.com/how_to/gui#image
  71628. */
  71629. get autoScale(): boolean;
  71630. set autoScale(value: boolean);
  71631. /** Gets or sets the streching mode used by the image */
  71632. get stretch(): number;
  71633. set stretch(value: number);
  71634. /** @hidden */
  71635. _rotate90(n: number, preserveProperties?: boolean): Image;
  71636. private _handleRotationForSVGImage;
  71637. private _rotate90SourceProperties;
  71638. /**
  71639. * Gets or sets the internal DOM image used to render the control
  71640. */
  71641. set domImage(value: HTMLImageElement);
  71642. get domImage(): HTMLImageElement;
  71643. private _onImageLoaded;
  71644. private _extractNinePatchSliceDataFromImage;
  71645. /**
  71646. * Gets or sets image source url
  71647. */
  71648. set source(value: BABYLON.Nullable<string>);
  71649. /**
  71650. * Checks for svg document with icon id present
  71651. */
  71652. private _svgCheck;
  71653. /**
  71654. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71655. * given external svg file and icon id
  71656. */
  71657. private _getSVGAttribs;
  71658. /**
  71659. * Gets or sets the cell width to use when animation sheet is enabled
  71660. * @see http://doc.babylonjs.com/how_to/gui#image
  71661. */
  71662. get cellWidth(): number;
  71663. set cellWidth(value: number);
  71664. /**
  71665. * Gets or sets the cell height to use when animation sheet is enabled
  71666. * @see http://doc.babylonjs.com/how_to/gui#image
  71667. */
  71668. get cellHeight(): number;
  71669. set cellHeight(value: number);
  71670. /**
  71671. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71672. * @see http://doc.babylonjs.com/how_to/gui#image
  71673. */
  71674. get cellId(): number;
  71675. set cellId(value: number);
  71676. /**
  71677. * Creates a new Image
  71678. * @param name defines the control name
  71679. * @param url defines the image url
  71680. */
  71681. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71682. /**
  71683. * Tests if a given coordinates belong to the current control
  71684. * @param x defines x coordinate to test
  71685. * @param y defines y coordinate to test
  71686. * @returns true if the coordinates are inside the control
  71687. */
  71688. contains(x: number, y: number): boolean;
  71689. protected _getTypeName(): string;
  71690. /** Force the control to synchronize with its content */
  71691. synchronizeSizeWithContent(): void;
  71692. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71693. private _prepareWorkingCanvasForOpaqueDetection;
  71694. private _drawImage;
  71695. _draw(context: CanvasRenderingContext2D): void;
  71696. private _renderCornerPatch;
  71697. private _renderNinePatch;
  71698. dispose(): void;
  71699. /** STRETCH_NONE */
  71700. static readonly STRETCH_NONE: number;
  71701. /** STRETCH_FILL */
  71702. static readonly STRETCH_FILL: number;
  71703. /** STRETCH_UNIFORM */
  71704. static readonly STRETCH_UNIFORM: number;
  71705. /** STRETCH_EXTEND */
  71706. static readonly STRETCH_EXTEND: number;
  71707. /** NINE_PATCH */
  71708. static readonly STRETCH_NINE_PATCH: number;
  71709. }
  71710. }
  71711. declare module BABYLON.GUI {
  71712. /**
  71713. * Class used to create 2D buttons
  71714. */
  71715. export class Button extends Rectangle {
  71716. name?: string | undefined;
  71717. /**
  71718. * Function called to generate a pointer enter animation
  71719. */
  71720. pointerEnterAnimation: () => void;
  71721. /**
  71722. * Function called to generate a pointer out animation
  71723. */
  71724. pointerOutAnimation: () => void;
  71725. /**
  71726. * Function called to generate a pointer down animation
  71727. */
  71728. pointerDownAnimation: () => void;
  71729. /**
  71730. * Function called to generate a pointer up animation
  71731. */
  71732. pointerUpAnimation: () => void;
  71733. /**
  71734. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71735. */
  71736. delegatePickingToChildren: boolean;
  71737. private _image;
  71738. /**
  71739. * Returns the image part of the button (if any)
  71740. */
  71741. get image(): BABYLON.Nullable<Image>;
  71742. private _textBlock;
  71743. /**
  71744. * Returns the image part of the button (if any)
  71745. */
  71746. get textBlock(): BABYLON.Nullable<TextBlock>;
  71747. /**
  71748. * Creates a new Button
  71749. * @param name defines the name of the button
  71750. */
  71751. constructor(name?: string | undefined);
  71752. protected _getTypeName(): string;
  71753. /** @hidden */
  71754. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71755. /** @hidden */
  71756. _onPointerEnter(target: Control): boolean;
  71757. /** @hidden */
  71758. _onPointerOut(target: Control, force?: boolean): void;
  71759. /** @hidden */
  71760. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71761. /** @hidden */
  71762. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71763. /**
  71764. * Creates a new button made with an image and a text
  71765. * @param name defines the name of the button
  71766. * @param text defines the text of the button
  71767. * @param imageUrl defines the url of the image
  71768. * @returns a new Button
  71769. */
  71770. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71771. /**
  71772. * Creates a new button made with an image
  71773. * @param name defines the name of the button
  71774. * @param imageUrl defines the url of the image
  71775. * @returns a new Button
  71776. */
  71777. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71778. /**
  71779. * Creates a new button made with a text
  71780. * @param name defines the name of the button
  71781. * @param text defines the text of the button
  71782. * @returns a new Button
  71783. */
  71784. static CreateSimpleButton(name: string, text: string): Button;
  71785. /**
  71786. * Creates a new button made with an image and a centered text
  71787. * @param name defines the name of the button
  71788. * @param text defines the text of the button
  71789. * @param imageUrl defines the url of the image
  71790. * @returns a new Button
  71791. */
  71792. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71793. }
  71794. }
  71795. declare module BABYLON.GUI {
  71796. /**
  71797. * Class used to create a 2D stack panel container
  71798. */
  71799. export class StackPanel extends Container {
  71800. name?: string | undefined;
  71801. private _isVertical;
  71802. private _manualWidth;
  71803. private _manualHeight;
  71804. private _doNotTrackManualChanges;
  71805. /**
  71806. * Gets or sets a boolean indicating that layou warnings should be ignored
  71807. */
  71808. ignoreLayoutWarnings: boolean;
  71809. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71810. get isVertical(): boolean;
  71811. set isVertical(value: boolean);
  71812. /**
  71813. * Gets or sets panel width.
  71814. * This value should not be set when in horizontal mode as it will be computed automatically
  71815. */
  71816. set width(value: string | number);
  71817. get width(): string | number;
  71818. /**
  71819. * Gets or sets panel height.
  71820. * This value should not be set when in vertical mode as it will be computed automatically
  71821. */
  71822. set height(value: string | number);
  71823. get height(): string | number;
  71824. /**
  71825. * Creates a new StackPanel
  71826. * @param name defines control name
  71827. */
  71828. constructor(name?: string | undefined);
  71829. protected _getTypeName(): string;
  71830. /** @hidden */
  71831. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71832. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71833. protected _postMeasure(): void;
  71834. }
  71835. }
  71836. declare module BABYLON.GUI {
  71837. /**
  71838. * Class used to represent a 2D checkbox
  71839. */
  71840. export class Checkbox extends Control {
  71841. name?: string | undefined;
  71842. private _isChecked;
  71843. private _background;
  71844. private _checkSizeRatio;
  71845. private _thickness;
  71846. /** Gets or sets border thickness */
  71847. get thickness(): number;
  71848. set thickness(value: number);
  71849. /**
  71850. * BABYLON.Observable raised when isChecked property changes
  71851. */
  71852. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71853. /** Gets or sets a value indicating the ratio between overall size and check size */
  71854. get checkSizeRatio(): number;
  71855. set checkSizeRatio(value: number);
  71856. /** Gets or sets background color */
  71857. get background(): string;
  71858. set background(value: string);
  71859. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71860. get isChecked(): boolean;
  71861. set isChecked(value: boolean);
  71862. /**
  71863. * Creates a new CheckBox
  71864. * @param name defines the control name
  71865. */
  71866. constructor(name?: string | undefined);
  71867. protected _getTypeName(): string;
  71868. /** @hidden */
  71869. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71870. /** @hidden */
  71871. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71872. /**
  71873. * Utility function to easily create a checkbox with a header
  71874. * @param title defines the label to use for the header
  71875. * @param onValueChanged defines the callback to call when value changes
  71876. * @returns a StackPanel containing the checkbox and a textBlock
  71877. */
  71878. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71879. }
  71880. }
  71881. declare module BABYLON.GUI {
  71882. /**
  71883. * Class used to store key control properties
  71884. */
  71885. export class KeyPropertySet {
  71886. /** Width */
  71887. width?: string;
  71888. /** Height */
  71889. height?: string;
  71890. /** Left padding */
  71891. paddingLeft?: string;
  71892. /** Right padding */
  71893. paddingRight?: string;
  71894. /** Top padding */
  71895. paddingTop?: string;
  71896. /** Bottom padding */
  71897. paddingBottom?: string;
  71898. /** Foreground color */
  71899. color?: string;
  71900. /** Background color */
  71901. background?: string;
  71902. }
  71903. /**
  71904. * Class used to create virtual keyboard
  71905. */
  71906. export class VirtualKeyboard extends StackPanel {
  71907. /** BABYLON.Observable raised when a key is pressed */
  71908. onKeyPressObservable: BABYLON.Observable<string>;
  71909. /** Gets or sets default key button width */
  71910. defaultButtonWidth: string;
  71911. /** Gets or sets default key button height */
  71912. defaultButtonHeight: string;
  71913. /** Gets or sets default key button left padding */
  71914. defaultButtonPaddingLeft: string;
  71915. /** Gets or sets default key button right padding */
  71916. defaultButtonPaddingRight: string;
  71917. /** Gets or sets default key button top padding */
  71918. defaultButtonPaddingTop: string;
  71919. /** Gets or sets default key button bottom padding */
  71920. defaultButtonPaddingBottom: string;
  71921. /** Gets or sets default key button foreground color */
  71922. defaultButtonColor: string;
  71923. /** Gets or sets default key button background color */
  71924. defaultButtonBackground: string;
  71925. /** Gets or sets shift button foreground color */
  71926. shiftButtonColor: string;
  71927. /** Gets or sets shift button thickness*/
  71928. selectedShiftThickness: number;
  71929. /** Gets shift key state */
  71930. shiftState: number;
  71931. protected _getTypeName(): string;
  71932. private _createKey;
  71933. /**
  71934. * Adds a new row of keys
  71935. * @param keys defines the list of keys to add
  71936. * @param propertySets defines the associated property sets
  71937. */
  71938. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71939. /**
  71940. * Set the shift key to a specific state
  71941. * @param shiftState defines the new shift state
  71942. */
  71943. applyShiftState(shiftState: number): void;
  71944. private _currentlyConnectedInputText;
  71945. private _connectedInputTexts;
  71946. private _onKeyPressObserver;
  71947. /** Gets the input text control currently attached to the keyboard */
  71948. get connectedInputText(): BABYLON.Nullable<InputText>;
  71949. /**
  71950. * Connects the keyboard with an input text control
  71951. *
  71952. * @param input defines the target control
  71953. */
  71954. connect(input: InputText): void;
  71955. /**
  71956. * Disconnects the keyboard from connected InputText controls
  71957. *
  71958. * @param input optionally defines a target control, otherwise all are disconnected
  71959. */
  71960. disconnect(input?: InputText): void;
  71961. private _removeConnectedInputObservables;
  71962. /**
  71963. * Release all resources
  71964. */
  71965. dispose(): void;
  71966. /**
  71967. * Creates a new keyboard using a default layout
  71968. *
  71969. * @param name defines control name
  71970. * @returns a new VirtualKeyboard
  71971. */
  71972. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71973. }
  71974. }
  71975. declare module BABYLON.GUI {
  71976. /**
  71977. * Class used to create input text control
  71978. */
  71979. export class InputText extends Control implements IFocusableControl {
  71980. name?: string | undefined;
  71981. private _text;
  71982. private _placeholderText;
  71983. private _background;
  71984. private _focusedBackground;
  71985. private _focusedColor;
  71986. private _placeholderColor;
  71987. private _thickness;
  71988. private _margin;
  71989. private _autoStretchWidth;
  71990. private _maxWidth;
  71991. private _isFocused;
  71992. private _blinkTimeout;
  71993. private _blinkIsEven;
  71994. private _cursorOffset;
  71995. private _scrollLeft;
  71996. private _textWidth;
  71997. private _clickedCoordinate;
  71998. private _deadKey;
  71999. private _addKey;
  72000. private _currentKey;
  72001. private _isTextHighlightOn;
  72002. private _textHighlightColor;
  72003. private _highligherOpacity;
  72004. private _highlightedText;
  72005. private _startHighlightIndex;
  72006. private _endHighlightIndex;
  72007. private _cursorIndex;
  72008. private _onFocusSelectAll;
  72009. private _isPointerDown;
  72010. private _onClipboardObserver;
  72011. private _onPointerDblTapObserver;
  72012. /** @hidden */
  72013. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72014. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72015. promptMessage: string;
  72016. /** Force disable prompt on mobile device */
  72017. disableMobilePrompt: boolean;
  72018. /** BABYLON.Observable raised when the text changes */
  72019. onTextChangedObservable: BABYLON.Observable<InputText>;
  72020. /** BABYLON.Observable raised just before an entered character is to be added */
  72021. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72022. /** BABYLON.Observable raised when the control gets the focus */
  72023. onFocusObservable: BABYLON.Observable<InputText>;
  72024. /** BABYLON.Observable raised when the control loses the focus */
  72025. onBlurObservable: BABYLON.Observable<InputText>;
  72026. /**Observable raised when the text is highlighted */
  72027. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72028. /**Observable raised when copy event is triggered */
  72029. onTextCopyObservable: BABYLON.Observable<InputText>;
  72030. /** BABYLON.Observable raised when cut event is triggered */
  72031. onTextCutObservable: BABYLON.Observable<InputText>;
  72032. /** BABYLON.Observable raised when paste event is triggered */
  72033. onTextPasteObservable: BABYLON.Observable<InputText>;
  72034. /** BABYLON.Observable raised when a key event was processed */
  72035. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72036. /** Gets or sets the maximum width allowed by the control */
  72037. get maxWidth(): string | number;
  72038. /** Gets the maximum width allowed by the control in pixels */
  72039. get maxWidthInPixels(): number;
  72040. set maxWidth(value: string | number);
  72041. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72042. get highligherOpacity(): number;
  72043. set highligherOpacity(value: number);
  72044. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72045. get onFocusSelectAll(): boolean;
  72046. set onFocusSelectAll(value: boolean);
  72047. /** Gets or sets the text hightlight color */
  72048. get textHighlightColor(): string;
  72049. set textHighlightColor(value: string);
  72050. /** Gets or sets control margin */
  72051. get margin(): string;
  72052. /** Gets control margin in pixels */
  72053. get marginInPixels(): number;
  72054. set margin(value: string);
  72055. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72056. get autoStretchWidth(): boolean;
  72057. set autoStretchWidth(value: boolean);
  72058. /** Gets or sets border thickness */
  72059. get thickness(): number;
  72060. set thickness(value: number);
  72061. /** Gets or sets the background color when focused */
  72062. get focusedBackground(): string;
  72063. set focusedBackground(value: string);
  72064. /** Gets or sets the background color when focused */
  72065. get focusedColor(): string;
  72066. set focusedColor(value: string);
  72067. /** Gets or sets the background color */
  72068. get background(): string;
  72069. set background(value: string);
  72070. /** Gets or sets the placeholder color */
  72071. get placeholderColor(): string;
  72072. set placeholderColor(value: string);
  72073. /** Gets or sets the text displayed when the control is empty */
  72074. get placeholderText(): string;
  72075. set placeholderText(value: string);
  72076. /** Gets or sets the dead key flag */
  72077. get deadKey(): boolean;
  72078. set deadKey(flag: boolean);
  72079. /** Gets or sets the highlight text */
  72080. get highlightedText(): string;
  72081. set highlightedText(text: string);
  72082. /** Gets or sets if the current key should be added */
  72083. get addKey(): boolean;
  72084. set addKey(flag: boolean);
  72085. /** Gets or sets the value of the current key being entered */
  72086. get currentKey(): string;
  72087. set currentKey(key: string);
  72088. /** Gets or sets the text displayed in the control */
  72089. get text(): string;
  72090. set text(value: string);
  72091. /** Gets or sets control width */
  72092. get width(): string | number;
  72093. set width(value: string | number);
  72094. /**
  72095. * Creates a new InputText
  72096. * @param name defines the control name
  72097. * @param text defines the text of the control
  72098. */
  72099. constructor(name?: string | undefined, text?: string);
  72100. /** @hidden */
  72101. onBlur(): void;
  72102. /** @hidden */
  72103. onFocus(): void;
  72104. protected _getTypeName(): string;
  72105. /**
  72106. * Function called to get the list of controls that should not steal the focus from this control
  72107. * @returns an array of controls
  72108. */
  72109. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72110. /** @hidden */
  72111. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72112. /** @hidden */
  72113. private _updateValueFromCursorIndex;
  72114. /** @hidden */
  72115. private _processDblClick;
  72116. /** @hidden */
  72117. private _selectAllText;
  72118. /**
  72119. * Handles the keyboard event
  72120. * @param evt Defines the KeyboardEvent
  72121. */
  72122. processKeyboard(evt: KeyboardEvent): void;
  72123. /** @hidden */
  72124. private _onCopyText;
  72125. /** @hidden */
  72126. private _onCutText;
  72127. /** @hidden */
  72128. private _onPasteText;
  72129. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72130. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72131. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72132. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72133. protected _beforeRenderText(text: string): string;
  72134. dispose(): void;
  72135. }
  72136. }
  72137. declare module BABYLON.GUI {
  72138. /**
  72139. * Class used to create a 2D grid container
  72140. */
  72141. export class Grid extends Container {
  72142. name?: string | undefined;
  72143. private _rowDefinitions;
  72144. private _columnDefinitions;
  72145. private _cells;
  72146. private _childControls;
  72147. /**
  72148. * Gets the number of columns
  72149. */
  72150. get columnCount(): number;
  72151. /**
  72152. * Gets the number of rows
  72153. */
  72154. get rowCount(): number;
  72155. /** Gets the list of children */
  72156. get children(): Control[];
  72157. /** Gets the list of cells (e.g. the containers) */
  72158. get cells(): {
  72159. [key: string]: Container;
  72160. };
  72161. /**
  72162. * Gets the definition of a specific row
  72163. * @param index defines the index of the row
  72164. * @returns the row definition
  72165. */
  72166. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72167. /**
  72168. * Gets the definition of a specific column
  72169. * @param index defines the index of the column
  72170. * @returns the column definition
  72171. */
  72172. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72173. /**
  72174. * Adds a new row to the grid
  72175. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72176. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72177. * @returns the current grid
  72178. */
  72179. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72180. /**
  72181. * Adds a new column to the grid
  72182. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72183. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72184. * @returns the current grid
  72185. */
  72186. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72187. /**
  72188. * Update a row definition
  72189. * @param index defines the index of the row to update
  72190. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72191. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72192. * @returns the current grid
  72193. */
  72194. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72195. /**
  72196. * Update a column definition
  72197. * @param index defines the index of the column to update
  72198. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72199. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72200. * @returns the current grid
  72201. */
  72202. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72203. /**
  72204. * Gets the list of children stored in a specific cell
  72205. * @param row defines the row to check
  72206. * @param column defines the column to check
  72207. * @returns the list of controls
  72208. */
  72209. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72210. /**
  72211. * Gets a string representing the child cell info (row x column)
  72212. * @param child defines the control to get info from
  72213. * @returns a string containing the child cell info (row x column)
  72214. */
  72215. getChildCellInfo(child: Control): string;
  72216. private _removeCell;
  72217. private _offsetCell;
  72218. /**
  72219. * Remove a column definition at specified index
  72220. * @param index defines the index of the column to remove
  72221. * @returns the current grid
  72222. */
  72223. removeColumnDefinition(index: number): Grid;
  72224. /**
  72225. * Remove a row definition at specified index
  72226. * @param index defines the index of the row to remove
  72227. * @returns the current grid
  72228. */
  72229. removeRowDefinition(index: number): Grid;
  72230. /**
  72231. * Adds a new control to the current grid
  72232. * @param control defines the control to add
  72233. * @param row defines the row where to add the control (0 by default)
  72234. * @param column defines the column where to add the control (0 by default)
  72235. * @returns the current grid
  72236. */
  72237. addControl(control: Control, row?: number, column?: number): Grid;
  72238. /**
  72239. * Removes a control from the current container
  72240. * @param control defines the control to remove
  72241. * @returns the current container
  72242. */
  72243. removeControl(control: Control): Container;
  72244. /**
  72245. * Creates a new Grid
  72246. * @param name defines control name
  72247. */
  72248. constructor(name?: string | undefined);
  72249. protected _getTypeName(): string;
  72250. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72251. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72252. _flagDescendantsAsMatrixDirty(): void;
  72253. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72254. /** Releases associated resources */
  72255. dispose(): void;
  72256. }
  72257. }
  72258. declare module BABYLON.GUI {
  72259. /** Class used to create color pickers */
  72260. export class ColorPicker extends Control {
  72261. name?: string | undefined;
  72262. private static _Epsilon;
  72263. private _colorWheelCanvas;
  72264. private _value;
  72265. private _tmpColor;
  72266. private _pointerStartedOnSquare;
  72267. private _pointerStartedOnWheel;
  72268. private _squareLeft;
  72269. private _squareTop;
  72270. private _squareSize;
  72271. private _h;
  72272. private _s;
  72273. private _v;
  72274. private _lastPointerDownID;
  72275. /**
  72276. * BABYLON.Observable raised when the value changes
  72277. */
  72278. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72279. /** Gets or sets the color of the color picker */
  72280. get value(): BABYLON.Color3;
  72281. set value(value: BABYLON.Color3);
  72282. /**
  72283. * Gets or sets control width
  72284. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72285. */
  72286. get width(): string | number;
  72287. set width(value: string | number);
  72288. /**
  72289. * Gets or sets control height
  72290. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72291. */
  72292. get height(): string | number;
  72293. /** Gets or sets control height */
  72294. set height(value: string | number);
  72295. /** Gets or sets control size */
  72296. get size(): string | number;
  72297. set size(value: string | number);
  72298. /**
  72299. * Creates a new ColorPicker
  72300. * @param name defines the control name
  72301. */
  72302. constructor(name?: string | undefined);
  72303. protected _getTypeName(): string;
  72304. /** @hidden */
  72305. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72306. private _updateSquareProps;
  72307. private _drawGradientSquare;
  72308. private _drawCircle;
  72309. private _createColorWheelCanvas;
  72310. /** @hidden */
  72311. _draw(context: CanvasRenderingContext2D): void;
  72312. private _pointerIsDown;
  72313. private _updateValueFromPointer;
  72314. private _isPointOnSquare;
  72315. private _isPointOnWheel;
  72316. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72317. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72318. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72319. /**
  72320. * This function expands the color picker by creating a color picker dialog with manual
  72321. * color value input and the ability to save colors into an array to be used later in
  72322. * subsequent launches of the dialogue.
  72323. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72324. * @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.
  72325. * @returns picked color as a hex string and the saved colors array as hex strings.
  72326. */
  72327. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72328. pickerWidth?: string;
  72329. pickerHeight?: string;
  72330. headerHeight?: string;
  72331. lastColor?: string;
  72332. swatchLimit?: number;
  72333. numSwatchesPerLine?: number;
  72334. savedColors?: Array<string>;
  72335. }): Promise<{
  72336. savedColors?: string[];
  72337. pickedColor: string;
  72338. }>;
  72339. }
  72340. }
  72341. declare module BABYLON.GUI {
  72342. /** Class used to create 2D ellipse containers */
  72343. export class Ellipse extends Container {
  72344. name?: string | undefined;
  72345. private _thickness;
  72346. /** Gets or sets border thickness */
  72347. get thickness(): number;
  72348. set thickness(value: number);
  72349. /**
  72350. * Creates a new Ellipse
  72351. * @param name defines the control name
  72352. */
  72353. constructor(name?: string | undefined);
  72354. protected _getTypeName(): string;
  72355. protected _localDraw(context: CanvasRenderingContext2D): void;
  72356. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72357. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72358. }
  72359. }
  72360. declare module BABYLON.GUI {
  72361. /**
  72362. * Class used to create a password control
  72363. */
  72364. export class InputPassword extends InputText {
  72365. protected _beforeRenderText(text: string): string;
  72366. }
  72367. }
  72368. declare module BABYLON.GUI {
  72369. /** Class used to render 2D lines */
  72370. export class Line extends Control {
  72371. name?: string | undefined;
  72372. private _lineWidth;
  72373. private _x1;
  72374. private _y1;
  72375. private _x2;
  72376. private _y2;
  72377. private _dash;
  72378. private _connectedControl;
  72379. private _connectedControlDirtyObserver;
  72380. /** Gets or sets the dash pattern */
  72381. get dash(): Array<number>;
  72382. set dash(value: Array<number>);
  72383. /** Gets or sets the control connected with the line end */
  72384. get connectedControl(): Control;
  72385. set connectedControl(value: Control);
  72386. /** Gets or sets start coordinates on X axis */
  72387. get x1(): string | number;
  72388. set x1(value: string | number);
  72389. /** Gets or sets start coordinates on Y axis */
  72390. get y1(): string | number;
  72391. set y1(value: string | number);
  72392. /** Gets or sets end coordinates on X axis */
  72393. get x2(): string | number;
  72394. set x2(value: string | number);
  72395. /** Gets or sets end coordinates on Y axis */
  72396. get y2(): string | number;
  72397. set y2(value: string | number);
  72398. /** Gets or sets line width */
  72399. get lineWidth(): number;
  72400. set lineWidth(value: number);
  72401. /** Gets or sets horizontal alignment */
  72402. set horizontalAlignment(value: number);
  72403. /** Gets or sets vertical alignment */
  72404. set verticalAlignment(value: number);
  72405. private get _effectiveX2();
  72406. private get _effectiveY2();
  72407. /**
  72408. * Creates a new Line
  72409. * @param name defines the control name
  72410. */
  72411. constructor(name?: string | undefined);
  72412. protected _getTypeName(): string;
  72413. _draw(context: CanvasRenderingContext2D): void;
  72414. _measure(): void;
  72415. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72416. /**
  72417. * Move one end of the line given 3D cartesian coordinates.
  72418. * @param position Targeted world position
  72419. * @param scene BABYLON.Scene
  72420. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72421. */
  72422. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72423. /**
  72424. * Move one end of the line to a position in screen absolute space.
  72425. * @param projectedPosition Position in screen absolute space (X, Y)
  72426. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72427. */
  72428. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72429. }
  72430. }
  72431. declare module BABYLON.GUI {
  72432. /**
  72433. * Class used to store a point for a MultiLine object.
  72434. * The point can be pure 2D coordinates, a mesh or a control
  72435. */
  72436. export class MultiLinePoint {
  72437. private _multiLine;
  72438. private _x;
  72439. private _y;
  72440. private _control;
  72441. private _mesh;
  72442. private _controlObserver;
  72443. private _meshObserver;
  72444. /** @hidden */
  72445. _point: BABYLON.Vector2;
  72446. /**
  72447. * Creates a new MultiLinePoint
  72448. * @param multiLine defines the source MultiLine object
  72449. */
  72450. constructor(multiLine: MultiLine);
  72451. /** Gets or sets x coordinate */
  72452. get x(): string | number;
  72453. set x(value: string | number);
  72454. /** Gets or sets y coordinate */
  72455. get y(): string | number;
  72456. set y(value: string | number);
  72457. /** Gets or sets the control associated with this point */
  72458. get control(): BABYLON.Nullable<Control>;
  72459. set control(value: BABYLON.Nullable<Control>);
  72460. /** Gets or sets the mesh associated with this point */
  72461. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72462. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72463. /** Resets links */
  72464. resetLinks(): void;
  72465. /**
  72466. * Gets a translation vector
  72467. * @returns the translation vector
  72468. */
  72469. translate(): BABYLON.Vector2;
  72470. private _translatePoint;
  72471. /** Release associated resources */
  72472. dispose(): void;
  72473. }
  72474. }
  72475. declare module BABYLON.GUI {
  72476. /**
  72477. * Class used to create multi line control
  72478. */
  72479. export class MultiLine extends Control {
  72480. name?: string | undefined;
  72481. private _lineWidth;
  72482. private _dash;
  72483. private _points;
  72484. private _minX;
  72485. private _minY;
  72486. private _maxX;
  72487. private _maxY;
  72488. /**
  72489. * Creates a new MultiLine
  72490. * @param name defines the control name
  72491. */
  72492. constructor(name?: string | undefined);
  72493. /** Gets or sets dash pattern */
  72494. get dash(): Array<number>;
  72495. set dash(value: Array<number>);
  72496. /**
  72497. * Gets point stored at specified index
  72498. * @param index defines the index to look for
  72499. * @returns the requested point if found
  72500. */
  72501. getAt(index: number): MultiLinePoint;
  72502. /** Function called when a point is updated */
  72503. onPointUpdate: () => void;
  72504. /**
  72505. * Adds new points to the point collection
  72506. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72507. * @returns the list of created MultiLinePoint
  72508. */
  72509. add(...items: (AbstractMesh | Control | {
  72510. x: string | number;
  72511. y: string | number;
  72512. })[]): MultiLinePoint[];
  72513. /**
  72514. * Adds a new point to the point collection
  72515. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72516. * @returns the created MultiLinePoint
  72517. */
  72518. push(item?: (AbstractMesh | Control | {
  72519. x: string | number;
  72520. y: string | number;
  72521. })): MultiLinePoint;
  72522. /**
  72523. * Remove a specific value or point from the active point collection
  72524. * @param value defines the value or point to remove
  72525. */
  72526. remove(value: number | MultiLinePoint): void;
  72527. /**
  72528. * Resets this object to initial state (no point)
  72529. */
  72530. reset(): void;
  72531. /**
  72532. * Resets all links
  72533. */
  72534. resetLinks(): void;
  72535. /** Gets or sets line width */
  72536. get lineWidth(): number;
  72537. set lineWidth(value: number);
  72538. set horizontalAlignment(value: number);
  72539. set verticalAlignment(value: number);
  72540. protected _getTypeName(): string;
  72541. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72542. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72543. _measure(): void;
  72544. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72545. dispose(): void;
  72546. }
  72547. }
  72548. declare module BABYLON.GUI {
  72549. /**
  72550. * Class used to create radio button controls
  72551. */
  72552. export class RadioButton extends Control {
  72553. name?: string | undefined;
  72554. private _isChecked;
  72555. private _background;
  72556. private _checkSizeRatio;
  72557. private _thickness;
  72558. /** Gets or sets border thickness */
  72559. get thickness(): number;
  72560. set thickness(value: number);
  72561. /** Gets or sets group name */
  72562. group: string;
  72563. /** BABYLON.Observable raised when isChecked is changed */
  72564. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72565. /** Gets or sets a value indicating the ratio between overall size and check size */
  72566. get checkSizeRatio(): number;
  72567. set checkSizeRatio(value: number);
  72568. /** Gets or sets background color */
  72569. get background(): string;
  72570. set background(value: string);
  72571. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72572. get isChecked(): boolean;
  72573. set isChecked(value: boolean);
  72574. /**
  72575. * Creates a new RadioButton
  72576. * @param name defines the control name
  72577. */
  72578. constructor(name?: string | undefined);
  72579. protected _getTypeName(): string;
  72580. _draw(context: CanvasRenderingContext2D): void;
  72581. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72582. /**
  72583. * Utility function to easily create a radio button with a header
  72584. * @param title defines the label to use for the header
  72585. * @param group defines the group to use for the radio button
  72586. * @param isChecked defines the initial state of the radio button
  72587. * @param onValueChanged defines the callback to call when value changes
  72588. * @returns a StackPanel containing the radio button and a textBlock
  72589. */
  72590. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72591. }
  72592. }
  72593. declare module BABYLON.GUI {
  72594. /**
  72595. * Class used to create slider controls
  72596. */
  72597. export class BaseSlider extends Control {
  72598. name?: string | undefined;
  72599. protected _thumbWidth: ValueAndUnit;
  72600. private _minimum;
  72601. private _maximum;
  72602. private _value;
  72603. private _isVertical;
  72604. protected _barOffset: ValueAndUnit;
  72605. private _isThumbClamped;
  72606. protected _displayThumb: boolean;
  72607. private _step;
  72608. private _lastPointerDownID;
  72609. protected _effectiveBarOffset: number;
  72610. protected _renderLeft: number;
  72611. protected _renderTop: number;
  72612. protected _renderWidth: number;
  72613. protected _renderHeight: number;
  72614. protected _backgroundBoxLength: number;
  72615. protected _backgroundBoxThickness: number;
  72616. protected _effectiveThumbThickness: number;
  72617. /** BABYLON.Observable raised when the sldier value changes */
  72618. onValueChangedObservable: BABYLON.Observable<number>;
  72619. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72620. get displayThumb(): boolean;
  72621. set displayThumb(value: boolean);
  72622. /** Gets or sets a step to apply to values (0 by default) */
  72623. get step(): number;
  72624. set step(value: number);
  72625. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72626. get barOffset(): string | number;
  72627. /** Gets main bar offset in pixels*/
  72628. get barOffsetInPixels(): number;
  72629. set barOffset(value: string | number);
  72630. /** Gets or sets thumb width */
  72631. get thumbWidth(): string | number;
  72632. /** Gets thumb width in pixels */
  72633. get thumbWidthInPixels(): number;
  72634. set thumbWidth(value: string | number);
  72635. /** Gets or sets minimum value */
  72636. get minimum(): number;
  72637. set minimum(value: number);
  72638. /** Gets or sets maximum value */
  72639. get maximum(): number;
  72640. set maximum(value: number);
  72641. /** Gets or sets current value */
  72642. get value(): number;
  72643. set value(value: number);
  72644. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72645. get isVertical(): boolean;
  72646. set isVertical(value: boolean);
  72647. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72648. get isThumbClamped(): boolean;
  72649. set isThumbClamped(value: boolean);
  72650. /**
  72651. * Creates a new BaseSlider
  72652. * @param name defines the control name
  72653. */
  72654. constructor(name?: string | undefined);
  72655. protected _getTypeName(): string;
  72656. protected _getThumbPosition(): number;
  72657. protected _getThumbThickness(type: string): number;
  72658. protected _prepareRenderingData(type: string): void;
  72659. private _pointerIsDown;
  72660. /** @hidden */
  72661. protected _updateValueFromPointer(x: number, y: number): void;
  72662. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72663. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72664. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72665. }
  72666. }
  72667. declare module BABYLON.GUI {
  72668. /**
  72669. * Class used to create slider controls
  72670. */
  72671. export class Slider extends BaseSlider {
  72672. name?: string | undefined;
  72673. private _background;
  72674. private _borderColor;
  72675. private _isThumbCircle;
  72676. protected _displayValueBar: boolean;
  72677. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72678. get displayValueBar(): boolean;
  72679. set displayValueBar(value: boolean);
  72680. /** Gets or sets border color */
  72681. get borderColor(): string;
  72682. set borderColor(value: string);
  72683. /** Gets or sets background color */
  72684. get background(): string;
  72685. set background(value: string);
  72686. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72687. get isThumbCircle(): boolean;
  72688. set isThumbCircle(value: boolean);
  72689. /**
  72690. * Creates a new Slider
  72691. * @param name defines the control name
  72692. */
  72693. constructor(name?: string | undefined);
  72694. protected _getTypeName(): string;
  72695. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72696. }
  72697. }
  72698. declare module BABYLON.GUI {
  72699. /** Class used to create a RadioGroup
  72700. * which contains groups of radio buttons
  72701. */
  72702. export class SelectorGroup {
  72703. /** name of SelectorGroup */
  72704. name: string;
  72705. private _groupPanel;
  72706. private _selectors;
  72707. private _groupHeader;
  72708. /**
  72709. * Creates a new SelectorGroup
  72710. * @param name of group, used as a group heading
  72711. */
  72712. constructor(
  72713. /** name of SelectorGroup */
  72714. name: string);
  72715. /** Gets the groupPanel of the SelectorGroup */
  72716. get groupPanel(): StackPanel;
  72717. /** Gets the selectors array */
  72718. get selectors(): StackPanel[];
  72719. /** Gets and sets the group header */
  72720. get header(): string;
  72721. set header(label: string);
  72722. /** @hidden */
  72723. private _addGroupHeader;
  72724. /** @hidden*/
  72725. _getSelector(selectorNb: number): StackPanel | undefined;
  72726. /** Removes the selector at the given position
  72727. * @param selectorNb the position of the selector within the group
  72728. */
  72729. removeSelector(selectorNb: number): void;
  72730. }
  72731. /** Class used to create a CheckboxGroup
  72732. * which contains groups of checkbox buttons
  72733. */
  72734. export class CheckboxGroup extends SelectorGroup {
  72735. /** Adds a checkbox as a control
  72736. * @param text is the label for the selector
  72737. * @param func is the function called when the Selector is checked
  72738. * @param checked is true when Selector is checked
  72739. */
  72740. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72741. /** @hidden */
  72742. _setSelectorLabel(selectorNb: number, label: string): void;
  72743. /** @hidden */
  72744. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72745. /** @hidden */
  72746. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72747. /** @hidden */
  72748. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72749. }
  72750. /** Class used to create a RadioGroup
  72751. * which contains groups of radio buttons
  72752. */
  72753. export class RadioGroup extends SelectorGroup {
  72754. private _selectNb;
  72755. /** Adds a radio button as a control
  72756. * @param label is the label for the selector
  72757. * @param func is the function called when the Selector is checked
  72758. * @param checked is true when Selector is checked
  72759. */
  72760. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72761. /** @hidden */
  72762. _setSelectorLabel(selectorNb: number, label: string): void;
  72763. /** @hidden */
  72764. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72765. /** @hidden */
  72766. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72767. /** @hidden */
  72768. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72769. }
  72770. /** Class used to create a SliderGroup
  72771. * which contains groups of slider buttons
  72772. */
  72773. export class SliderGroup extends SelectorGroup {
  72774. /**
  72775. * Adds a slider to the SelectorGroup
  72776. * @param label is the label for the SliderBar
  72777. * @param func is the function called when the Slider moves
  72778. * @param unit is a string describing the units used, eg degrees or metres
  72779. * @param min is the minimum value for the Slider
  72780. * @param max is the maximum value for the Slider
  72781. * @param value is the start value for the Slider between min and max
  72782. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72783. */
  72784. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72785. /** @hidden */
  72786. _setSelectorLabel(selectorNb: number, label: string): void;
  72787. /** @hidden */
  72788. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72789. /** @hidden */
  72790. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72791. /** @hidden */
  72792. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72793. }
  72794. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72795. * @see http://doc.babylonjs.com/how_to/selector
  72796. */
  72797. export class SelectionPanel extends Rectangle {
  72798. /** name of SelectionPanel */
  72799. name: string;
  72800. /** an array of SelectionGroups */
  72801. groups: SelectorGroup[];
  72802. private _panel;
  72803. private _buttonColor;
  72804. private _buttonBackground;
  72805. private _headerColor;
  72806. private _barColor;
  72807. private _barHeight;
  72808. private _spacerHeight;
  72809. private _labelColor;
  72810. private _groups;
  72811. private _bars;
  72812. /**
  72813. * Creates a new SelectionPanel
  72814. * @param name of SelectionPanel
  72815. * @param groups is an array of SelectionGroups
  72816. */
  72817. constructor(
  72818. /** name of SelectionPanel */
  72819. name: string,
  72820. /** an array of SelectionGroups */
  72821. groups?: SelectorGroup[]);
  72822. protected _getTypeName(): string;
  72823. /** Gets or sets the headerColor */
  72824. get headerColor(): string;
  72825. set headerColor(color: string);
  72826. private _setHeaderColor;
  72827. /** Gets or sets the button color */
  72828. get buttonColor(): string;
  72829. set buttonColor(color: string);
  72830. private _setbuttonColor;
  72831. /** Gets or sets the label color */
  72832. get labelColor(): string;
  72833. set labelColor(color: string);
  72834. private _setLabelColor;
  72835. /** Gets or sets the button background */
  72836. get buttonBackground(): string;
  72837. set buttonBackground(color: string);
  72838. private _setButtonBackground;
  72839. /** Gets or sets the color of separator bar */
  72840. get barColor(): string;
  72841. set barColor(color: string);
  72842. private _setBarColor;
  72843. /** Gets or sets the height of separator bar */
  72844. get barHeight(): string;
  72845. set barHeight(value: string);
  72846. private _setBarHeight;
  72847. /** Gets or sets the height of spacers*/
  72848. get spacerHeight(): string;
  72849. set spacerHeight(value: string);
  72850. private _setSpacerHeight;
  72851. /** Adds a bar between groups */
  72852. private _addSpacer;
  72853. /** Add a group to the selection panel
  72854. * @param group is the selector group to add
  72855. */
  72856. addGroup(group: SelectorGroup): void;
  72857. /** Remove the group from the given position
  72858. * @param groupNb is the position of the group in the list
  72859. */
  72860. removeGroup(groupNb: number): void;
  72861. /** Change a group header label
  72862. * @param label is the new group header label
  72863. * @param groupNb is the number of the group to relabel
  72864. * */
  72865. setHeaderName(label: string, groupNb: number): void;
  72866. /** Change selector label to the one given
  72867. * @param label is the new selector label
  72868. * @param groupNb is the number of the groupcontaining the selector
  72869. * @param selectorNb is the number of the selector within a group to relabel
  72870. * */
  72871. relabel(label: string, groupNb: number, selectorNb: number): void;
  72872. /** For a given group position remove the selector at the given position
  72873. * @param groupNb is the number of the group to remove the selector from
  72874. * @param selectorNb is the number of the selector within the group
  72875. */
  72876. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72877. /** For a given group position of correct type add a checkbox button
  72878. * @param groupNb is the number of the group to remove the selector from
  72879. * @param label is the label for the selector
  72880. * @param func is the function called when the Selector is checked
  72881. * @param checked is true when Selector is checked
  72882. */
  72883. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72884. /** For a given group position of correct type add a radio button
  72885. * @param groupNb is the number of the group to remove the selector from
  72886. * @param label is the label for the selector
  72887. * @param func is the function called when the Selector is checked
  72888. * @param checked is true when Selector is checked
  72889. */
  72890. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72891. /**
  72892. * For a given slider group add a slider
  72893. * @param groupNb is the number of the group to add the slider to
  72894. * @param label is the label for the Slider
  72895. * @param func is the function called when the Slider moves
  72896. * @param unit is a string describing the units used, eg degrees or metres
  72897. * @param min is the minimum value for the Slider
  72898. * @param max is the maximum value for the Slider
  72899. * @param value is the start value for the Slider between min and max
  72900. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72901. */
  72902. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72903. }
  72904. }
  72905. declare module BABYLON.GUI {
  72906. /**
  72907. * Class used to hold a the container for ScrollViewer
  72908. * @hidden
  72909. */
  72910. export class _ScrollViewerWindow extends Container {
  72911. parentClientWidth: number;
  72912. parentClientHeight: number;
  72913. private _freezeControls;
  72914. private _parentMeasure;
  72915. private _oldLeft;
  72916. private _oldTop;
  72917. get freezeControls(): boolean;
  72918. set freezeControls(value: boolean);
  72919. private _bucketWidth;
  72920. private _bucketHeight;
  72921. private _buckets;
  72922. private _bucketLen;
  72923. get bucketWidth(): number;
  72924. get bucketHeight(): number;
  72925. setBucketSizes(width: number, height: number): void;
  72926. private _useBuckets;
  72927. private _makeBuckets;
  72928. private _dispatchInBuckets;
  72929. private _updateMeasures;
  72930. private _updateChildrenMeasures;
  72931. /**
  72932. * Creates a new ScrollViewerWindow
  72933. * @param name of ScrollViewerWindow
  72934. */
  72935. constructor(name?: string);
  72936. protected _getTypeName(): string;
  72937. /** @hidden */
  72938. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72939. /** @hidden */
  72940. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72941. private _scrollChildren;
  72942. private _scrollChildrenWithBuckets;
  72943. /** @hidden */
  72944. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72945. protected _postMeasure(): void;
  72946. }
  72947. }
  72948. declare module BABYLON.GUI {
  72949. /**
  72950. * Class used to create slider controls
  72951. */
  72952. export class ScrollBar extends BaseSlider {
  72953. name?: string | undefined;
  72954. private _background;
  72955. private _borderColor;
  72956. private _tempMeasure;
  72957. /** Gets or sets border color */
  72958. get borderColor(): string;
  72959. set borderColor(value: string);
  72960. /** Gets or sets background color */
  72961. get background(): string;
  72962. set background(value: string);
  72963. /**
  72964. * Creates a new Slider
  72965. * @param name defines the control name
  72966. */
  72967. constructor(name?: string | undefined);
  72968. protected _getTypeName(): string;
  72969. protected _getThumbThickness(): number;
  72970. _draw(context: CanvasRenderingContext2D): void;
  72971. private _first;
  72972. private _originX;
  72973. private _originY;
  72974. /** @hidden */
  72975. protected _updateValueFromPointer(x: number, y: number): void;
  72976. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72977. }
  72978. }
  72979. declare module BABYLON.GUI {
  72980. /**
  72981. * Class used to create slider controls
  72982. */
  72983. export class ImageScrollBar extends BaseSlider {
  72984. name?: string | undefined;
  72985. private _backgroundBaseImage;
  72986. private _backgroundImage;
  72987. private _thumbImage;
  72988. private _thumbBaseImage;
  72989. private _thumbLength;
  72990. private _thumbHeight;
  72991. private _barImageHeight;
  72992. private _tempMeasure;
  72993. /** Number of 90° rotation to apply on the images when in vertical mode */
  72994. num90RotationInVerticalMode: number;
  72995. /**
  72996. * Gets or sets the image used to render the background for horizontal bar
  72997. */
  72998. get backgroundImage(): Image;
  72999. set backgroundImage(value: Image);
  73000. /**
  73001. * Gets or sets the image used to render the thumb
  73002. */
  73003. get thumbImage(): Image;
  73004. set thumbImage(value: Image);
  73005. /**
  73006. * Gets or sets the length of the thumb
  73007. */
  73008. get thumbLength(): number;
  73009. set thumbLength(value: number);
  73010. /**
  73011. * Gets or sets the height of the thumb
  73012. */
  73013. get thumbHeight(): number;
  73014. set thumbHeight(value: number);
  73015. /**
  73016. * Gets or sets the height of the bar image
  73017. */
  73018. get barImageHeight(): number;
  73019. set barImageHeight(value: number);
  73020. /**
  73021. * Creates a new ImageScrollBar
  73022. * @param name defines the control name
  73023. */
  73024. constructor(name?: string | undefined);
  73025. protected _getTypeName(): string;
  73026. protected _getThumbThickness(): number;
  73027. _draw(context: CanvasRenderingContext2D): void;
  73028. private _first;
  73029. private _originX;
  73030. private _originY;
  73031. /** @hidden */
  73032. protected _updateValueFromPointer(x: number, y: number): void;
  73033. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73034. }
  73035. }
  73036. declare module BABYLON.GUI {
  73037. /**
  73038. * Class used to hold a viewer window and sliders in a grid
  73039. */
  73040. export class ScrollViewer extends Rectangle {
  73041. private _grid;
  73042. private _horizontalBarSpace;
  73043. private _verticalBarSpace;
  73044. private _dragSpace;
  73045. private _horizontalBar;
  73046. private _verticalBar;
  73047. private _barColor;
  73048. private _barBackground;
  73049. private _barImage;
  73050. private _horizontalBarImage;
  73051. private _verticalBarImage;
  73052. private _barBackgroundImage;
  73053. private _horizontalBarBackgroundImage;
  73054. private _verticalBarBackgroundImage;
  73055. private _barSize;
  73056. private _window;
  73057. private _pointerIsOver;
  73058. private _wheelPrecision;
  73059. private _onWheelObserver;
  73060. private _clientWidth;
  73061. private _clientHeight;
  73062. private _useImageBar;
  73063. private _thumbLength;
  73064. private _thumbHeight;
  73065. private _barImageHeight;
  73066. private _horizontalBarImageHeight;
  73067. private _verticalBarImageHeight;
  73068. /**
  73069. * Gets the horizontal scrollbar
  73070. */
  73071. get horizontalBar(): ScrollBar | ImageScrollBar;
  73072. /**
  73073. * Gets the vertical scrollbar
  73074. */
  73075. get verticalBar(): ScrollBar | ImageScrollBar;
  73076. /**
  73077. * Adds a new control to the current container
  73078. * @param control defines the control to add
  73079. * @returns the current container
  73080. */
  73081. addControl(control: BABYLON.Nullable<Control>): Container;
  73082. /**
  73083. * Removes a control from the current container
  73084. * @param control defines the control to remove
  73085. * @returns the current container
  73086. */
  73087. removeControl(control: Control): Container;
  73088. /** Gets the list of children */
  73089. get children(): Control[];
  73090. _flagDescendantsAsMatrixDirty(): void;
  73091. /**
  73092. * Freezes or unfreezes the controls in the window.
  73093. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73094. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73095. */
  73096. get freezeControls(): boolean;
  73097. set freezeControls(value: boolean);
  73098. /** Gets the bucket width */
  73099. get bucketWidth(): number;
  73100. /** Gets the bucket height */
  73101. get bucketHeight(): number;
  73102. /**
  73103. * Sets the bucket sizes.
  73104. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73105. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73106. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73107. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73108. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73109. * used), that's why it is not enabled by default.
  73110. * @param width width of the bucket
  73111. * @param height height of the bucket
  73112. */
  73113. setBucketSizes(width: number, height: number): void;
  73114. private _forceHorizontalBar;
  73115. private _forceVerticalBar;
  73116. /**
  73117. * Forces the horizontal scroll bar to be displayed
  73118. */
  73119. get forceHorizontalBar(): boolean;
  73120. set forceHorizontalBar(value: boolean);
  73121. /**
  73122. * Forces the vertical scroll bar to be displayed
  73123. */
  73124. get forceVerticalBar(): boolean;
  73125. set forceVerticalBar(value: boolean);
  73126. /**
  73127. * Creates a new ScrollViewer
  73128. * @param name of ScrollViewer
  73129. */
  73130. constructor(name?: string, isImageBased?: boolean);
  73131. /** Reset the scroll viewer window to initial size */
  73132. resetWindow(): void;
  73133. protected _getTypeName(): string;
  73134. private _buildClientSizes;
  73135. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73136. protected _postMeasure(): void;
  73137. /**
  73138. * Gets or sets the mouse wheel precision
  73139. * from 0 to 1 with a default value of 0.05
  73140. * */
  73141. get wheelPrecision(): number;
  73142. set wheelPrecision(value: number);
  73143. /** Gets or sets the scroll bar container background color */
  73144. get scrollBackground(): string;
  73145. set scrollBackground(color: string);
  73146. /** Gets or sets the bar color */
  73147. get barColor(): string;
  73148. set barColor(color: string);
  73149. /** Gets or sets the bar image */
  73150. get thumbImage(): Image;
  73151. set thumbImage(value: Image);
  73152. /** Gets or sets the horizontal bar image */
  73153. get horizontalThumbImage(): Image;
  73154. set horizontalThumbImage(value: Image);
  73155. /** Gets or sets the vertical bar image */
  73156. get verticalThumbImage(): Image;
  73157. set verticalThumbImage(value: Image);
  73158. /** Gets or sets the size of the bar */
  73159. get barSize(): number;
  73160. set barSize(value: number);
  73161. /** Gets or sets the length of the thumb */
  73162. get thumbLength(): number;
  73163. set thumbLength(value: number);
  73164. /** Gets or sets the height of the thumb */
  73165. get thumbHeight(): number;
  73166. set thumbHeight(value: number);
  73167. /** Gets or sets the height of the bar image */
  73168. get barImageHeight(): number;
  73169. set barImageHeight(value: number);
  73170. /** Gets or sets the height of the horizontal bar image */
  73171. get horizontalBarImageHeight(): number;
  73172. set horizontalBarImageHeight(value: number);
  73173. /** Gets or sets the height of the vertical bar image */
  73174. get verticalBarImageHeight(): number;
  73175. set verticalBarImageHeight(value: number);
  73176. /** Gets or sets the bar background */
  73177. get barBackground(): string;
  73178. set barBackground(color: string);
  73179. /** Gets or sets the bar background image */
  73180. get barImage(): Image;
  73181. set barImage(value: Image);
  73182. /** Gets or sets the horizontal bar background image */
  73183. get horizontalBarImage(): Image;
  73184. set horizontalBarImage(value: Image);
  73185. /** Gets or sets the vertical bar background image */
  73186. get verticalBarImage(): Image;
  73187. set verticalBarImage(value: Image);
  73188. private _setWindowPosition;
  73189. /** @hidden */
  73190. private _updateScroller;
  73191. _link(host: AdvancedDynamicTexture): void;
  73192. /** @hidden */
  73193. private _addBar;
  73194. /** @hidden */
  73195. private _attachWheel;
  73196. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73197. /** Releases associated resources */
  73198. dispose(): void;
  73199. }
  73200. }
  73201. declare module BABYLON.GUI {
  73202. /** Class used to render a grid */
  73203. export class DisplayGrid extends Control {
  73204. name?: string | undefined;
  73205. private _cellWidth;
  73206. private _cellHeight;
  73207. private _minorLineTickness;
  73208. private _minorLineColor;
  73209. private _majorLineTickness;
  73210. private _majorLineColor;
  73211. private _majorLineFrequency;
  73212. private _background;
  73213. private _displayMajorLines;
  73214. private _displayMinorLines;
  73215. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73216. get displayMinorLines(): boolean;
  73217. set displayMinorLines(value: boolean);
  73218. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73219. get displayMajorLines(): boolean;
  73220. set displayMajorLines(value: boolean);
  73221. /** Gets or sets background color (Black by default) */
  73222. get background(): string;
  73223. set background(value: string);
  73224. /** Gets or sets the width of each cell (20 by default) */
  73225. get cellWidth(): number;
  73226. set cellWidth(value: number);
  73227. /** Gets or sets the height of each cell (20 by default) */
  73228. get cellHeight(): number;
  73229. set cellHeight(value: number);
  73230. /** Gets or sets the tickness of minor lines (1 by default) */
  73231. get minorLineTickness(): number;
  73232. set minorLineTickness(value: number);
  73233. /** Gets or sets the color of minor lines (DarkGray by default) */
  73234. get minorLineColor(): string;
  73235. set minorLineColor(value: string);
  73236. /** Gets or sets the tickness of major lines (2 by default) */
  73237. get majorLineTickness(): number;
  73238. set majorLineTickness(value: number);
  73239. /** Gets or sets the color of major lines (White by default) */
  73240. get majorLineColor(): string;
  73241. set majorLineColor(value: string);
  73242. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73243. get majorLineFrequency(): number;
  73244. set majorLineFrequency(value: number);
  73245. /**
  73246. * Creates a new GridDisplayRectangle
  73247. * @param name defines the control name
  73248. */
  73249. constructor(name?: string | undefined);
  73250. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73251. protected _getTypeName(): string;
  73252. }
  73253. }
  73254. declare module BABYLON.GUI {
  73255. /**
  73256. * Class used to create slider controls based on images
  73257. */
  73258. export class ImageBasedSlider extends BaseSlider {
  73259. name?: string | undefined;
  73260. private _backgroundImage;
  73261. private _thumbImage;
  73262. private _valueBarImage;
  73263. private _tempMeasure;
  73264. get displayThumb(): boolean;
  73265. set displayThumb(value: boolean);
  73266. /**
  73267. * Gets or sets the image used to render the background
  73268. */
  73269. get backgroundImage(): Image;
  73270. set backgroundImage(value: Image);
  73271. /**
  73272. * Gets or sets the image used to render the value bar
  73273. */
  73274. get valueBarImage(): Image;
  73275. set valueBarImage(value: Image);
  73276. /**
  73277. * Gets or sets the image used to render the thumb
  73278. */
  73279. get thumbImage(): Image;
  73280. set thumbImage(value: Image);
  73281. /**
  73282. * Creates a new ImageBasedSlider
  73283. * @param name defines the control name
  73284. */
  73285. constructor(name?: string | undefined);
  73286. protected _getTypeName(): string;
  73287. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73288. }
  73289. }
  73290. declare module BABYLON.GUI {
  73291. /**
  73292. * Forcing an export so that this code will execute
  73293. * @hidden
  73294. */
  73295. const name = "Statics";
  73296. }
  73297. declare module BABYLON.GUI {
  73298. /**
  73299. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73300. */
  73301. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73302. /**
  73303. * Define the instrumented AdvancedDynamicTexture.
  73304. */
  73305. texture: AdvancedDynamicTexture;
  73306. private _captureRenderTime;
  73307. private _renderTime;
  73308. private _captureLayoutTime;
  73309. private _layoutTime;
  73310. private _onBeginRenderObserver;
  73311. private _onEndRenderObserver;
  73312. private _onBeginLayoutObserver;
  73313. private _onEndLayoutObserver;
  73314. /**
  73315. * Gets the perf counter used to capture render time
  73316. */
  73317. get renderTimeCounter(): BABYLON.PerfCounter;
  73318. /**
  73319. * Gets the perf counter used to capture layout time
  73320. */
  73321. get layoutTimeCounter(): BABYLON.PerfCounter;
  73322. /**
  73323. * Enable or disable the render time capture
  73324. */
  73325. get captureRenderTime(): boolean;
  73326. set captureRenderTime(value: boolean);
  73327. /**
  73328. * Enable or disable the layout time capture
  73329. */
  73330. get captureLayoutTime(): boolean;
  73331. set captureLayoutTime(value: boolean);
  73332. /**
  73333. * Instantiates a new advanced dynamic texture instrumentation.
  73334. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73335. * @param texture Defines the AdvancedDynamicTexture to instrument
  73336. */
  73337. constructor(
  73338. /**
  73339. * Define the instrumented AdvancedDynamicTexture.
  73340. */
  73341. texture: AdvancedDynamicTexture);
  73342. /**
  73343. * Dispose and release associated resources.
  73344. */
  73345. dispose(): void;
  73346. }
  73347. }
  73348. declare module BABYLON.GUI {
  73349. /**
  73350. * Class used to load GUI via XML.
  73351. */
  73352. export class XmlLoader {
  73353. private _nodes;
  73354. private _nodeTypes;
  73355. private _isLoaded;
  73356. private _objectAttributes;
  73357. private _parentClass;
  73358. /**
  73359. * Create a new xml loader
  73360. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73361. */
  73362. constructor(parentClass?: null);
  73363. private _getChainElement;
  73364. private _getClassAttribute;
  73365. private _createGuiElement;
  73366. private _parseGrid;
  73367. private _parseElement;
  73368. private _prepareSourceElement;
  73369. private _parseElementsFromSource;
  73370. private _parseXml;
  73371. /**
  73372. * Gets if the loading has finished.
  73373. * @returns whether the loading has finished or not
  73374. */
  73375. isLoaded(): boolean;
  73376. /**
  73377. * Gets a loaded node / control by id.
  73378. * @param id the Controls id set in the xml
  73379. * @returns element of type Control
  73380. */
  73381. getNodeById(id: string): any;
  73382. /**
  73383. * Gets all loaded nodes / controls
  73384. * @returns Array of controls
  73385. */
  73386. getNodes(): any;
  73387. /**
  73388. * Initiates the xml layout loading
  73389. * @param xmlFile defines the xml layout to load
  73390. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73391. * @param callback defines the callback called on layout load.
  73392. */
  73393. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73394. }
  73395. }
  73396. declare module BABYLON.GUI {
  73397. /**
  73398. * Class used to create containers for controls
  73399. */
  73400. export class Container3D extends Control3D {
  73401. private _blockLayout;
  73402. /**
  73403. * Gets the list of child controls
  73404. */
  73405. protected _children: Control3D[];
  73406. /**
  73407. * Gets the list of child controls
  73408. */
  73409. get children(): Array<Control3D>;
  73410. /**
  73411. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73412. * This is helpful to optimize layout operation when adding multiple children in a row
  73413. */
  73414. get blockLayout(): boolean;
  73415. set blockLayout(value: boolean);
  73416. /**
  73417. * Creates a new container
  73418. * @param name defines the container name
  73419. */
  73420. constructor(name?: string);
  73421. /**
  73422. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73423. * @returns the current container
  73424. */
  73425. updateLayout(): Container3D;
  73426. /**
  73427. * Gets a boolean indicating if the given control is in the children of this control
  73428. * @param control defines the control to check
  73429. * @returns true if the control is in the child list
  73430. */
  73431. containsControl(control: Control3D): boolean;
  73432. /**
  73433. * Adds a control to the children of this control
  73434. * @param control defines the control to add
  73435. * @returns the current container
  73436. */
  73437. addControl(control: Control3D): Container3D;
  73438. /**
  73439. * This function will be called everytime a new control is added
  73440. */
  73441. protected _arrangeChildren(): void;
  73442. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73443. /**
  73444. * Removes a control from the children of this control
  73445. * @param control defines the control to remove
  73446. * @returns the current container
  73447. */
  73448. removeControl(control: Control3D): Container3D;
  73449. protected _getTypeName(): string;
  73450. /**
  73451. * Releases all associated resources
  73452. */
  73453. dispose(): void;
  73454. /** Control rotation will remain unchanged */
  73455. static readonly UNSET_ORIENTATION: number;
  73456. /** Control will rotate to make it look at sphere central axis */
  73457. static readonly FACEORIGIN_ORIENTATION: number;
  73458. /** Control will rotate to make it look back at sphere central axis */
  73459. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73460. /** Control will rotate to look at z axis (0, 0, 1) */
  73461. static readonly FACEFORWARD_ORIENTATION: number;
  73462. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73463. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73464. }
  73465. }
  73466. declare module BABYLON.GUI {
  73467. /**
  73468. * Class used to manage 3D user interface
  73469. * @see http://doc.babylonjs.com/how_to/gui3d
  73470. */
  73471. export class GUI3DManager implements BABYLON.IDisposable {
  73472. private _scene;
  73473. private _sceneDisposeObserver;
  73474. private _utilityLayer;
  73475. private _rootContainer;
  73476. private _pointerObserver;
  73477. private _pointerOutObserver;
  73478. /** @hidden */
  73479. _lastPickedControl: Control3D;
  73480. /** @hidden */
  73481. _lastControlOver: {
  73482. [pointerId: number]: Control3D;
  73483. };
  73484. /** @hidden */
  73485. _lastControlDown: {
  73486. [pointerId: number]: Control3D;
  73487. };
  73488. /**
  73489. * BABYLON.Observable raised when the point picked by the pointer events changed
  73490. */
  73491. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73492. /** @hidden */
  73493. _sharedMaterials: {
  73494. [key: string]: BABYLON.Material;
  73495. };
  73496. /** Gets the hosting scene */
  73497. get scene(): BABYLON.Scene;
  73498. /** Gets associated utility layer */
  73499. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73500. /**
  73501. * Creates a new GUI3DManager
  73502. * @param scene
  73503. */
  73504. constructor(scene?: BABYLON.Scene);
  73505. private _handlePointerOut;
  73506. private _doPicking;
  73507. /**
  73508. * Gets the root container
  73509. */
  73510. get rootContainer(): Container3D;
  73511. /**
  73512. * Gets a boolean indicating if the given control is in the root child list
  73513. * @param control defines the control to check
  73514. * @returns true if the control is in the root child list
  73515. */
  73516. containsControl(control: Control3D): boolean;
  73517. /**
  73518. * Adds a control to the root child list
  73519. * @param control defines the control to add
  73520. * @returns the current manager
  73521. */
  73522. addControl(control: Control3D): GUI3DManager;
  73523. /**
  73524. * Removes a control from the root child list
  73525. * @param control defines the control to remove
  73526. * @returns the current container
  73527. */
  73528. removeControl(control: Control3D): GUI3DManager;
  73529. /**
  73530. * Releases all associated resources
  73531. */
  73532. dispose(): void;
  73533. }
  73534. }
  73535. declare module BABYLON.GUI {
  73536. /**
  73537. * Class used to transport BABYLON.Vector3 information for pointer events
  73538. */
  73539. export class Vector3WithInfo extends BABYLON.Vector3 {
  73540. /** defines the current mouse button index */
  73541. buttonIndex: number;
  73542. /**
  73543. * Creates a new Vector3WithInfo
  73544. * @param source defines the vector3 data to transport
  73545. * @param buttonIndex defines the current mouse button index
  73546. */
  73547. constructor(source: BABYLON.Vector3,
  73548. /** defines the current mouse button index */
  73549. buttonIndex?: number);
  73550. }
  73551. }
  73552. declare module BABYLON.GUI {
  73553. /**
  73554. * Class used as base class for controls
  73555. */
  73556. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73557. /** Defines the control name */
  73558. name?: string | undefined;
  73559. /** @hidden */
  73560. _host: GUI3DManager;
  73561. private _node;
  73562. private _downCount;
  73563. private _enterCount;
  73564. private _downPointerIds;
  73565. private _isVisible;
  73566. /** Gets or sets the control position in world space */
  73567. get position(): BABYLON.Vector3;
  73568. set position(value: BABYLON.Vector3);
  73569. /** Gets or sets the control scaling in world space */
  73570. get scaling(): BABYLON.Vector3;
  73571. set scaling(value: BABYLON.Vector3);
  73572. /** Callback used to start pointer enter animation */
  73573. pointerEnterAnimation: () => void;
  73574. /** Callback used to start pointer out animation */
  73575. pointerOutAnimation: () => void;
  73576. /** Callback used to start pointer down animation */
  73577. pointerDownAnimation: () => void;
  73578. /** Callback used to start pointer up animation */
  73579. pointerUpAnimation: () => void;
  73580. /**
  73581. * An event triggered when the pointer move over the control
  73582. */
  73583. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73584. /**
  73585. * An event triggered when the pointer move out of the control
  73586. */
  73587. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73588. /**
  73589. * An event triggered when the pointer taps the control
  73590. */
  73591. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73592. /**
  73593. * An event triggered when pointer is up
  73594. */
  73595. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73596. /**
  73597. * An event triggered when a control is clicked on (with a mouse)
  73598. */
  73599. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73600. /**
  73601. * An event triggered when pointer enters the control
  73602. */
  73603. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73604. /**
  73605. * Gets or sets the parent container
  73606. */
  73607. parent: BABYLON.Nullable<Container3D>;
  73608. private _behaviors;
  73609. /**
  73610. * Gets the list of attached behaviors
  73611. * @see http://doc.babylonjs.com/features/behaviour
  73612. */
  73613. get behaviors(): BABYLON.Behavior<Control3D>[];
  73614. /**
  73615. * Attach a behavior to the control
  73616. * @see http://doc.babylonjs.com/features/behaviour
  73617. * @param behavior defines the behavior to attach
  73618. * @returns the current control
  73619. */
  73620. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73621. /**
  73622. * Remove an attached behavior
  73623. * @see http://doc.babylonjs.com/features/behaviour
  73624. * @param behavior defines the behavior to attach
  73625. * @returns the current control
  73626. */
  73627. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73628. /**
  73629. * Gets an attached behavior by name
  73630. * @param name defines the name of the behavior to look for
  73631. * @see http://doc.babylonjs.com/features/behaviour
  73632. * @returns null if behavior was not found else the requested behavior
  73633. */
  73634. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73635. /** Gets or sets a boolean indicating if the control is visible */
  73636. get isVisible(): boolean;
  73637. set isVisible(value: boolean);
  73638. /**
  73639. * Creates a new control
  73640. * @param name defines the control name
  73641. */
  73642. constructor(
  73643. /** Defines the control name */
  73644. name?: string | undefined);
  73645. /**
  73646. * Gets a string representing the class name
  73647. */
  73648. get typeName(): string;
  73649. /**
  73650. * Get the current class name of the control.
  73651. * @returns current class name
  73652. */
  73653. getClassName(): string;
  73654. protected _getTypeName(): string;
  73655. /**
  73656. * Gets the transform node used by this control
  73657. */
  73658. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73659. /**
  73660. * Gets the mesh used to render this control
  73661. */
  73662. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73663. /**
  73664. * Link the control as child of the given node
  73665. * @param node defines the node to link to. Use null to unlink the control
  73666. * @returns the current control
  73667. */
  73668. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73669. /** @hidden **/
  73670. _prepareNode(scene: BABYLON.Scene): void;
  73671. /**
  73672. * Node creation.
  73673. * Can be overriden by children
  73674. * @param scene defines the scene where the node must be attached
  73675. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73676. */
  73677. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73678. /**
  73679. * Affect a material to the given mesh
  73680. * @param mesh defines the mesh which will represent the control
  73681. */
  73682. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73683. /** @hidden */
  73684. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73685. /** @hidden */
  73686. _onPointerEnter(target: Control3D): boolean;
  73687. /** @hidden */
  73688. _onPointerOut(target: Control3D): void;
  73689. /** @hidden */
  73690. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73691. /** @hidden */
  73692. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73693. /** @hidden */
  73694. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73695. /** @hidden */
  73696. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73697. /** @hidden */
  73698. _disposeNode(): void;
  73699. /**
  73700. * Releases all associated resources
  73701. */
  73702. dispose(): void;
  73703. }
  73704. }
  73705. declare module BABYLON.GUI {
  73706. /**
  73707. * Class used as a root to all buttons
  73708. */
  73709. export class AbstractButton3D extends Control3D {
  73710. /**
  73711. * Creates a new button
  73712. * @param name defines the control name
  73713. */
  73714. constructor(name?: string);
  73715. protected _getTypeName(): string;
  73716. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73717. }
  73718. }
  73719. declare module BABYLON.GUI {
  73720. /**
  73721. * Class used to create a button in 3D
  73722. */
  73723. export class Button3D extends AbstractButton3D {
  73724. /** @hidden */
  73725. protected _currentMaterial: BABYLON.Material;
  73726. private _facadeTexture;
  73727. private _content;
  73728. private _contentResolution;
  73729. private _contentScaleRatio;
  73730. /**
  73731. * Gets or sets the texture resolution used to render content (512 by default)
  73732. */
  73733. get contentResolution(): BABYLON.int;
  73734. set contentResolution(value: BABYLON.int);
  73735. /**
  73736. * Gets or sets the texture scale ratio used to render content (2 by default)
  73737. */
  73738. get contentScaleRatio(): number;
  73739. set contentScaleRatio(value: number);
  73740. protected _disposeFacadeTexture(): void;
  73741. protected _resetContent(): void;
  73742. /**
  73743. * Creates a new button
  73744. * @param name defines the control name
  73745. */
  73746. constructor(name?: string);
  73747. /**
  73748. * Gets or sets the GUI 2D content used to display the button's facade
  73749. */
  73750. get content(): Control;
  73751. set content(value: Control);
  73752. /**
  73753. * Apply the facade texture (created from the content property).
  73754. * This function can be overloaded by child classes
  73755. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73756. */
  73757. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73758. protected _getTypeName(): string;
  73759. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73760. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73761. /**
  73762. * Releases all associated resources
  73763. */
  73764. dispose(): void;
  73765. }
  73766. }
  73767. declare module BABYLON.GUI {
  73768. /**
  73769. * Abstract class used to create a container panel deployed on the surface of a volume
  73770. */
  73771. export abstract class VolumeBasedPanel extends Container3D {
  73772. private _columns;
  73773. private _rows;
  73774. private _rowThenColum;
  73775. private _orientation;
  73776. protected _cellWidth: number;
  73777. protected _cellHeight: number;
  73778. /**
  73779. * Gets or sets the distance between elements
  73780. */
  73781. margin: number;
  73782. /**
  73783. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73784. * | Value | Type | Description |
  73785. * | ----- | ----------------------------------- | ----------- |
  73786. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73787. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73788. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73789. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73790. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73791. */
  73792. get orientation(): number;
  73793. set orientation(value: number);
  73794. /**
  73795. * Gets or sets the number of columns requested (10 by default).
  73796. * The panel will automatically compute the number of rows based on number of child controls.
  73797. */
  73798. get columns(): BABYLON.int;
  73799. set columns(value: BABYLON.int);
  73800. /**
  73801. * Gets or sets a the number of rows requested.
  73802. * The panel will automatically compute the number of columns based on number of child controls.
  73803. */
  73804. get rows(): BABYLON.int;
  73805. set rows(value: BABYLON.int);
  73806. /**
  73807. * Creates new VolumeBasedPanel
  73808. */
  73809. constructor();
  73810. protected _arrangeChildren(): void;
  73811. /** Child classes must implement this function to provide correct control positioning */
  73812. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73813. /** Child classes can implement this function to provide additional processing */
  73814. protected _finalProcessing(): void;
  73815. }
  73816. }
  73817. declare module BABYLON.GUI {
  73818. /**
  73819. * Class used to create a container panel deployed on the surface of a cylinder
  73820. */
  73821. export class CylinderPanel extends VolumeBasedPanel {
  73822. private _radius;
  73823. /**
  73824. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73825. */
  73826. get radius(): BABYLON.float;
  73827. set radius(value: BABYLON.float);
  73828. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73829. private _cylindricalMapping;
  73830. }
  73831. }
  73832. declare module BABYLON.GUI {
  73833. /** @hidden */
  73834. export var fluentVertexShader: {
  73835. name: string;
  73836. shader: string;
  73837. };
  73838. }
  73839. declare module BABYLON.GUI {
  73840. /** @hidden */
  73841. export var fluentPixelShader: {
  73842. name: string;
  73843. shader: string;
  73844. };
  73845. }
  73846. declare module BABYLON.GUI {
  73847. /** @hidden */
  73848. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73849. INNERGLOW: boolean;
  73850. BORDER: boolean;
  73851. HOVERLIGHT: boolean;
  73852. TEXTURE: boolean;
  73853. constructor();
  73854. }
  73855. /**
  73856. * Class used to render controls with fluent desgin
  73857. */
  73858. export class FluentMaterial extends BABYLON.PushMaterial {
  73859. /**
  73860. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73861. */
  73862. innerGlowColorIntensity: number;
  73863. /**
  73864. * Gets or sets the inner glow color (white by default)
  73865. */
  73866. innerGlowColor: BABYLON.Color3;
  73867. /**
  73868. * Gets or sets alpha value (default is 1.0)
  73869. */
  73870. alpha: number;
  73871. /**
  73872. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73873. */
  73874. albedoColor: BABYLON.Color3;
  73875. /**
  73876. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73877. */
  73878. renderBorders: boolean;
  73879. /**
  73880. * Gets or sets border width (default is 0.5)
  73881. */
  73882. borderWidth: number;
  73883. /**
  73884. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73885. */
  73886. edgeSmoothingValue: number;
  73887. /**
  73888. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73889. */
  73890. borderMinValue: number;
  73891. /**
  73892. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73893. */
  73894. renderHoverLight: boolean;
  73895. /**
  73896. * Gets or sets the radius used to render the hover light (default is 1.0)
  73897. */
  73898. hoverRadius: number;
  73899. /**
  73900. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73901. */
  73902. hoverColor: BABYLON.Color4;
  73903. /**
  73904. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73905. */
  73906. hoverPosition: BABYLON.Vector3;
  73907. private _albedoTexture;
  73908. /** Gets or sets the texture to use for albedo color */
  73909. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73910. /**
  73911. * Creates a new Fluent material
  73912. * @param name defines the name of the material
  73913. * @param scene defines the hosting scene
  73914. */
  73915. constructor(name: string, scene: BABYLON.Scene);
  73916. needAlphaBlending(): boolean;
  73917. needAlphaTesting(): boolean;
  73918. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73919. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73920. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73921. getActiveTextures(): BABYLON.BaseTexture[];
  73922. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73923. dispose(forceDisposeEffect?: boolean): void;
  73924. clone(name: string): FluentMaterial;
  73925. serialize(): any;
  73926. getClassName(): string;
  73927. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73928. }
  73929. }
  73930. declare module BABYLON.GUI {
  73931. /**
  73932. * Class used to create a holographic button in 3D
  73933. */
  73934. export class HolographicButton extends Button3D {
  73935. private _backPlate;
  73936. private _textPlate;
  73937. private _frontPlate;
  73938. private _text;
  73939. private _imageUrl;
  73940. private _shareMaterials;
  73941. private _frontMaterial;
  73942. private _backMaterial;
  73943. private _plateMaterial;
  73944. private _pickedPointObserver;
  73945. private _tooltipFade;
  73946. private _tooltipTextBlock;
  73947. private _tooltipTexture;
  73948. private _tooltipMesh;
  73949. private _tooltipHoverObserver;
  73950. private _tooltipOutObserver;
  73951. private _disposeTooltip;
  73952. /**
  73953. * Rendering ground id of all the mesh in the button
  73954. */
  73955. set renderingGroupId(id: number);
  73956. get renderingGroupId(): number;
  73957. /**
  73958. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73959. */
  73960. set tooltipText(text: BABYLON.Nullable<string>);
  73961. get tooltipText(): BABYLON.Nullable<string>;
  73962. /**
  73963. * Gets or sets text for the button
  73964. */
  73965. get text(): string;
  73966. set text(value: string);
  73967. /**
  73968. * Gets or sets the image url for the button
  73969. */
  73970. get imageUrl(): string;
  73971. set imageUrl(value: string);
  73972. /**
  73973. * Gets the back material used by this button
  73974. */
  73975. get backMaterial(): FluentMaterial;
  73976. /**
  73977. * Gets the front material used by this button
  73978. */
  73979. get frontMaterial(): FluentMaterial;
  73980. /**
  73981. * Gets the plate material used by this button
  73982. */
  73983. get plateMaterial(): BABYLON.StandardMaterial;
  73984. /**
  73985. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73986. */
  73987. get shareMaterials(): boolean;
  73988. /**
  73989. * Creates a new button
  73990. * @param name defines the control name
  73991. */
  73992. constructor(name?: string, shareMaterials?: boolean);
  73993. protected _getTypeName(): string;
  73994. private _rebuildContent;
  73995. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73996. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73997. private _createBackMaterial;
  73998. private _createFrontMaterial;
  73999. private _createPlateMaterial;
  74000. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74001. /**
  74002. * Releases all associated resources
  74003. */
  74004. dispose(): void;
  74005. }
  74006. }
  74007. declare module BABYLON.GUI {
  74008. /**
  74009. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74010. */
  74011. export class MeshButton3D extends Button3D {
  74012. /** @hidden */
  74013. protected _currentMesh: BABYLON.Mesh;
  74014. /**
  74015. * Creates a new 3D button based on a mesh
  74016. * @param mesh mesh to become a 3D button
  74017. * @param name defines the control name
  74018. */
  74019. constructor(mesh: BABYLON.Mesh, name?: string);
  74020. protected _getTypeName(): string;
  74021. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74022. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74023. }
  74024. }
  74025. declare module BABYLON.GUI {
  74026. /**
  74027. * Class used to create a container panel deployed on the surface of a plane
  74028. */
  74029. export class PlanePanel extends VolumeBasedPanel {
  74030. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74031. }
  74032. }
  74033. declare module BABYLON.GUI {
  74034. /**
  74035. * Class used to create a container panel where items get randomized planar mapping
  74036. */
  74037. export class ScatterPanel extends VolumeBasedPanel {
  74038. private _iteration;
  74039. /**
  74040. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74041. */
  74042. get iteration(): BABYLON.float;
  74043. set iteration(value: BABYLON.float);
  74044. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74045. private _scatterMapping;
  74046. protected _finalProcessing(): void;
  74047. }
  74048. }
  74049. declare module BABYLON.GUI {
  74050. /**
  74051. * Class used to create a container panel deployed on the surface of a sphere
  74052. */
  74053. export class SpherePanel extends VolumeBasedPanel {
  74054. private _radius;
  74055. /**
  74056. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74057. */
  74058. get radius(): BABYLON.float;
  74059. set radius(value: BABYLON.float);
  74060. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74061. private _sphericalMapping;
  74062. }
  74063. }
  74064. declare module BABYLON.GUI {
  74065. /**
  74066. * Class used to create a stack panel in 3D on XY plane
  74067. */
  74068. export class StackPanel3D extends Container3D {
  74069. private _isVertical;
  74070. /**
  74071. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74072. */
  74073. get isVertical(): boolean;
  74074. set isVertical(value: boolean);
  74075. /**
  74076. * Gets or sets the distance between elements
  74077. */
  74078. margin: number;
  74079. /**
  74080. * Creates new StackPanel
  74081. * @param isVertical
  74082. */
  74083. constructor(isVertical?: boolean);
  74084. protected _arrangeChildren(): void;
  74085. }
  74086. }
  74087. declare module BABYLON {
  74088. /**
  74089. * Configuration for glTF validation
  74090. */
  74091. export interface IGLTFValidationConfiguration {
  74092. /**
  74093. * The url of the glTF validator.
  74094. */
  74095. url: string;
  74096. }
  74097. /**
  74098. * glTF validation
  74099. */
  74100. export class GLTFValidation {
  74101. /**
  74102. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74103. */
  74104. static Configuration: IGLTFValidationConfiguration;
  74105. private static _LoadScriptPromise;
  74106. /**
  74107. * Validate a glTF asset using the glTF-Validator.
  74108. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74109. * @param rootUrl The root url for the glTF
  74110. * @param fileName The file name for the glTF
  74111. * @param getExternalResource The callback to get external resources for the glTF validator
  74112. * @returns A promise that resolves with the glTF validation results once complete
  74113. */
  74114. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74115. }
  74116. }
  74117. declare module BABYLON {
  74118. /**
  74119. * Mode that determines the coordinate system to use.
  74120. */
  74121. export enum GLTFLoaderCoordinateSystemMode {
  74122. /**
  74123. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74124. */
  74125. AUTO = 0,
  74126. /**
  74127. * Sets the useRightHandedSystem flag on the scene.
  74128. */
  74129. FORCE_RIGHT_HANDED = 1
  74130. }
  74131. /**
  74132. * Mode that determines what animations will start.
  74133. */
  74134. export enum GLTFLoaderAnimationStartMode {
  74135. /**
  74136. * No animation will start.
  74137. */
  74138. NONE = 0,
  74139. /**
  74140. * The first animation will start.
  74141. */
  74142. FIRST = 1,
  74143. /**
  74144. * All animations will start.
  74145. */
  74146. ALL = 2
  74147. }
  74148. /**
  74149. * Interface that contains the data for the glTF asset.
  74150. */
  74151. export interface IGLTFLoaderData {
  74152. /**
  74153. * The object that represents the glTF JSON.
  74154. */
  74155. json: Object;
  74156. /**
  74157. * The BIN chunk of a binary glTF.
  74158. */
  74159. bin: Nullable<IDataBuffer>;
  74160. }
  74161. /**
  74162. * Interface for extending the loader.
  74163. */
  74164. export interface IGLTFLoaderExtension {
  74165. /**
  74166. * The name of this extension.
  74167. */
  74168. readonly name: string;
  74169. /**
  74170. * Defines whether this extension is enabled.
  74171. */
  74172. enabled: boolean;
  74173. /**
  74174. * Defines the order of this extension.
  74175. * The loader sorts the extensions using these values when loading.
  74176. */
  74177. order?: number;
  74178. }
  74179. /**
  74180. * Loader state.
  74181. */
  74182. export enum GLTFLoaderState {
  74183. /**
  74184. * The asset is loading.
  74185. */
  74186. LOADING = 0,
  74187. /**
  74188. * The asset is ready for rendering.
  74189. */
  74190. READY = 1,
  74191. /**
  74192. * The asset is completely loaded.
  74193. */
  74194. COMPLETE = 2
  74195. }
  74196. /** @hidden */
  74197. export interface IImportMeshAsyncOutput {
  74198. meshes: AbstractMesh[];
  74199. particleSystems: IParticleSystem[];
  74200. skeletons: Skeleton[];
  74201. animationGroups: AnimationGroup[];
  74202. lights: Light[];
  74203. transformNodes: TransformNode[];
  74204. }
  74205. /** @hidden */
  74206. export interface IGLTFLoader extends IDisposable {
  74207. readonly state: Nullable<GLTFLoaderState>;
  74208. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74209. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74210. }
  74211. /**
  74212. * File loader for loading glTF files into a scene.
  74213. */
  74214. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74215. /** @hidden */
  74216. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74217. /** @hidden */
  74218. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74219. /**
  74220. * Raised when the asset has been parsed
  74221. */
  74222. onParsedObservable: Observable<IGLTFLoaderData>;
  74223. private _onParsedObserver;
  74224. /**
  74225. * Raised when the asset has been parsed
  74226. */
  74227. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74228. /**
  74229. * 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.
  74230. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74231. * Defaults to true.
  74232. * @hidden
  74233. */
  74234. static IncrementalLoading: boolean;
  74235. /**
  74236. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74237. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74238. * @hidden
  74239. */
  74240. static HomogeneousCoordinates: boolean;
  74241. /**
  74242. * The coordinate system mode. Defaults to AUTO.
  74243. */
  74244. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74245. /**
  74246. * The animation start mode. Defaults to FIRST.
  74247. */
  74248. animationStartMode: GLTFLoaderAnimationStartMode;
  74249. /**
  74250. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74251. */
  74252. compileMaterials: boolean;
  74253. /**
  74254. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74255. */
  74256. useClipPlane: boolean;
  74257. /**
  74258. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74259. */
  74260. compileShadowGenerators: boolean;
  74261. /**
  74262. * Defines if the Alpha blended materials are only applied as coverage.
  74263. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74264. * If true, no extra effects are applied to transparent pixels.
  74265. */
  74266. transparencyAsCoverage: boolean;
  74267. /**
  74268. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74269. * Enabling will disable offline support and glTF validator.
  74270. * Defaults to false.
  74271. */
  74272. useRangeRequests: boolean;
  74273. /**
  74274. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74275. */
  74276. createInstances: boolean;
  74277. /**
  74278. * Function called before loading a url referenced by the asset.
  74279. */
  74280. preprocessUrlAsync: (url: string) => Promise<string>;
  74281. /**
  74282. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74283. */
  74284. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74285. private _onMeshLoadedObserver;
  74286. /**
  74287. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74288. */
  74289. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74290. /**
  74291. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74292. */
  74293. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74294. private _onTextureLoadedObserver;
  74295. /**
  74296. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74297. */
  74298. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74299. /**
  74300. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74301. */
  74302. readonly onMaterialLoadedObservable: Observable<Material>;
  74303. private _onMaterialLoadedObserver;
  74304. /**
  74305. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74306. */
  74307. set onMaterialLoaded(callback: (material: Material) => void);
  74308. /**
  74309. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74310. */
  74311. readonly onCameraLoadedObservable: Observable<Camera>;
  74312. private _onCameraLoadedObserver;
  74313. /**
  74314. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74315. */
  74316. set onCameraLoaded(callback: (camera: Camera) => void);
  74317. /**
  74318. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74319. * For assets with LODs, raised when all of the LODs are complete.
  74320. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74321. */
  74322. readonly onCompleteObservable: Observable<void>;
  74323. private _onCompleteObserver;
  74324. /**
  74325. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74326. * For assets with LODs, raised when all of the LODs are complete.
  74327. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74328. */
  74329. set onComplete(callback: () => void);
  74330. /**
  74331. * Observable raised when an error occurs.
  74332. */
  74333. readonly onErrorObservable: Observable<any>;
  74334. private _onErrorObserver;
  74335. /**
  74336. * Callback raised when an error occurs.
  74337. */
  74338. set onError(callback: (reason: any) => void);
  74339. /**
  74340. * Observable raised after the loader is disposed.
  74341. */
  74342. readonly onDisposeObservable: Observable<void>;
  74343. private _onDisposeObserver;
  74344. /**
  74345. * Callback raised after the loader is disposed.
  74346. */
  74347. set onDispose(callback: () => void);
  74348. /**
  74349. * Observable raised after a loader extension is created.
  74350. * Set additional options for a loader extension in this event.
  74351. */
  74352. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74353. private _onExtensionLoadedObserver;
  74354. /**
  74355. * Callback raised after a loader extension is created.
  74356. */
  74357. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74358. /**
  74359. * Defines if the loader logging is enabled.
  74360. */
  74361. get loggingEnabled(): boolean;
  74362. set loggingEnabled(value: boolean);
  74363. /**
  74364. * Defines if the loader should capture performance counters.
  74365. */
  74366. get capturePerformanceCounters(): boolean;
  74367. set capturePerformanceCounters(value: boolean);
  74368. /**
  74369. * Defines if the loader should validate the asset.
  74370. */
  74371. validate: boolean;
  74372. /**
  74373. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74374. */
  74375. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74376. private _onValidatedObserver;
  74377. /**
  74378. * Callback raised after a loader extension is created.
  74379. */
  74380. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74381. private _loader;
  74382. /**
  74383. * Name of the loader ("gltf")
  74384. */
  74385. name: string;
  74386. /** @hidden */
  74387. extensions: ISceneLoaderPluginExtensions;
  74388. /**
  74389. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74390. */
  74391. dispose(): void;
  74392. /** @hidden */
  74393. _clear(): void;
  74394. /** @hidden */
  74395. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74396. /** @hidden */
  74397. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74398. /** @hidden */
  74399. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74400. meshes: AbstractMesh[];
  74401. particleSystems: IParticleSystem[];
  74402. skeletons: Skeleton[];
  74403. animationGroups: AnimationGroup[];
  74404. }>;
  74405. /** @hidden */
  74406. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74407. /** @hidden */
  74408. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74409. /** @hidden */
  74410. canDirectLoad(data: string): boolean;
  74411. /** @hidden */
  74412. directLoad(scene: Scene, data: string): any;
  74413. /**
  74414. * The callback that allows custom handling of the root url based on the response url.
  74415. * @param rootUrl the original root url
  74416. * @param responseURL the response url if available
  74417. * @returns the new root url
  74418. */
  74419. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74420. /** @hidden */
  74421. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74422. /**
  74423. * The loader state or null if the loader is not active.
  74424. */
  74425. get loaderState(): Nullable<GLTFLoaderState>;
  74426. /**
  74427. * Returns a promise that resolves when the asset is completely loaded.
  74428. * @returns a promise that resolves when the asset is completely loaded.
  74429. */
  74430. whenCompleteAsync(): Promise<void>;
  74431. private _validate;
  74432. private _getLoader;
  74433. private _parseJson;
  74434. private _unpackBinaryAsync;
  74435. private _unpackBinaryV1Async;
  74436. private _unpackBinaryV2Async;
  74437. private static _parseVersion;
  74438. private static _compareVersion;
  74439. private static readonly _logSpaces;
  74440. private _logIndentLevel;
  74441. private _loggingEnabled;
  74442. /** @hidden */
  74443. _log: (message: string) => void;
  74444. /** @hidden */
  74445. _logOpen(message: string): void;
  74446. /** @hidden */
  74447. _logClose(): void;
  74448. private _logEnabled;
  74449. private _logDisabled;
  74450. private _capturePerformanceCounters;
  74451. /** @hidden */
  74452. _startPerformanceCounter: (counterName: string) => void;
  74453. /** @hidden */
  74454. _endPerformanceCounter: (counterName: string) => void;
  74455. private _startPerformanceCounterEnabled;
  74456. private _startPerformanceCounterDisabled;
  74457. private _endPerformanceCounterEnabled;
  74458. private _endPerformanceCounterDisabled;
  74459. }
  74460. }
  74461. declare module BABYLON.GLTF1 {
  74462. /**
  74463. * Enums
  74464. * @hidden
  74465. */
  74466. export enum EComponentType {
  74467. BYTE = 5120,
  74468. UNSIGNED_BYTE = 5121,
  74469. SHORT = 5122,
  74470. UNSIGNED_SHORT = 5123,
  74471. FLOAT = 5126
  74472. }
  74473. /** @hidden */
  74474. export enum EShaderType {
  74475. FRAGMENT = 35632,
  74476. VERTEX = 35633
  74477. }
  74478. /** @hidden */
  74479. export enum EParameterType {
  74480. BYTE = 5120,
  74481. UNSIGNED_BYTE = 5121,
  74482. SHORT = 5122,
  74483. UNSIGNED_SHORT = 5123,
  74484. INT = 5124,
  74485. UNSIGNED_INT = 5125,
  74486. FLOAT = 5126,
  74487. FLOAT_VEC2 = 35664,
  74488. FLOAT_VEC3 = 35665,
  74489. FLOAT_VEC4 = 35666,
  74490. INT_VEC2 = 35667,
  74491. INT_VEC3 = 35668,
  74492. INT_VEC4 = 35669,
  74493. BOOL = 35670,
  74494. BOOL_VEC2 = 35671,
  74495. BOOL_VEC3 = 35672,
  74496. BOOL_VEC4 = 35673,
  74497. FLOAT_MAT2 = 35674,
  74498. FLOAT_MAT3 = 35675,
  74499. FLOAT_MAT4 = 35676,
  74500. SAMPLER_2D = 35678
  74501. }
  74502. /** @hidden */
  74503. export enum ETextureWrapMode {
  74504. CLAMP_TO_EDGE = 33071,
  74505. MIRRORED_REPEAT = 33648,
  74506. REPEAT = 10497
  74507. }
  74508. /** @hidden */
  74509. export enum ETextureFilterType {
  74510. NEAREST = 9728,
  74511. LINEAR = 9728,
  74512. NEAREST_MIPMAP_NEAREST = 9984,
  74513. LINEAR_MIPMAP_NEAREST = 9985,
  74514. NEAREST_MIPMAP_LINEAR = 9986,
  74515. LINEAR_MIPMAP_LINEAR = 9987
  74516. }
  74517. /** @hidden */
  74518. export enum ETextureFormat {
  74519. ALPHA = 6406,
  74520. RGB = 6407,
  74521. RGBA = 6408,
  74522. LUMINANCE = 6409,
  74523. LUMINANCE_ALPHA = 6410
  74524. }
  74525. /** @hidden */
  74526. export enum ECullingType {
  74527. FRONT = 1028,
  74528. BACK = 1029,
  74529. FRONT_AND_BACK = 1032
  74530. }
  74531. /** @hidden */
  74532. export enum EBlendingFunction {
  74533. ZERO = 0,
  74534. ONE = 1,
  74535. SRC_COLOR = 768,
  74536. ONE_MINUS_SRC_COLOR = 769,
  74537. DST_COLOR = 774,
  74538. ONE_MINUS_DST_COLOR = 775,
  74539. SRC_ALPHA = 770,
  74540. ONE_MINUS_SRC_ALPHA = 771,
  74541. DST_ALPHA = 772,
  74542. ONE_MINUS_DST_ALPHA = 773,
  74543. CONSTANT_COLOR = 32769,
  74544. ONE_MINUS_CONSTANT_COLOR = 32770,
  74545. CONSTANT_ALPHA = 32771,
  74546. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74547. SRC_ALPHA_SATURATE = 776
  74548. }
  74549. /** @hidden */
  74550. export interface IGLTFProperty {
  74551. extensions?: {
  74552. [key: string]: any;
  74553. };
  74554. extras?: Object;
  74555. }
  74556. /** @hidden */
  74557. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74558. name?: string;
  74559. }
  74560. /** @hidden */
  74561. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74562. bufferView: string;
  74563. byteOffset: number;
  74564. byteStride: number;
  74565. count: number;
  74566. type: string;
  74567. componentType: EComponentType;
  74568. max?: number[];
  74569. min?: number[];
  74570. name?: string;
  74571. }
  74572. /** @hidden */
  74573. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74574. buffer: string;
  74575. byteOffset: number;
  74576. byteLength: number;
  74577. byteStride: number;
  74578. target?: number;
  74579. }
  74580. /** @hidden */
  74581. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74582. uri: string;
  74583. byteLength?: number;
  74584. type?: string;
  74585. }
  74586. /** @hidden */
  74587. export interface IGLTFShader extends IGLTFChildRootProperty {
  74588. uri: string;
  74589. type: EShaderType;
  74590. }
  74591. /** @hidden */
  74592. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74593. attributes: string[];
  74594. fragmentShader: string;
  74595. vertexShader: string;
  74596. }
  74597. /** @hidden */
  74598. export interface IGLTFTechniqueParameter {
  74599. type: number;
  74600. count?: number;
  74601. semantic?: string;
  74602. node?: string;
  74603. value?: number | boolean | string | Array<any>;
  74604. source?: string;
  74605. babylonValue?: any;
  74606. }
  74607. /** @hidden */
  74608. export interface IGLTFTechniqueCommonProfile {
  74609. lightingModel: string;
  74610. texcoordBindings: Object;
  74611. parameters?: Array<any>;
  74612. }
  74613. /** @hidden */
  74614. export interface IGLTFTechniqueStatesFunctions {
  74615. blendColor?: number[];
  74616. blendEquationSeparate?: number[];
  74617. blendFuncSeparate?: number[];
  74618. colorMask: boolean[];
  74619. cullFace: number[];
  74620. }
  74621. /** @hidden */
  74622. export interface IGLTFTechniqueStates {
  74623. enable: number[];
  74624. functions: IGLTFTechniqueStatesFunctions;
  74625. }
  74626. /** @hidden */
  74627. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74628. parameters: {
  74629. [key: string]: IGLTFTechniqueParameter;
  74630. };
  74631. program: string;
  74632. attributes: {
  74633. [key: string]: string;
  74634. };
  74635. uniforms: {
  74636. [key: string]: string;
  74637. };
  74638. states: IGLTFTechniqueStates;
  74639. }
  74640. /** @hidden */
  74641. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74642. technique?: string;
  74643. values: string[];
  74644. }
  74645. /** @hidden */
  74646. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74647. attributes: {
  74648. [key: string]: string;
  74649. };
  74650. indices: string;
  74651. material: string;
  74652. mode?: number;
  74653. }
  74654. /** @hidden */
  74655. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74656. primitives: IGLTFMeshPrimitive[];
  74657. }
  74658. /** @hidden */
  74659. export interface IGLTFImage extends IGLTFChildRootProperty {
  74660. uri: string;
  74661. }
  74662. /** @hidden */
  74663. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74664. magFilter?: number;
  74665. minFilter?: number;
  74666. wrapS?: number;
  74667. wrapT?: number;
  74668. }
  74669. /** @hidden */
  74670. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74671. sampler: string;
  74672. source: string;
  74673. format?: ETextureFormat;
  74674. internalFormat?: ETextureFormat;
  74675. target?: number;
  74676. type?: number;
  74677. babylonTexture?: Texture;
  74678. }
  74679. /** @hidden */
  74680. export interface IGLTFAmbienLight {
  74681. color?: number[];
  74682. }
  74683. /** @hidden */
  74684. export interface IGLTFDirectionalLight {
  74685. color?: number[];
  74686. }
  74687. /** @hidden */
  74688. export interface IGLTFPointLight {
  74689. color?: number[];
  74690. constantAttenuation?: number;
  74691. linearAttenuation?: number;
  74692. quadraticAttenuation?: number;
  74693. }
  74694. /** @hidden */
  74695. export interface IGLTFSpotLight {
  74696. color?: number[];
  74697. constantAttenuation?: number;
  74698. fallOfAngle?: number;
  74699. fallOffExponent?: number;
  74700. linearAttenuation?: number;
  74701. quadraticAttenuation?: number;
  74702. }
  74703. /** @hidden */
  74704. export interface IGLTFLight extends IGLTFChildRootProperty {
  74705. type: string;
  74706. }
  74707. /** @hidden */
  74708. export interface IGLTFCameraOrthographic {
  74709. xmag: number;
  74710. ymag: number;
  74711. zfar: number;
  74712. znear: number;
  74713. }
  74714. /** @hidden */
  74715. export interface IGLTFCameraPerspective {
  74716. aspectRatio: number;
  74717. yfov: number;
  74718. zfar: number;
  74719. znear: number;
  74720. }
  74721. /** @hidden */
  74722. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74723. type: string;
  74724. }
  74725. /** @hidden */
  74726. export interface IGLTFAnimationChannelTarget {
  74727. id: string;
  74728. path: string;
  74729. }
  74730. /** @hidden */
  74731. export interface IGLTFAnimationChannel {
  74732. sampler: string;
  74733. target: IGLTFAnimationChannelTarget;
  74734. }
  74735. /** @hidden */
  74736. export interface IGLTFAnimationSampler {
  74737. input: string;
  74738. output: string;
  74739. interpolation?: string;
  74740. }
  74741. /** @hidden */
  74742. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74743. channels?: IGLTFAnimationChannel[];
  74744. parameters?: {
  74745. [key: string]: string;
  74746. };
  74747. samplers?: {
  74748. [key: string]: IGLTFAnimationSampler;
  74749. };
  74750. }
  74751. /** @hidden */
  74752. export interface IGLTFNodeInstanceSkin {
  74753. skeletons: string[];
  74754. skin: string;
  74755. meshes: string[];
  74756. }
  74757. /** @hidden */
  74758. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74759. bindShapeMatrix: number[];
  74760. inverseBindMatrices: string;
  74761. jointNames: string[];
  74762. babylonSkeleton?: Skeleton;
  74763. }
  74764. /** @hidden */
  74765. export interface IGLTFNode extends IGLTFChildRootProperty {
  74766. camera?: string;
  74767. children: string[];
  74768. skin?: string;
  74769. jointName?: string;
  74770. light?: string;
  74771. matrix: number[];
  74772. mesh?: string;
  74773. meshes?: string[];
  74774. rotation?: number[];
  74775. scale?: number[];
  74776. translation?: number[];
  74777. babylonNode?: Node;
  74778. }
  74779. /** @hidden */
  74780. export interface IGLTFScene extends IGLTFChildRootProperty {
  74781. nodes: string[];
  74782. }
  74783. /** @hidden */
  74784. export interface IGLTFRuntime {
  74785. extensions: {
  74786. [key: string]: any;
  74787. };
  74788. accessors: {
  74789. [key: string]: IGLTFAccessor;
  74790. };
  74791. buffers: {
  74792. [key: string]: IGLTFBuffer;
  74793. };
  74794. bufferViews: {
  74795. [key: string]: IGLTFBufferView;
  74796. };
  74797. meshes: {
  74798. [key: string]: IGLTFMesh;
  74799. };
  74800. lights: {
  74801. [key: string]: IGLTFLight;
  74802. };
  74803. cameras: {
  74804. [key: string]: IGLTFCamera;
  74805. };
  74806. nodes: {
  74807. [key: string]: IGLTFNode;
  74808. };
  74809. images: {
  74810. [key: string]: IGLTFImage;
  74811. };
  74812. textures: {
  74813. [key: string]: IGLTFTexture;
  74814. };
  74815. shaders: {
  74816. [key: string]: IGLTFShader;
  74817. };
  74818. programs: {
  74819. [key: string]: IGLTFProgram;
  74820. };
  74821. samplers: {
  74822. [key: string]: IGLTFSampler;
  74823. };
  74824. techniques: {
  74825. [key: string]: IGLTFTechnique;
  74826. };
  74827. materials: {
  74828. [key: string]: IGLTFMaterial;
  74829. };
  74830. animations: {
  74831. [key: string]: IGLTFAnimation;
  74832. };
  74833. skins: {
  74834. [key: string]: IGLTFSkins;
  74835. };
  74836. currentScene?: Object;
  74837. scenes: {
  74838. [key: string]: IGLTFScene;
  74839. };
  74840. extensionsUsed: string[];
  74841. extensionsRequired?: string[];
  74842. buffersCount: number;
  74843. shaderscount: number;
  74844. scene: Scene;
  74845. rootUrl: string;
  74846. loadedBufferCount: number;
  74847. loadedBufferViews: {
  74848. [name: string]: ArrayBufferView;
  74849. };
  74850. loadedShaderCount: number;
  74851. importOnlyMeshes: boolean;
  74852. importMeshesNames?: string[];
  74853. dummyNodes: Node[];
  74854. forAssetContainer: boolean;
  74855. }
  74856. /** @hidden */
  74857. export interface INodeToRoot {
  74858. bone: Bone;
  74859. node: IGLTFNode;
  74860. id: string;
  74861. }
  74862. /** @hidden */
  74863. export interface IJointNode {
  74864. node: IGLTFNode;
  74865. id: string;
  74866. }
  74867. }
  74868. declare module BABYLON.GLTF1 {
  74869. /**
  74870. * Utils functions for GLTF
  74871. * @hidden
  74872. */
  74873. export class GLTFUtils {
  74874. /**
  74875. * Sets the given "parameter" matrix
  74876. * @param scene: the Scene object
  74877. * @param source: the source node where to pick the matrix
  74878. * @param parameter: the GLTF technique parameter
  74879. * @param uniformName: the name of the shader's uniform
  74880. * @param shaderMaterial: the shader material
  74881. */
  74882. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74883. /**
  74884. * Sets the given "parameter" matrix
  74885. * @param shaderMaterial: the shader material
  74886. * @param uniform: the name of the shader's uniform
  74887. * @param value: the value of the uniform
  74888. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74889. */
  74890. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74891. /**
  74892. * Returns the wrap mode of the texture
  74893. * @param mode: the mode value
  74894. */
  74895. static GetWrapMode(mode: number): number;
  74896. /**
  74897. * Returns the byte stride giving an accessor
  74898. * @param accessor: the GLTF accessor objet
  74899. */
  74900. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74901. /**
  74902. * Returns the texture filter mode giving a mode value
  74903. * @param mode: the filter mode value
  74904. */
  74905. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74906. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74907. /**
  74908. * Returns a buffer from its accessor
  74909. * @param gltfRuntime: the GLTF runtime
  74910. * @param accessor: the GLTF accessor
  74911. */
  74912. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74913. /**
  74914. * Decodes a buffer view into a string
  74915. * @param view: the buffer view
  74916. */
  74917. static DecodeBufferToText(view: ArrayBufferView): string;
  74918. /**
  74919. * Returns the default material of gltf. Related to
  74920. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74921. * @param scene: the Babylon.js scene
  74922. */
  74923. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74924. private static _DefaultMaterial;
  74925. }
  74926. }
  74927. declare module BABYLON.GLTF1 {
  74928. /**
  74929. * Implementation of the base glTF spec
  74930. * @hidden
  74931. */
  74932. export class GLTFLoaderBase {
  74933. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74934. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74935. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74936. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74937. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74938. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74939. }
  74940. /**
  74941. * glTF V1 Loader
  74942. * @hidden
  74943. */
  74944. export class GLTFLoader implements IGLTFLoader {
  74945. static Extensions: {
  74946. [name: string]: GLTFLoaderExtension;
  74947. };
  74948. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74949. state: Nullable<GLTFLoaderState>;
  74950. dispose(): void;
  74951. private _importMeshAsync;
  74952. /**
  74953. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74954. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74955. * @param scene the scene the meshes should be added to
  74956. * @param forAssetContainer defines if the entities must be stored in the scene
  74957. * @param data gltf data containing information of the meshes in a loaded file
  74958. * @param rootUrl root url to load from
  74959. * @param onProgress event that fires when loading progress has occured
  74960. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74961. */
  74962. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  74963. private _loadAsync;
  74964. /**
  74965. * Imports all objects from a loaded gltf file and adds them to the scene
  74966. * @param scene the scene the objects should be added to
  74967. * @param data gltf data containing information of the meshes in a loaded file
  74968. * @param rootUrl root url to load from
  74969. * @param onProgress event that fires when loading progress has occured
  74970. * @returns a promise which completes when objects have been loaded to the scene
  74971. */
  74972. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74973. private _loadShadersAsync;
  74974. private _loadBuffersAsync;
  74975. private _createNodes;
  74976. }
  74977. /** @hidden */
  74978. export abstract class GLTFLoaderExtension {
  74979. private _name;
  74980. constructor(name: string);
  74981. get name(): string;
  74982. /**
  74983. * Defines an override for loading the runtime
  74984. * Return true to stop further extensions from loading the runtime
  74985. */
  74986. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74987. /**
  74988. * Defines an onverride for creating gltf runtime
  74989. * Return true to stop further extensions from creating the runtime
  74990. */
  74991. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74992. /**
  74993. * Defines an override for loading buffers
  74994. * Return true to stop further extensions from loading this buffer
  74995. */
  74996. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74997. /**
  74998. * Defines an override for loading texture buffers
  74999. * Return true to stop further extensions from loading this texture data
  75000. */
  75001. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75002. /**
  75003. * Defines an override for creating textures
  75004. * Return true to stop further extensions from loading this texture
  75005. */
  75006. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75007. /**
  75008. * Defines an override for loading shader strings
  75009. * Return true to stop further extensions from loading this shader data
  75010. */
  75011. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75012. /**
  75013. * Defines an override for loading materials
  75014. * Return true to stop further extensions from loading this material
  75015. */
  75016. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75017. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75018. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75019. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75020. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75021. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75022. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75023. private static LoadTextureBufferAsync;
  75024. private static CreateTextureAsync;
  75025. private static ApplyExtensions;
  75026. }
  75027. }
  75028. declare module BABYLON.GLTF1 {
  75029. /** @hidden */
  75030. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75031. private _bin;
  75032. constructor();
  75033. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75034. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75035. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75036. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75037. }
  75038. }
  75039. declare module BABYLON.GLTF1 {
  75040. /** @hidden */
  75041. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75042. constructor();
  75043. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75044. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75045. private _loadTexture;
  75046. }
  75047. }
  75048. declare module BABYLON.GLTF2.Loader {
  75049. /**
  75050. * Loader interface with an index field.
  75051. */
  75052. export interface IArrayItem {
  75053. /**
  75054. * The index of this item in the array.
  75055. */
  75056. index: number;
  75057. }
  75058. /**
  75059. * Loader interface with additional members.
  75060. */
  75061. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75062. /** @hidden */
  75063. _data?: Promise<ArrayBufferView>;
  75064. /** @hidden */
  75065. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75066. }
  75067. /**
  75068. * Loader interface with additional members.
  75069. */
  75070. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75071. }
  75072. /** @hidden */
  75073. export interface _IAnimationSamplerData {
  75074. input: Float32Array;
  75075. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75076. output: Float32Array;
  75077. }
  75078. /**
  75079. * Loader interface with additional members.
  75080. */
  75081. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75082. /** @hidden */
  75083. _data?: Promise<_IAnimationSamplerData>;
  75084. }
  75085. /**
  75086. * Loader interface with additional members.
  75087. */
  75088. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75089. channels: IAnimationChannel[];
  75090. samplers: IAnimationSampler[];
  75091. /** @hidden */
  75092. _babylonAnimationGroup?: AnimationGroup;
  75093. }
  75094. /**
  75095. * Loader interface with additional members.
  75096. */
  75097. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75098. /** @hidden */
  75099. _data?: Promise<ArrayBufferView>;
  75100. }
  75101. /**
  75102. * Loader interface with additional members.
  75103. */
  75104. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75105. /** @hidden */
  75106. _data?: Promise<ArrayBufferView>;
  75107. /** @hidden */
  75108. _babylonBuffer?: Promise<Buffer>;
  75109. }
  75110. /**
  75111. * Loader interface with additional members.
  75112. */
  75113. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75114. }
  75115. /**
  75116. * Loader interface with additional members.
  75117. */
  75118. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75119. /** @hidden */
  75120. _data?: Promise<ArrayBufferView>;
  75121. }
  75122. /**
  75123. * Loader interface with additional members.
  75124. */
  75125. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75126. }
  75127. /**
  75128. * Loader interface with additional members.
  75129. */
  75130. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75131. }
  75132. /**
  75133. * Loader interface with additional members.
  75134. */
  75135. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75136. baseColorTexture?: ITextureInfo;
  75137. metallicRoughnessTexture?: ITextureInfo;
  75138. }
  75139. /**
  75140. * Loader interface with additional members.
  75141. */
  75142. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75143. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75144. normalTexture?: IMaterialNormalTextureInfo;
  75145. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75146. emissiveTexture?: ITextureInfo;
  75147. /** @hidden */
  75148. _data?: {
  75149. [babylonDrawMode: number]: {
  75150. babylonMaterial: Material;
  75151. babylonMeshes: AbstractMesh[];
  75152. promise: Promise<void>;
  75153. };
  75154. };
  75155. }
  75156. /**
  75157. * Loader interface with additional members.
  75158. */
  75159. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75160. primitives: IMeshPrimitive[];
  75161. }
  75162. /**
  75163. * Loader interface with additional members.
  75164. */
  75165. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75166. /** @hidden */
  75167. _instanceData?: {
  75168. babylonSourceMesh: Mesh;
  75169. promise: Promise<any>;
  75170. };
  75171. }
  75172. /**
  75173. * Loader interface with additional members.
  75174. */
  75175. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75176. /**
  75177. * The parent glTF node.
  75178. */
  75179. parent?: INode;
  75180. /** @hidden */
  75181. _babylonTransformNode?: TransformNode;
  75182. /** @hidden */
  75183. _primitiveBabylonMeshes?: AbstractMesh[];
  75184. /** @hidden */
  75185. _babylonBones?: Bone[];
  75186. /** @hidden */
  75187. _numMorphTargets?: number;
  75188. }
  75189. /** @hidden */
  75190. export interface _ISamplerData {
  75191. noMipMaps: boolean;
  75192. samplingMode: number;
  75193. wrapU: number;
  75194. wrapV: number;
  75195. }
  75196. /**
  75197. * Loader interface with additional members.
  75198. */
  75199. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75200. /** @hidden */
  75201. _data?: _ISamplerData;
  75202. }
  75203. /**
  75204. * Loader interface with additional members.
  75205. */
  75206. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75207. }
  75208. /**
  75209. * Loader interface with additional members.
  75210. */
  75211. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75212. /** @hidden */
  75213. _data?: {
  75214. babylonSkeleton: Skeleton;
  75215. promise: Promise<void>;
  75216. };
  75217. }
  75218. /**
  75219. * Loader interface with additional members.
  75220. */
  75221. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75222. }
  75223. /**
  75224. * Loader interface with additional members.
  75225. */
  75226. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75227. }
  75228. /**
  75229. * Loader interface with additional members.
  75230. */
  75231. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75232. accessors?: IAccessor[];
  75233. animations?: IAnimation[];
  75234. buffers?: IBuffer[];
  75235. bufferViews?: IBufferView[];
  75236. cameras?: ICamera[];
  75237. images?: IImage[];
  75238. materials?: IMaterial[];
  75239. meshes?: IMesh[];
  75240. nodes?: INode[];
  75241. samplers?: ISampler[];
  75242. scenes?: IScene[];
  75243. skins?: ISkin[];
  75244. textures?: ITexture[];
  75245. }
  75246. }
  75247. declare module BABYLON.GLTF2 {
  75248. /**
  75249. * Interface for a glTF loader extension.
  75250. */
  75251. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75252. /**
  75253. * Called after the loader state changes to LOADING.
  75254. */
  75255. onLoading?(): void;
  75256. /**
  75257. * Called after the loader state changes to READY.
  75258. */
  75259. onReady?(): void;
  75260. /**
  75261. * Define this method to modify the default behavior when loading scenes.
  75262. * @param context The context when loading the asset
  75263. * @param scene The glTF scene property
  75264. * @returns A promise that resolves when the load is complete or null if not handled
  75265. */
  75266. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75267. /**
  75268. * Define this method to modify the default behavior when loading nodes.
  75269. * @param context The context when loading the asset
  75270. * @param node The glTF node property
  75271. * @param assign A function called synchronously after parsing the glTF properties
  75272. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75273. */
  75274. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75275. /**
  75276. * Define this method to modify the default behavior when loading cameras.
  75277. * @param context The context when loading the asset
  75278. * @param camera The glTF camera property
  75279. * @param assign A function called synchronously after parsing the glTF properties
  75280. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75281. */
  75282. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75283. /**
  75284. * @hidden
  75285. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75286. * @param context The context when loading the asset
  75287. * @param primitive The glTF mesh primitive property
  75288. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75289. */
  75290. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75291. /**
  75292. * @hidden
  75293. * Define this method to modify the default behavior when loading data for mesh primitives.
  75294. * @param context The context when loading the asset
  75295. * @param name The mesh name when loading the asset
  75296. * @param node The glTF node when loading the asset
  75297. * @param mesh The glTF mesh when loading the asset
  75298. * @param primitive The glTF mesh primitive property
  75299. * @param assign A function called synchronously after parsing the glTF properties
  75300. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75301. */
  75302. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75303. /**
  75304. * @hidden
  75305. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75306. * @param context The context when loading the asset
  75307. * @param material The glTF material property
  75308. * @param assign A function called synchronously after parsing the glTF properties
  75309. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75310. */
  75311. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75312. /**
  75313. * Define this method to modify the default behavior when creating materials.
  75314. * @param context The context when loading the asset
  75315. * @param material The glTF material property
  75316. * @param babylonDrawMode The draw mode for the Babylon material
  75317. * @returns The Babylon material or null if not handled
  75318. */
  75319. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75320. /**
  75321. * Define this method to modify the default behavior when loading material properties.
  75322. * @param context The context when loading the asset
  75323. * @param material The glTF material property
  75324. * @param babylonMaterial The Babylon material
  75325. * @returns A promise that resolves when the load is complete or null if not handled
  75326. */
  75327. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75328. /**
  75329. * Define this method to modify the default behavior when loading texture infos.
  75330. * @param context The context when loading the asset
  75331. * @param textureInfo The glTF texture info property
  75332. * @param assign A function called synchronously after parsing the glTF properties
  75333. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75334. */
  75335. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75336. /**
  75337. * @hidden
  75338. * Define this method to modify the default behavior when loading textures.
  75339. * @param context The context when loading the asset
  75340. * @param texture The glTF texture property
  75341. * @param assign A function called synchronously after parsing the glTF properties
  75342. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75343. */
  75344. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75345. /**
  75346. * Define this method to modify the default behavior when loading animations.
  75347. * @param context The context when loading the asset
  75348. * @param animation The glTF animation property
  75349. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75350. */
  75351. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75352. /**
  75353. * @hidden
  75354. * Define this method to modify the default behavior when loading skins.
  75355. * @param context The context when loading the asset
  75356. * @param node The glTF node property
  75357. * @param skin The glTF skin property
  75358. * @returns A promise that resolves when the load is complete or null if not handled
  75359. */
  75360. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75361. /**
  75362. * @hidden
  75363. * Define this method to modify the default behavior when loading uris.
  75364. * @param context The context when loading the asset
  75365. * @param property The glTF property associated with the uri
  75366. * @param uri The uri to load
  75367. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75368. */
  75369. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75370. /**
  75371. * Define this method to modify the default behavior when loading buffer views.
  75372. * @param context The context when loading the asset
  75373. * @param bufferView The glTF buffer view property
  75374. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75375. */
  75376. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75377. /**
  75378. * Define this method to modify the default behavior when loading buffers.
  75379. * @param context The context when loading the asset
  75380. * @param buffer The glTF buffer property
  75381. * @param byteOffset The byte offset to load
  75382. * @param byteLength The byte length to load
  75383. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75384. */
  75385. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75386. }
  75387. }
  75388. declare module BABYLON.GLTF2 {
  75389. /**
  75390. * Helper class for working with arrays when loading the glTF asset
  75391. */
  75392. export class ArrayItem {
  75393. /**
  75394. * Gets an item from the given array.
  75395. * @param context The context when loading the asset
  75396. * @param array The array to get the item from
  75397. * @param index The index to the array
  75398. * @returns The array item
  75399. */
  75400. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75401. /**
  75402. * Assign an `index` field to each item of the given array.
  75403. * @param array The array of items
  75404. */
  75405. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75406. }
  75407. /**
  75408. * The glTF 2.0 loader
  75409. */
  75410. export class GLTFLoader implements IGLTFLoader {
  75411. /** @hidden */
  75412. _completePromises: Promise<any>[];
  75413. /** @hidden */
  75414. _forAssetContainer: boolean;
  75415. /** Storage */
  75416. _babylonLights: Light[];
  75417. private _disposed;
  75418. private _parent;
  75419. private _state;
  75420. private _extensions;
  75421. private _rootUrl;
  75422. private _fileName;
  75423. private _uniqueRootUrl;
  75424. private _gltf;
  75425. private _bin;
  75426. private _babylonScene;
  75427. private _rootBabylonMesh;
  75428. private _defaultBabylonMaterialData;
  75429. private _progressCallback?;
  75430. private _requests;
  75431. private static _RegisteredExtensions;
  75432. /**
  75433. * The default glTF sampler.
  75434. */
  75435. static readonly DefaultSampler: ISampler;
  75436. /**
  75437. * Registers a loader extension.
  75438. * @param name The name of the loader extension.
  75439. * @param factory The factory function that creates the loader extension.
  75440. */
  75441. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75442. /**
  75443. * Unregisters a loader extension.
  75444. * @param name The name of the loader extension.
  75445. * @returns A boolean indicating whether the extension has been unregistered
  75446. */
  75447. static UnregisterExtension(name: string): boolean;
  75448. /**
  75449. * The loader state.
  75450. */
  75451. get state(): Nullable<GLTFLoaderState>;
  75452. /**
  75453. * The object that represents the glTF JSON.
  75454. */
  75455. get gltf(): IGLTF;
  75456. /**
  75457. * The BIN chunk of a binary glTF.
  75458. */
  75459. get bin(): Nullable<IDataBuffer>;
  75460. /**
  75461. * The parent file loader.
  75462. */
  75463. get parent(): GLTFFileLoader;
  75464. /**
  75465. * The Babylon scene when loading the asset.
  75466. */
  75467. get babylonScene(): Scene;
  75468. /**
  75469. * The root Babylon mesh when loading the asset.
  75470. */
  75471. get rootBabylonMesh(): Mesh;
  75472. /** @hidden */
  75473. constructor(parent: GLTFFileLoader);
  75474. /** @hidden */
  75475. dispose(): void;
  75476. /** @hidden */
  75477. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  75478. /** @hidden */
  75479. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75480. private _loadAsync;
  75481. private _loadData;
  75482. private _setupData;
  75483. private _loadExtensions;
  75484. private _checkExtensions;
  75485. private _setState;
  75486. private _createRootNode;
  75487. /**
  75488. * Loads a glTF scene.
  75489. * @param context The context when loading the asset
  75490. * @param scene The glTF scene property
  75491. * @returns A promise that resolves when the load is complete
  75492. */
  75493. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75494. private _forEachPrimitive;
  75495. private _getMeshes;
  75496. private _getTransformNodes;
  75497. private _getSkeletons;
  75498. private _getAnimationGroups;
  75499. private _startAnimations;
  75500. /**
  75501. * Loads a glTF node.
  75502. * @param context The context when loading the asset
  75503. * @param node The glTF node property
  75504. * @param assign A function called synchronously after parsing the glTF properties
  75505. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75506. */
  75507. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75508. private _loadMeshAsync;
  75509. /**
  75510. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75511. * @param context The context when loading the asset
  75512. * @param name The mesh name when loading the asset
  75513. * @param node The glTF node when loading the asset
  75514. * @param mesh The glTF mesh when loading the asset
  75515. * @param primitive The glTF mesh primitive property
  75516. * @param assign A function called synchronously after parsing the glTF properties
  75517. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75518. */
  75519. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75520. private _loadVertexDataAsync;
  75521. private _createMorphTargets;
  75522. private _loadMorphTargetsAsync;
  75523. private _loadMorphTargetVertexDataAsync;
  75524. private static _LoadTransform;
  75525. private _loadSkinAsync;
  75526. private _loadBones;
  75527. private _loadBone;
  75528. private _loadSkinInverseBindMatricesDataAsync;
  75529. private _updateBoneMatrices;
  75530. private _getNodeMatrix;
  75531. /**
  75532. * Loads a glTF camera.
  75533. * @param context The context when loading the asset
  75534. * @param camera The glTF camera property
  75535. * @param assign A function called synchronously after parsing the glTF properties
  75536. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75537. */
  75538. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75539. private _loadAnimationsAsync;
  75540. /**
  75541. * Loads a glTF animation.
  75542. * @param context The context when loading the asset
  75543. * @param animation The glTF animation property
  75544. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75545. */
  75546. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75547. /**
  75548. * @hidden Loads a glTF animation channel.
  75549. * @param context The context when loading the asset
  75550. * @param animationContext The context of the animation when loading the asset
  75551. * @param animation The glTF animation property
  75552. * @param channel The glTF animation channel property
  75553. * @param babylonAnimationGroup The babylon animation group property
  75554. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75555. * @returns A void promise when the channel load is complete
  75556. */
  75557. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75558. private _loadAnimationSamplerAsync;
  75559. private _loadBufferAsync;
  75560. /**
  75561. * Loads a glTF buffer view.
  75562. * @param context The context when loading the asset
  75563. * @param bufferView The glTF buffer view property
  75564. * @returns A promise that resolves with the loaded data when the load is complete
  75565. */
  75566. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75567. private _loadAccessorAsync;
  75568. private _loadFloatAccessorAsync;
  75569. private _loadIndicesAccessorAsync;
  75570. private _loadVertexBufferViewAsync;
  75571. private _loadVertexAccessorAsync;
  75572. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75573. /** @hidden */
  75574. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75575. private _createDefaultMaterial;
  75576. /**
  75577. * Creates a Babylon material from a glTF material.
  75578. * @param context The context when loading the asset
  75579. * @param material The glTF material property
  75580. * @param babylonDrawMode The draw mode for the Babylon material
  75581. * @returns The Babylon material
  75582. */
  75583. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75584. /**
  75585. * Loads properties from a glTF material into a Babylon material.
  75586. * @param context The context when loading the asset
  75587. * @param material The glTF material property
  75588. * @param babylonMaterial The Babylon material
  75589. * @returns A promise that resolves when the load is complete
  75590. */
  75591. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75592. /**
  75593. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75594. * @param context The context when loading the asset
  75595. * @param material The glTF material property
  75596. * @param babylonMaterial The Babylon material
  75597. * @returns A promise that resolves when the load is complete
  75598. */
  75599. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75600. /**
  75601. * Loads the alpha properties from a glTF material into a Babylon material.
  75602. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75603. * @param context The context when loading the asset
  75604. * @param material The glTF material property
  75605. * @param babylonMaterial The Babylon material
  75606. */
  75607. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75608. /**
  75609. * Loads a glTF texture info.
  75610. * @param context The context when loading the asset
  75611. * @param textureInfo The glTF texture info property
  75612. * @param assign A function called synchronously after parsing the glTF properties
  75613. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75614. */
  75615. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75616. /** @hidden */
  75617. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75618. /** @hidden */
  75619. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75620. private _loadSampler;
  75621. /**
  75622. * Loads a glTF image.
  75623. * @param context The context when loading the asset
  75624. * @param image The glTF image property
  75625. * @returns A promise that resolves with the loaded data when the load is complete
  75626. */
  75627. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75628. /**
  75629. * Loads a glTF uri.
  75630. * @param context The context when loading the asset
  75631. * @param property The glTF property associated with the uri
  75632. * @param uri The base64 or relative uri
  75633. * @returns A promise that resolves with the loaded data when the load is complete
  75634. */
  75635. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75636. private _onProgress;
  75637. /**
  75638. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75639. * @param babylonObject the Babylon object with metadata
  75640. * @param pointer the JSON pointer
  75641. */
  75642. static AddPointerMetadata(babylonObject: {
  75643. metadata: any;
  75644. }, pointer: string): void;
  75645. private static _GetTextureWrapMode;
  75646. private static _GetTextureSamplingMode;
  75647. private static _GetTypedArrayConstructor;
  75648. private static _GetTypedArray;
  75649. private static _GetNumComponents;
  75650. private static _ValidateUri;
  75651. private static _GetDrawMode;
  75652. private _compileMaterialsAsync;
  75653. private _compileShadowGeneratorsAsync;
  75654. private _forEachExtensions;
  75655. private _applyExtensions;
  75656. private _extensionsOnLoading;
  75657. private _extensionsOnReady;
  75658. private _extensionsLoadSceneAsync;
  75659. private _extensionsLoadNodeAsync;
  75660. private _extensionsLoadCameraAsync;
  75661. private _extensionsLoadVertexDataAsync;
  75662. private _extensionsLoadMeshPrimitiveAsync;
  75663. private _extensionsLoadMaterialAsync;
  75664. private _extensionsCreateMaterial;
  75665. private _extensionsLoadMaterialPropertiesAsync;
  75666. private _extensionsLoadTextureInfoAsync;
  75667. private _extensionsLoadTextureAsync;
  75668. private _extensionsLoadAnimationAsync;
  75669. private _extensionsLoadSkinAsync;
  75670. private _extensionsLoadUriAsync;
  75671. private _extensionsLoadBufferViewAsync;
  75672. private _extensionsLoadBufferAsync;
  75673. /**
  75674. * Helper method called by a loader extension to load an glTF extension.
  75675. * @param context The context when loading the asset
  75676. * @param property The glTF property to load the extension from
  75677. * @param extensionName The name of the extension to load
  75678. * @param actionAsync The action to run
  75679. * @returns The promise returned by actionAsync or null if the extension does not exist
  75680. */
  75681. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75682. /**
  75683. * Helper method called by a loader extension to load a glTF extra.
  75684. * @param context The context when loading the asset
  75685. * @param property The glTF property to load the extra from
  75686. * @param extensionName The name of the extension to load
  75687. * @param actionAsync The action to run
  75688. * @returns The promise returned by actionAsync or null if the extra does not exist
  75689. */
  75690. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75691. /**
  75692. * Checks for presence of an extension.
  75693. * @param name The name of the extension to check
  75694. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75695. */
  75696. isExtensionUsed(name: string): boolean;
  75697. /**
  75698. * Increments the indentation level and logs a message.
  75699. * @param message The message to log
  75700. */
  75701. logOpen(message: string): void;
  75702. /**
  75703. * Decrements the indentation level.
  75704. */
  75705. logClose(): void;
  75706. /**
  75707. * Logs a message
  75708. * @param message The message to log
  75709. */
  75710. log(message: string): void;
  75711. /**
  75712. * Starts a performance counter.
  75713. * @param counterName The name of the performance counter
  75714. */
  75715. startPerformanceCounter(counterName: string): void;
  75716. /**
  75717. * Ends a performance counter.
  75718. * @param counterName The name of the performance counter
  75719. */
  75720. endPerformanceCounter(counterName: string): void;
  75721. }
  75722. }
  75723. declare module BABYLON.GLTF2.Loader.Extensions {
  75724. /**
  75725. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75726. */
  75727. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75728. /**
  75729. * The name of this extension.
  75730. */
  75731. readonly name: string;
  75732. /**
  75733. * Defines whether this extension is enabled.
  75734. */
  75735. enabled: boolean;
  75736. private _loader;
  75737. private _lights?;
  75738. /** @hidden */
  75739. constructor(loader: GLTFLoader);
  75740. /** @hidden */
  75741. dispose(): void;
  75742. /** @hidden */
  75743. onLoading(): void;
  75744. /** @hidden */
  75745. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75746. private _loadLightAsync;
  75747. }
  75748. }
  75749. declare module BABYLON.GLTF2.Loader.Extensions {
  75750. /**
  75751. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75752. */
  75753. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75754. /**
  75755. * The name of this extension.
  75756. */
  75757. readonly name: string;
  75758. /**
  75759. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75760. */
  75761. dracoCompression?: DracoCompression;
  75762. /**
  75763. * Defines whether this extension is enabled.
  75764. */
  75765. enabled: boolean;
  75766. private _loader;
  75767. /** @hidden */
  75768. constructor(loader: GLTFLoader);
  75769. /** @hidden */
  75770. dispose(): void;
  75771. /** @hidden */
  75772. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75773. }
  75774. }
  75775. declare module BABYLON.GLTF2.Loader.Extensions {
  75776. /**
  75777. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  75778. */
  75779. export class KHR_lights implements IGLTFLoaderExtension {
  75780. /**
  75781. * The name of this extension.
  75782. */
  75783. readonly name: string;
  75784. /**
  75785. * Defines whether this extension is enabled.
  75786. */
  75787. enabled: boolean;
  75788. private _loader;
  75789. private _lights?;
  75790. /** @hidden */
  75791. constructor(loader: GLTFLoader);
  75792. /** @hidden */
  75793. dispose(): void;
  75794. /** @hidden */
  75795. onLoading(): void;
  75796. /** @hidden */
  75797. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75798. }
  75799. }
  75800. declare module BABYLON.GLTF2.Loader.Extensions {
  75801. /**
  75802. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75803. */
  75804. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75805. /**
  75806. * The name of this extension.
  75807. */
  75808. readonly name: string;
  75809. /**
  75810. * Defines whether this extension is enabled.
  75811. */
  75812. enabled: boolean;
  75813. /**
  75814. * Defines a number that determines the order the extensions are applied.
  75815. */
  75816. order: number;
  75817. private _loader;
  75818. /** @hidden */
  75819. constructor(loader: GLTFLoader);
  75820. /** @hidden */
  75821. dispose(): void;
  75822. /** @hidden */
  75823. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75824. private _loadSpecularGlossinessPropertiesAsync;
  75825. }
  75826. }
  75827. declare module BABYLON.GLTF2.Loader.Extensions {
  75828. /**
  75829. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75830. */
  75831. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75832. /**
  75833. * The name of this extension.
  75834. */
  75835. readonly name: string;
  75836. /**
  75837. * Defines whether this extension is enabled.
  75838. */
  75839. enabled: boolean;
  75840. /**
  75841. * Defines a number that determines the order the extensions are applied.
  75842. */
  75843. order: number;
  75844. private _loader;
  75845. /** @hidden */
  75846. constructor(loader: GLTFLoader);
  75847. /** @hidden */
  75848. dispose(): void;
  75849. /** @hidden */
  75850. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75851. private _loadUnlitPropertiesAsync;
  75852. }
  75853. }
  75854. declare module BABYLON.GLTF2.Loader.Extensions {
  75855. /**
  75856. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75857. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75858. * !!! Experimental Extension Subject to Changes !!!
  75859. */
  75860. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75861. /**
  75862. * The name of this extension.
  75863. */
  75864. readonly name: string;
  75865. /**
  75866. * Defines whether this extension is enabled.
  75867. */
  75868. enabled: boolean;
  75869. /**
  75870. * Defines a number that determines the order the extensions are applied.
  75871. */
  75872. order: number;
  75873. private _loader;
  75874. /** @hidden */
  75875. constructor(loader: GLTFLoader);
  75876. /** @hidden */
  75877. dispose(): void;
  75878. /** @hidden */
  75879. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75880. private _loadClearCoatPropertiesAsync;
  75881. }
  75882. }
  75883. declare module BABYLON.GLTF2.Loader.Extensions {
  75884. /**
  75885. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75886. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75887. * !!! Experimental Extension Subject to Changes !!!
  75888. */
  75889. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75890. /**
  75891. * The name of this extension.
  75892. */
  75893. readonly name: string;
  75894. /**
  75895. * Defines whether this extension is enabled.
  75896. */
  75897. enabled: boolean;
  75898. /**
  75899. * Defines a number that determines the order the extensions are applied.
  75900. */
  75901. order: number;
  75902. private _loader;
  75903. /** @hidden */
  75904. constructor(loader: GLTFLoader);
  75905. /** @hidden */
  75906. dispose(): void;
  75907. /** @hidden */
  75908. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75909. private _loadSheenPropertiesAsync;
  75910. }
  75911. }
  75912. declare module BABYLON.GLTF2.Loader.Extensions {
  75913. /**
  75914. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75915. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75916. * !!! Experimental Extension Subject to Changes !!!
  75917. */
  75918. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75919. /**
  75920. * The name of this extension.
  75921. */
  75922. readonly name: string;
  75923. /**
  75924. * Defines whether this extension is enabled.
  75925. */
  75926. enabled: boolean;
  75927. /**
  75928. * Defines a number that determines the order the extensions are applied.
  75929. */
  75930. order: number;
  75931. private _loader;
  75932. /** @hidden */
  75933. constructor(loader: GLTFLoader);
  75934. /** @hidden */
  75935. dispose(): void;
  75936. /** @hidden */
  75937. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75938. private _loadSpecularPropertiesAsync;
  75939. }
  75940. }
  75941. declare module BABYLON.GLTF2.Loader.Extensions {
  75942. /**
  75943. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75944. */
  75945. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75946. /**
  75947. * The name of this extension.
  75948. */
  75949. readonly name: string;
  75950. /**
  75951. * Defines whether this extension is enabled.
  75952. */
  75953. enabled: boolean;
  75954. /** @hidden */
  75955. constructor(loader: GLTFLoader);
  75956. /** @hidden */
  75957. dispose(): void;
  75958. }
  75959. }
  75960. declare module BABYLON.GLTF2.Loader.Extensions {
  75961. /**
  75962. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  75963. * !!! Experimental Extension Subject to Changes !!!
  75964. */
  75965. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  75966. /** The name of this extension. */
  75967. readonly name: string;
  75968. /** Defines whether this extension is enabled. */
  75969. enabled: boolean;
  75970. private _loader;
  75971. /** @hidden */
  75972. constructor(loader: GLTFLoader);
  75973. /** @hidden */
  75974. dispose(): void;
  75975. /** @hidden */
  75976. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75977. }
  75978. }
  75979. declare module BABYLON.GLTF2.Loader.Extensions {
  75980. /**
  75981. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  75982. */
  75983. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75984. /**
  75985. * The name of this extension.
  75986. */
  75987. readonly name: string;
  75988. /**
  75989. * Defines whether this extension is enabled.
  75990. */
  75991. enabled: boolean;
  75992. private _loader;
  75993. /** @hidden */
  75994. constructor(loader: GLTFLoader);
  75995. /** @hidden */
  75996. dispose(): void;
  75997. /** @hidden */
  75998. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75999. }
  76000. }
  76001. declare module BABYLON.GLTF2.Loader.Extensions {
  76002. /**
  76003. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76004. */
  76005. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76006. /**
  76007. * The name of this extension.
  76008. */
  76009. readonly name: string;
  76010. /**
  76011. * Defines whether this extension is enabled.
  76012. */
  76013. enabled: boolean;
  76014. private _loader;
  76015. private _clips;
  76016. private _emitters;
  76017. /** @hidden */
  76018. constructor(loader: GLTFLoader);
  76019. /** @hidden */
  76020. dispose(): void;
  76021. /** @hidden */
  76022. onLoading(): void;
  76023. /** @hidden */
  76024. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76025. /** @hidden */
  76026. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76027. /** @hidden */
  76028. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76029. private _loadClipAsync;
  76030. private _loadEmitterAsync;
  76031. private _getEventAction;
  76032. private _loadAnimationEventAsync;
  76033. }
  76034. }
  76035. declare module BABYLON.GLTF2.Loader.Extensions {
  76036. /**
  76037. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76038. */
  76039. export class MSFT_lod implements IGLTFLoaderExtension {
  76040. /**
  76041. * The name of this extension.
  76042. */
  76043. readonly name: string;
  76044. /**
  76045. * Defines whether this extension is enabled.
  76046. */
  76047. enabled: boolean;
  76048. /**
  76049. * Defines a number that determines the order the extensions are applied.
  76050. */
  76051. order: number;
  76052. /**
  76053. * Maximum number of LODs to load, starting from the lowest LOD.
  76054. */
  76055. maxLODsToLoad: number;
  76056. /**
  76057. * Observable raised when all node LODs of one level are loaded.
  76058. * The event data is the index of the loaded LOD starting from zero.
  76059. * Dispose the loader to cancel the loading of the next level of LODs.
  76060. */
  76061. onNodeLODsLoadedObservable: Observable<number>;
  76062. /**
  76063. * Observable raised when all material LODs of one level are loaded.
  76064. * The event data is the index of the loaded LOD starting from zero.
  76065. * Dispose the loader to cancel the loading of the next level of LODs.
  76066. */
  76067. onMaterialLODsLoadedObservable: Observable<number>;
  76068. private _loader;
  76069. private _nodeIndexLOD;
  76070. private _nodeSignalLODs;
  76071. private _nodePromiseLODs;
  76072. private _materialIndexLOD;
  76073. private _materialSignalLODs;
  76074. private _materialPromiseLODs;
  76075. private _indexLOD;
  76076. private _bufferLODs;
  76077. /** @hidden */
  76078. constructor(loader: GLTFLoader);
  76079. /** @hidden */
  76080. dispose(): void;
  76081. /** @hidden */
  76082. onReady(): void;
  76083. /** @hidden */
  76084. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76085. /** @hidden */
  76086. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76087. /** @hidden */
  76088. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76089. /** @hidden */
  76090. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76091. /** @hidden */
  76092. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76093. private _loadBufferLOD;
  76094. /**
  76095. * Gets an array of LOD properties from lowest to highest.
  76096. */
  76097. private _getLODs;
  76098. private _disposeTransformNode;
  76099. private _disposeMaterials;
  76100. }
  76101. }
  76102. declare module BABYLON.GLTF2.Loader.Extensions {
  76103. /** @hidden */
  76104. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76105. readonly name: string;
  76106. enabled: boolean;
  76107. private _loader;
  76108. constructor(loader: GLTFLoader);
  76109. dispose(): void;
  76110. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76111. }
  76112. }
  76113. declare module BABYLON.GLTF2.Loader.Extensions {
  76114. /** @hidden */
  76115. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76116. readonly name: string;
  76117. enabled: boolean;
  76118. private _loader;
  76119. constructor(loader: GLTFLoader);
  76120. dispose(): void;
  76121. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76122. }
  76123. }
  76124. declare module BABYLON.GLTF2.Loader.Extensions {
  76125. /**
  76126. * Store glTF extras (if present) in BJS objects' metadata
  76127. */
  76128. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76129. /**
  76130. * The name of this extension.
  76131. */
  76132. readonly name: string;
  76133. /**
  76134. * Defines whether this extension is enabled.
  76135. */
  76136. enabled: boolean;
  76137. private _loader;
  76138. private _assignExtras;
  76139. /** @hidden */
  76140. constructor(loader: GLTFLoader);
  76141. /** @hidden */
  76142. dispose(): void;
  76143. /** @hidden */
  76144. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76145. /** @hidden */
  76146. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76147. /** @hidden */
  76148. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76149. }
  76150. }
  76151. declare module BABYLON {
  76152. /**
  76153. * Class reading and parsing the MTL file bundled with the obj file.
  76154. */
  76155. export class MTLFileLoader {
  76156. /**
  76157. * Invert Y-Axis of referenced textures on load
  76158. */
  76159. static INVERT_TEXTURE_Y: boolean;
  76160. /**
  76161. * All material loaded from the mtl will be set here
  76162. */
  76163. materials: StandardMaterial[];
  76164. /**
  76165. * This function will read the mtl file and create each material described inside
  76166. * This function could be improve by adding :
  76167. * -some component missing (Ni, Tf...)
  76168. * -including the specific options available
  76169. *
  76170. * @param scene defines the scene the material will be created in
  76171. * @param data defines the mtl data to parse
  76172. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76173. * @param forAssetContainer defines if the material should be registered in the scene
  76174. */
  76175. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76176. /**
  76177. * Gets the texture for the material.
  76178. *
  76179. * If the material is imported from input file,
  76180. * We sanitize the url to ensure it takes the textre from aside the material.
  76181. *
  76182. * @param rootUrl The root url to load from
  76183. * @param value The value stored in the mtl
  76184. * @return The Texture
  76185. */
  76186. private static _getTexture;
  76187. }
  76188. }
  76189. declare module BABYLON {
  76190. /**
  76191. * Options for loading OBJ/MTL files
  76192. */
  76193. type MeshLoadOptions = {
  76194. /**
  76195. * Defines if UVs are optimized by default during load.
  76196. */
  76197. OptimizeWithUV: boolean;
  76198. /**
  76199. * Defines custom scaling of UV coordinates of loaded meshes.
  76200. */
  76201. UVScaling: Vector2;
  76202. /**
  76203. * Invert model on y-axis (does a model scaling inversion)
  76204. */
  76205. InvertY: boolean;
  76206. /**
  76207. * Invert Y-Axis of referenced textures on load
  76208. */
  76209. InvertTextureY: boolean;
  76210. /**
  76211. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76212. */
  76213. ImportVertexColors: boolean;
  76214. /**
  76215. * Compute the normals for the model, even if normals are present in the file.
  76216. */
  76217. ComputeNormals: boolean;
  76218. /**
  76219. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76220. */
  76221. SkipMaterials: boolean;
  76222. /**
  76223. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76224. */
  76225. MaterialLoadingFailsSilently: boolean;
  76226. };
  76227. /**
  76228. * OBJ file type loader.
  76229. * This is a babylon scene loader plugin.
  76230. */
  76231. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76232. /**
  76233. * Defines if UVs are optimized by default during load.
  76234. */
  76235. static OPTIMIZE_WITH_UV: boolean;
  76236. /**
  76237. * Invert model on y-axis (does a model scaling inversion)
  76238. */
  76239. static INVERT_Y: boolean;
  76240. /**
  76241. * Invert Y-Axis of referenced textures on load
  76242. */
  76243. static get INVERT_TEXTURE_Y(): boolean;
  76244. static set INVERT_TEXTURE_Y(value: boolean);
  76245. /**
  76246. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76247. */
  76248. static IMPORT_VERTEX_COLORS: boolean;
  76249. /**
  76250. * Compute the normals for the model, even if normals are present in the file.
  76251. */
  76252. static COMPUTE_NORMALS: boolean;
  76253. /**
  76254. * Defines custom scaling of UV coordinates of loaded meshes.
  76255. */
  76256. static UV_SCALING: Vector2;
  76257. /**
  76258. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76259. */
  76260. static SKIP_MATERIALS: boolean;
  76261. /**
  76262. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76263. *
  76264. * Defaults to true for backwards compatibility.
  76265. */
  76266. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76267. /**
  76268. * Defines the name of the plugin.
  76269. */
  76270. name: string;
  76271. /**
  76272. * Defines the extension the plugin is able to load.
  76273. */
  76274. extensions: string;
  76275. /** @hidden */
  76276. obj: RegExp;
  76277. /** @hidden */
  76278. group: RegExp;
  76279. /** @hidden */
  76280. mtllib: RegExp;
  76281. /** @hidden */
  76282. usemtl: RegExp;
  76283. /** @hidden */
  76284. smooth: RegExp;
  76285. /** @hidden */
  76286. vertexPattern: RegExp;
  76287. /** @hidden */
  76288. normalPattern: RegExp;
  76289. /** @hidden */
  76290. uvPattern: RegExp;
  76291. /** @hidden */
  76292. facePattern1: RegExp;
  76293. /** @hidden */
  76294. facePattern2: RegExp;
  76295. /** @hidden */
  76296. facePattern3: RegExp;
  76297. /** @hidden */
  76298. facePattern4: RegExp;
  76299. /** @hidden */
  76300. facePattern5: RegExp;
  76301. private _forAssetContainer;
  76302. private _meshLoadOptions;
  76303. /**
  76304. * Creates loader for .OBJ files
  76305. *
  76306. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76307. */
  76308. constructor(meshLoadOptions?: MeshLoadOptions);
  76309. private static get currentMeshLoadOptions();
  76310. /**
  76311. * Calls synchronously the MTL file attached to this obj.
  76312. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76313. * Without this function materials are not displayed in the first frame (but displayed after).
  76314. * In consequence it is impossible to get material information in your HTML file
  76315. *
  76316. * @param url The URL of the MTL file
  76317. * @param rootUrl
  76318. * @param onSuccess Callback function to be called when the MTL file is loaded
  76319. * @private
  76320. */
  76321. private _loadMTL;
  76322. /**
  76323. * Instantiates a OBJ file loader plugin.
  76324. * @returns the created plugin
  76325. */
  76326. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76327. /**
  76328. * If the data string can be loaded directly.
  76329. *
  76330. * @param data string containing the file data
  76331. * @returns if the data can be loaded directly
  76332. */
  76333. canDirectLoad(data: string): boolean;
  76334. /**
  76335. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76336. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76337. * @param scene the scene the meshes should be added to
  76338. * @param data the OBJ data to load
  76339. * @param rootUrl root url to load from
  76340. * @param onProgress event that fires when loading progress has occured
  76341. * @param fileName Defines the name of the file to load
  76342. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76343. */
  76344. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76345. meshes: AbstractMesh[];
  76346. particleSystems: IParticleSystem[];
  76347. skeletons: Skeleton[];
  76348. animationGroups: AnimationGroup[];
  76349. }>;
  76350. /**
  76351. * Imports all objects from the loaded OBJ data and adds them to the scene
  76352. * @param scene the scene the objects should be added to
  76353. * @param data the OBJ data to load
  76354. * @param rootUrl root url to load from
  76355. * @param onProgress event that fires when loading progress has occured
  76356. * @param fileName Defines the name of the file to load
  76357. * @returns a promise which completes when objects have been loaded to the scene
  76358. */
  76359. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76360. /**
  76361. * Load into an asset container.
  76362. * @param scene The scene to load into
  76363. * @param data The data to import
  76364. * @param rootUrl The root url for scene and resources
  76365. * @param onProgress The callback when the load progresses
  76366. * @param fileName Defines the name of the file to load
  76367. * @returns The loaded asset container
  76368. */
  76369. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76370. /**
  76371. * Read the OBJ file and create an Array of meshes.
  76372. * Each mesh contains all information given by the OBJ and the MTL file.
  76373. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76374. *
  76375. * @param meshesNames
  76376. * @param scene Scene The scene where are displayed the data
  76377. * @param data String The content of the obj file
  76378. * @param rootUrl String The path to the folder
  76379. * @returns Array<AbstractMesh>
  76380. * @private
  76381. */
  76382. private _parseSolid;
  76383. }
  76384. }
  76385. declare module BABYLON {
  76386. /**
  76387. * STL file type loader.
  76388. * This is a babylon scene loader plugin.
  76389. */
  76390. export class STLFileLoader implements ISceneLoaderPlugin {
  76391. /** @hidden */
  76392. solidPattern: RegExp;
  76393. /** @hidden */
  76394. facetsPattern: RegExp;
  76395. /** @hidden */
  76396. normalPattern: RegExp;
  76397. /** @hidden */
  76398. vertexPattern: RegExp;
  76399. /**
  76400. * Defines the name of the plugin.
  76401. */
  76402. name: string;
  76403. /**
  76404. * Defines the extensions the stl loader is able to load.
  76405. * force data to come in as an ArrayBuffer
  76406. * we'll convert to string if it looks like it's an ASCII .stl
  76407. */
  76408. extensions: ISceneLoaderPluginExtensions;
  76409. /**
  76410. * Import meshes into a scene.
  76411. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76412. * @param scene The scene to import into
  76413. * @param data The data to import
  76414. * @param rootUrl The root url for scene and resources
  76415. * @param meshes The meshes array to import into
  76416. * @param particleSystems The particle systems array to import into
  76417. * @param skeletons The skeletons array to import into
  76418. * @param onError The callback when import fails
  76419. * @returns True if successful or false otherwise
  76420. */
  76421. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76422. /**
  76423. * Load into a scene.
  76424. * @param scene The scene to load into
  76425. * @param data The data to import
  76426. * @param rootUrl The root url for scene and resources
  76427. * @param onError The callback when import fails
  76428. * @returns true if successful or false otherwise
  76429. */
  76430. load(scene: Scene, data: any, rootUrl: string): boolean;
  76431. /**
  76432. * Load into an asset container.
  76433. * @param scene The scene to load into
  76434. * @param data The data to import
  76435. * @param rootUrl The root url for scene and resources
  76436. * @param onError The callback when import fails
  76437. * @returns The loaded asset container
  76438. */
  76439. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76440. private _isBinary;
  76441. private _parseBinary;
  76442. private _parseASCII;
  76443. }
  76444. }
  76445. declare module BABYLON {
  76446. /**
  76447. * Class for generating OBJ data from a Babylon scene.
  76448. */
  76449. export class OBJExport {
  76450. /**
  76451. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76452. * @param mesh defines the list of meshes to serialize
  76453. * @param materials defines if materials should be exported
  76454. * @param matlibname defines the name of the associated mtl file
  76455. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76456. * @returns the OBJ content
  76457. */
  76458. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76459. /**
  76460. * Exports the material(s) of a mesh in .MTL file format (text)
  76461. * @param mesh defines the mesh to extract the material from
  76462. * @returns the mtl content
  76463. */
  76464. static MTL(mesh: Mesh): string;
  76465. }
  76466. }
  76467. declare module BABYLON {
  76468. /** @hidden */
  76469. export var __IGLTFExporterExtension: number;
  76470. /**
  76471. * Interface for extending the exporter
  76472. * @hidden
  76473. */
  76474. export interface IGLTFExporterExtension {
  76475. /**
  76476. * The name of this extension
  76477. */
  76478. readonly name: string;
  76479. /**
  76480. * Defines whether this extension is enabled
  76481. */
  76482. enabled: boolean;
  76483. /**
  76484. * Defines whether this extension is required
  76485. */
  76486. required: boolean;
  76487. }
  76488. }
  76489. declare module BABYLON.GLTF2.Exporter {
  76490. /** @hidden */
  76491. export var __IGLTFExporterExtensionV2: number;
  76492. /**
  76493. * Interface for a glTF exporter extension
  76494. * @hidden
  76495. */
  76496. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76497. /**
  76498. * Define this method to modify the default behavior before exporting a texture
  76499. * @param context The context when loading the asset
  76500. * @param babylonTexture The Babylon.js texture
  76501. * @param mimeType The mime-type of the generated image
  76502. * @returns A promise that resolves with the exported texture
  76503. */
  76504. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  76505. /**
  76506. * Define this method to get notified when a texture info is created
  76507. * @param context The context when loading the asset
  76508. * @param textureInfo The glTF texture info
  76509. * @param babylonTexture The Babylon.js texture
  76510. */
  76511. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76512. /**
  76513. * Define this method to modify the default behavior when exporting texture info
  76514. * @param context The context when loading the asset
  76515. * @param meshPrimitive glTF mesh primitive
  76516. * @param babylonSubMesh Babylon submesh
  76517. * @param binaryWriter glTF serializer binary writer instance
  76518. * @returns nullable IMeshPrimitive promise
  76519. */
  76520. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76521. /**
  76522. * Define this method to modify the default behavior when exporting a node
  76523. * @param context The context when exporting the node
  76524. * @param node glTF node
  76525. * @param babylonNode BabylonJS node
  76526. * @returns nullable INode promise
  76527. */
  76528. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  76529. [key: number]: number;
  76530. }): Promise<Nullable<INode>>;
  76531. /**
  76532. * Define this method to modify the default behavior when exporting a material
  76533. * @param material glTF material
  76534. * @param babylonMaterial BabylonJS material
  76535. * @returns nullable IMaterial promise
  76536. */
  76537. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  76538. /**
  76539. * Define this method to return additional textures to export from a material
  76540. * @param material glTF material
  76541. * @param babylonMaterial BabylonJS material
  76542. * @returns List of textures
  76543. */
  76544. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76545. /** Gets a boolean indicating that this extension was used */
  76546. wasUsed: boolean;
  76547. /** Gets a boolean indicating that this extension is required for the file to work */
  76548. required: boolean;
  76549. /**
  76550. * Called after the exporter state changes to EXPORTING
  76551. */
  76552. onExporting?(): void;
  76553. }
  76554. }
  76555. declare module BABYLON.GLTF2.Exporter {
  76556. /**
  76557. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76558. * @hidden
  76559. */
  76560. export class _GLTFMaterialExporter {
  76561. /**
  76562. * Represents the dielectric specular values for R, G and B
  76563. */
  76564. private static readonly _DielectricSpecular;
  76565. /**
  76566. * Allows the maximum specular power to be defined for material calculations
  76567. */
  76568. private static readonly _MaxSpecularPower;
  76569. /**
  76570. * Mapping to store textures
  76571. */
  76572. private _textureMap;
  76573. /**
  76574. * Numeric tolerance value
  76575. */
  76576. private static readonly _Epsilon;
  76577. /**
  76578. * Reference to the glTF Exporter
  76579. */
  76580. private _exporter;
  76581. constructor(exporter: _Exporter);
  76582. /**
  76583. * Specifies if two colors are approximately equal in value
  76584. * @param color1 first color to compare to
  76585. * @param color2 second color to compare to
  76586. * @param epsilon threshold value
  76587. */
  76588. private static FuzzyEquals;
  76589. /**
  76590. * Gets the materials from a Babylon scene and converts them to glTF materials
  76591. * @param scene babylonjs scene
  76592. * @param mimeType texture mime type
  76593. * @param images array of images
  76594. * @param textures array of textures
  76595. * @param materials array of materials
  76596. * @param imageData mapping of texture names to base64 textures
  76597. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76598. */
  76599. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76600. /**
  76601. * Makes a copy of the glTF material without the texture parameters
  76602. * @param originalMaterial original glTF material
  76603. * @returns glTF material without texture parameters
  76604. */
  76605. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76606. /**
  76607. * Specifies if the material has any texture parameters present
  76608. * @param material glTF Material
  76609. * @returns boolean specifying if texture parameters are present
  76610. */
  76611. _hasTexturesPresent(material: IMaterial): boolean;
  76612. /**
  76613. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76614. * @param babylonStandardMaterial
  76615. * @returns glTF Metallic Roughness Material representation
  76616. */
  76617. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76618. /**
  76619. * Computes the metallic factor
  76620. * @param diffuse diffused value
  76621. * @param specular specular value
  76622. * @param oneMinusSpecularStrength one minus the specular strength
  76623. * @returns metallic value
  76624. */
  76625. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76626. /**
  76627. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76628. * @param glTFMaterial glTF material
  76629. * @param babylonMaterial Babylon material
  76630. */
  76631. private static _SetAlphaMode;
  76632. /**
  76633. * Converts a Babylon Standard Material to a glTF Material
  76634. * @param babylonStandardMaterial BJS Standard Material
  76635. * @param mimeType mime type to use for the textures
  76636. * @param images array of glTF image interfaces
  76637. * @param textures array of glTF texture interfaces
  76638. * @param materials array of glTF material interfaces
  76639. * @param imageData map of image file name to data
  76640. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76641. */
  76642. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76643. private _finishMaterial;
  76644. /**
  76645. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76646. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76647. * @param mimeType mime type to use for the textures
  76648. * @param images array of glTF image interfaces
  76649. * @param textures array of glTF texture interfaces
  76650. * @param materials array of glTF material interfaces
  76651. * @param imageData map of image file name to data
  76652. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76653. */
  76654. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76655. /**
  76656. * Converts an image typed array buffer to a base64 image
  76657. * @param buffer typed array buffer
  76658. * @param width width of the image
  76659. * @param height height of the image
  76660. * @param mimeType mimetype of the image
  76661. * @returns base64 image string
  76662. */
  76663. private _createBase64FromCanvasAsync;
  76664. /**
  76665. * Generates a white texture based on the specified width and height
  76666. * @param width width of the texture in pixels
  76667. * @param height height of the texture in pixels
  76668. * @param scene babylonjs scene
  76669. * @returns white texture
  76670. */
  76671. private _createWhiteTexture;
  76672. /**
  76673. * 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
  76674. * @param texture1 first texture to resize
  76675. * @param texture2 second texture to resize
  76676. * @param scene babylonjs scene
  76677. * @returns resized textures or null
  76678. */
  76679. private _resizeTexturesToSameDimensions;
  76680. /**
  76681. * Converts an array of pixels to a Float32Array
  76682. * Throws an error if the pixel format is not supported
  76683. * @param pixels - array buffer containing pixel values
  76684. * @returns Float32 of pixels
  76685. */
  76686. private _convertPixelArrayToFloat32;
  76687. /**
  76688. * Convert Specular Glossiness Textures to Metallic Roughness
  76689. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76690. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76691. * @param diffuseTexture texture used to store diffuse information
  76692. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76693. * @param factors specular glossiness material factors
  76694. * @param mimeType the mime type to use for the texture
  76695. * @returns pbr metallic roughness interface or null
  76696. */
  76697. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76698. /**
  76699. * Converts specular glossiness material properties to metallic roughness
  76700. * @param specularGlossiness interface with specular glossiness material properties
  76701. * @returns interface with metallic roughness material properties
  76702. */
  76703. private _convertSpecularGlossinessToMetallicRoughness;
  76704. /**
  76705. * Calculates the surface reflectance, independent of lighting conditions
  76706. * @param color Color source to calculate brightness from
  76707. * @returns number representing the perceived brightness, or zero if color is undefined
  76708. */
  76709. private _getPerceivedBrightness;
  76710. /**
  76711. * Returns the maximum color component value
  76712. * @param color
  76713. * @returns maximum color component value, or zero if color is null or undefined
  76714. */
  76715. private _getMaxComponent;
  76716. /**
  76717. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76718. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76719. * @param mimeType mime type to use for the textures
  76720. * @param images array of glTF image interfaces
  76721. * @param textures array of glTF texture interfaces
  76722. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76723. * @param imageData map of image file name to data
  76724. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76725. * @returns glTF PBR Metallic Roughness factors
  76726. */
  76727. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76728. private _getGLTFTextureSampler;
  76729. private _getGLTFTextureWrapMode;
  76730. private _getGLTFTextureWrapModesSampler;
  76731. /**
  76732. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76733. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76734. * @param mimeType mime type to use for the textures
  76735. * @param images array of glTF image interfaces
  76736. * @param textures array of glTF texture interfaces
  76737. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76738. * @param imageData map of image file name to data
  76739. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76740. * @returns glTF PBR Metallic Roughness factors
  76741. */
  76742. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76743. /**
  76744. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76745. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76746. * @param mimeType mime type to use for the textures
  76747. * @param images array of glTF image interfaces
  76748. * @param textures array of glTF texture interfaces
  76749. * @param materials array of glTF material interfaces
  76750. * @param imageData map of image file name to data
  76751. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76752. */
  76753. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76754. private setMetallicRoughnessPbrMaterial;
  76755. private getPixelsFromTexture;
  76756. /**
  76757. * Extracts a texture from a Babylon texture into file data and glTF data
  76758. * @param babylonTexture Babylon texture to extract
  76759. * @param mimeType Mime Type of the babylonTexture
  76760. * @return glTF texture info, or null if the texture format is not supported
  76761. */
  76762. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76763. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76764. /**
  76765. * Builds a texture from base64 string
  76766. * @param base64Texture base64 texture string
  76767. * @param baseTextureName Name to use for the texture
  76768. * @param mimeType image mime type for the texture
  76769. * @param images array of images
  76770. * @param textures array of textures
  76771. * @param imageData map of image data
  76772. * @returns glTF texture info, or null if the texture format is not supported
  76773. */
  76774. private _getTextureInfoFromBase64;
  76775. }
  76776. }
  76777. declare module BABYLON {
  76778. /**
  76779. * Class for holding and downloading glTF file data
  76780. */
  76781. export class GLTFData {
  76782. /**
  76783. * Object which contains the file name as the key and its data as the value
  76784. */
  76785. glTFFiles: {
  76786. [fileName: string]: string | Blob;
  76787. };
  76788. /**
  76789. * Initializes the glTF file object
  76790. */
  76791. constructor();
  76792. /**
  76793. * Downloads the glTF data as files based on their names and data
  76794. */
  76795. downloadFiles(): void;
  76796. }
  76797. }
  76798. declare module BABYLON {
  76799. /**
  76800. * Holds a collection of exporter options and parameters
  76801. */
  76802. export interface IExportOptions {
  76803. /**
  76804. * Function which indicates whether a babylon node should be exported or not
  76805. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76806. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76807. */
  76808. shouldExportNode?(node: Node): boolean;
  76809. /**
  76810. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76811. * @param metadata source metadata to read from
  76812. * @returns the data to store to glTF node extras
  76813. */
  76814. metadataSelector?(metadata: any): any;
  76815. /**
  76816. * The sample rate to bake animation curves
  76817. */
  76818. animationSampleRate?: number;
  76819. /**
  76820. * Begin serialization without waiting for the scene to be ready
  76821. */
  76822. exportWithoutWaitingForScene?: boolean;
  76823. /**
  76824. * Indicates if coordinate system swapping root nodes should be included in export
  76825. */
  76826. includeCoordinateSystemConversionNodes?: boolean;
  76827. }
  76828. /**
  76829. * Class for generating glTF data from a Babylon scene.
  76830. */
  76831. export class GLTF2Export {
  76832. /**
  76833. * Exports the geometry of the scene to .gltf file format asynchronously
  76834. * @param scene Babylon scene with scene hierarchy information
  76835. * @param filePrefix File prefix to use when generating the glTF file
  76836. * @param options Exporter options
  76837. * @returns Returns an object with a .gltf file and associates texture names
  76838. * as keys and their data and paths as values
  76839. */
  76840. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76841. private static _PreExportAsync;
  76842. private static _PostExportAsync;
  76843. /**
  76844. * Exports the geometry of the scene to .glb file format asychronously
  76845. * @param scene Babylon scene with scene hierarchy information
  76846. * @param filePrefix File prefix to use when generating glb file
  76847. * @param options Exporter options
  76848. * @returns Returns an object with a .glb filename as key and data as value
  76849. */
  76850. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76851. }
  76852. }
  76853. declare module BABYLON.GLTF2.Exporter {
  76854. /**
  76855. * @hidden
  76856. */
  76857. export class _GLTFUtilities {
  76858. /**
  76859. * Creates a buffer view based on the supplied arguments
  76860. * @param bufferIndex index value of the specified buffer
  76861. * @param byteOffset byte offset value
  76862. * @param byteLength byte length of the bufferView
  76863. * @param byteStride byte distance between conequential elements
  76864. * @param name name of the buffer view
  76865. * @returns bufferView for glTF
  76866. */
  76867. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76868. /**
  76869. * Creates an accessor based on the supplied arguments
  76870. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76871. * @param name The name of the accessor
  76872. * @param type The type of the accessor
  76873. * @param componentType The datatype of components in the attribute
  76874. * @param count The number of attributes referenced by this accessor
  76875. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76876. * @param min Minimum value of each component in this attribute
  76877. * @param max Maximum value of each component in this attribute
  76878. * @returns accessor for glTF
  76879. */
  76880. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76881. /**
  76882. * Calculates the minimum and maximum values of an array of position floats
  76883. * @param positions Positions array of a mesh
  76884. * @param vertexStart Starting vertex offset to calculate min and max values
  76885. * @param vertexCount Number of vertices to check for min and max values
  76886. * @returns min number array and max number array
  76887. */
  76888. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76889. min: number[];
  76890. max: number[];
  76891. };
  76892. /**
  76893. * Converts a new right-handed Vector3
  76894. * @param vector vector3 array
  76895. * @returns right-handed Vector3
  76896. */
  76897. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76898. /**
  76899. * Converts a Vector3 to right-handed
  76900. * @param vector Vector3 to convert to right-handed
  76901. */
  76902. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76903. /**
  76904. * Converts a three element number array to right-handed
  76905. * @param vector number array to convert to right-handed
  76906. */
  76907. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76908. /**
  76909. * Converts a new right-handed Vector3
  76910. * @param vector vector3 array
  76911. * @returns right-handed Vector3
  76912. */
  76913. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76914. /**
  76915. * Converts a Vector3 to right-handed
  76916. * @param vector Vector3 to convert to right-handed
  76917. */
  76918. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76919. /**
  76920. * Converts a three element number array to right-handed
  76921. * @param vector number array to convert to right-handed
  76922. */
  76923. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76924. /**
  76925. * Converts a Vector4 to right-handed
  76926. * @param vector Vector4 to convert to right-handed
  76927. */
  76928. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76929. /**
  76930. * Converts a Vector4 to right-handed
  76931. * @param vector Vector4 to convert to right-handed
  76932. */
  76933. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76934. /**
  76935. * Converts a Quaternion to right-handed
  76936. * @param quaternion Source quaternion to convert to right-handed
  76937. */
  76938. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76939. /**
  76940. * Converts a Quaternion to right-handed
  76941. * @param quaternion Source quaternion to convert to right-handed
  76942. */
  76943. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76944. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76945. }
  76946. }
  76947. declare module BABYLON.GLTF2.Exporter {
  76948. /**
  76949. * Converts Babylon Scene into glTF 2.0.
  76950. * @hidden
  76951. */
  76952. export class _Exporter {
  76953. /**
  76954. * Stores the glTF to export
  76955. */
  76956. _glTF: IGLTF;
  76957. /**
  76958. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76959. */
  76960. _bufferViews: IBufferView[];
  76961. /**
  76962. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76963. */
  76964. _accessors: IAccessor[];
  76965. /**
  76966. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76967. */
  76968. _nodes: INode[];
  76969. /**
  76970. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76971. */
  76972. private _scenes;
  76973. /**
  76974. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76975. */
  76976. private _meshes;
  76977. /**
  76978. * Stores all the generated material information, which represents the appearance of each primitive
  76979. */
  76980. _materials: IMaterial[];
  76981. _materialMap: {
  76982. [materialID: number]: number;
  76983. };
  76984. /**
  76985. * Stores all the generated texture information, which is referenced by glTF materials
  76986. */
  76987. _textures: ITexture[];
  76988. /**
  76989. * Stores all the generated image information, which is referenced by glTF textures
  76990. */
  76991. _images: IImage[];
  76992. /**
  76993. * Stores all the texture samplers
  76994. */
  76995. _samplers: ISampler[];
  76996. /**
  76997. * Stores all the generated animation samplers, which is referenced by glTF animations
  76998. */
  76999. /**
  77000. * Stores the animations for glTF models
  77001. */
  77002. private _animations;
  77003. /**
  77004. * Stores the total amount of bytes stored in the glTF buffer
  77005. */
  77006. private _totalByteLength;
  77007. /**
  77008. * Stores a reference to the Babylon scene containing the source geometry and material information
  77009. */
  77010. _babylonScene: Scene;
  77011. /**
  77012. * Stores a map of the image data, where the key is the file name and the value
  77013. * is the image data
  77014. */
  77015. _imageData: {
  77016. [fileName: string]: {
  77017. data: Uint8Array;
  77018. mimeType: ImageMimeType;
  77019. };
  77020. };
  77021. /**
  77022. * Stores a map of the unique id of a node to its index in the node array
  77023. */
  77024. _nodeMap: {
  77025. [key: number]: number;
  77026. };
  77027. /**
  77028. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77029. */
  77030. _convertToRightHandedSystem: boolean;
  77031. /**
  77032. * Specifies if a Babylon node should be converted to right-handed on export
  77033. */
  77034. _convertToRightHandedSystemMap: {
  77035. [nodeId: number]: boolean;
  77036. };
  77037. _includeCoordinateSystemConversionNodes: boolean;
  77038. /**
  77039. * Baked animation sample rate
  77040. */
  77041. private _animationSampleRate;
  77042. private _options;
  77043. private _localEngine;
  77044. _glTFMaterialExporter: _GLTFMaterialExporter;
  77045. private _extensions;
  77046. private static _ExtensionNames;
  77047. private static _ExtensionFactories;
  77048. private _applyExtension;
  77049. private _applyExtensions;
  77050. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77051. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77052. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77053. [key: number]: number;
  77054. }): Promise<Nullable<INode>>;
  77055. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77056. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77057. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77058. private _forEachExtensions;
  77059. private _extensionsOnExporting;
  77060. /**
  77061. * Load glTF serializer extensions
  77062. */
  77063. private _loadExtensions;
  77064. /**
  77065. * Creates a glTF Exporter instance, which can accept optional exporter options
  77066. * @param babylonScene Babylon scene object
  77067. * @param options Options to modify the behavior of the exporter
  77068. */
  77069. constructor(babylonScene: Scene, options?: IExportOptions);
  77070. dispose(): void;
  77071. /**
  77072. * Registers a glTF exporter extension
  77073. * @param name Name of the extension to export
  77074. * @param factory The factory function that creates the exporter extension
  77075. */
  77076. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77077. /**
  77078. * Un-registers an exporter extension
  77079. * @param name The name fo the exporter extension
  77080. * @returns A boolean indicating whether the extension has been un-registered
  77081. */
  77082. static UnregisterExtension(name: string): boolean;
  77083. /**
  77084. * Lazy load a local engine
  77085. */
  77086. _getLocalEngine(): Engine;
  77087. private reorderIndicesBasedOnPrimitiveMode;
  77088. /**
  77089. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77090. * clock-wise during export to glTF
  77091. * @param submesh BabylonJS submesh
  77092. * @param primitiveMode Primitive mode of the mesh
  77093. * @param sideOrientation the winding order of the submesh
  77094. * @param vertexBufferKind The type of vertex attribute
  77095. * @param meshAttributeArray The vertex attribute data
  77096. * @param byteOffset The offset to the binary data
  77097. * @param binaryWriter The binary data for the glTF file
  77098. * @param convertToRightHandedSystem Converts the values to right-handed
  77099. */
  77100. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77101. /**
  77102. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77103. * clock-wise during export to glTF
  77104. * @param submesh BabylonJS submesh
  77105. * @param primitiveMode Primitive mode of the mesh
  77106. * @param sideOrientation the winding order of the submesh
  77107. * @param vertexBufferKind The type of vertex attribute
  77108. * @param meshAttributeArray The vertex attribute data
  77109. * @param byteOffset The offset to the binary data
  77110. * @param binaryWriter The binary data for the glTF file
  77111. * @param convertToRightHandedSystem Converts the values to right-handed
  77112. */
  77113. private reorderTriangleFillMode;
  77114. /**
  77115. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77116. * clock-wise during export to glTF
  77117. * @param submesh BabylonJS submesh
  77118. * @param primitiveMode Primitive mode of the mesh
  77119. * @param sideOrientation the winding order of the submesh
  77120. * @param vertexBufferKind The type of vertex attribute
  77121. * @param meshAttributeArray The vertex attribute data
  77122. * @param byteOffset The offset to the binary data
  77123. * @param binaryWriter The binary data for the glTF file
  77124. * @param convertToRightHandedSystem Converts the values to right-handed
  77125. */
  77126. private reorderTriangleStripDrawMode;
  77127. /**
  77128. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77129. * clock-wise during export to glTF
  77130. * @param submesh BabylonJS submesh
  77131. * @param primitiveMode Primitive mode of the mesh
  77132. * @param sideOrientation the winding order of the submesh
  77133. * @param vertexBufferKind The type of vertex attribute
  77134. * @param meshAttributeArray The vertex attribute data
  77135. * @param byteOffset The offset to the binary data
  77136. * @param binaryWriter The binary data for the glTF file
  77137. * @param convertToRightHandedSystem Converts the values to right-handed
  77138. */
  77139. private reorderTriangleFanMode;
  77140. /**
  77141. * Writes the vertex attribute data to binary
  77142. * @param vertices The vertices to write to the binary writer
  77143. * @param byteOffset The offset into the binary writer to overwrite binary data
  77144. * @param vertexAttributeKind The vertex attribute type
  77145. * @param meshAttributeArray The vertex attribute data
  77146. * @param binaryWriter The writer containing the binary data
  77147. * @param convertToRightHandedSystem Converts the values to right-handed
  77148. */
  77149. private writeVertexAttributeData;
  77150. /**
  77151. * Writes mesh attribute data to a data buffer
  77152. * Returns the bytelength of the data
  77153. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77154. * @param meshAttributeArray Array containing the attribute data
  77155. * @param binaryWriter The buffer to write the binary data to
  77156. * @param indices Used to specify the order of the vertex data
  77157. * @param convertToRightHandedSystem Converts the values to right-handed
  77158. */
  77159. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77160. /**
  77161. * Generates glTF json data
  77162. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77163. * @param glTFPrefix Text to use when prefixing a glTF file
  77164. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77165. * @returns json data as string
  77166. */
  77167. private generateJSON;
  77168. /**
  77169. * Generates data for .gltf and .bin files based on the glTF prefix string
  77170. * @param glTFPrefix Text to use when prefixing a glTF file
  77171. * @param dispose Dispose the exporter
  77172. * @returns GLTFData with glTF file data
  77173. */
  77174. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77175. /**
  77176. * Creates a binary buffer for glTF
  77177. * @returns array buffer for binary data
  77178. */
  77179. private _generateBinaryAsync;
  77180. /**
  77181. * Pads the number to a multiple of 4
  77182. * @param num number to pad
  77183. * @returns padded number
  77184. */
  77185. private _getPadding;
  77186. /**
  77187. * @hidden
  77188. */
  77189. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77190. /**
  77191. * Sets the TRS for each node
  77192. * @param node glTF Node for storing the transformation data
  77193. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77194. * @param convertToRightHandedSystem Converts the values to right-handed
  77195. */
  77196. private setNodeTransformation;
  77197. private getVertexBufferFromMesh;
  77198. /**
  77199. * Creates a bufferview based on the vertices type for the Babylon mesh
  77200. * @param kind Indicates the type of vertices data
  77201. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77202. * @param binaryWriter The buffer to write the bufferview data to
  77203. * @param convertToRightHandedSystem Converts the values to right-handed
  77204. */
  77205. private createBufferViewKind;
  77206. /**
  77207. * The primitive mode of the Babylon mesh
  77208. * @param babylonMesh The BabylonJS mesh
  77209. */
  77210. private getMeshPrimitiveMode;
  77211. /**
  77212. * Sets the primitive mode of the glTF mesh primitive
  77213. * @param meshPrimitive glTF mesh primitive
  77214. * @param primitiveMode The primitive mode
  77215. */
  77216. private setPrimitiveMode;
  77217. /**
  77218. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77219. * @param meshPrimitive glTF mesh primitive
  77220. * @param attributeKind vertex attribute
  77221. * @returns boolean specifying if uv coordinates are present
  77222. */
  77223. private setAttributeKind;
  77224. /**
  77225. * Sets data for the primitive attributes of each submesh
  77226. * @param mesh glTF Mesh object to store the primitive attribute information
  77227. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77228. * @param binaryWriter Buffer to write the attribute data to
  77229. * @param convertToRightHandedSystem Converts the values to right-handed
  77230. */
  77231. private setPrimitiveAttributesAsync;
  77232. /**
  77233. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  77234. * @param node The node to check
  77235. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  77236. */
  77237. private isBabylonCoordinateSystemConvertingNode;
  77238. /**
  77239. * Creates a glTF scene based on the array of meshes
  77240. * Returns the the total byte offset
  77241. * @param babylonScene Babylon scene to get the mesh data from
  77242. * @param binaryWriter Buffer to write binary data to
  77243. */
  77244. private createSceneAsync;
  77245. /**
  77246. * Creates a mapping of Node unique id to node index and handles animations
  77247. * @param babylonScene Babylon Scene
  77248. * @param nodes Babylon transform nodes
  77249. * @param binaryWriter Buffer to write binary data to
  77250. * @returns Node mapping of unique id to index
  77251. */
  77252. private createNodeMapAndAnimationsAsync;
  77253. /**
  77254. * Creates a glTF node from a Babylon mesh
  77255. * @param babylonMesh Source Babylon mesh
  77256. * @param binaryWriter Buffer for storing geometry data
  77257. * @param convertToRightHandedSystem Converts the values to right-handed
  77258. * @param nodeMap Node mapping of unique id to glTF node index
  77259. * @returns glTF node
  77260. */
  77261. private createNodeAsync;
  77262. }
  77263. /**
  77264. * @hidden
  77265. *
  77266. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77267. */
  77268. export class _BinaryWriter {
  77269. /**
  77270. * Array buffer which stores all binary data
  77271. */
  77272. private _arrayBuffer;
  77273. /**
  77274. * View of the array buffer
  77275. */
  77276. private _dataView;
  77277. /**
  77278. * byte offset of data in array buffer
  77279. */
  77280. private _byteOffset;
  77281. /**
  77282. * Initialize binary writer with an initial byte length
  77283. * @param byteLength Initial byte length of the array buffer
  77284. */
  77285. constructor(byteLength: number);
  77286. /**
  77287. * Resize the array buffer to the specified byte length
  77288. * @param byteLength
  77289. */
  77290. private resizeBuffer;
  77291. /**
  77292. * Get an array buffer with the length of the byte offset
  77293. * @returns ArrayBuffer resized to the byte offset
  77294. */
  77295. getArrayBuffer(): ArrayBuffer;
  77296. /**
  77297. * Get the byte offset of the array buffer
  77298. * @returns byte offset
  77299. */
  77300. getByteOffset(): number;
  77301. /**
  77302. * Stores an UInt8 in the array buffer
  77303. * @param entry
  77304. * @param byteOffset If defined, specifies where to set the value as an offset.
  77305. */
  77306. setUInt8(entry: number, byteOffset?: number): void;
  77307. /**
  77308. * Gets an UInt32 in the array buffer
  77309. * @param entry
  77310. * @param byteOffset If defined, specifies where to set the value as an offset.
  77311. */
  77312. getUInt32(byteOffset: number): number;
  77313. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77314. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77315. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77316. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77317. /**
  77318. * Stores a Float32 in the array buffer
  77319. * @param entry
  77320. */
  77321. setFloat32(entry: number, byteOffset?: number): void;
  77322. /**
  77323. * Stores an UInt32 in the array buffer
  77324. * @param entry
  77325. * @param byteOffset If defined, specifies where to set the value as an offset.
  77326. */
  77327. setUInt32(entry: number, byteOffset?: number): void;
  77328. }
  77329. }
  77330. declare module BABYLON.GLTF2.Exporter {
  77331. /**
  77332. * @hidden
  77333. * Interface to store animation data.
  77334. */
  77335. export interface _IAnimationData {
  77336. /**
  77337. * Keyframe data.
  77338. */
  77339. inputs: number[];
  77340. /**
  77341. * Value data.
  77342. */
  77343. outputs: number[][];
  77344. /**
  77345. * Animation interpolation data.
  77346. */
  77347. samplerInterpolation: AnimationSamplerInterpolation;
  77348. /**
  77349. * Minimum keyframe value.
  77350. */
  77351. inputsMin: number;
  77352. /**
  77353. * Maximum keyframe value.
  77354. */
  77355. inputsMax: number;
  77356. }
  77357. /**
  77358. * @hidden
  77359. */
  77360. export interface _IAnimationInfo {
  77361. /**
  77362. * The target channel for the animation
  77363. */
  77364. animationChannelTargetPath: AnimationChannelTargetPath;
  77365. /**
  77366. * The glTF accessor type for the data.
  77367. */
  77368. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77369. /**
  77370. * Specifies if quaternions should be used.
  77371. */
  77372. useQuaternion: boolean;
  77373. }
  77374. /**
  77375. * @hidden
  77376. * Utility class for generating glTF animation data from BabylonJS.
  77377. */
  77378. export class _GLTFAnimation {
  77379. /**
  77380. * @ignore
  77381. *
  77382. * Creates glTF channel animation from BabylonJS animation.
  77383. * @param babylonTransformNode - BabylonJS mesh.
  77384. * @param animation - animation.
  77385. * @param animationChannelTargetPath - The target animation channel.
  77386. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77387. * @param useQuaternion - Specifies if quaternions are used.
  77388. * @returns nullable IAnimationData
  77389. */
  77390. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77391. private static _DeduceAnimationInfo;
  77392. /**
  77393. * @ignore
  77394. * Create node animations from the transform node animations
  77395. * @param babylonNode
  77396. * @param runtimeGLTFAnimation
  77397. * @param idleGLTFAnimations
  77398. * @param nodeMap
  77399. * @param nodes
  77400. * @param binaryWriter
  77401. * @param bufferViews
  77402. * @param accessors
  77403. * @param convertToRightHandedSystem
  77404. * @param animationSampleRate
  77405. */
  77406. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77407. [key: number]: number;
  77408. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77409. /**
  77410. * @ignore
  77411. * Create node animations from the animation groups
  77412. * @param babylonScene
  77413. * @param glTFAnimations
  77414. * @param nodeMap
  77415. * @param nodes
  77416. * @param binaryWriter
  77417. * @param bufferViews
  77418. * @param accessors
  77419. * @param convertToRightHandedSystemMap
  77420. * @param animationSampleRate
  77421. */
  77422. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77423. [key: number]: number;
  77424. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  77425. [nodeId: number]: boolean;
  77426. }, animationSampleRate: number): void;
  77427. private static AddAnimation;
  77428. /**
  77429. * Create a baked animation
  77430. * @param babylonTransformNode BabylonJS mesh
  77431. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77432. * @param animationChannelTargetPath animation target channel
  77433. * @param minFrame minimum animation frame
  77434. * @param maxFrame maximum animation frame
  77435. * @param fps frames per second of the animation
  77436. * @param inputs input key frames of the animation
  77437. * @param outputs output key frame data of the animation
  77438. * @param convertToRightHandedSystem converts the values to right-handed
  77439. * @param useQuaternion specifies if quaternions should be used
  77440. */
  77441. private static _CreateBakedAnimation;
  77442. private static _ConvertFactorToVector3OrQuaternion;
  77443. private static _SetInterpolatedValue;
  77444. /**
  77445. * Creates linear animation from the animation key frames
  77446. * @param babylonTransformNode BabylonJS mesh
  77447. * @param animation BabylonJS animation
  77448. * @param animationChannelTargetPath The target animation channel
  77449. * @param frameDelta The difference between the last and first frame of the animation
  77450. * @param inputs Array to store the key frame times
  77451. * @param outputs Array to store the key frame data
  77452. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77453. * @param useQuaternion Specifies if quaternions are used in the animation
  77454. */
  77455. private static _CreateLinearOrStepAnimation;
  77456. /**
  77457. * Creates cubic spline animation from the animation key frames
  77458. * @param babylonTransformNode BabylonJS mesh
  77459. * @param animation BabylonJS animation
  77460. * @param animationChannelTargetPath The target animation channel
  77461. * @param frameDelta The difference between the last and first frame of the animation
  77462. * @param inputs Array to store the key frame times
  77463. * @param outputs Array to store the key frame data
  77464. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77465. * @param useQuaternion Specifies if quaternions are used in the animation
  77466. */
  77467. private static _CreateCubicSplineAnimation;
  77468. private static _GetBasePositionRotationOrScale;
  77469. /**
  77470. * Adds a key frame value
  77471. * @param keyFrame
  77472. * @param animation
  77473. * @param outputs
  77474. * @param animationChannelTargetPath
  77475. * @param basePositionRotationOrScale
  77476. * @param convertToRightHandedSystem
  77477. * @param useQuaternion
  77478. */
  77479. private static _AddKeyframeValue;
  77480. /**
  77481. * Determine the interpolation based on the key frames
  77482. * @param keyFrames
  77483. * @param animationChannelTargetPath
  77484. * @param useQuaternion
  77485. */
  77486. private static _DeduceInterpolation;
  77487. /**
  77488. * Adds an input tangent or output tangent to the output data
  77489. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77490. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77491. * @param outputs The animation data by keyframe
  77492. * @param animationChannelTargetPath The target animation channel
  77493. * @param interpolation The interpolation type
  77494. * @param keyFrame The key frame with the animation data
  77495. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77496. * @param useQuaternion Specifies if quaternions are used
  77497. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77498. */
  77499. private static AddSplineTangent;
  77500. /**
  77501. * Get the minimum and maximum key frames' frame values
  77502. * @param keyFrames animation key frames
  77503. * @returns the minimum and maximum key frame value
  77504. */
  77505. private static calculateMinMaxKeyFrames;
  77506. }
  77507. }
  77508. declare module BABYLON.GLTF2.Exporter {
  77509. /** @hidden */
  77510. export var textureTransformPixelShader: {
  77511. name: string;
  77512. shader: string;
  77513. };
  77514. }
  77515. declare module BABYLON.GLTF2.Exporter.Extensions {
  77516. /**
  77517. * @hidden
  77518. */
  77519. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77520. private _recordedTextures;
  77521. /** Name of this extension */
  77522. readonly name: string;
  77523. /** Defines whether this extension is enabled */
  77524. enabled: boolean;
  77525. /** Defines whether this extension is required */
  77526. required: boolean;
  77527. /** Reference to the glTF exporter */
  77528. private _wasUsed;
  77529. constructor(exporter: _Exporter);
  77530. dispose(): void;
  77531. /** @hidden */
  77532. get wasUsed(): boolean;
  77533. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77534. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77535. /**
  77536. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77537. * @param babylonTexture
  77538. * @param offset
  77539. * @param rotation
  77540. * @param scale
  77541. * @param scene
  77542. */
  77543. private _textureTransformTextureAsync;
  77544. }
  77545. }
  77546. declare module BABYLON.GLTF2.Exporter.Extensions {
  77547. /**
  77548. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77549. */
  77550. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77551. /** The name of this extension. */
  77552. readonly name: string;
  77553. /** Defines whether this extension is enabled. */
  77554. enabled: boolean;
  77555. /** Defines whether this extension is required */
  77556. required: boolean;
  77557. /** Reference to the glTF exporter */
  77558. private _exporter;
  77559. private _lights;
  77560. /** @hidden */
  77561. constructor(exporter: _Exporter);
  77562. /** @hidden */
  77563. dispose(): void;
  77564. /** @hidden */
  77565. get wasUsed(): boolean;
  77566. /** @hidden */
  77567. onExporting(): void;
  77568. /**
  77569. * Define this method to modify the default behavior when exporting a node
  77570. * @param context The context when exporting the node
  77571. * @param node glTF node
  77572. * @param babylonNode BabylonJS node
  77573. * @param nodeMap Node mapping of unique id to glTF node index
  77574. * @returns nullable INode promise
  77575. */
  77576. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77577. [key: number]: number;
  77578. }): Promise<Nullable<INode>>;
  77579. }
  77580. }
  77581. declare module BABYLON.GLTF2.Exporter.Extensions {
  77582. /**
  77583. * @hidden
  77584. */
  77585. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77586. /** Name of this extension */
  77587. readonly name: string;
  77588. /** Defines whether this extension is enabled */
  77589. enabled: boolean;
  77590. /** Defines whether this extension is required */
  77591. required: boolean;
  77592. /** Reference to the glTF exporter */
  77593. private _textureInfos;
  77594. private _exportedTextures;
  77595. private _wasUsed;
  77596. constructor(exporter: _Exporter);
  77597. dispose(): void;
  77598. /** @hidden */
  77599. get wasUsed(): boolean;
  77600. private _getTextureIndex;
  77601. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77602. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77603. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77604. }
  77605. }
  77606. declare module BABYLON {
  77607. /**
  77608. * Class for generating STL data from a Babylon scene.
  77609. */
  77610. export class STLExport {
  77611. /**
  77612. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77613. * @param meshes list defines the mesh to serialize
  77614. * @param download triggers the automatic download of the file.
  77615. * @param fileName changes the downloads fileName.
  77616. * @param binary changes the STL to a binary type.
  77617. * @param isLittleEndian toggle for binary type exporter.
  77618. * @returns the STL as UTF8 string
  77619. */
  77620. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77621. }
  77622. }
  77623. declare module "babylonjs-gltf2interface" {
  77624. export = BABYLON.GLTF2;
  77625. }
  77626. /**
  77627. * Module for glTF 2.0 Interface
  77628. */
  77629. declare module BABYLON.GLTF2 {
  77630. /**
  77631. * The datatype of the components in the attribute
  77632. */
  77633. const enum AccessorComponentType {
  77634. /**
  77635. * Byte
  77636. */
  77637. BYTE = 5120,
  77638. /**
  77639. * Unsigned Byte
  77640. */
  77641. UNSIGNED_BYTE = 5121,
  77642. /**
  77643. * Short
  77644. */
  77645. SHORT = 5122,
  77646. /**
  77647. * Unsigned Short
  77648. */
  77649. UNSIGNED_SHORT = 5123,
  77650. /**
  77651. * Unsigned Int
  77652. */
  77653. UNSIGNED_INT = 5125,
  77654. /**
  77655. * Float
  77656. */
  77657. FLOAT = 5126,
  77658. }
  77659. /**
  77660. * Specifies if the attirbute is a scalar, vector, or matrix
  77661. */
  77662. const enum AccessorType {
  77663. /**
  77664. * Scalar
  77665. */
  77666. SCALAR = "SCALAR",
  77667. /**
  77668. * Vector2
  77669. */
  77670. VEC2 = "VEC2",
  77671. /**
  77672. * Vector3
  77673. */
  77674. VEC3 = "VEC3",
  77675. /**
  77676. * Vector4
  77677. */
  77678. VEC4 = "VEC4",
  77679. /**
  77680. * Matrix2x2
  77681. */
  77682. MAT2 = "MAT2",
  77683. /**
  77684. * Matrix3x3
  77685. */
  77686. MAT3 = "MAT3",
  77687. /**
  77688. * Matrix4x4
  77689. */
  77690. MAT4 = "MAT4",
  77691. }
  77692. /**
  77693. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77694. */
  77695. const enum AnimationChannelTargetPath {
  77696. /**
  77697. * Translation
  77698. */
  77699. TRANSLATION = "translation",
  77700. /**
  77701. * Rotation
  77702. */
  77703. ROTATION = "rotation",
  77704. /**
  77705. * Scale
  77706. */
  77707. SCALE = "scale",
  77708. /**
  77709. * Weights
  77710. */
  77711. WEIGHTS = "weights",
  77712. }
  77713. /**
  77714. * Interpolation algorithm
  77715. */
  77716. const enum AnimationSamplerInterpolation {
  77717. /**
  77718. * The animated values are linearly interpolated between keyframes
  77719. */
  77720. LINEAR = "LINEAR",
  77721. /**
  77722. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77723. */
  77724. STEP = "STEP",
  77725. /**
  77726. * The animation's interpolation is computed using a cubic spline with specified tangents
  77727. */
  77728. CUBICSPLINE = "CUBICSPLINE",
  77729. }
  77730. /**
  77731. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77732. */
  77733. const enum CameraType {
  77734. /**
  77735. * A perspective camera containing properties to create a perspective projection matrix
  77736. */
  77737. PERSPECTIVE = "perspective",
  77738. /**
  77739. * An orthographic camera containing properties to create an orthographic projection matrix
  77740. */
  77741. ORTHOGRAPHIC = "orthographic",
  77742. }
  77743. /**
  77744. * The mime-type of the image
  77745. */
  77746. const enum ImageMimeType {
  77747. /**
  77748. * JPEG Mime-type
  77749. */
  77750. JPEG = "image/jpeg",
  77751. /**
  77752. * PNG Mime-type
  77753. */
  77754. PNG = "image/png",
  77755. }
  77756. /**
  77757. * The alpha rendering mode of the material
  77758. */
  77759. const enum MaterialAlphaMode {
  77760. /**
  77761. * The alpha value is ignored and the rendered output is fully opaque
  77762. */
  77763. OPAQUE = "OPAQUE",
  77764. /**
  77765. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77766. */
  77767. MASK = "MASK",
  77768. /**
  77769. * 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)
  77770. */
  77771. BLEND = "BLEND",
  77772. }
  77773. /**
  77774. * The type of the primitives to render
  77775. */
  77776. const enum MeshPrimitiveMode {
  77777. /**
  77778. * Points
  77779. */
  77780. POINTS = 0,
  77781. /**
  77782. * Lines
  77783. */
  77784. LINES = 1,
  77785. /**
  77786. * Line Loop
  77787. */
  77788. LINE_LOOP = 2,
  77789. /**
  77790. * Line Strip
  77791. */
  77792. LINE_STRIP = 3,
  77793. /**
  77794. * Triangles
  77795. */
  77796. TRIANGLES = 4,
  77797. /**
  77798. * Triangle Strip
  77799. */
  77800. TRIANGLE_STRIP = 5,
  77801. /**
  77802. * Triangle Fan
  77803. */
  77804. TRIANGLE_FAN = 6,
  77805. }
  77806. /**
  77807. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77808. */
  77809. const enum TextureMagFilter {
  77810. /**
  77811. * Nearest
  77812. */
  77813. NEAREST = 9728,
  77814. /**
  77815. * Linear
  77816. */
  77817. LINEAR = 9729,
  77818. }
  77819. /**
  77820. * Minification filter. All valid values correspond to WebGL enums
  77821. */
  77822. const enum TextureMinFilter {
  77823. /**
  77824. * Nearest
  77825. */
  77826. NEAREST = 9728,
  77827. /**
  77828. * Linear
  77829. */
  77830. LINEAR = 9729,
  77831. /**
  77832. * Nearest Mip-Map Nearest
  77833. */
  77834. NEAREST_MIPMAP_NEAREST = 9984,
  77835. /**
  77836. * Linear Mipmap Nearest
  77837. */
  77838. LINEAR_MIPMAP_NEAREST = 9985,
  77839. /**
  77840. * Nearest Mipmap Linear
  77841. */
  77842. NEAREST_MIPMAP_LINEAR = 9986,
  77843. /**
  77844. * Linear Mipmap Linear
  77845. */
  77846. LINEAR_MIPMAP_LINEAR = 9987,
  77847. }
  77848. /**
  77849. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77850. */
  77851. const enum TextureWrapMode {
  77852. /**
  77853. * Clamp to Edge
  77854. */
  77855. CLAMP_TO_EDGE = 33071,
  77856. /**
  77857. * Mirrored Repeat
  77858. */
  77859. MIRRORED_REPEAT = 33648,
  77860. /**
  77861. * Repeat
  77862. */
  77863. REPEAT = 10497,
  77864. }
  77865. /**
  77866. * glTF Property
  77867. */
  77868. interface IProperty {
  77869. /**
  77870. * Dictionary object with extension-specific objects
  77871. */
  77872. extensions?: {
  77873. [key: string]: any;
  77874. };
  77875. /**
  77876. * Application-Specific data
  77877. */
  77878. extras?: any;
  77879. }
  77880. /**
  77881. * glTF Child of Root Property
  77882. */
  77883. interface IChildRootProperty extends IProperty {
  77884. /**
  77885. * The user-defined name of this object
  77886. */
  77887. name?: string;
  77888. }
  77889. /**
  77890. * Indices of those attributes that deviate from their initialization value
  77891. */
  77892. interface IAccessorSparseIndices extends IProperty {
  77893. /**
  77894. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77895. */
  77896. bufferView: number;
  77897. /**
  77898. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77899. */
  77900. byteOffset?: number;
  77901. /**
  77902. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77903. */
  77904. componentType: AccessorComponentType;
  77905. }
  77906. /**
  77907. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77908. */
  77909. interface IAccessorSparseValues extends IProperty {
  77910. /**
  77911. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77912. */
  77913. bufferView: number;
  77914. /**
  77915. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77916. */
  77917. byteOffset?: number;
  77918. }
  77919. /**
  77920. * Sparse storage of attributes that deviate from their initialization value
  77921. */
  77922. interface IAccessorSparse extends IProperty {
  77923. /**
  77924. * The number of attributes encoded in this sparse accessor
  77925. */
  77926. count: number;
  77927. /**
  77928. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77929. */
  77930. indices: IAccessorSparseIndices;
  77931. /**
  77932. * 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
  77933. */
  77934. values: IAccessorSparseValues;
  77935. }
  77936. /**
  77937. * 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
  77938. */
  77939. interface IAccessor extends IChildRootProperty {
  77940. /**
  77941. * The index of the bufferview
  77942. */
  77943. bufferView?: number;
  77944. /**
  77945. * The offset relative to the start of the bufferView in bytes
  77946. */
  77947. byteOffset?: number;
  77948. /**
  77949. * The datatype of components in the attribute
  77950. */
  77951. componentType: AccessorComponentType;
  77952. /**
  77953. * Specifies whether integer data values should be normalized
  77954. */
  77955. normalized?: boolean;
  77956. /**
  77957. * The number of attributes referenced by this accessor
  77958. */
  77959. count: number;
  77960. /**
  77961. * Specifies if the attribute is a scalar, vector, or matrix
  77962. */
  77963. type: AccessorType;
  77964. /**
  77965. * Maximum value of each component in this attribute
  77966. */
  77967. max?: number[];
  77968. /**
  77969. * Minimum value of each component in this attribute
  77970. */
  77971. min?: number[];
  77972. /**
  77973. * Sparse storage of attributes that deviate from their initialization value
  77974. */
  77975. sparse?: IAccessorSparse;
  77976. }
  77977. /**
  77978. * Targets an animation's sampler at a node's property
  77979. */
  77980. interface IAnimationChannel extends IProperty {
  77981. /**
  77982. * The index of a sampler in this animation used to compute the value for the target
  77983. */
  77984. sampler: number;
  77985. /**
  77986. * The index of the node and TRS property to target
  77987. */
  77988. target: IAnimationChannelTarget;
  77989. }
  77990. /**
  77991. * The index of the node and TRS property that an animation channel targets
  77992. */
  77993. interface IAnimationChannelTarget extends IProperty {
  77994. /**
  77995. * The index of the node to target
  77996. */
  77997. node: number;
  77998. /**
  77999. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78000. */
  78001. path: AnimationChannelTargetPath;
  78002. }
  78003. /**
  78004. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78005. */
  78006. interface IAnimationSampler extends IProperty {
  78007. /**
  78008. * The index of an accessor containing keyframe input values, e.g., time
  78009. */
  78010. input: number;
  78011. /**
  78012. * Interpolation algorithm
  78013. */
  78014. interpolation?: AnimationSamplerInterpolation;
  78015. /**
  78016. * The index of an accessor, containing keyframe output values
  78017. */
  78018. output: number;
  78019. }
  78020. /**
  78021. * A keyframe animation
  78022. */
  78023. interface IAnimation extends IChildRootProperty {
  78024. /**
  78025. * An array of channels, each of which targets an animation's sampler at a node's property
  78026. */
  78027. channels: IAnimationChannel[];
  78028. /**
  78029. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78030. */
  78031. samplers: IAnimationSampler[];
  78032. }
  78033. /**
  78034. * Metadata about the glTF asset
  78035. */
  78036. interface IAsset extends IChildRootProperty {
  78037. /**
  78038. * A copyright message suitable for display to credit the content creator
  78039. */
  78040. copyright?: string;
  78041. /**
  78042. * Tool that generated this glTF model. Useful for debugging
  78043. */
  78044. generator?: string;
  78045. /**
  78046. * The glTF version that this asset targets
  78047. */
  78048. version: string;
  78049. /**
  78050. * The minimum glTF version that this asset targets
  78051. */
  78052. minVersion?: string;
  78053. }
  78054. /**
  78055. * A buffer points to binary geometry, animation, or skins
  78056. */
  78057. interface IBuffer extends IChildRootProperty {
  78058. /**
  78059. * 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
  78060. */
  78061. uri?: string;
  78062. /**
  78063. * The length of the buffer in bytes
  78064. */
  78065. byteLength: number;
  78066. }
  78067. /**
  78068. * A view into a buffer generally representing a subset of the buffer
  78069. */
  78070. interface IBufferView extends IChildRootProperty {
  78071. /**
  78072. * The index of the buffer
  78073. */
  78074. buffer: number;
  78075. /**
  78076. * The offset into the buffer in bytes
  78077. */
  78078. byteOffset?: number;
  78079. /**
  78080. * The lenth of the bufferView in bytes
  78081. */
  78082. byteLength: number;
  78083. /**
  78084. * The stride, in bytes
  78085. */
  78086. byteStride?: number;
  78087. }
  78088. /**
  78089. * An orthographic camera containing properties to create an orthographic projection matrix
  78090. */
  78091. interface ICameraOrthographic extends IProperty {
  78092. /**
  78093. * The floating-point horizontal magnification of the view. Must not be zero
  78094. */
  78095. xmag: number;
  78096. /**
  78097. * The floating-point vertical magnification of the view. Must not be zero
  78098. */
  78099. ymag: number;
  78100. /**
  78101. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78102. */
  78103. zfar: number;
  78104. /**
  78105. * The floating-point distance to the near clipping plane
  78106. */
  78107. znear: number;
  78108. }
  78109. /**
  78110. * A perspective camera containing properties to create a perspective projection matrix
  78111. */
  78112. interface ICameraPerspective extends IProperty {
  78113. /**
  78114. * The floating-point aspect ratio of the field of view
  78115. */
  78116. aspectRatio?: number;
  78117. /**
  78118. * The floating-point vertical field of view in radians
  78119. */
  78120. yfov: number;
  78121. /**
  78122. * The floating-point distance to the far clipping plane
  78123. */
  78124. zfar?: number;
  78125. /**
  78126. * The floating-point distance to the near clipping plane
  78127. */
  78128. znear: number;
  78129. }
  78130. /**
  78131. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78132. */
  78133. interface ICamera extends IChildRootProperty {
  78134. /**
  78135. * An orthographic camera containing properties to create an orthographic projection matrix
  78136. */
  78137. orthographic?: ICameraOrthographic;
  78138. /**
  78139. * A perspective camera containing properties to create a perspective projection matrix
  78140. */
  78141. perspective?: ICameraPerspective;
  78142. /**
  78143. * Specifies if the camera uses a perspective or orthographic projection
  78144. */
  78145. type: CameraType;
  78146. }
  78147. /**
  78148. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78149. */
  78150. interface IImage extends IChildRootProperty {
  78151. /**
  78152. * 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
  78153. */
  78154. uri?: string;
  78155. /**
  78156. * The image's MIME type
  78157. */
  78158. mimeType?: ImageMimeType;
  78159. /**
  78160. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78161. */
  78162. bufferView?: number;
  78163. }
  78164. /**
  78165. * Material Normal Texture Info
  78166. */
  78167. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78168. /**
  78169. * The scalar multiplier applied to each normal vector of the normal texture
  78170. */
  78171. scale?: number;
  78172. }
  78173. /**
  78174. * Material Occlusion Texture Info
  78175. */
  78176. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78177. /**
  78178. * A scalar multiplier controlling the amount of occlusion applied
  78179. */
  78180. strength?: number;
  78181. }
  78182. /**
  78183. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78184. */
  78185. interface IMaterialPbrMetallicRoughness {
  78186. /**
  78187. * The material's base color factor
  78188. */
  78189. baseColorFactor?: number[];
  78190. /**
  78191. * The base color texture
  78192. */
  78193. baseColorTexture?: ITextureInfo;
  78194. /**
  78195. * The metalness of the material
  78196. */
  78197. metallicFactor?: number;
  78198. /**
  78199. * The roughness of the material
  78200. */
  78201. roughnessFactor?: number;
  78202. /**
  78203. * The metallic-roughness texture
  78204. */
  78205. metallicRoughnessTexture?: ITextureInfo;
  78206. }
  78207. /**
  78208. * The material appearance of a primitive
  78209. */
  78210. interface IMaterial extends IChildRootProperty {
  78211. /**
  78212. * 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
  78213. */
  78214. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78215. /**
  78216. * The normal map texture
  78217. */
  78218. normalTexture?: IMaterialNormalTextureInfo;
  78219. /**
  78220. * The occlusion map texture
  78221. */
  78222. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78223. /**
  78224. * The emissive map texture
  78225. */
  78226. emissiveTexture?: ITextureInfo;
  78227. /**
  78228. * 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
  78229. */
  78230. emissiveFactor?: number[];
  78231. /**
  78232. * The alpha rendering mode of the material
  78233. */
  78234. alphaMode?: MaterialAlphaMode;
  78235. /**
  78236. * The alpha cutoff value of the material
  78237. */
  78238. alphaCutoff?: number;
  78239. /**
  78240. * Specifies whether the material is double sided
  78241. */
  78242. doubleSided?: boolean;
  78243. }
  78244. /**
  78245. * Geometry to be rendered with the given material
  78246. */
  78247. interface IMeshPrimitive extends IProperty {
  78248. /**
  78249. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78250. */
  78251. attributes: {
  78252. [name: string]: number;
  78253. };
  78254. /**
  78255. * The index of the accessor that contains the indices
  78256. */
  78257. indices?: number;
  78258. /**
  78259. * The index of the material to apply to this primitive when rendering
  78260. */
  78261. material?: number;
  78262. /**
  78263. * The type of primitives to render. All valid values correspond to WebGL enums
  78264. */
  78265. mode?: MeshPrimitiveMode;
  78266. /**
  78267. * 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
  78268. */
  78269. targets?: {
  78270. [name: string]: number;
  78271. }[];
  78272. }
  78273. /**
  78274. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78275. */
  78276. interface IMesh extends IChildRootProperty {
  78277. /**
  78278. * An array of primitives, each defining geometry to be rendered with a material
  78279. */
  78280. primitives: IMeshPrimitive[];
  78281. /**
  78282. * Array of weights to be applied to the Morph Targets
  78283. */
  78284. weights?: number[];
  78285. }
  78286. /**
  78287. * A node in the node hierarchy
  78288. */
  78289. interface INode extends IChildRootProperty {
  78290. /**
  78291. * The index of the camera referenced by this node
  78292. */
  78293. camera?: number;
  78294. /**
  78295. * The indices of this node's children
  78296. */
  78297. children?: number[];
  78298. /**
  78299. * The index of the skin referenced by this node
  78300. */
  78301. skin?: number;
  78302. /**
  78303. * A floating-point 4x4 transformation matrix stored in column-major order
  78304. */
  78305. matrix?: number[];
  78306. /**
  78307. * The index of the mesh in this node
  78308. */
  78309. mesh?: number;
  78310. /**
  78311. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78312. */
  78313. rotation?: number[];
  78314. /**
  78315. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78316. */
  78317. scale?: number[];
  78318. /**
  78319. * The node's translation along the x, y, and z axes
  78320. */
  78321. translation?: number[];
  78322. /**
  78323. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78324. */
  78325. weights?: number[];
  78326. }
  78327. /**
  78328. * Texture sampler properties for filtering and wrapping modes
  78329. */
  78330. interface ISampler extends IChildRootProperty {
  78331. /**
  78332. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78333. */
  78334. magFilter?: TextureMagFilter;
  78335. /**
  78336. * Minification filter. All valid values correspond to WebGL enums
  78337. */
  78338. minFilter?: TextureMinFilter;
  78339. /**
  78340. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78341. */
  78342. wrapS?: TextureWrapMode;
  78343. /**
  78344. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78345. */
  78346. wrapT?: TextureWrapMode;
  78347. }
  78348. /**
  78349. * The root nodes of a scene
  78350. */
  78351. interface IScene extends IChildRootProperty {
  78352. /**
  78353. * The indices of each root node
  78354. */
  78355. nodes: number[];
  78356. }
  78357. /**
  78358. * Joints and matrices defining a skin
  78359. */
  78360. interface ISkin extends IChildRootProperty {
  78361. /**
  78362. * 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
  78363. */
  78364. inverseBindMatrices?: number;
  78365. /**
  78366. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78367. */
  78368. skeleton?: number;
  78369. /**
  78370. * 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)
  78371. */
  78372. joints: number[];
  78373. }
  78374. /**
  78375. * A texture and its sampler
  78376. */
  78377. interface ITexture extends IChildRootProperty {
  78378. /**
  78379. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78380. */
  78381. sampler?: number;
  78382. /**
  78383. * The index of the image used by this texture
  78384. */
  78385. source: number;
  78386. }
  78387. /**
  78388. * Reference to a texture
  78389. */
  78390. interface ITextureInfo extends IProperty {
  78391. /**
  78392. * The index of the texture
  78393. */
  78394. index: number;
  78395. /**
  78396. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78397. */
  78398. texCoord?: number;
  78399. }
  78400. /**
  78401. * The root object for a glTF asset
  78402. */
  78403. interface IGLTF extends IProperty {
  78404. /**
  78405. * An array of accessors. An accessor is a typed view into a bufferView
  78406. */
  78407. accessors?: IAccessor[];
  78408. /**
  78409. * An array of keyframe animations
  78410. */
  78411. animations?: IAnimation[];
  78412. /**
  78413. * Metadata about the glTF asset
  78414. */
  78415. asset: IAsset;
  78416. /**
  78417. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78418. */
  78419. buffers?: IBuffer[];
  78420. /**
  78421. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78422. */
  78423. bufferViews?: IBufferView[];
  78424. /**
  78425. * An array of cameras
  78426. */
  78427. cameras?: ICamera[];
  78428. /**
  78429. * Names of glTF extensions used somewhere in this asset
  78430. */
  78431. extensionsUsed?: string[];
  78432. /**
  78433. * Names of glTF extensions required to properly load this asset
  78434. */
  78435. extensionsRequired?: string[];
  78436. /**
  78437. * An array of images. An image defines data used to create a texture
  78438. */
  78439. images?: IImage[];
  78440. /**
  78441. * An array of materials. A material defines the appearance of a primitive
  78442. */
  78443. materials?: IMaterial[];
  78444. /**
  78445. * An array of meshes. A mesh is a set of primitives to be rendered
  78446. */
  78447. meshes?: IMesh[];
  78448. /**
  78449. * An array of nodes
  78450. */
  78451. nodes?: INode[];
  78452. /**
  78453. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78454. */
  78455. samplers?: ISampler[];
  78456. /**
  78457. * The index of the default scene
  78458. */
  78459. scene?: number;
  78460. /**
  78461. * An array of scenes
  78462. */
  78463. scenes?: IScene[];
  78464. /**
  78465. * An array of skins. A skin is defined by joints and matrices
  78466. */
  78467. skins?: ISkin[];
  78468. /**
  78469. * An array of textures
  78470. */
  78471. textures?: ITexture[];
  78472. }
  78473. /**
  78474. * The glTF validation results
  78475. * @ignore
  78476. */
  78477. interface IGLTFValidationResults {
  78478. info: {
  78479. generator: string;
  78480. hasAnimations: boolean;
  78481. hasDefaultScene: boolean;
  78482. hasMaterials: boolean;
  78483. hasMorphTargets: boolean;
  78484. hasSkins: boolean;
  78485. hasTextures: boolean;
  78486. maxAttributesUsed: number;
  78487. primitivesCount: number
  78488. };
  78489. issues: {
  78490. messages: Array<string>;
  78491. numErrors: number;
  78492. numHints: number;
  78493. numInfos: number;
  78494. numWarnings: number;
  78495. truncated: boolean
  78496. };
  78497. mimeType: string;
  78498. uri: string;
  78499. validatedAt: string;
  78500. validatorVersion: string;
  78501. }
  78502. /**
  78503. * The glTF validation options
  78504. */
  78505. interface IGLTFValidationOptions {
  78506. /** Uri to use */
  78507. uri?: string;
  78508. /** Function used to load external resources */
  78509. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78510. /** Boolean indicating that we need to validate accessor data */
  78511. validateAccessorData?: boolean;
  78512. /** max number of issues allowed */
  78513. maxIssues?: number;
  78514. /** Ignored issues */
  78515. ignoredIssues?: Array<string>;
  78516. /** Value to override severy settings */
  78517. severityOverrides?: Object;
  78518. }
  78519. /**
  78520. * The glTF validator object
  78521. * @ignore
  78522. */
  78523. interface IGLTFValidator {
  78524. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78525. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78526. }
  78527. }
  78528. declare module BABYLON {
  78529. /** @hidden */
  78530. export var cellPixelShader: {
  78531. name: string;
  78532. shader: string;
  78533. };
  78534. }
  78535. declare module BABYLON {
  78536. /** @hidden */
  78537. export var cellVertexShader: {
  78538. name: string;
  78539. shader: string;
  78540. };
  78541. }
  78542. declare module BABYLON {
  78543. export class CellMaterial extends BABYLON.PushMaterial {
  78544. private _diffuseTexture;
  78545. diffuseTexture: BABYLON.BaseTexture;
  78546. diffuseColor: BABYLON.Color3;
  78547. _computeHighLevel: boolean;
  78548. computeHighLevel: boolean;
  78549. private _disableLighting;
  78550. disableLighting: boolean;
  78551. private _maxSimultaneousLights;
  78552. maxSimultaneousLights: number;
  78553. private _renderId;
  78554. constructor(name: string, scene: BABYLON.Scene);
  78555. needAlphaBlending(): boolean;
  78556. needAlphaTesting(): boolean;
  78557. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78558. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78559. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78560. getAnimatables(): BABYLON.IAnimatable[];
  78561. getActiveTextures(): BABYLON.BaseTexture[];
  78562. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78563. dispose(forceDisposeEffect?: boolean): void;
  78564. getClassName(): string;
  78565. clone(name: string): CellMaterial;
  78566. serialize(): any;
  78567. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78568. }
  78569. }
  78570. declare module BABYLON {
  78571. export class CustomShaderStructure {
  78572. FragmentStore: string;
  78573. VertexStore: string;
  78574. constructor();
  78575. }
  78576. export class ShaderSpecialParts {
  78577. constructor();
  78578. Fragment_Begin: string;
  78579. Fragment_Definitions: string;
  78580. Fragment_MainBegin: string;
  78581. Fragment_Custom_Diffuse: string;
  78582. Fragment_Before_Lights: string;
  78583. Fragment_Before_Fog: string;
  78584. Fragment_Custom_Alpha: string;
  78585. Fragment_Before_FragColor: string;
  78586. Vertex_Begin: string;
  78587. Vertex_Definitions: string;
  78588. Vertex_MainBegin: string;
  78589. Vertex_Before_PositionUpdated: string;
  78590. Vertex_Before_NormalUpdated: string;
  78591. Vertex_MainEnd: string;
  78592. }
  78593. export class CustomMaterial extends BABYLON.StandardMaterial {
  78594. static ShaderIndexer: number;
  78595. CustomParts: ShaderSpecialParts;
  78596. _isCreatedShader: boolean;
  78597. _createdShaderName: string;
  78598. _customUniform: string[];
  78599. _newUniforms: string[];
  78600. _newUniformInstances: any[];
  78601. _newSamplerInstances: BABYLON.Texture[];
  78602. FragmentShader: string;
  78603. VertexShader: string;
  78604. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78605. ReviewUniform(name: string, arr: string[]): string[];
  78606. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78607. constructor(name: string, scene: BABYLON.Scene);
  78608. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78609. Fragment_Begin(shaderPart: string): CustomMaterial;
  78610. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78611. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78612. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78613. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78614. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78615. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78616. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78617. Vertex_Begin(shaderPart: string): CustomMaterial;
  78618. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78619. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78620. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78621. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78622. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78623. }
  78624. }
  78625. declare module BABYLON {
  78626. export class ShaderAlebdoParts {
  78627. constructor();
  78628. Fragment_Begin: string;
  78629. Fragment_Definitions: string;
  78630. Fragment_MainBegin: string;
  78631. Fragment_Custom_Albedo: string;
  78632. Fragment_Before_Lights: string;
  78633. Fragment_Custom_MetallicRoughness: string;
  78634. Fragment_Custom_MicroSurface: string;
  78635. Fragment_Before_Fog: string;
  78636. Fragment_Custom_Alpha: string;
  78637. Fragment_Before_FragColor: string;
  78638. Vertex_Begin: string;
  78639. Vertex_Definitions: string;
  78640. Vertex_MainBegin: string;
  78641. Vertex_Before_PositionUpdated: string;
  78642. Vertex_Before_NormalUpdated: string;
  78643. Vertex_MainEnd: string;
  78644. }
  78645. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78646. static ShaderIndexer: number;
  78647. CustomParts: ShaderAlebdoParts;
  78648. _isCreatedShader: boolean;
  78649. _createdShaderName: string;
  78650. _customUniform: string[];
  78651. _newUniforms: string[];
  78652. _newUniformInstances: any[];
  78653. _newSamplerInstances: BABYLON.Texture[];
  78654. FragmentShader: string;
  78655. VertexShader: string;
  78656. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78657. ReviewUniform(name: string, arr: string[]): string[];
  78658. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78659. constructor(name: string, scene: BABYLON.Scene);
  78660. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78661. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78662. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78663. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78664. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78665. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78666. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78667. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78668. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78669. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78670. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78671. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78672. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78673. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78674. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78675. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78676. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78677. }
  78678. }
  78679. declare module BABYLON {
  78680. /** @hidden */
  78681. export var firePixelShader: {
  78682. name: string;
  78683. shader: string;
  78684. };
  78685. }
  78686. declare module BABYLON {
  78687. /** @hidden */
  78688. export var fireVertexShader: {
  78689. name: string;
  78690. shader: string;
  78691. };
  78692. }
  78693. declare module BABYLON {
  78694. export class FireMaterial extends BABYLON.PushMaterial {
  78695. private _diffuseTexture;
  78696. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78697. private _distortionTexture;
  78698. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78699. private _opacityTexture;
  78700. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78701. diffuseColor: BABYLON.Color3;
  78702. speed: number;
  78703. private _scaledDiffuse;
  78704. private _renderId;
  78705. private _lastTime;
  78706. constructor(name: string, scene: BABYLON.Scene);
  78707. needAlphaBlending(): boolean;
  78708. needAlphaTesting(): boolean;
  78709. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78710. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78711. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78712. getAnimatables(): BABYLON.IAnimatable[];
  78713. getActiveTextures(): BABYLON.BaseTexture[];
  78714. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78715. getClassName(): string;
  78716. dispose(forceDisposeEffect?: boolean): void;
  78717. clone(name: string): FireMaterial;
  78718. serialize(): any;
  78719. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78720. }
  78721. }
  78722. declare module BABYLON {
  78723. /** @hidden */
  78724. export var furPixelShader: {
  78725. name: string;
  78726. shader: string;
  78727. };
  78728. }
  78729. declare module BABYLON {
  78730. /** @hidden */
  78731. export var furVertexShader: {
  78732. name: string;
  78733. shader: string;
  78734. };
  78735. }
  78736. declare module BABYLON {
  78737. export class FurMaterial extends BABYLON.PushMaterial {
  78738. private _diffuseTexture;
  78739. diffuseTexture: BABYLON.BaseTexture;
  78740. private _heightTexture;
  78741. heightTexture: BABYLON.BaseTexture;
  78742. diffuseColor: BABYLON.Color3;
  78743. furLength: number;
  78744. furAngle: number;
  78745. furColor: BABYLON.Color3;
  78746. furOffset: number;
  78747. furSpacing: number;
  78748. furGravity: BABYLON.Vector3;
  78749. furSpeed: number;
  78750. furDensity: number;
  78751. furOcclusion: number;
  78752. furTexture: BABYLON.DynamicTexture;
  78753. private _disableLighting;
  78754. disableLighting: boolean;
  78755. private _maxSimultaneousLights;
  78756. maxSimultaneousLights: number;
  78757. highLevelFur: boolean;
  78758. _meshes: BABYLON.AbstractMesh[];
  78759. private _renderId;
  78760. private _furTime;
  78761. constructor(name: string, scene: BABYLON.Scene);
  78762. get furTime(): number;
  78763. set furTime(furTime: number);
  78764. needAlphaBlending(): boolean;
  78765. needAlphaTesting(): boolean;
  78766. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78767. updateFur(): void;
  78768. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78769. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78770. getAnimatables(): BABYLON.IAnimatable[];
  78771. getActiveTextures(): BABYLON.BaseTexture[];
  78772. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78773. dispose(forceDisposeEffect?: boolean): void;
  78774. clone(name: string): FurMaterial;
  78775. serialize(): any;
  78776. getClassName(): string;
  78777. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78778. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78779. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78780. }
  78781. }
  78782. declare module BABYLON {
  78783. /** @hidden */
  78784. export var gradientPixelShader: {
  78785. name: string;
  78786. shader: string;
  78787. };
  78788. }
  78789. declare module BABYLON {
  78790. /** @hidden */
  78791. export var gradientVertexShader: {
  78792. name: string;
  78793. shader: string;
  78794. };
  78795. }
  78796. declare module BABYLON {
  78797. export class GradientMaterial extends BABYLON.PushMaterial {
  78798. private _maxSimultaneousLights;
  78799. maxSimultaneousLights: number;
  78800. topColor: BABYLON.Color3;
  78801. topColorAlpha: number;
  78802. bottomColor: BABYLON.Color3;
  78803. bottomColorAlpha: number;
  78804. offset: number;
  78805. scale: number;
  78806. smoothness: number;
  78807. private _disableLighting;
  78808. disableLighting: boolean;
  78809. private _renderId;
  78810. constructor(name: string, scene: BABYLON.Scene);
  78811. needAlphaBlending(): boolean;
  78812. needAlphaTesting(): boolean;
  78813. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78814. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78815. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78816. getAnimatables(): BABYLON.IAnimatable[];
  78817. dispose(forceDisposeEffect?: boolean): void;
  78818. clone(name: string): GradientMaterial;
  78819. serialize(): any;
  78820. getClassName(): string;
  78821. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78822. }
  78823. }
  78824. declare module BABYLON {
  78825. /** @hidden */
  78826. export var gridPixelShader: {
  78827. name: string;
  78828. shader: string;
  78829. };
  78830. }
  78831. declare module BABYLON {
  78832. /** @hidden */
  78833. export var gridVertexShader: {
  78834. name: string;
  78835. shader: string;
  78836. };
  78837. }
  78838. declare module BABYLON {
  78839. /**
  78840. * The grid materials allows you to wrap any shape with a grid.
  78841. * Colors are customizable.
  78842. */
  78843. export class GridMaterial extends BABYLON.PushMaterial {
  78844. /**
  78845. * Main color of the grid (e.g. between lines)
  78846. */
  78847. mainColor: BABYLON.Color3;
  78848. /**
  78849. * Color of the grid lines.
  78850. */
  78851. lineColor: BABYLON.Color3;
  78852. /**
  78853. * The scale of the grid compared to unit.
  78854. */
  78855. gridRatio: number;
  78856. /**
  78857. * Allows setting an offset for the grid lines.
  78858. */
  78859. gridOffset: BABYLON.Vector3;
  78860. /**
  78861. * The frequency of thicker lines.
  78862. */
  78863. majorUnitFrequency: number;
  78864. /**
  78865. * The visibility of minor units in the grid.
  78866. */
  78867. minorUnitVisibility: number;
  78868. /**
  78869. * The grid opacity outside of the lines.
  78870. */
  78871. opacity: number;
  78872. /**
  78873. * Determine RBG output is premultiplied by alpha value.
  78874. */
  78875. preMultiplyAlpha: boolean;
  78876. private _opacityTexture;
  78877. opacityTexture: BABYLON.BaseTexture;
  78878. private _gridControl;
  78879. private _renderId;
  78880. /**
  78881. * constructor
  78882. * @param name The name given to the material in order to identify it afterwards.
  78883. * @param scene The scene the material is used in.
  78884. */
  78885. constructor(name: string, scene: BABYLON.Scene);
  78886. /**
  78887. * Returns wehter or not the grid requires alpha blending.
  78888. */
  78889. needAlphaBlending(): boolean;
  78890. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78891. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78892. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78893. /**
  78894. * Dispose the material and its associated resources.
  78895. * @param forceDisposeEffect will also dispose the used effect when true
  78896. */
  78897. dispose(forceDisposeEffect?: boolean): void;
  78898. clone(name: string): GridMaterial;
  78899. serialize(): any;
  78900. getClassName(): string;
  78901. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78902. }
  78903. }
  78904. declare module BABYLON {
  78905. /** @hidden */
  78906. export var lavaPixelShader: {
  78907. name: string;
  78908. shader: string;
  78909. };
  78910. }
  78911. declare module BABYLON {
  78912. /** @hidden */
  78913. export var lavaVertexShader: {
  78914. name: string;
  78915. shader: string;
  78916. };
  78917. }
  78918. declare module BABYLON {
  78919. export class LavaMaterial extends BABYLON.PushMaterial {
  78920. private _diffuseTexture;
  78921. diffuseTexture: BABYLON.BaseTexture;
  78922. noiseTexture: BABYLON.BaseTexture;
  78923. fogColor: BABYLON.Color3;
  78924. speed: number;
  78925. movingSpeed: number;
  78926. lowFrequencySpeed: number;
  78927. fogDensity: number;
  78928. private _lastTime;
  78929. diffuseColor: BABYLON.Color3;
  78930. private _disableLighting;
  78931. disableLighting: boolean;
  78932. private _unlit;
  78933. unlit: boolean;
  78934. private _maxSimultaneousLights;
  78935. maxSimultaneousLights: number;
  78936. private _scaledDiffuse;
  78937. private _renderId;
  78938. constructor(name: string, scene: BABYLON.Scene);
  78939. needAlphaBlending(): boolean;
  78940. needAlphaTesting(): boolean;
  78941. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78942. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78943. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78944. getAnimatables(): BABYLON.IAnimatable[];
  78945. getActiveTextures(): BABYLON.BaseTexture[];
  78946. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78947. dispose(forceDisposeEffect?: boolean): void;
  78948. clone(name: string): LavaMaterial;
  78949. serialize(): any;
  78950. getClassName(): string;
  78951. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78952. }
  78953. }
  78954. declare module BABYLON {
  78955. /** @hidden */
  78956. export var mixPixelShader: {
  78957. name: string;
  78958. shader: string;
  78959. };
  78960. }
  78961. declare module BABYLON {
  78962. /** @hidden */
  78963. export var mixVertexShader: {
  78964. name: string;
  78965. shader: string;
  78966. };
  78967. }
  78968. declare module BABYLON {
  78969. export class MixMaterial extends BABYLON.PushMaterial {
  78970. /**
  78971. * Mix textures
  78972. */
  78973. private _mixTexture1;
  78974. mixTexture1: BABYLON.BaseTexture;
  78975. private _mixTexture2;
  78976. mixTexture2: BABYLON.BaseTexture;
  78977. /**
  78978. * Diffuse textures
  78979. */
  78980. private _diffuseTexture1;
  78981. diffuseTexture1: BABYLON.Texture;
  78982. private _diffuseTexture2;
  78983. diffuseTexture2: BABYLON.Texture;
  78984. private _diffuseTexture3;
  78985. diffuseTexture3: BABYLON.Texture;
  78986. private _diffuseTexture4;
  78987. diffuseTexture4: BABYLON.Texture;
  78988. private _diffuseTexture5;
  78989. diffuseTexture5: BABYLON.Texture;
  78990. private _diffuseTexture6;
  78991. diffuseTexture6: BABYLON.Texture;
  78992. private _diffuseTexture7;
  78993. diffuseTexture7: BABYLON.Texture;
  78994. private _diffuseTexture8;
  78995. diffuseTexture8: BABYLON.Texture;
  78996. /**
  78997. * Uniforms
  78998. */
  78999. diffuseColor: BABYLON.Color3;
  79000. specularColor: BABYLON.Color3;
  79001. specularPower: number;
  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. needAlphaTesting(): boolean;
  79010. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79011. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79012. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79013. getAnimatables(): BABYLON.IAnimatable[];
  79014. getActiveTextures(): BABYLON.BaseTexture[];
  79015. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79016. dispose(forceDisposeEffect?: boolean): void;
  79017. clone(name: string): MixMaterial;
  79018. serialize(): any;
  79019. getClassName(): string;
  79020. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79021. }
  79022. }
  79023. declare module BABYLON {
  79024. /** @hidden */
  79025. export var normalPixelShader: {
  79026. name: string;
  79027. shader: string;
  79028. };
  79029. }
  79030. declare module BABYLON {
  79031. /** @hidden */
  79032. export var normalVertexShader: {
  79033. name: string;
  79034. shader: string;
  79035. };
  79036. }
  79037. declare module BABYLON {
  79038. export class NormalMaterial extends BABYLON.PushMaterial {
  79039. private _diffuseTexture;
  79040. diffuseTexture: BABYLON.BaseTexture;
  79041. diffuseColor: BABYLON.Color3;
  79042. private _disableLighting;
  79043. disableLighting: boolean;
  79044. private _maxSimultaneousLights;
  79045. maxSimultaneousLights: number;
  79046. private _renderId;
  79047. constructor(name: string, scene: BABYLON.Scene);
  79048. needAlphaBlending(): boolean;
  79049. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79050. needAlphaTesting(): boolean;
  79051. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79052. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79053. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79054. getAnimatables(): BABYLON.IAnimatable[];
  79055. getActiveTextures(): BABYLON.BaseTexture[];
  79056. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79057. dispose(forceDisposeEffect?: boolean): void;
  79058. clone(name: string): NormalMaterial;
  79059. serialize(): any;
  79060. getClassName(): string;
  79061. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79062. }
  79063. }
  79064. declare module BABYLON {
  79065. /** @hidden */
  79066. export var shadowOnlyPixelShader: {
  79067. name: string;
  79068. shader: string;
  79069. };
  79070. }
  79071. declare module BABYLON {
  79072. /** @hidden */
  79073. export var shadowOnlyVertexShader: {
  79074. name: string;
  79075. shader: string;
  79076. };
  79077. }
  79078. declare module BABYLON {
  79079. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79080. private _renderId;
  79081. private _activeLight;
  79082. constructor(name: string, scene: BABYLON.Scene);
  79083. shadowColor: BABYLON.Color3;
  79084. needAlphaBlending(): boolean;
  79085. needAlphaTesting(): boolean;
  79086. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79087. get activeLight(): BABYLON.IShadowLight;
  79088. set activeLight(light: BABYLON.IShadowLight);
  79089. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79090. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79091. clone(name: string): ShadowOnlyMaterial;
  79092. serialize(): any;
  79093. getClassName(): string;
  79094. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79095. }
  79096. }
  79097. declare module BABYLON {
  79098. /** @hidden */
  79099. export var simplePixelShader: {
  79100. name: string;
  79101. shader: string;
  79102. };
  79103. }
  79104. declare module BABYLON {
  79105. /** @hidden */
  79106. export var simpleVertexShader: {
  79107. name: string;
  79108. shader: string;
  79109. };
  79110. }
  79111. declare module BABYLON {
  79112. export class SimpleMaterial extends BABYLON.PushMaterial {
  79113. private _diffuseTexture;
  79114. diffuseTexture: BABYLON.BaseTexture;
  79115. diffuseColor: BABYLON.Color3;
  79116. private _disableLighting;
  79117. disableLighting: boolean;
  79118. private _maxSimultaneousLights;
  79119. maxSimultaneousLights: number;
  79120. private _renderId;
  79121. constructor(name: string, scene: BABYLON.Scene);
  79122. needAlphaBlending(): boolean;
  79123. needAlphaTesting(): boolean;
  79124. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79125. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79126. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79127. getAnimatables(): BABYLON.IAnimatable[];
  79128. getActiveTextures(): BABYLON.BaseTexture[];
  79129. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79130. dispose(forceDisposeEffect?: boolean): void;
  79131. clone(name: string): SimpleMaterial;
  79132. serialize(): any;
  79133. getClassName(): string;
  79134. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79135. }
  79136. }
  79137. declare module BABYLON {
  79138. /** @hidden */
  79139. export var skyPixelShader: {
  79140. name: string;
  79141. shader: string;
  79142. };
  79143. }
  79144. declare module BABYLON {
  79145. /** @hidden */
  79146. export var skyVertexShader: {
  79147. name: string;
  79148. shader: string;
  79149. };
  79150. }
  79151. declare module BABYLON {
  79152. /**
  79153. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79154. * @see https://doc.babylonjs.com/extensions/sky
  79155. */
  79156. export class SkyMaterial extends BABYLON.PushMaterial {
  79157. /**
  79158. * Defines the overall luminance of sky in interval ]0, 1[.
  79159. */
  79160. luminance: number;
  79161. /**
  79162. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79163. */
  79164. turbidity: number;
  79165. /**
  79166. * Defines the sky appearance (light intensity).
  79167. */
  79168. rayleigh: number;
  79169. /**
  79170. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79171. */
  79172. mieCoefficient: number;
  79173. /**
  79174. * Defines the amount of haze particles following the Mie scattering theory.
  79175. */
  79176. mieDirectionalG: number;
  79177. /**
  79178. * Defines the distance of the sun according to the active scene camera.
  79179. */
  79180. distance: number;
  79181. /**
  79182. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79183. * "inclined".
  79184. */
  79185. inclination: number;
  79186. /**
  79187. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79188. * an object direction and a reference direction.
  79189. */
  79190. azimuth: number;
  79191. /**
  79192. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79193. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79194. */
  79195. sunPosition: BABYLON.Vector3;
  79196. /**
  79197. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79198. * .sunPosition property.
  79199. */
  79200. useSunPosition: boolean;
  79201. /**
  79202. * Defines an offset vector used to get a horizon offset.
  79203. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79204. */
  79205. cameraOffset: BABYLON.Vector3;
  79206. private _cameraPosition;
  79207. private _renderId;
  79208. /**
  79209. * Instantiates a new sky material.
  79210. * This material allows to create dynamic and texture free
  79211. * effects for skyboxes by taking care of the atmosphere state.
  79212. * @see https://doc.babylonjs.com/extensions/sky
  79213. * @param name Define the name of the material in the scene
  79214. * @param scene Define the scene the material belong to
  79215. */
  79216. constructor(name: string, scene: BABYLON.Scene);
  79217. /**
  79218. * Specifies if the material will require alpha blending
  79219. * @returns a boolean specifying if alpha blending is needed
  79220. */
  79221. needAlphaBlending(): boolean;
  79222. /**
  79223. * Specifies if this material should be rendered in alpha test mode
  79224. * @returns false as the sky material doesn't need alpha testing.
  79225. */
  79226. needAlphaTesting(): boolean;
  79227. /**
  79228. * Get the texture used for alpha test purpose.
  79229. * @returns null as the sky material has no texture.
  79230. */
  79231. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79232. /**
  79233. * Get if the submesh is ready to be used and all its information available.
  79234. * Child classes can use it to update shaders
  79235. * @param mesh defines the mesh to check
  79236. * @param subMesh defines which submesh to check
  79237. * @param useInstances specifies that instances should be used
  79238. * @returns a boolean indicating that the submesh is ready or not
  79239. */
  79240. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79241. /**
  79242. * Binds the submesh to this material by preparing the effect and shader to draw
  79243. * @param world defines the world transformation matrix
  79244. * @param mesh defines the mesh containing the submesh
  79245. * @param subMesh defines the submesh to bind the material to
  79246. */
  79247. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79248. /**
  79249. * Get the list of animatables in the material.
  79250. * @returns the list of animatables object used in the material
  79251. */
  79252. getAnimatables(): BABYLON.IAnimatable[];
  79253. /**
  79254. * Disposes the material
  79255. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79256. */
  79257. dispose(forceDisposeEffect?: boolean): void;
  79258. /**
  79259. * Makes a duplicate of the material, and gives it a new name
  79260. * @param name defines the new name for the duplicated material
  79261. * @returns the cloned material
  79262. */
  79263. clone(name: string): SkyMaterial;
  79264. /**
  79265. * Serializes this material in a JSON representation
  79266. * @returns the serialized material object
  79267. */
  79268. serialize(): any;
  79269. /**
  79270. * Gets the current class name of the material e.g. "SkyMaterial"
  79271. * Mainly use in serialization.
  79272. * @returns the class name
  79273. */
  79274. getClassName(): string;
  79275. /**
  79276. * Creates a sky material from parsed material data
  79277. * @param source defines the JSON representation of the material
  79278. * @param scene defines the hosting scene
  79279. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79280. * @returns a new sky material
  79281. */
  79282. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79283. }
  79284. }
  79285. declare module BABYLON {
  79286. /** @hidden */
  79287. export var terrainPixelShader: {
  79288. name: string;
  79289. shader: string;
  79290. };
  79291. }
  79292. declare module BABYLON {
  79293. /** @hidden */
  79294. export var terrainVertexShader: {
  79295. name: string;
  79296. shader: string;
  79297. };
  79298. }
  79299. declare module BABYLON {
  79300. export class TerrainMaterial extends BABYLON.PushMaterial {
  79301. private _mixTexture;
  79302. mixTexture: BABYLON.BaseTexture;
  79303. private _diffuseTexture1;
  79304. diffuseTexture1: BABYLON.Texture;
  79305. private _diffuseTexture2;
  79306. diffuseTexture2: BABYLON.Texture;
  79307. private _diffuseTexture3;
  79308. diffuseTexture3: BABYLON.Texture;
  79309. private _bumpTexture1;
  79310. bumpTexture1: BABYLON.Texture;
  79311. private _bumpTexture2;
  79312. bumpTexture2: BABYLON.Texture;
  79313. private _bumpTexture3;
  79314. bumpTexture3: BABYLON.Texture;
  79315. diffuseColor: BABYLON.Color3;
  79316. specularColor: BABYLON.Color3;
  79317. specularPower: number;
  79318. private _disableLighting;
  79319. disableLighting: boolean;
  79320. private _maxSimultaneousLights;
  79321. maxSimultaneousLights: number;
  79322. private _renderId;
  79323. constructor(name: string, scene: BABYLON.Scene);
  79324. needAlphaBlending(): boolean;
  79325. needAlphaTesting(): boolean;
  79326. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79327. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79328. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79329. getAnimatables(): BABYLON.IAnimatable[];
  79330. getActiveTextures(): BABYLON.BaseTexture[];
  79331. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79332. dispose(forceDisposeEffect?: boolean): void;
  79333. clone(name: string): TerrainMaterial;
  79334. serialize(): any;
  79335. getClassName(): string;
  79336. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79337. }
  79338. }
  79339. declare module BABYLON {
  79340. /** @hidden */
  79341. export var triplanarPixelShader: {
  79342. name: string;
  79343. shader: string;
  79344. };
  79345. }
  79346. declare module BABYLON {
  79347. /** @hidden */
  79348. export var triplanarVertexShader: {
  79349. name: string;
  79350. shader: string;
  79351. };
  79352. }
  79353. declare module BABYLON {
  79354. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79355. mixTexture: BABYLON.BaseTexture;
  79356. private _diffuseTextureX;
  79357. diffuseTextureX: BABYLON.BaseTexture;
  79358. private _diffuseTextureY;
  79359. diffuseTextureY: BABYLON.BaseTexture;
  79360. private _diffuseTextureZ;
  79361. diffuseTextureZ: BABYLON.BaseTexture;
  79362. private _normalTextureX;
  79363. normalTextureX: BABYLON.BaseTexture;
  79364. private _normalTextureY;
  79365. normalTextureY: BABYLON.BaseTexture;
  79366. private _normalTextureZ;
  79367. normalTextureZ: BABYLON.BaseTexture;
  79368. tileSize: number;
  79369. diffuseColor: BABYLON.Color3;
  79370. specularColor: BABYLON.Color3;
  79371. specularPower: number;
  79372. private _disableLighting;
  79373. disableLighting: boolean;
  79374. private _maxSimultaneousLights;
  79375. maxSimultaneousLights: number;
  79376. private _renderId;
  79377. constructor(name: string, scene: BABYLON.Scene);
  79378. needAlphaBlending(): boolean;
  79379. needAlphaTesting(): boolean;
  79380. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79381. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79382. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79383. getAnimatables(): BABYLON.IAnimatable[];
  79384. getActiveTextures(): BABYLON.BaseTexture[];
  79385. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79386. dispose(forceDisposeEffect?: boolean): void;
  79387. clone(name: string): TriPlanarMaterial;
  79388. serialize(): any;
  79389. getClassName(): string;
  79390. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79391. }
  79392. }
  79393. declare module BABYLON {
  79394. /** @hidden */
  79395. export var waterPixelShader: {
  79396. name: string;
  79397. shader: string;
  79398. };
  79399. }
  79400. declare module BABYLON {
  79401. /** @hidden */
  79402. export var waterVertexShader: {
  79403. name: string;
  79404. shader: string;
  79405. };
  79406. }
  79407. declare module BABYLON {
  79408. export class WaterMaterial extends BABYLON.PushMaterial {
  79409. renderTargetSize: BABYLON.Vector2;
  79410. private _bumpTexture;
  79411. bumpTexture: BABYLON.BaseTexture;
  79412. diffuseColor: BABYLON.Color3;
  79413. specularColor: BABYLON.Color3;
  79414. specularPower: number;
  79415. private _disableLighting;
  79416. disableLighting: boolean;
  79417. private _maxSimultaneousLights;
  79418. maxSimultaneousLights: number;
  79419. /**
  79420. * @param {number}: Represents the wind force
  79421. */
  79422. windForce: number;
  79423. /**
  79424. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79425. */
  79426. windDirection: BABYLON.Vector2;
  79427. /**
  79428. * @param {number}: Wave height, represents the height of the waves
  79429. */
  79430. waveHeight: number;
  79431. /**
  79432. * @param {number}: Bump height, represents the bump height related to the bump map
  79433. */
  79434. bumpHeight: number;
  79435. /**
  79436. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79437. */
  79438. private _bumpSuperimpose;
  79439. bumpSuperimpose: boolean;
  79440. /**
  79441. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79442. */
  79443. private _fresnelSeparate;
  79444. fresnelSeparate: boolean;
  79445. /**
  79446. * @param {boolean}: bump Waves modify the reflection.
  79447. */
  79448. private _bumpAffectsReflection;
  79449. bumpAffectsReflection: boolean;
  79450. /**
  79451. * @param {number}: The water color blended with the refraction (near)
  79452. */
  79453. waterColor: BABYLON.Color3;
  79454. /**
  79455. * @param {number}: The blend factor related to the water color
  79456. */
  79457. colorBlendFactor: number;
  79458. /**
  79459. * @param {number}: The water color blended with the reflection (far)
  79460. */
  79461. waterColor2: BABYLON.Color3;
  79462. /**
  79463. * @param {number}: The blend factor related to the water color (reflection, far)
  79464. */
  79465. colorBlendFactor2: number;
  79466. /**
  79467. * @param {number}: Represents the maximum length of a wave
  79468. */
  79469. waveLength: number;
  79470. /**
  79471. * @param {number}: Defines the waves speed
  79472. */
  79473. waveSpeed: number;
  79474. /**
  79475. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79476. * will avoid calculating useless pixels in the pixel shader of the water material.
  79477. */
  79478. disableClipPlane: boolean;
  79479. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79480. private _mesh;
  79481. private _refractionRTT;
  79482. private _reflectionRTT;
  79483. private _reflectionTransform;
  79484. private _lastTime;
  79485. private _lastDeltaTime;
  79486. private _renderId;
  79487. private _useLogarithmicDepth;
  79488. private _waitingRenderList;
  79489. private _imageProcessingConfiguration;
  79490. private _imageProcessingObserver;
  79491. /**
  79492. * Gets a boolean indicating that current material needs to register RTT
  79493. */
  79494. get hasRenderTargetTextures(): boolean;
  79495. /**
  79496. * Constructor
  79497. */
  79498. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79499. get useLogarithmicDepth(): boolean;
  79500. set useLogarithmicDepth(value: boolean);
  79501. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79502. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79503. addToRenderList(node: any): void;
  79504. enableRenderTargets(enable: boolean): void;
  79505. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79506. get renderTargetsEnabled(): boolean;
  79507. needAlphaBlending(): boolean;
  79508. needAlphaTesting(): boolean;
  79509. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79510. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79511. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79512. private _createRenderTargets;
  79513. getAnimatables(): BABYLON.IAnimatable[];
  79514. getActiveTextures(): BABYLON.BaseTexture[];
  79515. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79516. dispose(forceDisposeEffect?: boolean): void;
  79517. clone(name: string): WaterMaterial;
  79518. serialize(): any;
  79519. getClassName(): string;
  79520. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79521. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79522. }
  79523. }
  79524. declare module BABYLON {
  79525. /** @hidden */
  79526. export var asciiartPixelShader: {
  79527. name: string;
  79528. shader: string;
  79529. };
  79530. }
  79531. declare module BABYLON {
  79532. /**
  79533. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79534. *
  79535. * It basically takes care rendering the font front the given font size to a texture.
  79536. * This is used later on in the postprocess.
  79537. */
  79538. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79539. private _font;
  79540. private _text;
  79541. private _charSize;
  79542. /**
  79543. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79544. */
  79545. get charSize(): number;
  79546. /**
  79547. * Create a new instance of the Ascii Art FontTexture class
  79548. * @param name the name of the texture
  79549. * @param font the font to use, use the W3C CSS notation
  79550. * @param text the caracter set to use in the rendering.
  79551. * @param scene the scene that owns the texture
  79552. */
  79553. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79554. /**
  79555. * Gets the max char width of a font.
  79556. * @param font the font to use, use the W3C CSS notation
  79557. * @return the max char width
  79558. */
  79559. private getFontWidth;
  79560. /**
  79561. * Gets the max char height of a font.
  79562. * @param font the font to use, use the W3C CSS notation
  79563. * @return the max char height
  79564. */
  79565. private getFontHeight;
  79566. /**
  79567. * Clones the current AsciiArtTexture.
  79568. * @return the clone of the texture.
  79569. */
  79570. clone(): AsciiArtFontTexture;
  79571. /**
  79572. * Parses a json object representing the texture and returns an instance of it.
  79573. * @param source the source JSON representation
  79574. * @param scene the scene to create the texture for
  79575. * @return the parsed texture
  79576. */
  79577. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79578. }
  79579. /**
  79580. * Option available in the Ascii Art Post Process.
  79581. */
  79582. export interface IAsciiArtPostProcessOptions {
  79583. /**
  79584. * The font to use following the w3c font definition.
  79585. */
  79586. font?: string;
  79587. /**
  79588. * The character set to use in the postprocess.
  79589. */
  79590. characterSet?: string;
  79591. /**
  79592. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79593. * This number is defined between 0 and 1;
  79594. */
  79595. mixToTile?: number;
  79596. /**
  79597. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79598. * This number is defined between 0 and 1;
  79599. */
  79600. mixToNormal?: number;
  79601. }
  79602. /**
  79603. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79604. *
  79605. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79606. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79607. */
  79608. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79609. /**
  79610. * The font texture used to render the char in the post process.
  79611. */
  79612. private _asciiArtFontTexture;
  79613. /**
  79614. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79615. * This number is defined between 0 and 1;
  79616. */
  79617. mixToTile: number;
  79618. /**
  79619. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79620. * This number is defined between 0 and 1;
  79621. */
  79622. mixToNormal: number;
  79623. /**
  79624. * Instantiates a new Ascii Art Post Process.
  79625. * @param name the name to give to the postprocess
  79626. * @camera the camera to apply the post process to.
  79627. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79628. */
  79629. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79630. }
  79631. }
  79632. declare module BABYLON {
  79633. /** @hidden */
  79634. export var digitalrainPixelShader: {
  79635. name: string;
  79636. shader: string;
  79637. };
  79638. }
  79639. declare module BABYLON {
  79640. /**
  79641. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79642. *
  79643. * It basically takes care rendering the font front the given font size to a texture.
  79644. * This is used later on in the postprocess.
  79645. */
  79646. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79647. private _font;
  79648. private _text;
  79649. private _charSize;
  79650. /**
  79651. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79652. */
  79653. get charSize(): number;
  79654. /**
  79655. * Create a new instance of the Digital Rain FontTexture class
  79656. * @param name the name of the texture
  79657. * @param font the font to use, use the W3C CSS notation
  79658. * @param text the caracter set to use in the rendering.
  79659. * @param scene the scene that owns the texture
  79660. */
  79661. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79662. /**
  79663. * Gets the max char width of a font.
  79664. * @param font the font to use, use the W3C CSS notation
  79665. * @return the max char width
  79666. */
  79667. private getFontWidth;
  79668. /**
  79669. * Gets the max char height of a font.
  79670. * @param font the font to use, use the W3C CSS notation
  79671. * @return the max char height
  79672. */
  79673. private getFontHeight;
  79674. /**
  79675. * Clones the current DigitalRainFontTexture.
  79676. * @return the clone of the texture.
  79677. */
  79678. clone(): DigitalRainFontTexture;
  79679. /**
  79680. * Parses a json object representing the texture and returns an instance of it.
  79681. * @param source the source JSON representation
  79682. * @param scene the scene to create the texture for
  79683. * @return the parsed texture
  79684. */
  79685. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79686. }
  79687. /**
  79688. * Option available in the Digital Rain Post Process.
  79689. */
  79690. export interface IDigitalRainPostProcessOptions {
  79691. /**
  79692. * The font to use following the w3c font definition.
  79693. */
  79694. font?: string;
  79695. /**
  79696. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79697. * This number is defined between 0 and 1;
  79698. */
  79699. mixToTile?: number;
  79700. /**
  79701. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79702. * This number is defined between 0 and 1;
  79703. */
  79704. mixToNormal?: number;
  79705. }
  79706. /**
  79707. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79708. *
  79709. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79710. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79711. */
  79712. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79713. /**
  79714. * The font texture used to render the char in the post process.
  79715. */
  79716. private _digitalRainFontTexture;
  79717. /**
  79718. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79719. * This number is defined between 0 and 1;
  79720. */
  79721. mixToTile: number;
  79722. /**
  79723. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79724. * This number is defined between 0 and 1;
  79725. */
  79726. mixToNormal: number;
  79727. /**
  79728. * Instantiates a new Digital Rain Post Process.
  79729. * @param name the name to give to the postprocess
  79730. * @camera the camera to apply the post process to.
  79731. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79732. */
  79733. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79734. }
  79735. }
  79736. declare module BABYLON {
  79737. /** @hidden */
  79738. export var brickProceduralTexturePixelShader: {
  79739. name: string;
  79740. shader: string;
  79741. };
  79742. }
  79743. declare module BABYLON {
  79744. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79745. private _numberOfBricksHeight;
  79746. private _numberOfBricksWidth;
  79747. private _jointColor;
  79748. private _brickColor;
  79749. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79750. updateShaderUniforms(): void;
  79751. get numberOfBricksHeight(): number;
  79752. set numberOfBricksHeight(value: number);
  79753. get numberOfBricksWidth(): number;
  79754. set numberOfBricksWidth(value: number);
  79755. get jointColor(): BABYLON.Color3;
  79756. set jointColor(value: BABYLON.Color3);
  79757. get brickColor(): BABYLON.Color3;
  79758. set brickColor(value: BABYLON.Color3);
  79759. /**
  79760. * Serializes this brick procedural texture
  79761. * @returns a serialized brick procedural texture object
  79762. */
  79763. serialize(): any;
  79764. /**
  79765. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79766. * @param parsedTexture defines parsed texture data
  79767. * @param scene defines the current scene
  79768. * @param rootUrl defines the root URL containing brick procedural texture information
  79769. * @returns a parsed Brick Procedural BABYLON.Texture
  79770. */
  79771. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79772. }
  79773. }
  79774. declare module BABYLON {
  79775. /** @hidden */
  79776. export var cloudProceduralTexturePixelShader: {
  79777. name: string;
  79778. shader: string;
  79779. };
  79780. }
  79781. declare module BABYLON {
  79782. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79783. private _skyColor;
  79784. private _cloudColor;
  79785. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79786. updateShaderUniforms(): void;
  79787. get skyColor(): BABYLON.Color4;
  79788. set skyColor(value: BABYLON.Color4);
  79789. get cloudColor(): BABYLON.Color4;
  79790. set cloudColor(value: BABYLON.Color4);
  79791. /**
  79792. * Serializes this cloud procedural texture
  79793. * @returns a serialized cloud procedural texture object
  79794. */
  79795. serialize(): any;
  79796. /**
  79797. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79798. * @param parsedTexture defines parsed texture data
  79799. * @param scene defines the current scene
  79800. * @param rootUrl defines the root URL containing cloud procedural texture information
  79801. * @returns a parsed Cloud Procedural BABYLON.Texture
  79802. */
  79803. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79804. }
  79805. }
  79806. declare module BABYLON {
  79807. /** @hidden */
  79808. export var fireProceduralTexturePixelShader: {
  79809. name: string;
  79810. shader: string;
  79811. };
  79812. }
  79813. declare module BABYLON {
  79814. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79815. private _time;
  79816. private _speed;
  79817. private _autoGenerateTime;
  79818. private _fireColors;
  79819. private _alphaThreshold;
  79820. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79821. updateShaderUniforms(): void;
  79822. render(useCameraPostProcess?: boolean): void;
  79823. static get PurpleFireColors(): BABYLON.Color3[];
  79824. static get GreenFireColors(): BABYLON.Color3[];
  79825. static get RedFireColors(): BABYLON.Color3[];
  79826. static get BlueFireColors(): BABYLON.Color3[];
  79827. get autoGenerateTime(): boolean;
  79828. set autoGenerateTime(value: boolean);
  79829. get fireColors(): BABYLON.Color3[];
  79830. set fireColors(value: BABYLON.Color3[]);
  79831. get time(): number;
  79832. set time(value: number);
  79833. get speed(): BABYLON.Vector2;
  79834. set speed(value: BABYLON.Vector2);
  79835. get alphaThreshold(): number;
  79836. set alphaThreshold(value: number);
  79837. /**
  79838. * Serializes this fire procedural texture
  79839. * @returns a serialized fire procedural texture object
  79840. */
  79841. serialize(): any;
  79842. /**
  79843. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79844. * @param parsedTexture defines parsed texture data
  79845. * @param scene defines the current scene
  79846. * @param rootUrl defines the root URL containing fire procedural texture information
  79847. * @returns a parsed Fire Procedural BABYLON.Texture
  79848. */
  79849. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79850. }
  79851. }
  79852. declare module BABYLON {
  79853. /** @hidden */
  79854. export var grassProceduralTexturePixelShader: {
  79855. name: string;
  79856. shader: string;
  79857. };
  79858. }
  79859. declare module BABYLON {
  79860. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79861. private _grassColors;
  79862. private _groundColor;
  79863. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79864. updateShaderUniforms(): void;
  79865. get grassColors(): BABYLON.Color3[];
  79866. set grassColors(value: BABYLON.Color3[]);
  79867. get groundColor(): BABYLON.Color3;
  79868. set groundColor(value: BABYLON.Color3);
  79869. /**
  79870. * Serializes this grass procedural texture
  79871. * @returns a serialized grass procedural texture object
  79872. */
  79873. serialize(): any;
  79874. /**
  79875. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79876. * @param parsedTexture defines parsed texture data
  79877. * @param scene defines the current scene
  79878. * @param rootUrl defines the root URL containing grass procedural texture information
  79879. * @returns a parsed Grass Procedural BABYLON.Texture
  79880. */
  79881. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79882. }
  79883. }
  79884. declare module BABYLON {
  79885. /** @hidden */
  79886. export var marbleProceduralTexturePixelShader: {
  79887. name: string;
  79888. shader: string;
  79889. };
  79890. }
  79891. declare module BABYLON {
  79892. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79893. private _numberOfTilesHeight;
  79894. private _numberOfTilesWidth;
  79895. private _amplitude;
  79896. private _jointColor;
  79897. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79898. updateShaderUniforms(): void;
  79899. get numberOfTilesHeight(): number;
  79900. set numberOfTilesHeight(value: number);
  79901. get amplitude(): number;
  79902. set amplitude(value: number);
  79903. get numberOfTilesWidth(): number;
  79904. set numberOfTilesWidth(value: number);
  79905. get jointColor(): BABYLON.Color3;
  79906. set jointColor(value: BABYLON.Color3);
  79907. /**
  79908. * Serializes this marble procedural texture
  79909. * @returns a serialized marble procedural texture object
  79910. */
  79911. serialize(): any;
  79912. /**
  79913. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79914. * @param parsedTexture defines parsed texture data
  79915. * @param scene defines the current scene
  79916. * @param rootUrl defines the root URL containing marble procedural texture information
  79917. * @returns a parsed Marble Procedural BABYLON.Texture
  79918. */
  79919. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79920. }
  79921. }
  79922. declare module BABYLON {
  79923. /** @hidden */
  79924. export var normalMapProceduralTexturePixelShader: {
  79925. name: string;
  79926. shader: string;
  79927. };
  79928. }
  79929. declare module BABYLON {
  79930. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79931. private _baseTexture;
  79932. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79933. updateShaderUniforms(): void;
  79934. render(useCameraPostProcess?: boolean): void;
  79935. resize(size: any, generateMipMaps: any): void;
  79936. get baseTexture(): BABYLON.Texture;
  79937. set baseTexture(texture: BABYLON.Texture);
  79938. /**
  79939. * Serializes this normal map procedural texture
  79940. * @returns a serialized normal map procedural texture object
  79941. */
  79942. serialize(): any;
  79943. /**
  79944. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79945. * @param parsedTexture defines parsed texture data
  79946. * @param scene defines the current scene
  79947. * @param rootUrl defines the root URL containing normal map procedural texture information
  79948. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79949. */
  79950. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79951. }
  79952. }
  79953. declare module BABYLON {
  79954. /** @hidden */
  79955. export var perlinNoiseProceduralTexturePixelShader: {
  79956. name: string;
  79957. shader: string;
  79958. };
  79959. }
  79960. declare module BABYLON {
  79961. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79962. time: number;
  79963. timeScale: number;
  79964. translationSpeed: number;
  79965. private _currentTranslation;
  79966. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79967. updateShaderUniforms(): void;
  79968. render(useCameraPostProcess?: boolean): void;
  79969. resize(size: any, generateMipMaps: any): void;
  79970. /**
  79971. * Serializes this perlin noise procedural texture
  79972. * @returns a serialized perlin noise procedural texture object
  79973. */
  79974. serialize(): any;
  79975. /**
  79976. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79977. * @param parsedTexture defines parsed texture data
  79978. * @param scene defines the current scene
  79979. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79980. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79981. */
  79982. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79983. }
  79984. }
  79985. declare module BABYLON {
  79986. /** @hidden */
  79987. export var roadProceduralTexturePixelShader: {
  79988. name: string;
  79989. shader: string;
  79990. };
  79991. }
  79992. declare module BABYLON {
  79993. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79994. private _roadColor;
  79995. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79996. updateShaderUniforms(): void;
  79997. get roadColor(): BABYLON.Color3;
  79998. set roadColor(value: BABYLON.Color3);
  79999. /**
  80000. * Serializes this road procedural texture
  80001. * @returns a serialized road procedural texture object
  80002. */
  80003. serialize(): any;
  80004. /**
  80005. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80006. * @param parsedTexture defines parsed texture data
  80007. * @param scene defines the current scene
  80008. * @param rootUrl defines the root URL containing road procedural texture information
  80009. * @returns a parsed Road Procedural BABYLON.Texture
  80010. */
  80011. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80012. }
  80013. }
  80014. declare module BABYLON {
  80015. /** @hidden */
  80016. export var starfieldProceduralTexturePixelShader: {
  80017. name: string;
  80018. shader: string;
  80019. };
  80020. }
  80021. declare module BABYLON {
  80022. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80023. private _time;
  80024. private _alpha;
  80025. private _beta;
  80026. private _zoom;
  80027. private _formuparam;
  80028. private _stepsize;
  80029. private _tile;
  80030. private _brightness;
  80031. private _darkmatter;
  80032. private _distfading;
  80033. private _saturation;
  80034. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80035. updateShaderUniforms(): void;
  80036. get time(): number;
  80037. set time(value: number);
  80038. get alpha(): number;
  80039. set alpha(value: number);
  80040. get beta(): number;
  80041. set beta(value: number);
  80042. get formuparam(): number;
  80043. set formuparam(value: number);
  80044. get stepsize(): number;
  80045. set stepsize(value: number);
  80046. get zoom(): number;
  80047. set zoom(value: number);
  80048. get tile(): number;
  80049. set tile(value: number);
  80050. get brightness(): number;
  80051. set brightness(value: number);
  80052. get darkmatter(): number;
  80053. set darkmatter(value: number);
  80054. get distfading(): number;
  80055. set distfading(value: number);
  80056. get saturation(): number;
  80057. set saturation(value: number);
  80058. /**
  80059. * Serializes this starfield procedural texture
  80060. * @returns a serialized starfield procedural texture object
  80061. */
  80062. serialize(): any;
  80063. /**
  80064. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80065. * @param parsedTexture defines parsed texture data
  80066. * @param scene defines the current scene
  80067. * @param rootUrl defines the root URL containing startfield procedural texture information
  80068. * @returns a parsed Starfield Procedural BABYLON.Texture
  80069. */
  80070. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80071. }
  80072. }
  80073. declare module BABYLON {
  80074. /** @hidden */
  80075. export var woodProceduralTexturePixelShader: {
  80076. name: string;
  80077. shader: string;
  80078. };
  80079. }
  80080. declare module BABYLON {
  80081. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80082. private _ampScale;
  80083. private _woodColor;
  80084. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80085. updateShaderUniforms(): void;
  80086. get ampScale(): number;
  80087. set ampScale(value: number);
  80088. get woodColor(): BABYLON.Color3;
  80089. set woodColor(value: BABYLON.Color3);
  80090. /**
  80091. * Serializes this wood procedural texture
  80092. * @returns a serialized wood procedural texture object
  80093. */
  80094. serialize(): any;
  80095. /**
  80096. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80097. * @param parsedTexture defines parsed texture data
  80098. * @param scene defines the current scene
  80099. * @param rootUrl defines the root URL containing wood procedural texture information
  80100. * @returns a parsed Wood Procedural BABYLON.Texture
  80101. */
  80102. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80103. }
  80104. }